Commit graph

426 commits

Author SHA1 Message Date
Florian Schneider f0a35b3260 VM: Add dart_precompiled build target, a standalone VM without the JIT compiler.
This removes most of the compiler-related code from dart_precompiled:
x64 stripped binary size 13M -> 9.1M
ARM stripped binary size 12M -> 8.3M

The precompiled build defines the DART_PRECOMPILED macro. This
stubs out the public interface to the compiler/parser with empty
function bodies.

Use gcc options -ffunction-sections and --gc-sections to make the linker remove
unused functions/symbols.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1459443002 .
2015-11-19 10:13:16 +01:00
Todd Turnidge 71b3d5aba8 Start isolates in a separate thread.
R=asiva@google.com

Review URL: https://codereview.chromium.org/1447353002 .
2015-11-18 11:02:32 -08:00
Matthias Hausner 648e52baa8 Collect closure functions in isolate
Instead of collecting closures functions in each class object, maintain one list per isolate. This is a step towards getting rid of top-level classes.

I'd appreciate if John could take a look at the service isolate and coverage related change.

I'd appreciate if Ryan could take a look at the precompilation related change.

When compiling all of corelib, the list of closures in the isolate is about 600 entries long. If this linear list should become a bottleneck, I'll deal with it later. (Sadly, some code relies on the fact that a closure can be identified with a list index, so making it a hash table instead of an array does not work.)

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1436243005 .
2015-11-17 15:40:27 -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
Srdjan Mitrovic 720e67ea1a Redo background compilation queues to allocate queue and its element in the C-heap
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1419533011 .
2015-11-05 12:13:37 -08:00
Ryan Macnak 830bfe61b7 Precompilation: Generate instance calls as IC calls that can switch to Megamoprhic calls.
dart2js ARM -10.3% size

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1418863003 .
2015-11-04 09:31:19 -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
Siva Annamalai d951f5bca8 1. Do not initialize the stack limit during isolate initialization and in StartIsolateScope, it is done during DartEntry::InvokeFunction which is the central point for all entry into dart code.
2. Do not initialize the stack limit in the vm isolate, get rid of InitializeStackLimit function.

3. Assert in StartIsolateScope that the thread enters an isolate without any nested scopes and the thread exits an isolate without any pending scopes.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1417523006 .
2015-11-03 08:26:54 -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
Srdjan Mitrovic 8e27f43f36 Allocate some data structures in old instead of in new space. Early inlining bailout for native functions. Verify heap after background compiler was shutdown.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1433463002 .
2015-11-02 16:39:22 -08:00
Siva Annamalai 10f40ce373 1. Get rid of SwitchIsolateScope as it is not clear when this should be used and there is also a bug in that Thread::ExitIsolate is not called if saved_isolate is not NULL
2. Added Dart::ShutDownIsolate(Isolate* isolate) to take care of ensuring that the isolate is entered before shutting it down and deal with the asymmetry on the way out.

R=zra@google.com

Review URL: https://codereview.chromium.org/1427583009 .
2015-11-02 14:29:16 -08: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
Srdjan Mitrovic e9171461fd Move compilation queues into BackgroundCompiler class
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1412463007 .
2015-10-30 13:32:21 -07:00
Srdjan Mitrovic fe4a5d7672 This adds a mechanism to invalidate code that was generated in the background. The invalidation can happen if a relevant event was invoked between background compilation start and installation of code (e.g, field type invalidatet, subclasses added, deferred loading).
We introduce 3 invalidation generation counters: CHA, field and library prefixes. If one of the counters was incremented during compilation, and is relevant for that compilation, the code installation is skipped since that code may have become invalid in the meantime.

Add BackgroundCompilationResult that remembers the 3 invalidation generations.

The generational counter can rollover, which is OK.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1418813008 .
2015-10-30 12:18:52 -07:00
Siva Annamalai 4f5a22726b Remove IsolateSpawnState::Cleanup as it is not used anywhere.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1422423002 .
2015-10-29 12:24:56 -07:00
Matthias Hausner 59dce43dfe Shared token objects
Instead of one array for literal and identifier tokens for each TokenStream, share one array among all TokenStreams in an isolate.

