Commit Graph

330 Commits

Author SHA1 Message Date
Samir Jindel d8a4a3896a [vm] Multiple entrypoints: backend/assembler support.
Test Plan:

Will be tested by following revisions which introduce optimizations that invoke the
new entrypoint.

Change-Id: I56d714bceb92c44a13c46d52457154b82577aa8c
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/67345
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-16 17:15:32 +00:00
Alexander Markov 120f595ccc [vm] Use zone memory allocation in StreamingFlowGraphBuilder::BuildSwitchStatement
Change-Id: Ia01bec5941a3daefd4aed43c5951e9ab44f48d46
Reviewed-on: https://dart-review.googlesource.com/69700
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-13 18:12:19 +00:00
Jens Johansen 164c7e3195 Debugging sync* and yield
Set position on yield in sync* functions; use yield position in VM.

Change-Id: I1c92fd47e3c8d4f747242e076007c122ea0d2186
Reviewed-on: https://dart-review.googlesource.com/68366
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-08-07 08:39:32 +00:00
Jens Johansen f609258f3f Use the position on as when issuing AssertAssignable for as
E.g. the following program gives a type error, but previously didn't
tell what line had an error. This CL fixes the issue.

```
import "dart:async";

Future<Object> foo() {
  return Future.value("hello");
}

main() async {
  int x = await foo();
}
```

Change-Id: I27ae483b8b7ca63b9efac555a5cbc651296f227a
Reviewed-on: https://dart-review.googlesource.com/68367
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2018-08-07 06:35:28 +00:00
Samir Jindel 8d3d82ab39 [vm/kernel] Untangle the spaghetti-code in BuildGraphOfFunction and fix bugs.
Also remove Fragment initializer-list constructor.

Bugs:

1. We were always building the body of a constructor even if the initializers
   graph was closed. This would confuse the inliner exit collector which was
   informed about return instructions inside the body which were never linked
   into the graph.

2. We were not checking for stack overflow on each call to an sync-yielding
   closure; only on the first call.

3. Not a behavioral bug, but the prologue flow graph is no longer built out of
   order (dartbug.com/29737).

Change-Id: I467fbf171fd627492bf01cd96d6353c57e143eaa
Reviewed-on: https://dart-review.googlesource.com/67561
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-08-03 16:32:02 +00:00
Vyacheslav Egorov 4fa139b4b8 [vm/compiler] Rework how logical expressions are compiled to IL.
When logical expression is evaluated in the control context (e.g. if (cond) { ... })
avoid materializing a boolean value and then dispatching on it. Instead connect
true and false successors directly to then and else branches.

This CL also improves IL generated when logical expression is evaluated for value
(e.g. x = (cond)): we similarly avoid materializing intermediate results and also
avoid comparisons that are not needed, e.g. when evaluating x = A && B we construct
graph x = A ? B : false, instead of x = A ? (B == true ? true : false) : false style
of graph.

Change-Id: I204d414cc6751949641b6c46423a6319f6e2d89b
Reviewed-on: https://dart-review.googlesource.com/67562
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-02 10:51:53 +00:00
Alexander Markov 07c462b471 [vm] Refactoring: extract BaseFlowGraphBuilder to a separate file
Also, a few methods (needed for bytecode compiler) moved from
FlowGraphBuilder to BaseFlowGraphBuilder

Change-Id: Ibee87e6d5fdc8143786fd41763a9fd4897d06cba
Reviewed-on: https://dart-review.googlesource.com/67504
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-07-31 16:53:14 +00:00
Ben Konyi 079bebb78b [ VM ] Added missing token position for assert statements
Fixes #33610

Change-Id: I9e7a286d63f051686a196134d49a100364f81fb9
Reviewed-on: https://dart-review.googlesource.com/67620
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2018-07-31 16:17:04 +00:00
Samir Jindel cf0a70e531 [vm] Remove unused NSM-forwarder bit.
The need for VM support for NSM forwarders was replaced by an elaboration in
the Kernel FE.

Change-Id: Ic9c0ecee47c7e7147c8055503956fc2550c7c224
Reviewed-on: https://dart-review.googlesource.com/66569
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-07-25 21:37:35 +00:00
Alexander Markov 6bc1cdb5b1 [vm] Add unsafe mode to VM
This CL adds experimental --experimental-unsafe-mode-use-at-your-own-risk
VM option which does the following:
* Dart 2 strong mode type and bool checks are omitted.
* VM compiler optimizations which rely on strong mode types are disabled.

