Commit Graph

939 Commits

Author SHA1 Message Date
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

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

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

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
Matthias Hausner 4ca8417725 Allow methods to be named ‘factory’
Because it’s the law.

BUG=25489
R=regis@google.com

Review URL: https://codereview.chromium.org/1636583003 .
2016-01-25 13:46:52 -08:00
Matthias Hausner 783cc8acae Parser recursion check
Let the parser issue a compile-time error when the C stack is about to overflow, instead of crashing the VM.

BUG=24476
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1620493002 .
2016-01-22 08:59:45 -08:00
Lasse R.H. Nielsen 693628e99e Implement ?? as compile-time constant in VM.
Extracted from https://codereview.chromium.org/1493693002/

R=hausner@google.com

Review URL: https://codereview.chromium.org/1575383002 .
2016-01-22 12:39:16 +01: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
John McCutchan 77101d63e3 Source positions for constructors and lots of async machinery
- Rework token position address space.
- Use ClassifyingTokenPositions::kMethodExtractor for the token position of a method extractor.
- Plumb token positions through all of Ast Transformer.
- Plumb token positions for temporary expressions, etc in Flow Graph Builder.
- Add token positions for parts of the await machinery.
- Move ClassifyingTokenPositions into token.h.
- Remove default token position of Scanner::kNoSourcePos for many IR instructions.
- A couple of unit tests.
- Use synthetic token positions for synthetic AstNodes.
- Fix SLEB128 encoding / decoding + test
- s/Scanner::kNoSourcePos/Token::kNoSourcePos.
- Remove >= 0 and < 0 checks against token positions and use helpers instead.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1589643002 .
2016-01-19 15:01:08 -08:00
Florian Schneider f47839ba09 Rename DART_PRECOMPILED -> DART_PRECOMPILED_RUNTIME
To avoid future confusion with precompiler compiler-related macros/build targets

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1581393008 .
2016-01-19 13:59:49 -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
Regis Crelier ca1d105c5a Fix finalization of recursive type graph with bounds (issue 25389).
Add regression test.
Rename malformed_error to bound_error.
Fix internal name of bounded type (broken by a previous cl).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1580643004 .
2016-01-13 11:19:14 -08:00
John McCutchan bda2b3d2ff Source position tests for switch and try catch finally
- Give AwaitMarkerNode a token position.
- Make it possible to provide a token position for SaveContext, RestoreContext, StoreContext, and CurrentContext.
- Pass in a token position to internally generated StoreLocal and LoadLocal instructions for try-catch-finally.
- Introduce a Context ClassifyingTokenPosition to be used when we can't attribute a context related instruction to a source position.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1575953005 .
2016-01-12 15:02:35 -08:00
Matthias Hausner 0964f26d24 Add flag to make await and yield keywords
Using --await_is_kw forces the parser to treat await and yield as keywords even in synchronous code.

BUG=
R=iposva@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1573153003 .
2016-01-12 09:52:51 -08:00
John McCutchan 3ca0a08117 More source position improvements and tests
- Provide source positions for some ConstantInstrs.
- Classify all other ConstantInstrs.
- Use the token position of ++ rather than x in the expr: "x++;" for the add, constant 1, and final load operations.
- More tests
- Improvements to the test helpers.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1576583003 .
2016-01-11 10:19:08 -08:00
Matthias Hausner 4ffdcb76df Eliminate phase parameter in constructors
Super initializer calls get implicitly moved to the end of the initializer list, so we don't need the two-phase constructor protocol anymore.

Ryan, can you please look at the mirror changes and check wether I've missed something?

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

Review URL: https://codereview.chromium.org/1569213003 .
2016-01-08 15:41:51 -08:00
John McCutchan 789ed02b39 Don't test directly against Scanner::kNoSourcePos instead use >= 0.
A follow up CL will introduce new sentinel token positions that are < Scanner::kNoSourcePos (-1)

Gazoo

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1568353002 .
2016-01-08 12:20:24 -08:00
Florian Loitsch e0fe0c0ed8 Add support for configuration-specific imports to the VM.
R=hausner@google.com, iposva@google.com