The shared array and the token-to-index map is stored in the object store until the embedder is done loading. Then the map is thrown away (and the array remains shared, referred to by the TokenStreams).

When new files get loaded, a new shared array is created. For temporary scripts, e.g. when evaluating one-shot functions, the token arrays are not shared.

This eliminates many duplicate LiteralToken and identifier tokens. Looking at the core libraries:

Before: 30877 identifiers and 9618 literal tokens
After: 12899 identifiers and 6371 literal tokens

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1420103006 .
2015-10-28 16:02:58 -07:00
Srdjan Mitrovic 772ee329c4 Make ICData changes thread safe (first compute array, then set it). Install code in the main thread instead of in the background compilation thread.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1410363005 .
2015-10-26 15:12:29 -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
Srdjan Mitrovic b9426418d8 Get rid of deprecated methods accessing mutator_thread_ instead of current thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1410643008 .
2015-10-20 10:26:08 -07:00
John McCutchan 9c4d06a4f2 Make sure that Dart_Ports are printed safely in the service protocol
- A Dart_Port is a random 64-bit integer.
- On 32-bit architectures we were silently truncating the isolate id when printing.
- Parsing in JavaScript would also have issues.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1411083007 .
2015-10-20 09:47:35 -07:00
Srdjan Mitrovic caedcce440 Cleanups
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1411403002 .
2015-10-19 14:13:27 -07:00
Srdjan Mitrovic 465cf10a7c Remove some Isolate::current_zone() calls, as it gets the zone from mutator thread not the current thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1414493003 .
2015-10-19 10:27:36 -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
Ryan Macnak a9fcf0ee8b Trace through const objects instead of spying on flow graph construction to find closure functions. Allows dropping local closure functions the optimizing compiler removes.
Remove a dead local function from Uri.parse.

Don't rely on HasCode to indicate a function's callees have been visited because it misses functions compiled by const evaluation.

Add missing VM entry point.

dart2js ARM
libprecompiled.so -2.7%
precompiled.isolate -3.4%

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1409523003 .
2015-10-14 15:30:42 -07:00
Srdjan Mitrovic ecd7457bb3 In precompilation, finalize all classes eagerly. Use the stable class hierarchy for doing CHA based optimizations: inline implicit setters and getters.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1392893003 .
2015-10-14 13:18:10 -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
Srdjan Mitrovic 5039117f50 Remove isolate parameter when allocating handles
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1401643002 .
2015-10-12 15:51:06 -07:00
John McCutchan 9dd7680fd8 Straw man setExceptionPauseMode
BUG=
R=turnidge@google.com

Review URL: https://codereview.chromium.org/1399743002 .
2015-10-12 11:04:44 -07:00
Ivan Posva d65ff2d8b3 - Fix ASAN build: delete != delete[]
BUG=

Review URL: https://codereview.chromium.org/1401163002 .
2015-10-12 10:58:11 -07:00
Ivan Posva 60eab65aa0 - Implement package map parameter when spawning isolate.
BUG=
R=lrn@google.com

Review URL: https://codereview.chromium.org/1403693002 .
2015-10-12 09:05:37 -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
Todd Turnidge 97c643a5f4 Improve isolate list. Expose isolate origin.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1395693003 .
2015-10-07 14:35:01 -07:00
Todd Turnidge 0d501ad53d VM restart + shutdown fixes
This change add the ability to restart the vm through the service
protocol.  All isolates are killed, and then the main isolate is
restarted cooperatively by the embedder.

This change also fixes the message handler to prevent it from
accidentally ignoring vm shutdown messages.

Previously, we would stop handling messages whenever we hit an error
(such as a compile error or an unhandled exception).  This would leave
shutdown requests sitting the oob queue, neglected.

We now process *all* oob requests, up to the first shutdown request.
When we hit a shutdown request, we clear the oob queue and process no
more messages.

To make all of this work, we had to change the return value of
HandleMessage from bool to a new enum type, allowing the message
handler to distinguish *normal* error cases from the more rarified
shutdown and restart cases.

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