Applications which do not fail any strong mode checks at run time
should behave exactly the same in strong and weak modes.
Applications with failing strong mode checks will not see corresponding
errors but VM should not crash.

This option can be used for experiments, or as a temporary remedy for
regressions caused by expensive strong mode type checks.

Change-Id: I042cbccba83c105b61b3e11c659a35c20e0329cd
Reviewed-on: https://dart-review.googlesource.com/65484
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-20 20:31:19 +00:00
Alexander Markov 8245707b4c [vm] Refactoring: remove misuses of StreamingFlowGraphBuilder
In certain cases StreamingFlowGraphBuilder was used not for building
flow graph, but as an advanced kernel reader. This CL extracts all such
functionality from StreamingFlowGraphBuilder and revises all such uses.

StreamingFlowGraphBuilder constructors without FlowGraphBuilder are
removed. After this CL StreamingFlowGraphBuilder is only used to build
flow graph, as intended.

Change-Id: I69b08e24d37f8f2f336bee85334af11be1639b24
Reviewed-on: https://dart-review.googlesource.com/64821
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-17 16:36:50 +00:00
Alexander Markov 7f8db8d06f [vm] Refactoring: extract constant evaluator and fingerprints helper
This CL continues refactoring aimed at isolating StreamingFlowGraphBuilder.

StreamingFlowGraphBuilder dependency is removed from classes
* StreamingConstantEvaluator (it still depends on FlowGraphBuilder)
* ConstantHelper
* SimpleExpressionConverter
and several methods in object.cc.

StreamingConstantEvaluator and ConstantHelper are moved from
kernel_binary_flowgraph{.h, .cc} to a new source file
constant_evaluator{.h, .cc}. StreamingConstantEvaluator is renamed
to ConstantEvaluator.

KernelFingerprintHelper and KernelSourceFingerprintHelper are moved to
a new source file kernel_fingerprints{.h, .cc}.

Instances of kernel::FlowGraphBuilder no longer contain back reference
to a StreamingFlowGraphBuilder. In order to drop this circular dependency
TranslateFinallyFinalizers() is moved from FlowGraphBuilder to
StreamingFlowGraphBuilder.

Change-Id: Id550d22b3567dea9512328a900935bd6145a8107
Reviewed-on: https://dart-review.googlesource.com/64463
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-07-11 21:30:13 +00:00
Alexander Markov e5d31282eb [vm] Support Dart metadata on libraries and library dependencies in Dart 2 mode
Fixes https://github.com/dart-lang/sdk/issues/33774

Change-Id: I0b34cdf2bee099076e29bec6cfb849b0b250f690
Reviewed-on: https://dart-review.googlesource.com/64245
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-09 23:58:26 +00:00
Jens Johansen d26dba1619 More positions in dart2 constant evaluator
Use positions already available in for instance AsExpressions,
also adds new offsets in the kernel format to
SuperInitializer and RedirectingInitializer.

Bug: #33216
Change-Id: I542967ddc6ec782e6513d62fce038a49239e1622
Reviewed-on: https://dart-review.googlesource.com/63883
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-07-09 07:31:44 +00:00
Alexander Markov 98391f2737 [vm] Refactoring: move StreamingScopeBuilder out of kernel_binary_flowgraph
After previous refactoring, StreamingScopeBuilder no longer depends on
StreamingFlowGraphBuilder.

This CL moves StreamingScopeBuilder to a separate file
vm/compiler/frontend/scope_builder{.h, .cc}.

Also:
* StreamingScopeBuilder is renamed to ScopeBuilder.
* IntMap is moved to hash_map.h.
* Minor cleanup of unused forward declarations and friend classes.
Change-Id: I5e780a53f37935c0a1d563d4fbaec3a92ae13d6a
Reviewed-on: https://dart-review.googlesource.com/63692
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-07 19:00:12 +00:00
Alexander Markov 620ab34de6 [vm] Implement reading of parameter annotations from kernel
Fixes https://github.com/dart-lang/sdk/issues/33207

Change-Id: I201d262bb913c342b705a607b0d88ba345e759e0
Reviewed-on: https://dart-review.googlesource.com/63644
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-03 23:23:06 +00:00
Alexander Markov f39eaf937c [vm] Refactoring: remove dependency of StreamingScopeBuilder on StreamingFlowGraphBuilder
StreamingScopeBuilder does not build a flow graph, but it was creating
and using StreamingFlowGraphBuilder under the hood (in order to read kernel).

