Commit Graph

73 Commits

Author SHA1 Message Date
Vyacheslav Egorov ee0f608ce4 Dart Byte Code interpreter.
This version is Clang/GCC only and does not support Windows because it uses computed goto's.

Only unoptimized mode is supported.

Architecture is described in constants_dbc.h and stack_frame_dbc.h.

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

Review URL: https://codereview.chromium.org/1858283002 .
2016-04-18 23:02:01 +02:00
Srdjan Mitrovic 1a9fc8b2fa Move CompilerStats from isolate to thread. Aggregate stats.
The mutator thread holds the aggregate values, the background compiler adds its value to it.

BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1841213003 .
2016-03-30 13:38:32 -07:00
Ivan Posva 528baf2173 - Limit 32-bit platforms to 1.5GB of memory for old gen by default.
- Fixed documentation for Dart_NewWeakPersistentHandle.
- Add clarifying comment.

BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1837803003 .
2016-03-28 17:37:52 -07:00
John McCutchan 41d9f2d107 Add Thread TaskKind
BUG=
R=asiva@google.com, turnidge@google.com

Review URL: https://codereview.chromium.org/1814243002 .
2016-03-21 09:41:47 -07:00
Siva Annamalai af32c047b1 Set the stack base value for thread pool threads at the start so that profile ticks for threads show up even if it never runs Dart code.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1815533002 .
2016-03-17 16:40:02 -07:00
Srdjan Mitrovic dda658f48a Restructure/fix thread pointer visiting; added some asserts.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1814853005 .
2016-03-17 13:25:46 -07:00
Siva Annamalai 56e888d4cd - Move
stack_limit_,
   stack_overflow_flags_,
   saved_stack_limit_,
   stack_overflow_count_ and
   other interrupts mask fields from Isolate structure to Thread structure

- Change the stack overflow check in the prolog to load the stack limit
  from the THR register, this removes the back to back dependent loads to
  load the stack limit from the Isolate structure

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

Review URL: https://codereview.chromium.org/1812753002 .
2016-03-17 12:57:36 -07:00
Srdjan Mitrovic 24fc2a53d2 Clear reusable handles of helper threads as well. Visit mutator_thread_ even if it is not active (api_handles_ could be still alive).
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1806093002 .
2016-03-16 13:43:49 -07:00
Siva Annamalai 5792996130 1. Fix memory leaks reported by running a simple test using ASAN
2. Get rid of some methods in cpuninfo that are not being used anymore and make some methods private.

R=zra@google.com

Review URL: https://codereview.chromium.org/1677043003 .
2016-02-09 10:54:34 -08:00
Srdjan Mitrovic 4316d1bd17 Move sticky_error_ from isolate to thread
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1672853002 .
2016-02-05 15:46:55 -08:00
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

The ThreadRegistry class now contains only the thread list for an isolate and the functionality of scheduling a thread onto an Isolate and unscheduling it from teh isolate. We could fold this functionality into the Isolate class in a different CL.

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

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
Siva Annamalai a0fedf3879 1. Add code to grow the heap instead of collecting garbage in Heap::AllocateOld when allocation is done by a non mutator thread which is at a safepoint. Garbage collection is triggered after the safepoint is done.
2. Add code to avoid multiple garbage collection requests on different threads to sync up and allow only one request to proceed at a time, other requests wait for this garbage collection request to be done and then proceed to allocation once the request is done.

R=iposva@google.com

Review URL: https://codereview.chromium.org/1562853003 .
2016-01-11 11:00:59 -08:00
Siva Annamalai b40775549f Fix for issue 25236
- Ensure that no new OSThreads are created once the VM is in shutdown mode
- Do not query thread_list_head_ without a lock (this leads to the race which causes two threads to delete the lock and TLS at the same time)

BUG=25236
R=zra@google.com

Review URL: https://codereview.chromium.org/1537543002 .
2015-12-18 10:16:28 -08:00
Ivan Posva e47ac24c79 - Make sure to prepare all threads for GC.
BUG=
R=asiva@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1533023002 .
2015-12-17 19:59:13 -08:00
Ryan Macnak 3e7212e194 Reapply "Precompilation/x64: Load float vector constants via Thread."
Fix unbalanced Enter/LeaveTestFrame in TestObjectCompare. Crashed on release + clang with the original change, and was failing on ASAN before that.