Review URL: https://codereview.chromium.org/1371193005 .
2015-10-06 11:27:26 -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
Srdjan Mitrovic 193eadbc10 Initial design for background compilation
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1386503002 .
2015-10-05 12:29:22 -07:00
Ryan Macnak 5dc51af924 Resolve some disagreements between SIMARM and XARM on offsets used in compiled code.
gcc ia32 (SIMARM) seems to prefer to pack structures whereas gcc arm (XARM) seems to prefer to keeping things aligned.

R=fschneider@google.com

Review URL: https://codereview.chromium.org//1351403004 .
2015-10-01 15:01:20 -07:00
Todd Turnidge 473413753d Some changes to service protocol before we land 1.13.
- Split AddBreakpoint into two rpcs: AddBreakpoint and
  AddBreakpointWithScriptUri.

- Remove Isolate.entry.

Closes #24329

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1379163002 .
2015-10-01 10:46:44 -07:00
Matthias Hausner 4995b84051 Remove obsolete timer list from VM
The functionality is now covered with TimeLine and CompilerStats

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1375343002 .
2015-09-30 12:47:23 -07:00
Florian Schneider 4a653d9e17 VM: Store edge counters in one per-function array.
Reserve first element in the Function's ic_data_array to hold the edge
counter array.

Until now we had a one-element array per edge counter. This reduces memory
used by edge counters.

This CL allows to optimize code without having to have the unoptimized
code present.

Also, save space in Instruction by making place_id_ and lifetime_position_
a union. place_id_ is exclusively needed by Load/StoreOptimizer,
lifetime_position by the FlowGraphAllocator.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1343383003 .
2015-09-28 13:28:04 +02: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
Todd Turnidge c553cd065a Distinguish internal kill messages from user-initiated kill messages.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1361213003 .
2015-09-24 10:22:05 -07:00
Florian Schneider 3a75f0d67a Add simple VM test for precompiled code.
The test creates a precompiled snapshot in a temporary directory, runs it and
checks the output.

Also:
Minor cleanup and fix segfault on dlopen error and with --trace-isolates

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1362743003 .
2015-09-24 11:36:46 +02:00
Todd Turnidge 66f9abc7e3 Refactor isolate interrupts to use OOB messages instead of interrupt bits.
Closes #24349

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1344993002 .
2015-09-23 12:13:25 -07:00
John McCutchan 860b9140a7 Add global timeline stream overrides
- Needed for the mojo TraceProvider implementation

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1362503002 .
2015-09-21 14:23:59 -07:00
Matthias Hausner a87da65c13 Blind attempt to fix test crash on Windows
Not sure what causes the crash. Move compiler stats output to
an earlier phase in Isolate shutdown, which is a good idea
anyway.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1340423005 .
2015-09-16 15:14:09 -07:00
Matthias Hausner 2ee5a1289d Fix compiler stats
Don’t print stats for VM and service isolates
Guard against division by zero in all cases

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1348383002 .
2015-09-16 14:10:40 -07:00
Ryan Macnak 9764a9f037 -Setup heap page for precompiled instructions to make heap verifier etc happy.
-Pre-mark instructions when writing the snapshot.
-Write the megamorphic miss function to the snapshot.
-Add missing ExceptionHandlers for megamorphic miss code.
-Add missing C++ entry points.
-Relocate Function and Code entry_points_ when reading precompiled snapshot.
-Don't try to load a script again when running from a precompiled snapshot.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1336763002 .
2015-09-16 11:22:57 -07:00
Matthias Hausner bb097ec37f Add benchmark output to compiler stats.
Add two compiler stats benchmarks to unit tests

Sample output:
xcodebuild/ReleaseIA32/run_vm_tests  CorelibCompilerStats
NumberOfTokens: 271148
NumClassesParsed: 730
NumFunctionsCompiled: 8987
NumFunctionsOptimized: 0
NumFunctionsParsed: 9694
NumTokensScanned: 0 tokens
ScannerTime: 0 ms
ScannerSpeed: 0 tokens/ms
NumTokensParsed: 531066 tokens
ParserTime: 262 ms
ParserSpeed: 2026 tokens/ms
NumTokensCompiled: 433816 tokens
CompilerTime: 648 ms
CompilerSpeed: 668 tokens/ms
CodeSize: 4428 KB
CodeDensity: 138 tokens/KB
InstrSize: 3127 KB
CorelibCompilerStats(RunTime): 694788

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1352483002 .
2015-09-16 11:18:31 -07:00
Ryan Macnak 525b6f0b08 Move pointer Isolate::heap_ above bool Isolate::errors_fatal_ so Ubuntu's gcc 4.8.4 and Linaro's gcc 4.8.3 agree on its offset.
Review URL: https://codereview.chromium.org//1341993003 .
2015-09-15 17:42:15 -07:00
Zachary Anderson 7093f2996b VM thread shutdown.
BUG=
R=iposva@google.com, turnidge@google.com

