Commit Graph

957 Commits

Author SHA1 Message Date
Srdjan Mitrovic c87181af57 Fix detection if a function was compiled,
Background compilation requires that a function was run through parser in mutator thread at least once. Because snapshots can/could preload ICData and code they are not reliable signals if the function was compiled or not. Add a bit to function object.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1857273002 .
2016-04-05 13:32:14 -07:00
Siva Annamalai 78a6b46155 Provide ability to patch external functions in a class that has already been finalized. The following restrictions are in place:
- No new fields or patching of existing fields can be done
 - Only external methods that have not already executed (i.e code for it has been   generated) can be patched

This change enables patching of JS Interop methods into a class and provides close to 5 sec drop in start up times for Green Tea app.

R=hausner@google.com, regis@google.com

Review URL: https://codereview.chromium.org/1850653003 .
2016-03-31 20:06:44 -07:00
Ryan Macnak b2f3e8efe1 Precompilation: don't include an object header for instructions in the text section.
Reference Instructions only through Code::entry_point_ (or Function::entry_point_). Store the instructions size in its corresponding Code object.

precompiled dart2js x64 22163470 -> 21621102 (-2.45%)

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1808553002 .
2016-03-29 11:04:04 -07:00
Srdjan Mitrovic 7ed2b851a9 Enable export lookup by two threads (mutator and background compiler) by carying a copy of exports_ in exports2_.
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1839123002 .
2016-03-29 10:56:56 -07:00
Srdjan Mitrovic 389dad87f7 Fix stub frame walking: when materializing the frame content during deoptimization, the stack is not yet set up properly (missing code object). This happens when background compiler requires GC.
Revert fixes other crashes in stack walk.
Revert "Reapply "Remove Code::active_instructions_.""

This reverts commit 28846c4bd4.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1830733002 .
2016-03-23 14:43:02 -07:00
Ryan Macnak 28846c4bd4 Reapply "Remove Code::active_instructions_."
Was reverted because it altered timing and saw a profile tick during
deoptimization, fixed in 7e9c892435.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1820333002 .
2016-03-22 10:16:13 -07:00
Ryan Macnak b070d98f6e Simpler regex names:
C++ JSRegExp -> RegExp
  Dart _JSSyntaxRegExp -> _RegExp
  Function RegExp.:irregexp: pattern -> RegExp.:matcher: pattern

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1815333002 .
2016-03-21 17:21:05 -07:00
Regis Crelier 966aea003b Remove recently introduced FunctionType vm class by merging it into class Type.
Fix syntax used when printing function type with optional named parameters.
Fix several issues discovered with cloning function types.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1815733003 .
2016-03-21 14:08:57 -07:00
Ryan Macnak d3901a3fa1 Revert "Remove Code::active_instructions_."
This reverts commit 714027a81b.

Review URL: https://codereview.chromium.org/1821793002 .
2016-03-21 13:06:46 -07:00
Ryan Macnak 714027a81b Remove Code::active_instructions_.
It is only used to test if the Code has been disabled, and we can instead test if the active entry point matches the Instruction's entry point. A Code's entry point is either for its own Instructions or Instructions of stub code in the VM isolate, so we don't need this field to keep the Instructions alive.

precompiled dart2js x64 22254552 -> 22165795 (-0.39%)

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

Review URL: https://codereview.chromium.org/1814623003 .
2016-03-21 10:53:31 -07:00
Florian Schneider f3de2377ab Move the VM's typed_data implementation to runtime/lib.
This removes the additional indirection to the VM's implementation
for all the factory constructors.

Additionally, it removes one class per typed data list type, thus reducing
snapshot and generated code size.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1790593002 .
2016-03-21 13:39:49 +01:00
Ryan Macnak a78ed1c47a Tree-shake consts.
BUG=http://dartbug.com/25892
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1758153002 .
2016-03-04 09:42:53 -08:00
Florian Schneider 72a815c39f VM: Add smi fast path operations for precompiled code
The non-smi case is handled in a slow-path deferred code path.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1756403002 .
2016-03-04 09:33:09 -08:00
Srdjan Mitrovic 5a69e3661b In background compilation make a copy of Field in order to freeze its state. Add flag --force_clone_compiler_objects for debugging purpose.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1722733002 .
2016-02-26 09:07:49 -08:00
John McCutchan 3b0104732b Remember token position where a function was inlined
When inlining a function, remember the token position of the call. I need this information for source level profiling.

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1739963002 .
2016-02-25 14:47:11 -08:00
Ryan Macnak 4b112c6d25 Precompilation: drop unused types and type arguments and empty classes and libraries.
precompiled dart2js arm 20748837 -> 20639848 (-0.52%)
precompiled flutter asteriods arm64 8926398 -> 8782136 (-1.6%)

R=regis@google.com