This change makes StreamingScopeBuilder independent of StreamingFlowGraphBuilder
and prepares StreamingScopeBuilder to be moved out of kernel_binary_flowgraph.

Also, several unused classes, fields and parameters are removed.

Change-Id: I40ff983caf0e548529b3c52f44dcb785bd4e9f40
Reviewed-on: https://dart-review.googlesource.com/63305
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-07-03 21:04:06 +00:00
Alexander Markov 8c63d578a6 [vm] Refactoring: move out classes independent of StreamingFlowGraphBuilder
This change continues refactoring to split kernel_binary_flowgraph and
kernel_to_il and move out parts which have no dependencies on flow graph
construction.

Bytecode reading is moved to a separate file bytecode_reader{.h, .cc}.

Metadata helpers, TypeTranslator, ActiveClass and other Active* are moved
to kernel_translation_helper.

Removed dependency of ICData tags on IL Instruction tags, so ICData objects
can be created by bytecode reader without depending on IL.

Unused AlternativeScriptScope is removed.

Change-Id: Ic9f98af82697b48013fb89802076b56833acf55d
Reviewed-on: https://dart-review.googlesource.com/63262
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-03 19:02:54 +00:00
Alexander Markov 7d03796193 [vm] Refactoring: make reading of kernel metadata and types independent of StreamingFlowGraphBuilder
This CL removes all dependencies on StreamingFlowGraphBuilder from
all metadata helpers and StreamingDartTypeTranslator.

This further decouples parts which are not related to flow graph building
and prepares them for moving.

StreamingDartTypeTranslator is also renamed to TypeTranslator.

Change-Id: I4cb90a214fae4f979160cca7ddc3f7fae1c637e8
Reviewed-on: https://dart-review.googlesource.com/62961
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-29 16:13:10 +00:00
Régis Crelier 18050cd45b [VM interpreter] Fix typo in loading constant pool entry for context offset.
Change-Id: I2404ed66c0ac38482ea2317e65ff6c2813eb2c3f
Reviewed-on: https://dart-review.googlesource.com/62884
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-06-28 21:05:08 +00:00
Alexander Markov f304948807 [vm] Refactoring: extract kernel translation helpers to a separate file
Change-Id: I228165e1ff768eacc7ee54ff787675931504e450
Reviewed-on: https://dart-review.googlesource.com/62722
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-28 15:43:35 +00:00
Régis Crelier 5db9e6c95e [VM interpreter] Do not load bytecode of synthesized functions with copied metadata.
Fix return of native call to bytecode function.
Fix stack level when returning from static field initializer.
Use a zone handle for handled exception types.

Change-Id: I3bd8340208a578f6248190b1aa9b3826d6ad6e48
Reviewed-on: https://dart-review.googlesource.com/62704
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-27 22:40:02 +00:00
Alexander Markov a7f0f7ea89 [vm] Add source positions to stack traces of bool checks
If a condition has a source position in kernel, this source position is
now used in stack traces for bool checks.

Issue: https://github.com/dart-lang/sdk/issues/33584
Change-Id: Idb833abbaeaa32e6c5deb0d383cc4215642d3f2a
Reviewed-on: https://dart-review.googlesource.com/62360
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-27 16:54:39 +00:00
Vyacheslav Egorov b9f11311f8 [vm/compiler] Fix incorrect assertion from 20ca5bbb05.
Must demangle the name before checking if it is a setter name.

Change-Id: I2d58b9d4d5cab319f67da045458277e9f42e2592
Reviewed-on: https://dart-review.googlesource.com/61933
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-06-25 09:52:13 +00:00
Vyacheslav Egorov 20ca5bbb05 [vm/jit] Introduce dynamic invocation forwarders that perform type checking
This forwarders are used at dynamic call-sites and perform type checking
for all non-generic-covariant arguments. This allows to skip the same
type checks in the actual method body.

This yield on average 10% improvement in performance across the body of
benchmarks including dart2js compilation times.

Bug: https://github.com/dart-lang/sdk/issues/33257
Change-Id: If3fc94a2e0a6f496ec0633f0b379d053a54a40ca
Reviewed-on: https://dart-review.googlesource.com/61244
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-06-25 07:27:04 +00:00
Alexander Markov eafa9ae4b6 [vm/kernel] Fix StreamingConstantEvaluator to handle non-const variables
Fixes https://github.com/dart-lang/sdk/issues/33214