Review URL: https://codereview.chromium.org//1275353005 .
2015-09-15 12:49:52 -07:00
Ryan Macnak 491b1d42f8 Reapply "Move megamorphic cache table into the Dart heap."
Prevent megamorphic miss function from losing its code:
 - Only include megamorphic function in precompiled snapshots.
 - Also put the megamorphic miss code in the object store.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1339363002 .
2015-09-15 11:18:43 -07:00
Ryan Macnak 33b037125f Revert "Move megamorphic cache table into the Dart heap."
We're somewhere attempting to recompile the megamoprhic miss function.

Review URL: https://codereview.chromium.org//1334283004 .
2015-09-14 17:54:43 -07:00
Ryan Macnak 3068f1e092 Move megamorphic cache table into the Dart heap.
R=asiva@google.com

Review URL: https://codereview.chromium.org//1346473002 .
2015-09-14 17:11:55 -07:00
Zachary Anderson 16393ee9c6 Uses SNPRINT macro where possible. Otherwise uses #define for format.
I was able to convert 49 SNPrint(NULL, 0, ...) patterns to use the
macro. I had to use a #define for the format string 5 times due to
uses that didn't fit the macro.

2 occurences of SNPrint(NULL, 0, ...) had >=2 possibilities for the
format string based on runtime values, and I didn't try to convert
them.

Fixed ~10 format strings.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1331623002 .
2015-09-11 00:18:14 -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
Matthias Hausner d3a2f619bb Fix compiler stats
Prints the stats into a zone-allocated string that can either be dumped to the console, or displayed as a whole in the observatory.

Distinguish token consumption between class parsing and function parsing when compiling.

Change stat counter macros use thread instead of isolate.

Review URL: https://codereview.chromium.org//1300033002 .
2015-09-04 13:13:56 -07:00
Ivan Posva 0a0b101fbd - Remove deprecated StackZone constructor with Isolate parameter.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1312813006 .
2015-09-02 16:07:48 -07:00
Ivan Posva 4bd7cdc75c - Ensure that HandleScope is initialized with a thread. (Remove
deprecated isolate based API.)
- Update all code impacted by this change. E.g. DARTSCOPE
- TEST_CASE now passes the current thread as a parameter to the   unit test.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1310463005 .
2015-09-01 17:18:55 -07:00
John McCutchan 7052bd6bed Rework service extensions to be safe
- When scheduling a service extension to be invoked, store the closure in an array held in the isolate.
- At the tail of IsolateMessageHandler::HandleMessage, invoke all pending service extension closures.

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

Review URL: https://codereview.chromium.org//1299493007 .
2015-08-27 11:23:39 -07:00
John McCutchan c9a4013553 More logging for pause tests
BUG=

Review URL: https://codereview.chromium.org//1310863004 .
2015-08-26 16:45:36 -07:00
John McCutchan d0882dd363 Remember when an isolate was paused and subtly display it in Obseravatory
- Display paused time as tooltip over "paused" word.
- Send a timestamp with every ServiceEvent.
- Unit tests verifying that paused on start, exit, and breakpoint timestamps are stable.
- Remember the pause time in DebuggerEvent.
- Remember the pause time in MessageHandler.
- Updated service protocol documentation.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//1311503004 .
2015-08-26 10:57:59 -07:00
John McCutchan 1015c7f4ff Add --print-metrics vm flag for printing metrics to console
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1303033005 .
2015-08-26 10:05:26 -07:00
Todd Turnidge 8ed37776d4 If the isolate is in the process of resuming, do not report it as paused.
This may be causing bug #24176.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1313713003 .
2015-08-24 13:38:33 -07:00
Todd Turnidge 7e8bb130f2 Add an IsolateRunnable event to the service protocol. Improve service docs.
Closes #24140

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1293383011 .
2015-08-21 10:25:38 -07:00
Ivan Posva 3aa62d03fc - Prevent interrupting the NULL thread when the isolate is
exiting from within a thread.