Review URL: https://codereview.chromium.org/1686773002 .
2016-02-22 14:05:03 -08:00
Ivan Posva c822c34af6 - Add DEBUG_ONLY and NOT_IN_PRODUCT macros.
- Remove user_name_ field from RawClass using macros.
- Consolidate "#ifndef PRODUCT" and "#ifdef DEBUG" code using macros.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1715123003 .
2016-02-19 17:48:08 -08:00
Ryan Macnak c03761a21a Don't include ICData::owner_ in precompiled snapshots.
It can refer to a function that has always been inlined and that the
tree shaker has removed.

precompiled dart2js x64 21647652 -> 21437594 (-0.97%)

R=srdjan@google.com

Review URL: https://codereview.chromium.org/1698323003 .
2016-02-16 13:38:28 -08:00
Florian Schneider 1f7458ddf8 VM: Precompiled rodata snapshot.
For now only contains PC descriptors and stack maps and one-byte strings.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1584443002 .
2016-02-15 09:15:26 +01:00
Todd Turnidge 6ed1a58741 Dart_SetReturnValue now accepts and propagates error handles.
The error propagation is delayed until the native function returns.

This should simplify error handling in embedder code and avoid failing
to propagate an error, which is a common failure.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1663613002 .
2016-02-03 11:20:02 -08:00
Ivan Posva 4f392df85e Fix some more shorten-64-to-32 warnings:
- Remove duplicate check for javascript integer overflow.
- Make sure the BitField class knows the type it is
  encoding into.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1644223006 .
2016-02-02 13:58:06 -08:00
John McCutchan d77d376124 Replace intptr_t with TokenDescriptor
- Use TokenDescriptor instead of intptr_t for all token positions.
- Use TokenDescriptor in raw_object instead of int32_t.
- TokenDescriptor is a POD with an int32_t (this shrinks the size of AST and IR nodes by 32-bits on 64-bit architectures).

There are some cleanups I plan on doing as a follow up CL:

- Replace TokenDescriptor::value() with TokenDescriptor::TokenPos()

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

Review URL: https://codereview.chromium.org/1644793002 .
2016-02-02 10:15:44 -08:00
Ryan Macnak c7efe5a756 Precompilation: compact the symbol table.
Also, don't leak handles out of the precompiler.

dart2js/x64:
symbols 62126 -> 38668 (-37.8%)
snapshot 22534723 -> 21740838 (-3.5%)

R=asiva@google.com

Review URL: https://codereview.chromium.org/1638143002 .
2016-01-28 10:23:14 -08:00
John McCutchan b5259257bd Introduce CodeSourceMap object to hold pc -> token position mappings
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1634863002 .
2016-01-26 13:07:22 -08:00
Regis Crelier 7f57ebcfa1 Remove signature classes from the VM.
They were used as the class of closure instances and as the type class of
function types.
All closure instances now have class _Closure and function types are represented
by a new class FunctionType extending AbstractType.
Fix issue 24567 and add regression test.

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

Review URL: https://codereview.chromium.org/1584223006 .
2016-01-19 16:32:59 -08:00
Matthias Hausner 782f7b268b Report missing semicolons after function declarations
Also take the opportunity to add the ability to report an error after a given token position. This way, the missing semicolon gets reported where it should: at the end of the line rather than the first token on the following line, when the error is actually detected.

BUG= 23761
R=regis@google.com

Review URL: https://codereview.chromium.org/1574213005 .
2016-01-19 09:31:33 -08:00
Srdjan Mitrovic ab7525a820 For background compilation we copy ICData so that it is immutable during comnpilation. However, we must emit the original, shared ICData in the code. Provide a link from cloned ICData object to the original one.
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1544583002 .
2015-12-21 14:49:30 -08:00
Florian Schneider 978e7834ab Remove unused fields in RawField from precompiled snapshot.
This saves around 1% (25K for hello.dart, 75K for dart2js) from the
precompiled isolate snapshot.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1539563003 .
2015-12-17 20:42:52 +01:00
Matthias Hausner ad0f14e0ce Eliminate all but one top-level class per library.
Each script has an associated top-level class in which the top-level functions and fields are stored, and the reference to the script. All other fields in the TL class are unused. There are 380 TL classes in corelib alone; eliminating them saves space.

This CL eliminates all TL classes but one per library. All TL functions and fields in the library are stored in that TL class. Because scripts are not stored directly in functions and fields, but are accessible via their owner class, the owner of TL entities are now PatchClasses, rather than classes.

Before:
Size of vm isolate snapshot = 930813
New space (0k of 0k) Old space (1184k of 1624k)
VM Isolate: Number of symbols : 14909
Size of isolate snapshot = 261873
New space (0k of 2048k) Old space (987k of 1024k)

After:
Size of vm isolate snapshot = 931101
New space (0k of 0k) Old space (713k of 1156k)
VM Isolate: Number of symbols : 14907
Size of isolate snapshot = 256956
New space (0k of 1024k) Old space (514k of 768k)