Change-Id: I7991b537204f160b2991abf9995685e4cae69f88
Reviewed-on: https://dart-review.googlesource.com/61682
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-06-22 17:16:45 +00:00
Régis Crelier 3e2708eada [VM interpreter] Fix broken interpreter build.
Change-Id: I1a877f22605874c6a199e2cab53b068a54383927
Reviewed-on: https://dart-review.googlesource.com/61910
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-06-22 16:53:25 +00:00
Alexander Markov f885a0c8f3 [vm/kernel] Fix crash when reading symbol literal from Dart annotation
Fixes https://github.com/dart-lang/sdk/issues/33513

Change-Id: I1595409dd3faa363922d595c1c33e6acce92af74
Reviewed-on: https://dart-review.googlesource.com/61800
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-22 00:22:13 +00:00
Ryan Macnak fa7c38dec5 [vm, standalone] Do not copy when loading kernel.
In a topaz release build with JIT apps,
mondrian(flutter_runner):      PSS 44.4M -> 35.8M (-19.4%)
ledger_dashboard(dart_runner): PSS 15.2M -> 12.0M (-21.1%)

Change-Id: I501c24de56a5a7c65a2f03b87709cb09bb95d465
Reviewed-on: https://dart-review.googlesource.com/60202
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-06-21 23:27:53 +00:00
Jens Johansen e2ce88dfcc Add startFileOffset on procedures et al, enable VMs GetSource
Prior to this change we only had fileOffset which points to the name.
This CL adds a field - startFileOffset - that points to the start
(e.g. 'static', 'factory', the return type or any presiding annotation
(including '@')), as well as fixing `Function::GetSource` in the VM to
fix a crash when using mirrors to ask for the source of a function or
constructor.

The field is added to procedures, constructors and classes.
The latter changes the location of classes with annotations to be
the position of the annotation. This is on-par with --no-preview-dart-2.
The change in regards to procedures and constructors mean, that both
the location and the source (from .location and .source on a
MethodMirror) will change to include any annotations. This is a
different behavior than --no-preview-dart-2.

Closes #33271.

Change-Id: I90f1232c5ec2d01e60e0bab070d44c37232b2730
Reviewed-on: https://dart-review.googlesource.com/60560
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-06-21 13:10:04 +00:00
Régis Crelier abc8793109 [VM interpreter] Adjust bytecode constant pool reading for inlined list of types in TypeArgumentsForInstanceAllocation entry.
Change-Id: Id1633b47d3caad87e22f03d24e869b516da744b2
Reviewed-on: https://dart-review.googlesource.com/61400
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-06-20 23:16:42 +00:00
Alexander Markov 23f87d54c6 [vm/kernel/bytecode] Implement strong mode type checks in bytecode
This includes argument type checks and implicit type checks inserted
by front-end.

Also, lookup of getter functions is fixed for StaticICData constant
pool entry to include non-static getters (StaticICData is used for
all kinds of direct calls including super calls).

Change-Id: Ic265ea6a7fca2bfcc9a96e4ede268ec8e693ff41
Reviewed-on: https://dart-review.googlesource.com/60822
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-19 16:58:33 +00:00
Martin Kustermann c54a302495 [VM] Evaluate symbols in kernel2kernel constant evaluator in AOT (even in non-const contexts)
Closes https://github.com/dart-lang/sdk/issues/33185

Change-Id: Ifa6a3e34e6f1a517f0adce1593e4ff747fe5c2cb
Reviewed-on: https://dart-review.googlesource.com/60246
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-06-14 13:35:39 +00:00
Régis Crelier 12b33ada44 [VM interpreter] Support NativeCall kernel bytecode.
Change-Id: I89c905d17fb48447239ee4b0c1c8c50060239b88
Reviewed-on: https://dart-review.googlesource.com/59560
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-13 23:30:44 +00:00
Régis Crelier 4b8af662fc [VM interpreter] Generation of pc descriptors, exception handlers for bytecode.
Fixes in stack unwinding and frame iteration.

Change-Id: Ic67eb5727512138cbfa9313094d48e21384b220c
Reviewed-on: https://dart-review.googlesource.com/59520
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-11 23:43:49 +00:00
Martin Kustermann 0a8b236159 [VM] Make the encoding of variable descriptors use variable indices
This decouples the scope building from knowing about frame layout.

Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I9058b242fb24f859f54d6e3660a5972df86d39e6
Reviewed-on: https://dart-review.googlesource.com/59093
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-11 09:55:54 +00:00
Martin Kustermann a603635b85 [VM] Decouple frontend from frame layout
So far the frontend (parser, flow graph builder, ssa construction) were
aware of the actual frame layout.

