Commit Graph

39 Commits

Author SHA1 Message Date
Kevin Millikin d562f7ced5 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

BUG=
R=asgerf@google.com, jensj@google.com, vegorov@google.com

Committed: https://github.com/dart-lang/sdk/commit/ed77783cd32d55fdad61bf9bc749030847ba9384
Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-30 09:31:31 +02:00
Zach Anderson a7d1d99389 Revert "Remove definitions from Kernel canonical names."
This reverts commit ed77783cd3.

BUG=
R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2782913003 .
2017-03-29 11:25:17 -07:00
Kevin Millikin ed77783cd3 Remove definitions from Kernel canonical names.
Before: Canonical names contained pointers to the corresponding Kernel
tree which assumed that the whole tree was in memory whenever the
canonical names were.

Now: Canonical names do not contain these pointers.  They were only
really used to perform name-based lookup in the VM's heap so the
canonical name itself is enough.

If we later find that we need to get from a canonical name to its
Kernel tree we can add an offset in the binary (for instance) to the
canonical name or in a separate mapping on the side.

BUG=
R=asgerf@google.com, vegorov@google.com

Review-Url: https://codereview.chromium.org/2781893004 .
2017-03-29 16:03:03 +02:00
Dmitry Olshansky a8bc1de524 VM [KERNEL] Fix performance issue in KernelReader
Original code is constructing Class fields
and functions incrementally going through
poorly scalable AddFunction and AddField
reallocating the whole array on each call.

Instead accumulate things in GrowableArrays
and insert in one go.

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

Review-Url: https://codereview.chromium.org/2777963002 .
2017-03-27 20:24:15 +02:00
Kevin Millikin d715611c03 Use canonical names for some name-based lookup.
For compiling the platform libraries separately and for hot reload, we
will not link canonical names of Kernel libraries, classes, and
members to their Kernel definitions.  Those definitions will not be
persistent.

As a first step, change name-based lookup of libraries and classes to
be be based on the canonical name instead of the Kernel definition.

BUG=
R=jensj@google.com, kustermann@google.com

Committed: https://github.com/dart-lang/sdk/commit/a15b8c49ea195345f542d4efbe8d6dd29268d030
Review-Url: https://codereview.chromium.org/2762213002 .
2017-03-27 12:14:50 +02:00
Kevin Millikin 91bc604415 Revert "Use canonical names for some name-based lookup."
This reverts commit a15b8c49ea.

BUG=

Review-Url: https://codereview.chromium.org/2772803002 .
2017-03-23 14:21:06 +01:00
Kevin Millikin a15b8c49ea Use canonical names for some name-based lookup.
For compiling the platform libraries separately and for hot reload, we
will not link canonical names of Kernel libraries, classes, and
members to their Kernel definitions.  Those definitions will not be
persistent.

As a first step, change name-based lookup of libraries and classes to
be be based on the canonical name instead of the Kernel definition.

BUG=
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2762213002 .
2017-03-23 12:24:05 +01:00
Jens Johansen dc566e137b [kernel] Fix getter, run service tests in debug mode
Don't create getters for uninitialized static fields.
This fixes two assert hits that was hit when running service tests in debug mode via kernel. These can thus now be enabled.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2771443003 .
2017-03-23 08:26:10 +01:00
Vyacheslav Egorov 9bd34ef785 VM: [Kernel] Set DoubleInitializedBit on fields with double initializers.
If this field is not set correctly then background compiler constantly bails
out when encoutering stores to these fields.

R=erikcorry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2732273002 .
2017-03-07 14:52:52 +01:00
Jens Johansen 26b6ecdf63 Enable causal stacktrace in kernel
R=kmillikin@google.com, kustermann@google.com