Review URL: https://codereview.chromium.org/1380383002 .
2016-01-06 20:16:09 +01:00
Ryan Macnak c4480b6ded More 0 => Scanner::kNoSourcePos.
Arguably method extractors, invoke-field dispatchers and noSuchMethod dispatchers should also have their token position as kNoSourcePos instead of 0, but this would complicate how parser initializes its token iterator, so I'm leaving them as is.

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

Review URL: https://codereview.chromium.org/1566553003 .
2016-01-06 11:12:03 -08:00
Florian Schneider e9968ca5ff Fix VM bug with try-catch inside of try-finally.
There were two exception handlers with the same index added to the code so that only the one added
last was executed. In case of an exception that means that a re-throw may be omitted, causing invalid
control flow.

Also, add assertion to ensure unique try-index for exception handlers.

BUG=#25333
R=hausner@google.com

Review URL: https://codereview.chromium.org/1569523002 .
2016-01-06 18:50:53 +01:00
John McCutchan cb8b641cc9 Make Scanner::kNoSourcePos be a true sentinel value
- It is possible to write a Dart program with a function token_pos of 0.
- Switch Scanner::kNoSourcePos from 0 to -1.

R=hausner@google.com

Review URL: https://codereview.chromium.org/1564493002 .
2016-01-06 09:06:28 -08:00
Matthias Hausner 11a101a325 Canonicalize expressions that may be used as constants
Evaluate and canonicalize the parameters to the built-in function
identical(a,b) if they are strings. This guarantees that
identical(“ab”, “a”+”b”) evaluates to true.

Note: when the parser parses “a”+”b”, it doesn’t know whether the
expression will be used in a context that may require a
constant value. The canonicalization is thus deferred until it is
known that it is required.

BUG=25024
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1558033002 .
2016-01-05 08:51:52 -08:00
Florian Schneider 413ec9682e VM compiler: Remove dead strict-compare instructions in optimized code.
Also, remove two redundant const_casts.

BUG=
R=vegorov@google.com

Review URL: https://codereview.chromium.org/1554183002 .
2016-01-04 18:22:26 +01:00
Srdjan Mitrovic 6f867815d8 Incremental changes from background compilation work
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1541133003 .
2015-12-22 12:24:01 -08:00
Matthias Hausner cb5e586848 Ignore constructor phase parameter
When --move_super is true (the default value), the super constructor call
is moved to the end of the initializer list. In that case, the phase parameter
is not necessary. This change eliminates the check of the phase parameter in the constructor code, but does not yet eliminate the phase parameter.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1544703002 .
2015-12-21 15:01:13 -08:00
Matthias Hausner f51f96816d Move super initializer to end of list.
Introduce --warn_super flag to print a warning when a super call is found that is not at the end of the initializer list.

Mark failing tests as Fail, OK.

In a later step, we can eliminate the implicit 'phase' parameter in constructors.

BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org/1540673002 .
2015-12-18 15:37:07 -08:00
Ryan Macnak c740fea545 VM: Fix crash parsing metadata with a closure as a const constructor argument.
BUG=http://dartbug.com/25240
R=hausner@google.com

Review URL: https://codereview.chromium.org/1534033003 .
2015-12-17 17:18:01 -08:00
Matthias Hausner 8293e9665b Fix owner of mixin forwarding constructors
Not sure why the new test appears to be a change to existing files, rather than an new files. I'm too dumb for git.

BUG=25246
R=regis@google.com

Review URL: https://codereview.chromium.org/1533823004 .
2015-12-17 14:16:40 -08:00
Florian Schneider 4a037f0ccb VM: Use read-only handle Object::dynamic_type() where possible.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1528873002 .
2015-12-16 11:31:53 +01:00
Florian Schneider fbdce6a59e VM: Const-correctness fixes.
Three types of fixes:
1. Remove redundant const_cast
2. Remove const_cast by adding const when appropiate.
3. Remove const_cast by removing const (e.g. places where we call free with it)

