Commit Graph

230 Commits

Author SHA1 Message Date
Ryan Macnak f5adc13468 Load predefined symbols address via Thread.
R=fschneider@google.com

Review URL: https://codereview.chromium.org//1304243008 .
2015-09-04 10:32:46 -07:00
Ryan Macnak 9d8dcd1288 Load runtime entries from the Thread instead of the ObjectPool.
Removes the need to relocate their ObjectPool entries when loading a precompiled snapshot.

Saves about ~2kB of ObjectPool in hello_world at the cost of ~400B/Thread (64-bit).

R=fschneider@google.com

Review URL: https://codereview.chromium.org//1315893004 .
2015-09-02 14:58:26 -07:00
Daniel Andersson db8e0e6423 - Add marking task running on separate thread.
- A task has its own MarkingVisitor and SkippedCodeFunctions.
- Weak processing still happens on main thread, with tasks paused.
- Finalization (detaching code) happens in task.
- Cmdline-flag "marker_tasks=0" reverts to old behavior.

BUG=

Review URL: https://codereview.chromium.org//1309033007 .
2015-08-28 10:00:05 -07:00
Daniel Andersson 44d4d84be8 On Windows, set current thread in TLS to NULL before deleting the thread.
This mimics the behavior of the pthreads destructor protocol:
"At thread exit, if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument."

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1309563004 .
2015-08-25 15:34:52 -07:00
Ivan Posva 41840f3740 - Really delete InterruptableThreadState.
R=koda@google.com

Review URL: https://codereview.chromium.org//1308973003 .
2015-08-21 15:59:34 -07:00
Ivan Posva d0b03eebbd - Initialize fields used in the profiler interrupts.
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1304043003 .
2015-08-20 21:37:19 -07:00
John McCutchan 664742f016 Completely remove InterruptableThreadState
- InterruptableThreadState is gone.
- Moved InterruptableThreadState fields directly into Thread.
- Iterate over all threads in an isolate when profiling.
- Still only sample the mutator thread.

Fix ThreadRegistry leak

- When deleting a Thread, iterate over all isolates and remove it from the isolate's thread registry.

R=iposva@google.com

Review URL: https://codereview.chromium.org//1293253005 .
2015-08-20 14:38:38 -07:00
Daniel Andersson 645b809e63 Ensure helper threads get empty initial store buffer block.
This is a temporary remedy for issue
https://github.com/dart-lang/sdk/issues/24114

The proper solution is to iterate over and flush all threads when they are coordinating a safepoint.

R=iposva@google.com
TBR=iposva@google.com
BUG=https://github.com/dart-lang/sdk/issues/24114

Review URL: https://codereview.chromium.org//1304473002 .
2015-08-18 13:19:06 -07:00
Daniel Andersson 655df891fc Add unit test to ensure that we can execute a full GC on a thread other than the main mutator. (For now, the main mutator waits manually, since the GC does not yet safepoint.)
Adding this unit test ensures that we do not add any new code to the dependencies of the GC that assumes the current thread is the main mutator.

* Equip helper threads with a store buffer automatically, just like for the main thread.
* Share code by refactoring flushing.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1289153002 .
2015-08-18 07:23:17 -07:00
Zachary Anderson d4d89d6f12 Reverts VM thread cleanup
BUG=

Review URL: https://codereview.chromium.org//1275853008 .
2015-08-07 19:10:31 -07:00
Zachary Anderson 55bfb3d54b Clean VM thread shutdown:
Second attempt at: https://codereview.chromium.org/1177153005/

This time with fixed error propagation in the embedder.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//1279733003 .
2015-08-07 18:42:00 -07:00
Daniel Andersson 124edc0e79 Correct thread state update order (fixes Windows crashes).
Also add a corresponding ASSERT for non-Windows.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1276753003 .
2015-08-07 13:16:39 -07:00
Daniel Andersson df448e21da Begin migration of InterruptableThreadState into Thread.
Move the field from Isolate to Thread::state_ to allow using a single thread local key.

