Commit Graph

2925 Commits

Author SHA1 Message Date
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 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
Florian Schneider 94e5994f16 VM: Change debug printing of Context to not print the raw-pointer
This makes comparing flow-graphs from different runs of the VM much easier.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1408223009 .
2015-10-30 19:19:40 +01:00
Matthias Hausner 7c924f0a25 Token stream iterator improvement
Eliminate the double indirection in accessing the token object array. It has no measurable effect, unfortunately :)

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1427863002 .
2015-10-29 16:36:31 -07:00
Ryan Macnak 37dd876bf1 VM: Service isolate under precompilation.
- Include the embedder's portion of the service isolate's Dart code in precompiled snapshots. Swap it in as the root library when running precompiled instead of loading from source.
- Make linter happy with gen_snapshot.
- Fix profiler to consider Instructions in the VM isolate may have their corresponding Code in the regular isolate.
- Make non-functional service RPCs fail cleanly instead of crashing.

BUG=http://dartbug.com/24651
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1418833004 .
2015-10-29 15:15:46 -07:00
Ryan Macnak 7cacbff77b Allow for multiple rounds of precompilation.
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1420533006 .
2015-10-29 14:25:09 -07:00
Srdjan Mitrovic 4efbbe06f4 Fixes bad C++ code generation by XCode 7
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1424733005 .
2015-10-29 13:26:05 -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 44ccbb5e29 Copy ICData descriptors when starting background compilation, so that they do not change while compiling
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1414933006 .
2015-10-28 10:19:35 -07:00
Srdjan Mitrovic cea892f234 Cache initial (empty) ic_data arrays so that they are not repeatedly allocated. Factor out descriptor and data array allocation. Will be used later when we copy the descriptor for background compilation.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1410573006 .
2015-10-27 15:05:14 -07:00
Srdjan Mitrovic cd98aff665 Getting rid of Isolate::current_zone() usage. Pass thread instead of isolate where it makes sense.
BUG=
R=hausner@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1424703004 .
2015-10-26 15:31:50 -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
Regis Crelier b25c1c24ca Make Instance::IsClosure() GC safe.
R=asiva@google.com

Review URL: https://codereview.chromium.org/1423693003 .
2015-10-23 08:19:48 -07:00
Florian Schneider 36e63481e0 More general CHA-based inlining and devirtualization for precompiled code.
Generalize current approach used for implicit getters/setters to all instance calls.

Additionally use propagated type to resolve targets if no concrete cid
is known:

class A {
  void m() { }
  void n() => m();
}
class B extends A { }

Even though the receiver type in n() can be A or B (concrete cid unknown), we can still
call m() directly since it is not overridden.

Also, allow inlining of methods that were not compiled yet in precompiled code.

BUG=
R=rmacnak@google.com, srdjan@google.com

Review URL: https://codereview.chromium.org/1410733006 .
2015-10-23 13:34:32 +02:00
Siva Annamalai 99abe7d883 - Some cleanup of dynamic_type usage.
- Avoid egregious creation of handles in Class::CreateInvocationDispatcher

R=regis@google.com

Review URL: https://codereview.chromium.org/1409113006 .
2015-10-21 17:24:10 -07:00
Srdjan Mitrovic c9a7080f47 nt # Enter a description of the change.
Set invocation counter to INT_MIN once a function is entered into the optimization queue, so that it does not get repeatedly triggered. Mutex on megamorphic cache lookup. Make AttachCode thread safe. Cleanups.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1413233004 .
2015-10-21 11:00:08 -07:00
John McCutchan b90b67588a Include "BoundVariable" and "BoundField" types in service response
Fixes #24654

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1420633003 .
2015-10-21 07:09:45 -07:00
Ryan Macnak b5979b6a22 Drop uncompiled implicit closure functions. Only seems to happen in a few co19 tests, so this is more to make asserts in BindStaticCalls/DedupStackmaps happy than to save space.
Fix changed standalone entry. Add missing VM entry.

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1397713007 .
2015-10-20 15:19:59 -07:00
Ryan Macnak 9de6b3be0a Move selector and arguments descriptor into MegamorphicCache.
Towards making call sites swappable between ICs and MegamorphicCaches.

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1420433004 .
2015-10-20 13:44:21 -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
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
Ryan Macnak d8490425c8 Skip making code pages temporarily writable when finalizing the VM isolate loaded from precompiled snapshot.
R=asiva@google.com

Review URL: https://codereview.chromium.org/1408653002 .
2015-10-15 13:45:13 -07:00
Matthias Hausner 72328eaf93 Eliminate unused function maps
If a class contains more than 16 functions, the lookup works via a map rather than via a linear lookup in the functions array. If there are less than 16 functions, there is no need to allocate the map.

This saves about 240 maps and 7600 map entries in the core libraries alone.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1410443003 .
2015-10-15 10:08:07 -07:00
Florian Schneider 99a02ee652 VM: Speed up PC descriptor verification code used in DEBUG mode.
Use O(n) verification code instead of O(n*n).

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

