Commit Graph

362 Commits

Author SHA1 Message Date
Alan Knight 12e93cc41e Revert "Updated parser to produce error when trying to reinitialize final variables in class constructors. Fixes issue #29658."
This reverts commit 9755a98b00.

BUG=

Review-Url: https://codereview.chromium.org/2949943002 .
2017-06-20 15:25:55 -07:00
Ben Konyi 9755a98b00 Updated parser to produce error when trying to reinitialize final variables in class constructors. Fixes issue #29658.
BUG=
R=zra@google.com

Example:
Foo {
  final int x = 10;
  Foo(this.x); // Error
  Foo.named() : x = 42; // Error
}
Review-Url: https://codereview.chromium.org/2947043002 .
2017-06-20 14:40:36 -07:00
Ben Konyi a4a227e375 Revert "Updated parser to produce error when trying to reinitialize final variables in class constructors. Fixes issue #29658."
This reverts commit b5cff3f68f.

TBR=zra@google.com

Review-Url: https://codereview.chromium.org/2944223002 .
2017-06-19 17:23:01 -07:00
Ben Konyi b5cff3f68f Updated parser to produce error when trying to reinitialize final variables in class constructors. Fixes issue #29658.
BUG=
R=asiva@google.com

Example:
Foo {
  final int x = 10;
  Foo(this.x); // Error
  Foo.named() : x = 42; // Error
}
Review-Url: https://codereview.chromium.org/2939553005 .
2017-06-19 12:07:37 -07:00
Régis Crelier b7ebbf8c77 Allow a function named 'get' to be generic (fixes #29746).
Add regression test.
Mark status files for failing dartk, dart2js, and analyzer.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2911333002 .
2017-05-30 15:31:04 -07:00
Martin Kustermann ef71b485eb Fix new space allocation in parser which can be triggered on background compiler
This CL introduces also `Parser::allocation_space_` field which is set
to Heap::kNew on mutator thread and Heap::kOld on all other threads.

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

Review-Url: https://codereview.chromium.org/2902063003 .
2017-05-29 11:06:51 +02:00
Siva Chandra 3b9cf7351b Allow setting breakpoints in literal function initializers of fields.
Fixes #29581 when the VM parser is used.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2904793002 .
2017-05-26 13:43:34 -07:00
Régis Crelier 9aafded095 Pass type argument vector to generic functions (if --reify-generic-functions is
true, still false per default).
Work in progress, not functional yet (passed vector is still ignored in callee).

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

Review-Url: https://codereview.chromium.org/2859673002 .
2017-05-18 14:03:47 -07:00
Régis Crelier fd5089c9e8 Remove parent_level field of function type parameters.
Add function_type_arguments field in closure instances.
Lots of other smaller changes, also related to generic function semantics.
This is still work in progress, with a change of direction in the design:
The type argument vector of a generic function will be prepended with the type
arguments of enclosing generic functions. The re-allocation and concatenation
will be done in nested generic function's prolog. This will greatly simplify
instantiation of types at run time without having to search the context for
parent function's type arguments. However, a closure instance now requires an
additional field. On the other hand, type parameters do not require a
parent_level field anymore.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2818273002 .
2017-04-17 08:58:24 -07:00
Matthias Hausner d8ddd7766b Fix debugger regression in issue 28980
When generating the implicit try-catch of an async function, use the
end token position of the function for the completeError() call. Before
this change, the position was one token past last function token.

CL https://codereview.chromium.org/2646093006/ introduced a regression.
This CL fixes #28980 and implements a different fix for #28443.

BUG=#28980
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2740783007 .
2017-03-09 16:20:48 -08:00
Regis Crelier 09b5d6f619 Manage and capture class and function instantiators in the parser.
This is work in progress towards supporting generic function semantics.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2736733005 .
2017-03-08 08:55:30 -08:00
Regis Crelier f3080b8803 Refactor type finalization in VM so that the parser only resolves type
parameters, whereas the class finalizer resolves all other type names and
performs finalization and canonicalization. This allows to remove a lot of
duplicated code between parser and class finalizer.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2673093003 .
2017-02-03 12:38:31 -08:00
Regis Crelier 97f968de1c Implement generic function type syntax in the VM (fixes #27966).
The new function type syntax is allowed everywhere and not just in typedef.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2643523002 .
2017-01-27 08:45:03 -08:00
Florian Schneider 9c82d88d67 VM: Fix bug in deferred loading.
In some cases when loading a deferred library twice, the VM would crash/throw.

Make sure we generate the correct static NoSuchMethod error when referring to
a deferred library that is not loaded yet.

Fixes #28278.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2618823002 .
2017-01-05 18:20:51 -08:00
John McCutchan f125cc7d0b Improve the casing of Stackmap and Stacktrace.
- [x] Stackmap -> StackMap
- [x] Stacktrace -> StackTrace

This makes us consistent with the Dart language (StackTrace) and
corrects the casing of StackMap.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2572563004 .
2016-12-12 14:51:30 -08:00
Regis Crelier 6da1083953 Disallow deprecated typedef syntax for mixin apps in the VM (fixes #14410).
Update status files (will reassign issue #14410 to dart2js, since it still
accepts the syntax).

R=floitsch@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2556433004 .
2016-12-07 07:34:09 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

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

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
John McCutchan 8061bd5a8a Add local variable declaration token position to service protocol
- [x] Add three public fields to the "BoundVariable" service type: declarationTokenPos, visibleStartTokenPos, and visibleEndTokenPos. (naming suggestions welcome!)
- [x] Extend LocalVarDescriptors to hold the declaration token position (it already had the scope visibility boundaries).
- [x] Extend ContextScope to hold the declaration token position.
- [x] Add a unit test which verifies this works for local variables, function parameters, and closure captured variables.

Fixes https://github.com/dart-lang/sdk/issues/25569

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2419013004 .
2016-10-17 11:18:24 -07:00
Vyacheslav Egorov f67ce21068 VM support for running Kernel binaries.
BUG=
R=asiva@google.com, fschneider@google.com

Review URL: https://codereview.chromium.org/2411823003 .
2016-10-15 22:48:46 +02:00
Regis Crelier 11562f6874 Support generic method syntax (fixes #25869).
Function type parameters are parsed and resolved, but mapped to malformed types
(i.e. dynamic) until full support is implemented.

R=hausner@google.com

Review URL: https://codereview.chromium.org/2349593003 .
2016-09-19 15:17:33 -07:00
Lasse R.H. Nielsen 99439a336a See: https://docs.google.com/document/d/1iEuLbDMgbB657R5aFj9EfnT6B0obzQk93Of7CfWKc00/edit#heading=h.9ixvz54wwawi
Implement assert in initializer list in VM.

R=hausner@google.com

Review URL: https://codereview.chromium.org/2002923002 .
2016-08-24 12:43:26 +02:00
Matthias Hausner 4d4ebafad3 Implement parsing support for generic functions
Take two. (This version adds status file entries for checked
tests.)

Type parameters and arguments are parsed but ignored. Proper
handling of the parameters will be added subsequently.

The feature must be enabled with --generic-method-syntax.

Compiling all of dart2js consumes about 2.2% more tokens with
this change, due to the necessary lookahead to distinguish
generic functions from generic types.

===== with this change =========

Number of tokens:        1056691
Source length:           5850143 characters
Number of source tokens: 936226

Total tokens consumed:   3628934  <<<<<
Classes parsed:          2457
  Tokens consumed:       977999
Functions parsed:        49607
  Tokens consumed:       2430638

===== without this change ======

Number of tokens:        1056691
Source length:           5850143 characters
Number of source tokens: 936226

Total tokens consumed:   3547765 <<<<<
Classes parsed:          2457
  Tokens consumed:       942536
Functions parsed:        49607
  Tokens consumed:       2371357

(This reverts commit a1edb1766fd16b1268f3506feb7c9856b32bedfc.)

BUG= 25869

Review URL: https://codereview.chromium.org/2269693002 .
2016-08-22 10:58:55 -07:00
Matthias Hausner a1edb1766f Revert "Implement parsing support for generic functions"
This reverts commit 19af852471.

Checked tests failed. Will work on this on Monday.

TBR=asiva

Review URL: https://codereview.chromium.org/2267473002 .
2016-08-19 16:40:03 -07:00
Matthias Hausner 19af852471 Implement parsing support for generic functions
Type parameters and arguments are parsed but ignored. Proper
handling of the parameters will be added subsequently.

The feature must be enabled with --generic-method-syntax.

Compiling all of dart2js consumes about 2.2% more tokens with
this change, due to the necessary lookahead to distinguish
generic functions from generic types.

===== with this change =========

Number of tokens:        1056691
Source length:           5850143 characters
Number of source tokens: 936226

Total tokens consumed:   3628934  <<<<<
Classes parsed:          2457
  Tokens consumed:       977999
Functions parsed:        49607
  Tokens consumed:       2430638

===== without this change ======

Number of tokens:        1056691
Source length:           5850143 characters
Number of source tokens: 936226

Total tokens consumed:   3547765 <<<<<
Classes parsed:          2457
  Tokens consumed:       942536
Functions parsed:        49607
  Tokens consumed:       2371357

BUG=25869
R=asiva@google.com

Review URL: https://codereview.chromium.org/2260693002 .
2016-08-19 16:21:00 -07:00
Matthias Hausner e11ca24053 Use metadata annotation @patch for patch classes
Annotate patch classes and top-level patch functions with @patch
instead of the pseudo-keyword patch. This allows the analyzer
to read patch files, and matches the syntax that dart2js uses.

The deprecated syntax is still supported, but a warning is printed when detected.

BUG=

Review URL: https://codereview.chromium.org/2220883004 .
2016-08-09 09:48:03 -07:00
Ryan Macnak ee942bd8d6 Remove per-isolate compile-time constants cache.
There are no scripts in the VM isolate as of 83da4db9f9.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2147493005 .
2016-07-12 17:35:54 -07:00
Regis Crelier 455110c6ee Tighten check disallowing use of initializing formals (fixes #26855).
Add regression test.
Add exception for analyzer (filed an issue).

R=asiva@google.com

Review URL: https://codereview.chromium.org/2139003002 .
2016-07-11 15:30:24 -07:00
Todd Turnidge 62ccff992f Cache compile-time constants on the script object, sometimes.
When a script is not in the vm heap, we now cache compile time
constants on the script object itself.  During isolate reload we may
have both an old and a new version of a script being compiled at the
same time and they need to cache their constants separately.  This
also means that compile time constants from old scripts can be
collected when the script is collected, which is good.

When a script is in the vm heap, we continue to use the old system of
employing a shared per-isolate cache stored in the object store.

Closes #26833

BUG=
R=fschneider@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2126393003 .
2016-07-11 14:15:37 -07:00
Matthias Hausner 98033d4132 Simplify generated code for assert()
Move the assert condition check and throwing the error into
the Dart library. This eliminates one call to library code.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2073623002 .
2016-06-16 10:44:30 -07:00
Lasse R.H. Nielsen c56411d576 Make VM accept function values in assert statements.
Fix for issue #18454.

BUG= http://dartbug.com/18454

Review URL: https://codereview.chromium.org/2064663002 .
2016-06-15 10:08:39 +02:00
Matthias Hausner 1859ce46c3 Fix finally clause inlining for forward jumps
In switch statements, ‘continue L’ jumps can refer to a label
that the compiler hasn’t seen yet. The label is tentatively
to be in the innermost switch statement, but may later
be moved to an outer switch statement. The compiler must
make sure that the correct finally blocks are inlined in front
of these jumps.

BUG=26577, 25310
R=regis@google.com

Review URL: https://codereview.chromium.org/2030763002 .
2016-06-02 09:03:49 -07:00
Matthias Hausner 7daa2a8915 Fix capturing variables in optimized compilations
Fourth(!) attempt. This CL fixes another instance where parsing a nested function modifies the parser state of the function that is being compiled.

When a local function gets compiled the second time, constant
expressions may not be parsed again, since the constant value
is found in the cache. If the expression refers to an outer
variable, it does not get captured correctly.

Fix: instead of parsing a local function repeatedly to capture
outer variables, use the local function’s context scope to mark
outer variables as captured. This fixes the bug, and makes the
compiler more efficient as well.

BUG= 26453
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2010283004 .
2016-05-27 11:27:10 -07:00
Vyacheslav Egorov 655bc90489 Enable optimizer pipeline for DBC.
Most of the infrastructure is fixed to work with DBC stack layout:

- register allocator allocates DBC registers with the limitation that we allocate only 20 registers and bail out if anything needs spilling (there is no use implementing spilling on DBC because registers are memory locations themselves). We should be able to bump number of CPU registers on DBC up to 256 but this requires major surgery in some parts - so I postponed this;
- lazy deoptimization is implemented, eager deoptimization is not - because we don't emit any code that actually requires it. it's a minor change to support it once we have a target;
- stack scanning respects stack maps built by registers allocator;

We bailout from all unsupported instructions.

R=zra@google.com

Review URL: https://codereview.chromium.org/1992963002 .
2016-05-24 14:35:50 +02:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07:00
Siva Annamalai 95904322e7 Minor cleanup based on profiler output of CompileParseFunction.
- Add a zone parameter to TokenStream::Iterator
- Add IsXXXX() functions in raw_object.h using GetClassId()
- Modify
    - Function::owner
    - Function::origin
    - Type::IsMalformed
    - Type::IsMalbounded
    - Type::error
  to not create a Handle in the common path

R=regis@google.com

Review URL: https://codereview.chromium.org/1952023002 .
2016-05-04 15:30:56 -07:00
Srdjan Mitrovic 0c77e70b49 Cleanup access to guarded_fields
BUG=
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1712563006 .
2016-02-19 11:07:44 -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
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
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
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
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
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
Matthias Hausner 019a4e4e5c Add flag which moves super initializer statement
--move_super directs the VM compiler to move the super initializer
of a constructor to the end of the initializer list. The default
value is false. If we opt to enable this functionality, the implicit
phase parameter of constructors can be eliminated, simplifying
constructors significantly.

BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1382533003 .
2015-10-07 10:26:22 -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
Matthias Hausner f286b5b8b6 Moar constant caching
Insert all compile-time constants expression in the constant cache.

BUG=

Review URL: https://codereview.chromium.org//1303973007 .
2015-09-01 14:42:53 -07:00
Srdjan Mitrovic f857c1ba8e Remove more GrowableObjectArray usage in parser
Allocate appropriate data structures in old space from beginning

BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org//1316373002 .
2015-08-27 13:46:32 -07:00
Matthias Hausner 62e9d05668 Introduce per-isolate cache for compile time constants
Compile-time constant values are maintained in a cache, keyed
by script and token position. When the same code is compiled
again later, e.g. by the optimizing compiler, the value is
found in the cache and does not need to be computed again.

In this version, the key is a string concatenated from the
script url and the token position. That’s probably more overhead
than we want.

Added two compiler stat counters for number of cached constants
and number of cache hits. Running dart2js to compile a hello world
program results in about 1400 cached values and 85 cache hits.

BUG=
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1308073005 .
2015-08-26 16:17:20 -07:00
Srdjan Mitrovic 5985718945 Clean up default parameter computation in parser
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1316763002 .
2015-08-25 14:54:48 -07:00
Srdjan Mitrovic 304dc3486f Make default_parameter_values a ZoneGrowableArray instead of an array in new space
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1307943008 .
2015-08-24 17:22:44 -07:00