BUG=http://dartbug.com/24450
BUG=http://dartbug.com/25002
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1499763002 .
2015-12-04 09:46:21 -08:00
Ryan Macnak 7dfb517618 Revert "Precompilation/x64: Load float vector constants via Thread."
This reverts commit 9cf30c9697.

Review URL: https://codereview.chromium.org/1494323002 .
2015-12-03 14:19:21 -08:00
Ryan Macnak 9cf30c9697 Precompilation/x64: Load float vector constants via Thread.
Cannot put these in the object pool because some of these instructions
are used in intrinsics.

BUG=http://dartbug.com/24450
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1488403002 .
2015-12-03 13:35:31 -08:00
Siva Annamalai 01b69ebabc Move ApiLocalScope out of class ApiState into class Thread so that the API local handles and zone etc. are thread specific instead of being Isolate specific.
R=zra@google.com

Review URL: https://codereview.chromium.org/1473403003 .
2015-11-25 11:07:22 -08:00
Siva Annamalai 9e19d236ca - Add an OSThread structure which is the generic TLS structure for all C++
fields in a thread (i.e fields that are not Dart VM related)
- Split the Thread structure to be a pure Dart per thread structure and add
  a pointer to os_thread which points to the OSThread structure
- Change Schedule/UnSchedule to set the Dart Thread structure as the TLS of
  the thread when it is inside the Dart world and reset the TLS back to the
  OSThread strcuture when is exits the Dart World.
- Moved the stack_base and few stack size related functions to OSThread from Isolate

R=johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1439483003 .
2015-11-19 13:45:10 -08:00
Ryan Macnak df64bb1619 - Annotate instructions that load objects from the ObjectPool or Thread.
- Remove disassembly tooltips.
- Surface whether a function has an intrinsic or is recognized.
- Mark intrinsified or ffi functions in the profile.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1439893002 .
2015-11-12 15:18:31 -08:00
John McCutchan 43b0ae00e7 Timeline service protocol support with Observatory UI
Service Protocol:
- _clearVMTimeline (clear timeline)
- _getVMTimeline (fetch timeline)
- _setVMTimelineFlag (control recording)
- _getVMTimelineFlag (...)
- _getVMTimeline service unit test

Observatory:
- timeline page with record on/off, clear timeline, and refresh buttons.
- trace-viewer based timeline view that runs in an iframe driven by a small javascript program

Misc:
- Fix default enable logic bugs
- Add 'Debugger Pause' timeline event
- Threads can have a name and that name will be displayed in Observatory
- Tighten up locking when printing JSON

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1406413006 .
2015-11-10 08:02:22 -08:00
John McCutchan ceb12c4f69 Switch profiler from isolates to threads
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.

Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:

void DisableThreadInterrupts();
void EnableThreadInterrupts();

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

Review URL: https://codereview.chromium.org/1423473004 .
2015-11-04 07:59:16 -08:00
William Hesse cc4a5d2e7c Revert "Switch profiler from isolates to threads"
Reverts commit 6365c27f81 and
commit 8b9ed6cfb3.

They are causing flaky timeouts (hangs) on all vm cc tests on all Windows vm bots.

R=mit@google.com

Review URL: https://codereview.chromium.org/1425093006 .
2015-11-03 10:42:55 +01:00
John McCutchan 6365c27f81 Switch profiler from isolates to threads
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.

Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:

void DisableThreadInterrupts();
void EnableThreadInterrupts();

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

Review URL: https://codereview.chromium.org/1412733008 .
2015-11-02 12:47:52 -08:00
Zachary Anderson 3563dc0fb0 Use ExitProcess on Windows.
Even after joining threads, it is still possible for the exit code to be
polluted. NaCL uses ExitProcess to avoid this problem:

https://code.google.com/p/chromium/codesearch#chromium/src/native_client/src/shared/platform/win/nacl_exit.c