Profiling is still only enabled for the Dart mutator thread.

The next step is to migrate the VM tags.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1261923008 .
2015-08-07 10:28:56 -07:00
Daniel Andersson eb1bcef36f Process marking stack chunk-wise.
Prepares for parallel processing of a shared marking stack, but code remains
unsynchronized for now.

Share basic data structures with the StoreBuffer.

BUG=

Review URL: https://codereview.chromium.org//1271833002 .
2015-08-07 06:43:07 -07:00
Daniel Andersson 7d82391e89 Fix race and limit access to mutator_thread_.
Unsynchronized access to the contents of another thread is dangerous, even for just ASSERTs, as shown by issue 23958.

Verify the bidirectional Isolate<->Thread pointer invariant when *setting* the mutator_thread_ field, and
limit the interface to comparisons with NULL and the current thread.

BUG=https://github.com/dart-lang/sdk/issues/23958
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1260283007 .
2015-08-04 13:30:50 -07:00
Florian Schneider ef7a55281f VM: Load allocation-top and -end via Thread.
Cache a pointer to the isolate's Heap in the Thread object
and use it in generated code for allocation.

Change generated allocation code to load allocation-top and
end via THR (THR->heap.top). This is slightly slower than
embedding the address, but faster than loading it
via the Isolate (THR->isolate->heap.top)

BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1263513002 .
2015-08-03 16:26:23 +02:00
Daniel Andersson 868d2c6c3e The sweeper must not be running during isolate shutdown.
In release mode, there seems to be nothing to prevent this.
In debug mode, the "Verify" call waits for the sweeper, but there is still a race between the task count update and the ExitIsolateAsHelper call, which could cause problems.

Fix both of these, and add more assertions and verbose error messages.

- make sweeper task cleanly exit isolate *before* notifying
- wait for sweeper before shutting down isolate
- verbose pthread failures

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1233563004 .
2015-07-13 17:49:49 -07:00
Daniel Andersson 7f890eeecf Support per-thread zones and stack resources.
This is needed to enable parallel marking/sweeping (and in the future, compilation) tasks to have their own zone allocations and to safely call code that relies on various scoped constructs (stack resources).

The next step is to migrate the scopes like NoSafepointScope, NoHandleScope, etc. from isolate- to thread-based interfaces.

NOTE: This is a copy of issue 1204303003.

BUG=

Review URL: https://codereview.chromium.org//1226403003 .
2015-07-09 11:22:26 -07:00
Florian Schneider 9bdab8ee2b VM: Load common VM constants from Thread on ARM and MIPS.
This saves code size and also makes intrinsic code relocatable since
the UpdateStoreBuffer-stub is now called indirectly (loaded from THR)
instead of embedded as an immediate.

Also addressed feedback from previous CL.

BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1227733002 .
2015-07-09 11:12:52 +02:00
Florian Schneider 3b8cbf8bfa Remove fixed contant pool entries by caching some global constants in Thread
They can be loaded via the THR register.

In particular, do this for null, true, false, and the entry point of the UpdateStoreBufferStub.

This will help supporting precompilation and reduce memory usage from constant pools (assuming there are more constant pools than threads).

R=srdjan@google.com