Committed: https://github.com/dart-lang/sdk/commit/b29829660bcdee7eb394e6fd4635ff7a6a77ef01
Review-Url: https://codereview.chromium.org/2690873005 .
2017-02-24 12:11:30 +01:00
Jens Johansen 86d788e699 [Kernel] replace function debuggable originalAsyncMarker
Previously a functions debuggable field was set to false in the async transformation (and because it wasn't done yet, not in async* and sync* transformation, though it should have been). Now instead, set the original async status and set debuggable on the c++ side equivalently.

Also, on the c++ side, set a functions modifier to async etc if they were originally async etc.

BUG=
R=asgerf@google.com, kmillikin@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2697193008 .
2017-02-22 12:12:54 +01:00
Vyacheslav Egorov 364b8575de VM: Restore old implementation of ClassID.cid* fields.
When we were implementing bootstraping from Kernel in https://github.com/dart-lang/sdk/commit/23fd1a184b393825f29444243780f3593ce0b3c1 we switched ClassID.cid* fields to become 'static final' lazily initialized fields instead of constants as they were before. This was mainly done to allow dartk compile patched_sdk - because these fields were previously injected in runtime and never existed in the text form.

However this regressed code quality for app-jit and app-aot snapshots because 'static final' fields are reset by snapshotting so resulting code contains InitStaticField and LoadStaticField instructions.

BUG=
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2693863006 .
2017-02-16 17:43:42 +01:00
Regis Crelier 2037e7e884 Properly resolve upper bounds of generic function's type parameters.
Various minor cleanup related to generic functions.
Add flag in preparation of future work to fully support generic methods.

R=hausner@google.com

Review-Url: https://codereview.chromium.org/2696783002 .
2017-02-14 01:50:02 -08:00
Jens Johansen e7766c950e Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Committed: https://github.com/dart-lang/sdk/commit/2d5147be9d7435c06dd892d145d8717b6d1f62d5
Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:59:06 +01:00
Jens Johansen d0e0ef52ef Revert "Debugging in kernel shaping up."
This reverts commit 2d5147be9d.

INTPTR_MAX doesn't exist on all builders.

BUG=
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2664143002 .
2017-01-31 11:26:46 +01:00
Jens Johansen 2d5147be9d Debugging in kernel shaping up.
This introduces

- a list of valid token positions, so debugging actually
  starts to work, and the observatory can be loaded without crash.

- a list of valid yield positions, so stepping over await stuff
  works as expected.

- Adding "DebugStepCheckInstr" to the kernel generated il so stepping
  over await stuff works as expected, we can break in empty methods etc.

With this, approximately 80% of the service tests pass in kernel mode.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2632183002 .
2017-01-31 11:01:29 +01:00
Martin Kustermann e97bcc5475 VM: [Kernel] Partial support for metadata annotations
The CL adds metadata support for Fields/Classes/Functions/Constructors. There
are other places where annotations can be put in the Dart language but the
Kernel IR currently does not store it in the AST.

Whenever a element (e.g. a function) gets annotated, the VM will make a [Field] for this
element whos value is an array of evaluated constant metadata annotations.

This CL attaches to these [Fields] a `kernel_function` which is then used to do the constant
evaluation.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2632253002 .
2017-01-18 10:51:24 +01:00
Jens Johansen b2b00e8909 TokenPositions on more nodes when running from Kernel
Utilize the offsets added in previous CLs.
While this doesn't by it self give anything that resembles
a good debugging experience, it should now be possible to
set *some* breakpoints and actually break on them.

Because of the way observatory works (and because of an
unfinished Script::GenerateLineNumberArray (for kernel))
the formatting of the code you try to load up and 'debug'
has to be quite specific (e.g. no indentation at all),
and even then it mostly doesn't work.

This is step #3 in introducing these things, next step(s) will be
fixing stuff like the above.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2628693004 .
2017-01-13 13:10:20 +01:00
Kevin Millikin a39234eede Small cleanups in the Kernel FlowGraphBuilder
- The flow graph builder is only used to visit Statements and
  Expressions so it does not need TreeVisitor as a base class.  This
  will make refactoring it easier.

- The TranslationHelper is bound to a Thread so we do not need
  Thread::Current where we have a TranslationHelper.

- BlockExpression does not exist in Kernel any more, so it can be
  removed from the C++ AST implementation.

BUG=
R=kustermann@google.com

Review-Url: https://codereview.chromium.org/2624513005 .
2017-01-10 10:50:56 +01:00
Jens Johansen aecb572d76 Include source in kernel.
- For now include source uncompressed.
- When running from kernel, use token position 0
  (i.e. dummy, but 'real' position) as start and end on functions
  and classes to enable Observatory to run with the dill file.
- Debugging does not work, but one can browse the source in
  Observatory.

R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2587673004 .
2017-01-03 14:33:16 +01:00
Jens Johansen 760c048798 Set correct script on fields in kernel.
R=kmillikin@google.com

Review-Url: https://codereview.chromium.org/2583153002 .
2017-01-03 09:56:49 +01:00
Martin Kustermann ff8951a515 VM: [Kernel] Allocate objects in KernelReader/kernel::FlowGraphBuilder in Heap::kOld if appropriate
If we generate too much surviving objects in Heap::kNew during program reading
time or flow graph construction time we trigger (very aggressive) growth of new
space.

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2539173002 .
2016-12-01 13:51:29 +01:00
Vyacheslav Egorov 8eceda053f VM: [Kernel] Don't add implicit getters for top level fields into the library dictionary.
Tree shaker can't cope with this and produces incorrect snapshots that contains tree shaken classes.

R=kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org/2536683002 .
2016-11-28 15:50:24 +01:00
Vyacheslav Egorov 73ef820ec1 VM: [Kernel] Relax assertions in SSA construction and in Kernel loading.
- Kernel-to-IL translation leaves behind some unused constants without temp indices assigned.

- Let compile time errors propagate instead of failing with FATAL error in the post load class finalization.

R=kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org/2528763002 .
2016-11-24 16:19:22 +01:00
Jens Johansen f0da43445e Use field.RawOwner() for initializer to keep correct script.
E.g.

file1:
------------
library crash;

part "file2.dart";

main() {
  print(field2);
}

crash() {
  try {
    throw "Crashing!";
  } catch(exception, stacktrace) {
    print(stacktrace);
  }
}

file2:
------------
part of crash;

var field2 = crash();

We want something like

#0      crash (whatnot/file1.dart:11:5)
#1      field2 (whatnot/file2.dart:3:14) <-- good line
#2      field2 (whatnot/file2.dart:3:5)
#3      main (whatnot/file1.dart:6:9)

and not like

#0      crash (whatnot/file1.dart:11:5)
#1      field2 (whatnot/file1.dart:3:14) <-- bad line
#2      field2 (whatnot/file2.dart:3:5)
#3      main (whatnot/file1.dart:6:9)

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2519133004 .
2016-11-24 09:27:25 +01:00
Martin Kustermann 1aff626804 VM: [Kernel] Split kernel API into 3 steps: ([read binary], parse-binary, bootstrap, load program)
This avoids reading and parsing the kernel binary multiple times and avois
having it multiple times in memory (we don't free the 'kernel::Program*' object
ATM).

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2525623002 .
2016-11-23 09:26:15 +01:00
Martin Kustermann d41ea8ca6a VM: [Kernel] Fix bad-merge after rebasing
Review URL: https://codereview.chromium.org/2513393005 .
2016-11-21 17:31:20 +01:00
Martin Kustermann 27aeb31a8d VM: [Kernel] Cherry-pick from dart-lang/kernel_sdk
Do not eagerly finalize types in procedures.

Translate types in procedures without finalizing them.  This change
supercedes https://chromereviews.googleplex.com/516397015/.

Review URL: https://chromereviews.googleplex.com/521117013 .

R=vegorov@google.com

Review URL: https://codereview.chromium.org/2521603002 .
2016-11-21 16:43:53 +01:00
Martin Kustermann 63af3f56ee VM: [Kernel] Cherry-pick from dart-lang/kernel_sdk
Fix a trio of issues in type finalization.

1. We were using is_type_finalized to detect classes that had already been
   initialized by DilReader::ReadPreliminaryClass.  This state is not
   guaranteed by this function, however is_cycle_free is.

2. In the VM, classes that were created type finalized were not marked as
   cycle free because finalization did not consider them so cycle-freeness
   didn't matter.  We would therefore try to initialize these classes with
   DilReader::ReadPreliminaryClass and mutate types in them.  This causes
   them to have unfinalized types but still have is_type_finalized true.

3. Types in top-level procedures were not necessarily finalized.  A simple
   way to achieve this is to finalize each library's top-level class.

Review URL: https://chromereviews.googleplex.com/520437013 .

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2514373002 .
2016-11-21 16:38:30 +01:00
Vyacheslav Egorov 46fcf14475 VM: [Kernel] Don't use Parser::ParseStaticFieldInitializer for fields that come from Kernel.
Introduce separate function kernel::ParseStaticFieldInitializer to handle these fields.

R=kustermann@google.com
BUG=

Review URL: https://codereview.chromium.org/2515763002 .
2016-11-21 15:53:00 +01:00
Jens Johansen 63e9c7641b Merge of source position information from kernel-sdk.
I.e. use offsets (on some nodes) in the dill file to
get stacktraces with line- and column numbers.

"sdk" version of "kernel-sdk"s
https://chromereviews.googleplex.com/520617013/

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2512653002 .

Committed: https://github.com/dart-lang/sdk/commit/6fd3a42edb4c7902a49811318de6bb6b18dbd829
2016-11-21 14:13:46 +01:00
Jens Johansen 1056c562aa Revert "Merge of source position information from kernel-sdk."
The commit broke 2 tests:
vm/cc/IsolateReload_TypeIdentityGeneric
vm/cc/SourceReport_Coverage_AllFunctions_ForceCompile

This reverts commit 6fd3a42edb.

BUG=

Review URL: https://codereview.chromium.org/2517953002 .
2016-11-21 11:16:29 +01:00
Jens Johansen 6fd3a42edb Merge of source position information from kernel-sdk.
I.e. use offsets (on some nodes) in the dill file to
get stacktraces with line- and column numbers.

"sdk" version of "kernel-sdk"s
https://chromereviews.googleplex.com/520617013/

R=kmillikin@google.com

Review URL: https://codereview.chromium.org/2512653002 .
2016-11-21 10:19:31 +01:00
Vyacheslav Egorov 30e01bcd67 VM: [Kernel] Relax assertion in Script::GetTokenLocation().
Kernel binaries do not carry token streams.

Introduce a dummy URI to identify dummy Script objects created for Kernel entities.

R=rmacnak@google.com
BUG=

Review URL: https://codereview.chromium.org/2511883002 .
2016-11-18 15:58:16 +01:00
Vyacheslav Egorov 23fd1a184b VM: Support bootstrapping core libraries from Kernel binaries instead of source.
BUG=http://dartbug.com/27590
R=asiva@google.com

Review URL: https://codereview.chromium.org/2485993002 .
2016-11-16 13:56:20 +01: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
Martin Kustermann ab172a32d9 VM: [Kernel] Remove special-casing in FGB which is now handled by the frontend
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2473593003 .
2016-11-02 19:54:11 +01:00
Martin Kustermann 75eb4a6fc2 [Kernel] Remove handling of mixin classes in kernel support, since they are desugared in the frontend
R=vegorov@google.com

Review URL: https://codereview.chromium.org/2466413004 .
2016-11-02 09:54:17 +01: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