This change also cleans up thread local storage for the last Thread.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org/1410293006 .
2015-10-29 23:35:46 -07:00
Siva Annamalai 5e4a3d7a65 Add IsMutatorThread to the Thread class and use it instead of MutatorThreadIsCurrentThread
Review URL: https://codereview.chromium.org/1408923005 .
2015-10-26 13:12:10 -07:00
John McCutchan b83e5a718e Fix ThreadIterator_AddFindRemove test
- A pointer test was unsafe because the allocator could recycle the address for a new thread.

Fixes #24692

R=asiva@google.com

Review URL: https://codereview.chromium.org/1425463004 .
2015-10-26 11:07:16 -07:00
Srdjan Mitrovic 8915fb6fde More work for background compilation; move pending_functions_ from ObjectStore to Thread.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1409173002 .
2015-10-16 17:02:43 -07:00
John McCutchan da946fbf99 Simplify timeline backend
Now that we have a central list of all threads that are interacting with the VM we can stop relying on the Isolate's thread registry to cache timeline blocks.

- Move from caching blocks in the Isolate's thread registry and caching them in the Thread directly.
- This allows cached blocks to have events from multiple isolates, increasing usage density and reducing the number of blocks being cached at any given time.
- We no longer need a distinct global block, this allows me to remove a bunch of dead code.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1402383003 .
2015-10-16 13:36:58 -07:00
John McCutchan e36b9fa3bf Complete support for Windows TLS destructors
- Maintain a list of TLS destructors that should be run when a thread exits.
- Walk that list on thread exit and invoke destructors.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1410493002 .
2015-10-16 10:00:44 -07:00
John McCutchan 1ec9d78b89 Call known TLS destructors on Windows
Partially fixes #23474 by freeing the MonitorWaitData and Thread objects on Windows when a thread exits.

Machinery to run a function at thread exit on Windows taken from Chromium's base.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1391013006 .
2015-10-14 07:59:33 -07:00
John McCutchan 7803350a23 Don't cleanup thread list mutex until VM shutdown is clean
- We had a race where the thread pool would be starting up a thread while Dart::Cleanup was running on the main thread.
- The mutex used to guard the thread list was being deleted and set to NULL.
- Thread would try and add itself to the list and die when attempting to lock the mutex.

This CL does two things:

- Moves Thread list mutex cleanup to only run under FLAG_shutdown.
- Fixes a forgotten NULL initilization of thread list mutex.

R=whesse@google.com

Review URL: https://codereview.chromium.org/1397883007 .
2015-10-13 14:44:09 -07:00
Srdjan Mitrovic ab20fa00da Move no_callback_scope_depth_ and cha_ from isolate -> thread
Add checks for background compilation:
- Dart code may not be invoked
- Object allocation must happen in old space

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1401413002 .
2015-10-13 14:29:43 -07:00
Srdjan Mitrovic 6f53350611 Move deopt_id and related helpers/definitions from Isolate to Thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1390153004 .
2015-10-13 10:08:14 -07:00
John McCutchan 321d64a849 Add ThreadIterator for iterating over all Threads
- Register all Threads in a central list.
- Introduce ThreadIterator to iterate over threads.

This will be used by the profiler when it switches from iterating over isolates to threads. It will also be used to simplify the timeline backend.

R=asiva@google.com

Review URL: https://codereview.chromium.org/1393423005 .
2015-10-13 09:49:20 -07:00
Srdjan Mitrovic 828f9eb115 Fix GC problem with vm_handles in thread
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org/1393013005 .
2015-10-09 15:52:09 -07:00
Srdjan Mitrovic 53e814f0dd Move reusable handles from isolate to thread.
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org/1394673002 .
2015-10-09 10:10:34 -07:00
Srdjan Mitrovic dc2d81b636 Move vm_tags from isolate to thread, since we may have multiple threads in same isolate (GC, background compilation)
BUG=
R=johnmccutchan@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1387643002 .
2015-10-05 12:50:17 -07:00
John McCutchan db3421ecfc Make TimelineEventBlocks reclaimable
- Add Timeline::ReclaimAllBlocks and Timeline::ReclaimIsolateBlocks utility functions to ensure that all cached blocks are closed before reporting the timeline
- Adjust Timeline_Dart_GlobalTimelineGetTrace to exercise block reclaiming
- Add ability to reclaim blocks from threads entered into an isolate
- Fix IsolateTimelineEventFilter to actually filter out open blocks
- Make some existing tests call Timeline::ReclaimIsolateBlocks before reporting
- Added implementation and locking notes to timeline.cc