For now I only fixed places where the fix is local enough - i.e. does not require
changed a large amount of code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1526123002 .
2015-12-15 19:24:40 +01:00
John McCutchan 27d05fc98a Add more compiler timeline durations
All phases of unoptimized and optimized compilation are now on the timeline.

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

Review URL: https://codereview.chromium.org/1523833003 .
2015-12-15 09:51:47 -08:00
Florian Schneider 12155b1920 VM: Add missing source line info in await-for statements.
When an exception occurs in the constructor of the steam iterator, the
stack trace was missing the source position.

BUG=#24084
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1516493002 .
2015-12-10 18:58:12 +01:00
Matthias Hausner d68a7de36a Fix mismatched parenthesis error message
'file:xxxx.dart': error: line 2 pos 4: unterminated '('
foo(state { // <= missing closing parenthesis
   ^

Also include a couple of postscripts from previous change.

BUG=5830
R=iposva@google.com

Review URL: https://codereview.chromium.org/1504313003 .
2015-12-08 15:36:10 -08:00
Ryan Macnak bf1724948f Add timeline events for CompileClass and CompileTopLevel.
R=iposva@google.com

Review URL: https://codereview.chromium.org/1513503003 .
2015-12-08 15:26:07 -08:00
Matthias Hausner 23bfa8163d Strip meta-data when VM runs with --enable-mirrors=false
When the mirrors system is unavailable, there is no need to create the fields for metadata annotations in code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1504673004 .
2015-12-07 12:49:08 -08:00
Matthias Hausner 0bbfe1e23b There are about 60 patch classes in the libraries. Running dart2js causes about 25 of them to be compiled and applied, so we get rid of 25 of 60 Class objects.
Review URL: https://codereview.chromium.org/1498933002 .
2015-12-04 13:11:25 -08:00
Matthias Hausner 4733386ca8 Reset top-level class finalization
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1493533002 .
2015-12-02 09:59:32 -08:00
Florian Schneider 5f073e7be0 VM: More read-only handles for constant null-objects/-instances.
Use Object::null_## for null-constants where possible.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1488773004 .
2015-12-02 11:36:30 +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
Zachary Anderson c888f04ba3 Fixes setjmp clobbering warnings.
Also fixes an unused result warning.

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

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

Review URL: https://codereview.chromium.org/1473403003 .
2015-11-25 11:07:22 -08:00
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
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 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
Srdjan Mitrovic c4aee38224 Pass type argument to Field construction, thus freezing that field, denoting it cannot be changed later.
BUG=
R=regis@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/1406943006 .
2015-11-09 13:54:57 -08:00
Srdjan Mitrovic 9dcd1fd076 Background compilation fixes
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1426513006 .
2015-11-05 09:53:13 -08:00
Srdjan Mitrovic 181e8cc2a9 Move resolving of natives to a late stage (during code emission). That eliminates unnecessary native resolution (e.g., when native gets recognized or rejected in the inliner). Removed tests that are now impossible to implement with AST (fake native functions).
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org/1420173006 .
2015-11-03 16:18:24 -08:00
Florian Schneider 598018bd21 VM: Fix bug with ??= expressions using await.
Moving the construction of ?? into the parser using LetNode, so that the await-transformations are properly applied.

a ?? b becomes { temp = a; temp !== null ? temp : b; }

a ??= b becomes { temp = a; temp != null ? temp : a = b; }

BUG=issue #24392
R=hausner@google.com

Review URL: https://codereview.chromium.org/1417733007 .
2015-11-03 21:47:06 +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
Matthias Hausner f094c36141 Constant cache improvement
Change the compile-time constant map to use a pair (url, token_pos) as
the key. Previously, the two values were concatenated into a string, which creates a lot of new strings.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org/1424393002 .
2015-11-02 10:59:19 -08: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
Florian Schneider 9a0b13fe86 VM: Replace CheckedHandle with Cast/Handle in some places.
CheckedHandle are only when entering C++ from native code,
or when calling out via the API.

Otherwise Cast and Object::Handle is sufficient.

BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1376183002 .
2015-10-21 16:54:50 +02: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