This CL makes the indices we assign to [LocalVariable]s logical
indices, assigning:

  * M parameters the indices      1 ... M
  * N local variables the indices 0 -1 ... -(N-1)

The scope building, flow graph builder and ssa construction operate on
those logical indices.

When emitting actual code, the backend will translate those indices into
actual FP relative indices. This allows us to be more flexible in the
backend which frame layout we choose.

Issue https://github.com/dart-lang/sdk/issues/33274

Change-Id: I9a504bf97821c257aafd2b3430df9f4c9da4b442
Reviewed-on: https://dart-review.googlesource.com/57321
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-07 11:35:58 +00:00
Ryan Macnak edb1642709 [vm] Repair interpreter build.
Change-Id: I194b705523cec3ebb1c3edba6546561c337b28c9
Reviewed-on: https://dart-review.googlesource.com/58600
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-06-05 21:44:26 +00:00
Ryan Macnak 787a43ec78 [vm] Fix some missing private name mangling in the kernel reader.
Bug: https://github.com/dart-lang/sdk/issues/32345
Bug: https://github.com/dart-lang/sdk/issues/33326
Bug: https://github.com/dart-lang/sdk/issues/33345
Change-Id: I89fb8f0332ef6f9f40de59c219af2a7c23e5943f
Reviewed-on: https://dart-review.googlesource.com/58400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-05 20:14:46 +00:00
Alexander Markov 5bfe8d454e [vm/kernel] Set active class when evaluating Dart annotations, take 2
In https://github.com/dart-lang/sdk/commit/4fb0c6093879f7383ad597b04b3c89f3384dec19
active class was set in StreamingDartTypeTranslator, but it turns out
this is not enough. This CL sets active class in StreamingFlowGraphBuilder;
all dependent helper objects should pick it automatically.

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

Change-Id: If16afff35de32cbdba23f6260dac0e0fd7e9786a
Reviewed-on: https://dart-review.googlesource.com/57524
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-06-04 19:05:33 +00:00
Régis Crelier 57dc25c6f6 [VM interpreter] Initial version of stack walking of interpreted frames.
Various improvements and bug fixes.

Change-Id: Ice0ce0ba8db8c9f78b9fad89f951218c90c831b7
Reviewed-on: https://dart-review.googlesource.com/57443
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-06-04 18:37:30 +00:00
asiva e9a60098bb [VM] Use UserVisibleName for types in error messages reported to users to make the error more clear. This fixes the case in issue 33303.
Bug: 33303
Change-Id: Idd31eadea3d2caca1cc9416b3286d39102bc2108
Reviewed-on: https://dart-review.googlesource.com/57880
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2018-06-01 16:41:44 +00:00
Samir Jindel 9a02f5bf4d [vm/kernel] Fix bugs with expression evaluation in debug mode.
Fixes #33170: We had an assert that type variables are not bounded by "dynamic".
This assert was previously valid because the FE replaces "extends dynamic" with
"extends Object". However, it's not necessary in any way, and it's difficult to
access the Object type from outside the FE when synthesizing type parameters for
expression compilation.

Fixes #33171: The synthetic class generated during serialization to hold the
synthetic method may need to extend core library classes if the expression's
scope was within a core library class. In this case, the class finalizer needs
to avoid applying the restrictions on class extension to the synthetic class.

To facilitate this, we now use a single class name for all synthetic classes,
rather than copying the original class name. The name of the synthetic class has
no function at all, since the synthetic method is reparented to the original
class before execution.

Fixes #33239: The arguments descriptor passed to InvokeFunction for expression
functions which capture generic type parameters was using the wrong argument
count.

Fixes #33270: Use LookupClassAllowPrivate instead of LookupClass when resolving
the expression's scope in the VM.

Test Plan:

#33170: python tools/test.py -m debug -c dartk --strong service/evaluate_function_type_parameters_test
#33171: python tools/test.py -m debug -c dartk --strong service/eval_test
#33239: Updated "evaluate_function_type_parameters_test.dart".
#33270: Updated "eval_test.dart".

Change-Id: I376926bddd2224ec2322b43685d6c13831f1a8e7
Reviewed-on: https://dart-review.googlesource.com/56060
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2018-05-31 18:46:07 +00:00
Samir Jindel 3d2b66074c Reland "[vm] Support definition of entry-points via @pragma('vm.extern') annotations.""
When the constant transformation is enabled on annotations, we need to fix handling
of @ExternalName annotations in the kernel_loader to ensure that we are setting
is_external = false on native methods.