Review URL: https://codereview.chromium.org/1402123004 .
2015-10-15 19:01:05 +02:00
Florian Schneider 7fe1e05826 VM: Precompile method extractors for implicit and explicit closurization.
Also, avoid creating duplicate method extractors with explicit closurization:
Before the compiler would create one extractor per site when using the explicit
#-closurization operator.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1404163002 .
2015-10-15 12:27:23 +02:00
Matthias Hausner 45034b7626 Eliminate RawClass::patch_class_ field
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1407533005 .
2015-10-14 14:52:14 -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
Todd Turnidge cc672473b9 Use offset and count to request slices of lists, maps, and typed_data.
This should allow debugging clients to support pagination of these
potentially large types.

Closes #24536

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1400393002 .
2015-10-14 11:05:21 -07:00
Ryan Macnak 1a5a8fb58a Don't assume at least one closure function is encountered before tree-shaking. Allow for uncompiled closure functions and drop them.
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1400193003 .
2015-10-13 14:56:35 -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
Ryan Macnak 8df96f0f48 -Fix display of megamorphic miss function.
-Fix inbound reference of megamorphic miss function.
-Speculative fix for eval Script.
-Rationalize isolate list as isolate list.
-Fix attempted eval in precompiled isolate.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1403883002 .
2015-10-13 10:26:44 -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 8d618766a8 Remove isolate argument from handle allocation: Part II
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1389353004 .
2015-10-12 14:06:50 -07:00
Ryan Macnak 8341085f11 Add view for MegamorphicCache. Update view for ObjectPool.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1392953003 .
2015-10-12 13:57:48 -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
John McCutchan 7137f9ef06 Stop holding onto TimelineEvents
Due to the need to reclaim TimelineEventBlocks from the system, it is not safe to hold onto a TimelineEvent other than briefly to fill it out.

- Switch TimelineDurationScope to emit two events (begin, end) instead of one duration event.
- When setting duration arguments, hold them in the TimelineDurationScope and then emit them with the end event.

The above two changes allows TimelineDurationScope to work without holding onto a TimelineEvent.

To stop the block from being reclaimed while we are filling out an event, calls to StartEvent return with a lock held that is unlocked when CompleteEvent is called.

- Update tests.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1395803002 .
2015-10-08 14:56:25 -07:00
John McCutchan 535a9715ac Remove deprecated dart:profiler library
Fixes #24510

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1398433002 .
2015-10-07 10:01:33 -07:00
Jacob Richman 027e1808b2 Add flag specifying whether patch signature mismatches can be ignored.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1385973002 .
2015-10-07 09:53:46 -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
Siva Annamalai c8549e064e When a snapshot is generated on a 64 bit architecture and then read into a 32 bit architecture, values which are Smi on the 64 bit architecture could potentially be converted to Mint objects, however since Smi values do not have any notion of canonical bits we lose that information when the object becomes a Mint.
Some of these values could be literal values and end up in the VM isolate heap. Later when these values are referenced in a constant list we try to ensure that all the objects in the list are canonical and try to canonicalize them. When these Mint objects are encountered they do not have the canonical bit set and canonicalizing them won't work as the VM heap is read only now. In these cases we clone the object into the isolate and then canonicalize it.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1391433002 .
2015-10-06 10:57:02 -07:00
Srdjan Mitrovic 8c7a94e9f4 Preparation for moving reusable handles to thread and more cleanups: isolate -> thread based handle allocation.
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org/1384403002 .
2015-10-06 10:17:12 -07:00
John McCutchan af0ab36f7c Make dart:_vmservice a proper builtin library
- Drops custom resource table for sources.
- Stops loading dart:vmservice library by sources.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1387043002 .
2015-10-06 07:58:14 -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 1a11dbfc1c Allocate error messages in old space: needed for background compilation and rarely done
BUG=
R=koda@google.com, regis@google.com

Review URL: https://codereview.chromium.org//1375443004 .
2015-10-01 13:13:04 -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
Srdjan Mitrovic edccf3af0a Cleanup: we are not patching entries any longer
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1376963002 .
2015-09-30 10:22:59 -07:00
Daniel Andersson f500a1bdd8 Clarify heap write protection interface and use WritableVMIsolateScope to resolve issue 23217.
BUG=23217
R=asiva@google.com

Review URL: https://codereview.chromium.org//1374373004 .
2015-09-30 10:17:51 -07:00
John McCutchan 6b622133ca Fill the header of an Instructions object with null
Fixes debug mode failure discovered on mips bot.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1375283003 .
2015-09-30 10:06:30 -07:00
John McCutchan 3e5214ab2e Restore back pointer from Instructions to Code
Fixes #24449

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1377583005 .
2015-09-30 07:27:37 -07:00