R=iposva@google.com

Review URL: https://codereview.chromium.org/1410383020 .
2015-12-01 09:21:17 -08:00
Ryan Macnak 75cd019a9c Add RPC and UI for reachable size of an object / all instances of a class.
BUG=http://dartbug.com/24945
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1453983002 .
2015-11-20 10:02:16 -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
Ryan Macnak 73b6080a6b Omit nonessential code metadata from precompiled snapshots.
dart2js ARM -9.9% size

Before
VMIsolate(CodeSize): 2627828
Isolate(CodeSize): 11977642
Instructions(CodeSize): 12908480
Total(CodeSize): 27513950

After
VMIsolate(CodeSize): 2627206
Isolate(CodeSize): 9247198
Instructions(CodeSize): 12908512
Total(CodeSize): 24782916

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1413763018 .
2015-11-13 13:56:22 -08:00
Ryan Macnak 8be0d4aca1 Save the native name on the function instead of finding it in the token stream to resolve lazily-linked natives. Drop token streams from precompiled snapshots.
dart2js ARM -7.0% size

Before
VMIsolate(CodeSize): 4663679
Isolate(CodeSize): 11970519
Instructions(CodeSize): 12904384
Total(CodeSize): 29538582

After
VMIsolate(CodeSize): 2611555
Isolate(CodeSize): 11965825
Instructions(CodeSize): 12906464
Total(CodeSize): 27483844

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1412633007 .
2015-11-12 17:24:42 -08:00
John McCutchan f5e63ba792 Make profiler work without Instructions -> Code pointer
- Do one eager pass over both the vm and current isolate's heaps to populate the live code table instead of lazily sampling the heap for code objects.
- Remove Instructions -> Code pointer

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1435533003 .
2015-11-10 11:33:53 -08: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
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
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
Siva Annamalai 02c702bf92 1. Write the backing data array of a GrowableObjectArray as a reference
2. Cleanup and refactor WriteObjectRef and WriteObjectInlined and pass as_reference as a parameter to the WriteTo function to allow respective types to deal with it.
3. Added a as_reference parameter to the ReadFrom functions (currently the parameter is not used but the next round of changes will cleanup ReadObjectRef and ReadObjectInlined similarly).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1388543008 .
2015-10-12 12:45:59 -07:00
Daniel Andersson 3279885596 Parallel marking.
Provide both Unsync/SyncMarkingVisitor, where the latter uses CAS to acquire the header bits, guaranteeing that each object is processed by exactly one task when parallel tasks are running.

UnsyncMarkingVisitor preserves the old behavior w.r.t. synchronization, and is used when num_tasks is 0.

Split root set into two parts, and give them to separate tasks when possible.

Add basic logging to help investigate how well work is distributed. (Marking stack block size is currently 64.)

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1351453008 .
2015-10-08 15:01:57 -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
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
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
Siva Annamalai aac5baa90e Clean up serialization of RawFunction, RawCode
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1377543003 .
2015-09-29 13:11:53 -07:00
Ryan Macnak d7b46bf5c1 Don't use a special var descriptor for :async_op since it can now be either stack or context allocated.
BUG=http://dartbug.com/24439
R=regis@google.com

Review URL: https://codereview.chromium.org//1361423004 .
2015-09-25 13:47:41 -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 bac82e2592 VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

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

Committed: https://github.com/dart-lang/sdk/commit/1d343e5a7b75168fb6c9f86b64c55173cdbdc9b2

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-19 13:21:09 +02: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
Florian Schneider 7af7a2db87 Revert "VM: New calling convention for generated code."
This reverts commit 1d343e5a7b.

Because of Windows test failures.

BUG=
TBR=whesse@google.com

Review URL: https://codereview.chromium.org//1343373003 .
2015-09-16 13:46:05 +02:00
Florian Schneider 1d343e5a7b VM: New calling convention for generated code.
Instead of calling code object directly, call indirectly and
pass the code object in a register. The object pool is then loaded from
the code object. This is another preparation step for making generated code
relocatable.

All non-ia32 platforms:
No entry patching.

ARM:
PC marker (now code object) moves to the same place as on x64 (below saved PP, above saved FP).
R9 is now used as PP, R10 as CODE_REG.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1192103004 .
2015-09-16 13:05:58 +02:00
Siva Annamalai 228e8f6edd - Turn on writing of ic_data_array so that we have that information for script snapshots that would allow for code to be optimized right away
- Use snapshot Ids for singleton VM isolate singleton objects instead of writing them out into the snapshot

- Add support for writing function objects as an Id, this is needed to serialize function objects from the core library in a script snapshot (these function objects could potentially appear in the ICData).

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1337083004 .
2015-09-15 17:18:21 -07:00