Review URL: https://codereview.chromium.org//1225933002.
2015-07-08 13:37:47 +02:00
Daniel Andersson 8b4ac45038 Reuse empty StoreBufferBlocks.
Keep cache of empty blocks shared among all isolates, limited in size.
Change overflow threshold check to include partially filled blocks.
Make Isolate::store_buffer_ a pointer, now that it's less frequently accessed, to keep the offsets of other fields small

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1173043002.
2015-06-18 16:16:50 -07:00
Daniel Andersson a410c0f993 Thread-local store buffers, v2
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1168483003.
2015-06-09 09:33:36 -07:00
koda@google.com 1e3b00d72e Automatic thread cleanup on non-Windows platforms.
Issue 23474 is tracking Windows support (use Chromium's method).

BUG=23474
R=iposva@google.com

Review URL: https://codereview.chromium.org//1134003005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45817 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 17:30:33 +00:00
koda@google.com c026736cff Fix race in debug assertion.
Change order of initialization for the two-way pointers between Isolate and Thread.

This only affects the debug assertion in Isolate::mutator_thread().

R=iposva@google.com

Review URL: https://codereview.chromium.org//1138643006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45814 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 16:28:26 +00:00
koda@google.com 0e04456696 Remove fake isolate from concurrent sweeper and extend lifetime of VM threads.
* Use real isolate in concurrent sweeper rather than shallow copy.

The only part of the isolate, other than the page being swept, used by the sweeper is the class table (via RawObject::Size), which is now safe to read concurrently (copy-on-write).

* Do not eagerly destroy a VM thread whenever it exits an isolate.

This extends the lifetime of a VM thread across entering/exiting multiple isolates. This is necessary in case an embedder callback executes during
compilation and switches/spawns isolates.

For embedder threads, since there is no API to signal "I'm done using the VM in this thread", this means we leak the (small) Thread structure.

For our own ThreadPool threads, we explicitly clean up.

BUG=23153
R=iposva@google.com

Review URL: https://codereview.chromium.org//1136143003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45810 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 12:48:49 +00:00
johnmccutchan@google.com e4f20705f5 Fix idle ticks during isolate startup
- Change default isolate vm tag from idle to Embedder
- When a thread is exiting an isolate, only set the Idle tag if the isolate has been made runnable. Set LoadWait tag otherwise.

R=iposva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//1107213003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45436 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-28 00:32:44 +00:00
koda@google.com c042387868 Move CHA field back to Isolate, pending a permanent fix.
Since the Thread structure is currently cleared on Enter/ExitIsolate,
there is a risk that CHA is cleared if an embedder callback executes during
compilation and switches/spawns isolates. This CL eliminates that risk.

However, Isolate is still not a good long-term place for CHA,
since it doesn't fit with a concurrent compilation model. Issue 23153 tracks
the work towards a permanent solution that couples its life cycle with
compilation.

R=fschneider@google.com, iposva@google.com

Review URL: https://codereview.chromium.org//1061243003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45121 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-13 20:59:51 +00:00
koda@google.com f4419287aa Prepares for multiple threads by further decoupling Thread from Isolate.
- Replace Isolate::SetCurrent with more explicit Thread::Enter/ExitIsolate.
- Lazily initialize Thread instances when entering an isolate, to avoid new API calls for embedders.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1041523002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44835 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-01 17:48:11 +00:00
koda@google.com 642ff6ebb4 volatile -> const, where possible
These 'volatile' modifiers were added to silence warnings about setjmp/longjmp clobbering, but 'const' works too and allows more optimization.

TBR=iposva@google.com

Review URL: https://codereview.chromium.org//1037333002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44749 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-27 18:11:51 +00:00
koda@google.com 89daba5454 Split Thread/Isolate instances, but still maintain 1:1 relationship.
The life cycle of Thread is still coupled with the life cycle of Isolate, but the added indirection allows the migration work to proceed, at negligible performance impact.

This is a small step towards making Thread different from Isolate and allow a many-to-one relationship. In particular, in prepares for being able to have the sweeper have some minimal separate state from the main thread (eliminating the current fake-isolate hack).

Concretely, it moves the thread-local storage key into the Thread class, but for now, keeps a "main_thread" in Isolate for quick access in native/runtime_entry.
Also moves cha_ field to Thread (the first of many fields that will move).

To summarize, this CL enables the next steps:
- moving other fields from Isolate to Thread without circular include-dependencies
- replacing sweeper's fake Isolate with a helper Thread (referencing the original Isolate)

Also add 'volatile' to local variables that clang thinks could be clobbered.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1037453002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44703 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-25 22:41:33 +00:00