BUG=

Review URL: https://codereview.chromium.org//1307833002 .
2015-08-20 23:00:06 -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 00ef260503 Enable concurrent optimization test after migrating scopes to Thread*
Also move static call target table allocation into old space.

Note that stats are not thread-safe, so running two compilers concurrently may lead to inaccurate stats.

BUG=https://github.com/dart-lang/sdk/issues/24109

Review URL: https://codereview.chromium.org//1291803009 .
2015-08-19 15:16:47 -07:00
John McCutchan 1ff7144c31 Switch to a VM wide timeline recorder
- Initialize and shutdown timeline recorder with VM.
- Allocate global blocks for timeline events without an isolate.
- Stop storing the Stream pointer inside a TimelineEvent.
- Store category name in TimelineEvent.
- Store isolate pointer in TimelineEvent.
- TimelineEventRecorder::WriteTo is full VM dump.
- Allow JSONStream to be used without an isolate.
- When a ThreadRegistry is deleted, Finish all open timeline blocks.
- PrintJSON takes a filter.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1294023009 .
2015-08-18 15:18:02 -07:00
Daniel Andersson 76ff397c1c Migrate LongJumpScope to Thread.
This was one of the blockers for concurrent compilation (issue 24109).

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1299653003 .
2015-08-17 13:29:17 -07:00
Lasse R.H. Nielsen 43f6230376 Make uncaught errors terminating isolates only get printed if nobody is listening.
If an isolate has an error port attached, then the uncaught error is not printed
when it causes the isolate to terminate.

Fixes issue 24052
BUG= https://github.com/dart-lang/sdk/issues/24052

Review URL: https://codereview.chromium.org//1286163002 .
2015-08-14 12:48:01 +02:00
Daniel Andersson 2ae8544e8d Restore frame validation (fixes to CL faaf60801f).
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1280013004 .
2015-08-12 08:47:54 -07:00
Daniel Andersson faaf60801f Enable iterating over roots from helper threads by moving stack walking.
This will be needed for helper threads to invoke GC.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1282423003 .
2015-08-11 09:41:06 -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 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
Zachary Anderson 4ca87e6d88 Revert VM thread cleanup
TBR

BUG=

Review URL: https://codereview.chromium.org//1270323002 .
2015-08-05 01:27:01 -07:00
Florian Schneider 63a8e5227d VM: More abstract interface for generating stub calls.
This makes the code in the code generator independent from how stubs
are actually called (i.e. directly embedding the target address, or
indirectly by loading the target address from the code object).

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1270803003 .
2015-08-05 10:18:35 +02:00
Zachary Anderson 174d552574 Enables clean VM shutdown.
. Disables isolate spawning during Dart_Cleanup.
. Adds a static call Isolate::KillAllIsolates, which sends the
  OOB Kill message to all isolates when called from
  Dart_Cleanup.
. Modifies thread pool shutdown to block until all threads have
  exited.
. Fixes tests.

BUG=
R=turnidge@google.com

Review URL: https://codereview.chromium.org//1177153005 .
2015-08-04 23:29:25 -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
Ryan Macnak 8a3e134502 Non-tree-shaking --precompile.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1261673004 .
2015-07-30 15:29:19 -07:00
Florian Schneider 8d38a58c18 Make array allocation stub shared between isolates.
This allows to make the last explicitly named stubs shared between isolates.

When sharing code stubs, we can't do patching at their entry anymore.
Therefore, I had to remove patching support of the array allocation stub.
Is this a functionality we want to keep?

The change is mostly performance-neutral because optimized code has an inlined fast
path for array allocation and only uses the stub for the slow-case.

The only isolate-specific stubs left are object allocation stubs which are
associated with their Class are per-isolate.

Since this CL removes any isolate-specific stubs from StubCode, it becomes AllStatic.

BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1247783002 .
2015-07-23 12:56:16 +02:00
Ivan Posva fe03640e85 - Implement VM parts of https://codereview.chromium.org/1240743003/
- Pass additional state in the IsolateSpawnState to set
  error and exit handlers, as well as fatal errors on isolate start.

BUG=
R=floitsch@google.com

Review URL: https://codereview.chromium.org//1244733002 .
2015-07-20 16:46:54 +02:00
Daniel Andersson ee49289308 Fix crash in code coverage generation.
Separate the higher- and lower-level cleanup steps during isolate shutdown. The former (currently only code coverage and timeline) may need to allocate, but the latter should not. Add assertions.

(cc:zra, who's working on clean shutdown)

BUG=23848
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1236913006 .
2015-07-17 13:06:21 -07:00
Todd Turnidge e4684c7627 Provide stdout and stderr output in the Observatory debugger.
Implement two new streams, 'Stdout' and 'Stderr' in the service protocol.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1232193003 .
2015-07-14 12:54:07 -07: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
Daniel Andersson 3fc6fce1c0 Safer interface for heap iteration.
Address issue 21620, by sharing code to wait for concurrent sweeper to finish, and freeing the caller from this responsibility. The new public interface is Heap::Iterate*, and the old Heap::Visit* are made private, for GC use only.

(Eventually, we'll want to support iterating over the heap while concurrent GC runs, but that will have to wait until all header accesss is synchronized.)

BUG=21620
R=asiva@google.com

Review URL: https://codereview.chromium.org//1212943010 .
2015-07-07 17:20:20 -07: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 c7e9dd2f99 Assert helper threads do not (yet) attempt to access the "current zone".
This guards against a sweeper thread trying to directly allocate in the "current zone".
This assertion will be removed when the "current zone" has completely migrated into Thread.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1185013005.
2015-06-17 08:25:26 -07:00
John McCutchan f58029a0cd Refactor some Timeline interfaces to be simpler and support streaming
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1173333007.
2015-06-16 10:52:48 -07:00
John McCutchan c7187924a9 Initial Timeline Events
- Each isolate has its own TimelineEventBuffer
- Each isolate has TimelineEventStreams for API, Compiler, Embedder, Isolate, and GC
- Compiler, Isolate, Embedder, and GC are being inserted into the stream
- Basic unit tests
- Dart API for injecting timeline events
- Arbitrary number of native and Dart arguments can be attached to each event
- JSON printing
- Output can be loaded by about://tracing
- Add --timeline-trace-dir flag

Short term follow up CLS:
- Service protocol requests to enable / disable tracing and retrieve a trace
- UI for Observatory
- Dart code EventStreams and Events

R=asiva@google.com

Review URL: https://codereview.chromium.org//1170503004.
2015-06-16 10:10:14 -07:00
Ryan Macnak 392a83221f Allow setting break-on-exceptions option over the service protocol. Add command to Observatory's debugger.
Decide whether to cache service objects based on the fixedId property.

Be more tolerant of eval scripts and functions.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1174313002.
2015-06-15 12:05:23 -07:00
Ivan Posva f5e3f94019 Fix http://dartbug.com/23578:
- Complete revamp of isolate-specific flags.
- Associate flags with the isolate on creation.
- Dart_CreateIsolate and associate callback do take an
  extra flags argument.
- Make sure to clear IC data array when clearing code.

BUG=23578

Review URL: https://codereview.chromium.org//1162033005
2015-06-07 17:57:34 +02:00
Todd Turnidge 996f012707 2nd attempt at adding streamListen/streamCancel to the service protocol.
This time I am committing the protocol changes first and saving the
Observatory changes for a second cl.

------

We currently support 5 streams: Isolate, Debug, GC, _Echo, and _Graph.

Only generate events when at least one client is listening to the
corresponding event stream.

Only send events to the clients that actually request them.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1166433008
2015-06-04 09:57:22 -07:00
Lasse R.H. Nielsen 5a843ebbf3 Add "checked" parameter to Isolate.spawnUri.
R=iposva@google.com

Review URL: https://codereview.chromium.org//1154673004
2015-06-03 12:32:52 +02:00
John McCutchan b7534facef Include 'fixedId' key when printing service ids
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1157173005
2015-05-26 16:56:31 -07:00