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 .
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 .
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 .
- 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 .
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 .
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 .
- 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 .
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 .
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 .
- 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 .
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 .
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 .
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 .
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 .
- 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 .
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 .
-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 .
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 .
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 .
- 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 .
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 .
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 .
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 .
- 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 .
- 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 .
- 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 .
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 .
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 .
. 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 .
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 .
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 .
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 .
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 .
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 .
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 .
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.
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.
- 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.
- 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
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