The original revision is in patchset 1.

# Test Plan

The only regression was on benchmarks, Golem results are pending.

Change-Id: Ib80bb9f532299056e770a3b378cc5ad9ee451f57
Reviewed-on: https://dart-review.googlesource.com/56960
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-30 20:06:40 +00:00
Samir Jindel 58dc4e476d Revert "[vm] Support definition of entry-points via @pragma('vm.extern') annotations."
This reverts commit 3e50ea32b5.

Reason for revert: Severe performance regressions on many aot-v2 benchmarks.

Original change's description:
> [vm] Support definition of entry-points via @pragma('vm.extern') annotations.
> 
> The `@pragma` annotations are evaluated by the constants transformation and
> visible to TFA and the precompiler, which match on the "options" field of the
> annotation to determine whether to mark the class/procedure as a root.
> 
> This required enabling the transformation of annotation constants by default.
> 
> # Test Plan
> 
> The "vmservice_io.main" entry-point is removed from `main.cc` and annotated with
> `@pragma`. All precompiler tests will crash if "vmservice_io.main" is not
> available at runtime.
> 
> Debug/release precompiler bots are visible in "cl-linux" button.
> 
> Change-Id: I03c5d6ba7918672ed9905fcaee8dabe675a93a5d
> Reviewed-on: https://dart-review.googlesource.com/56660
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,alexmarkov@google.com,sjindel@google.com

Change-Id: I779c17d003659129a4b3fcf284423104948f60e2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/56820
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-05-28 19:23:16 +00:00
Samir Jindel 3e50ea32b5 [vm] Support definition of entry-points via @pragma('vm.extern') annotations.
The `@pragma` annotations are evaluated by the constants transformation and
visible to TFA and the precompiler, which match on the "options" field of the
annotation to determine whether to mark the class/procedure as a root.

This required enabling the transformation of annotation constants by default.

# Test Plan

The "vmservice_io.main" entry-point is removed from `main.cc` and annotated with
`@pragma`. All precompiler tests will crash if "vmservice_io.main" is not
available at runtime.

Debug/release precompiler bots are visible in "cl-linux" button.

Change-Id: I03c5d6ba7918672ed9905fcaee8dabe675a93a5d
Reviewed-on: https://dart-review.googlesource.com/56660
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-05-28 15:13:55 +00:00
Samir Jindel 6fc0c1fa4f [vm/kernel] Only create zone handles when necessary (e.g. in IR instructions, LocalVariable).
Summary:

When evaluating constants for direct inspection (and not for injection into the
FG), we store many intermediate values in ZoneHandles. This leaks memory, since
the only need for ZoneHandles is preserving constants which are referenced by
the FG.

Test Plan:

Existing coverage is sufficient since no functionality is changed.

Change-Id: I33951eab762a4ad626f07ebf11118247c5a9ad3e
Reviewed-on: https://dart-review.googlesource.com/56345
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-05-24 13:14:29 +00:00
Samir Jindel 02bcbc12fa [vm/kernel] Fix partial instantiation implementation in StreamingConstantEvaluator.
# Summary

As part of commit 772c9bb5f, we changed the representation of partially
instantiated closures to facilitate partial instantiation of local functions.
The compile-time constant evaluator was not updated -- this revision implements
that update.

Fixes task 33211.

# Test Plan

Updated `partial_tearoff_instantiation_test.dart` to test the case which caused
incorrect behavior in task 33211.

Change-Id: I7bbd4fb83a5aea86ffc85c1d9952f1202f098d6b
Reviewed-on: https://dart-review.googlesource.com/56346
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-05-24 12:20:42 +00:00
Alexander Markov 4fb0c60938 [vm/kernel] Set active class when evaluating Dart annotations
Without active class, kernel reader is not able to finalize types
and fails to parse type literals.

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

Change-Id: Iefe7f33a371f3d4f892f21f8ea0060d70887186c
Reviewed-on: https://dart-review.googlesource.com/56242
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-05-23 16:17:55 +00:00
Martin Kustermann e0144d51bb [VM] Add UNREACHABLE() to AOT constant evaluator in the VM
Since commit 775eeece we use a kernel2kernel constant evaluator for
AOT compilations. We can now start to ensure we never hit the constant
evaluator in the VM anymore.

Issue https://github.com/dart-lang/sdk/issues/33185

Change-Id: If0e3b5c89fba64a7f93af606e7146e52c45b38df
Reviewed-on: https://dart-review.googlesource.com/56340
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-05-23 16:01:45 +00:00