R=turnidge@google.com

Review URL: https://codereview.chromium.org//1363033003 .
2015-09-24 11:32:21 -07:00
Ryan Macnak f1a0056430 Load the native call wrapper via Thread.
R=fschneider@google.com

Review URL: https://codereview.chromium.org//1358773002 .
2015-09-20 13:48:17 -07:00
Daniel Andersson e98fcf9354 Distinct block sizes for StoreBuffer/MarkingStack.
Remove typedef hack by templatizing the shared structures,
parameterized by block size.

Smaller marking stack blocks are needed for better work distribution during parallel GC.

As a consequence, MarkingStack and StoreBuffer have separate global caches of empty blocks.

Also, use inheritance to differentiate: only StoreBuffer needs the threshold-checking functionality.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1350933004 .
2015-09-17 12:21:55 -07:00
John McCutchan fe548c4bcd Add --timing
- Dump per thread timing information when an isolate shuts down.

DeltaBlue(RunTime): 3654.6660583941607 us.
Timing for isolate DeltaBlue.dart$main-109078706 (from 2 threads)

Thread 0 (f68f8b40):
HandleMessage : 2163.455 ms total on stack; 940.038 ms total executing; 2114.231 ms max on stack; 930.085 ms max executing.
CompileFunction : 81.020 ms total on stack; 81.020 ms total executing; 7.745 ms max on stack; 7.745 ms max executing.
CompileOptimizedFunction : 109.817 ms total on stack; 109.817 ms total executing; 10.443 ms max on stack; 10.443 ms max executing.
CollectNewGeneration : 1032.580 ms total on stack; 1032.580 ms total executing; 7.677 ms max on stack; 7.677 ms max executing.

Thread 1 (f7419700):
InitializeIsolate : 12.121 ms total on stack; 0.418 ms total executing; 12.121 ms max on stack; 0.418 ms max executing.
ObjectStore::Init : 0.002 ms total on stack; 0.002 ms total executing; 0.002 ms max on stack; 0.002 ms max executing.
Object::Init : 0.268 ms total on stack; 0.268 ms total executing; 0.268 ms max on stack; 0.268 ms max executing.
IsolateSnapshotReader : 11.433 ms total on stack; 11.433 ms total executing; 11.433 ms max on stack; 11.433 ms max executing.
CompileFunction : 111.849 ms total on stack; 111.849 ms total executing; 10.798 ms max on stack; 10.704 ms max executing.

Totals:
HandleMessage : 2163.455 ms total on stack; 940.038 ms total executing; 2114.231 ms max on stack; 930.085 ms max executing.
CompileFunction : 192.869 ms total on stack; 192.869 ms total executing; 10.798 ms max on stack; 10.704 ms max executing.
CompileOptimizedFunction : 109.817 ms total on stack; 109.817 ms total executing; 10.443 ms max on stack; 10.443 ms max executing.
CollectNewGeneration : 1032.580 ms total on stack; 1032.580 ms total executing; 7.677 ms max on stack; 7.677 ms max executing.
InitializeIsolate : 12.121 ms total on stack; 0.418 ms total executing; 12.121 ms max on stack; 0.418 ms max executing.
ObjectStore::Init : 0.002 ms total on stack; 0.002 ms total executing; 0.002 ms max on stack; 0.002 ms max executing.
Object::Init : 0.268 ms total on stack; 0.268 ms total executing; 0.268 ms max on stack; 0.268 ms max executing.
IsolateSnapshotReader : 11.433 ms total on stack; 11.433 ms total executing; 11.433 ms max on stack; 11.433 ms max executing.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1296353002 .
2015-09-10 09:31:16 -07:00
Daniel Andersson a1bc527306 Migrate logging infrastructure Isolate->Thread
This enables thread-safe logging (e.g., ISL_Print, which will soon be renamed to THR_Print), which is needed for concurrent
marking (DetachCode) and compilation.

Make finalization of GC marking tasks concurrent, now that it's thread-safe.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1314673008 .
2015-09-09 15:30:38 -07:00
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