Commit Graph

95 Commits

Author SHA1 Message Date
Peter von der Ahé e45e334548 Rename strong mode to legacy mode in package:kernel
Change-Id: Ia4a8a9cac7817a8db5771ec82541b556c705f7c8
Reviewed-on: https://dart-review.googlesource.com/c/86353
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2018-12-20 18:06:34 +00:00
Régis Crelier 25851db73d [vm/bytecode] Replace InstanceCall instruction with InterfaceCall and DynamicCall.
Dispatch interface calls via hashtable rather than inline cache.
InterfaceCall doesn't need to take arguments descriptor into account
when doing method lookup.

Change-Id: I30eae6ea638d1d2ad2cf3ff073c653fee3377f31
Reviewed-on: https://dart-review.googlesource.com/c/86106
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-12-14 16:51:51 +00:00
Alexander Markov 170d5578c7 [vm/kernel] Move functionality of Fuchsia's compiler.dart into pkg/vm
This includes:
* Selecting front-end target.
* Support for multi-root virtual file system.
* Not linking platform into resulting kernel file.
* Specifying input as URI (instead of file path) on command line.
* Automatically converting input script URI to package URI.
* Writing ninja dependencies file.
* Writing package-split kernel binaries.

After this change Fuchsia's compiler.dart will become a small wrapper
over pkg/vm, sharing most logic and even most command line options
with pkg/vm gen_kernel tool.

Also, this CL attempts to share some pieces of code between frontend
server and gen_kernel.

In addition, seperate bytecode generation for package-split binaries
is implemented (needed for https://dart-review.googlesource.com/c/sdk/+/85469).

Corresponding Fuchsia CL: https://fuchsia-review.googlesource.com/c/topaz/+/229964

Change-Id: I12d7b2f6401357b3c9df2e31bc736af5a9dc5fd2
Reviewed-on: https://dart-review.googlesource.com/c/85721
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-12-04 01:08:03 +00:00
Alexander Markov 9f49b47823 [vm/bytecode] Revise representation of objects and strings in bytecode
This is a major revamp of bytecode metadata format. Now bytecode has
its own serialization mechanisms.

This CL adds 'bytecode component' metadata, which contains bytecode
object table and string table. All references from bytecode (constant
pools) to libraries, classes, members, types and strings now have a new
format. References to frequently used objects are represented as indices
in object table, while rarely used objects are written inline.
This allows VM to cache frequently used objects while reading bytecode.

Representation of strings is aligned with VM - string characters are
stored in separate pools of one-byte and two-byte strings. This allows
VM to avoid UTF-8 decoding and extra copying.

Closure declarations are now explicit. Type parameters no longer require
enslosing scopes when reading/writing them.

Benchmarks:
GenKernelKernelReadAllBytecode (Intel Core i5) +29.84%
GenKernelKernelReadAllBytecode (Intel Xeon) +28.74%
Change-Id: I4b80009733a8f8c038264af74f97c4e094b9e311
Reviewed-on: https://dart-review.googlesource.com/c/85469
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-12-03 19:08:42 +00:00
Alexander Markov 62c562ed7a [vm/bytecode] Encapsulate constant pool entry creation
This refactoring is needed to simplify upcoming changes in constant pool entries.

Change-Id: Ia0356b0a738d33b4e676cd5be67bd77a2f75279a
Reviewed-on: https://dart-review.googlesource.com/c/84684
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-19 17:23:40 +00:00
Alexander Markov a9abc64613 [vm/bytecode] Add context IDs to disambiguate accesses to distinct contexts
This CL adds context ID operand to AllocateContext, CloneContext,
LoadContextVar and StoreContextVar bytecode instructions.
The context ID will be used to create distinct Slots and disambiguate
accesses to context objects corresponding to different scopes.

Change-Id: I98850ab763017b71c1dcacfccaffc085bd850e00
Reviewed-on: https://dart-review.googlesource.com/c/84681
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-17 00:35:30 +00:00
Alexander Markov 7fafcec013 [vm/bytecode] Eliminate AssertBoolean instructions if condition is non-nullable
Number of AssertBoolean instructions in the 100Mb dynamic trace of
Richards benchmark in pure interpreted mode (platform with bytecode):

Before: 1812005
After:   251451
Change-Id: I9fe9d37499d73ffa7636c9ca5fb9c2c18dbc1397
Reviewed-on: https://dart-review.googlesource.com/c/84643
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-11-16 19:18:27 +00:00
Vyacheslav Egorov ddbe22190c [vm/compiler] Refactor representation of stores and loads in IL.
Make StoreIntanceField and LoadField instructions use a single uniform
abstraction: Slot (used to be called NativeFieldDesc), which represents
either a real Dart field (i.e. a field that has a corresponding Field object)
or a native VM field that does not have a corresponding Field object.

This refactoring eliminates raw stores/loads that were just using offsets
before - now we always know what kind of slots we are accessing and
this yields better aliasing information.

Change-Id: I2f48332d58258219565bd961764e8cc9dd4d75ce
Reviewed-on: https://dart-review.googlesource.com/c/74582
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-16 17:57:29 +00:00
Zach Anderson b981cbfff8 [vm] Adds a flag to dump dynamic bytecode traces in a debug build.
Also adds a program in pkg/vm/bin/dump_bytecode_ngrams.dart that
analyzes the traces.

Change-Id: I39c9645ca858195a41e001dab47a7b1398f4b15e
Reviewed-on: https://dart-review.googlesource.com/c/83340
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-11-16 06:24:02 +00:00
Alexander Markov 8f7a0f400b [vm/bytecode] Emit source positions for bytecode instructions
Change-Id: I83963771db301089317823f6bf14eb4a2728dbfb
Reviewed-on: https://dart-review.googlesource.com/c/81740
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-14 00:27:45 +00:00
Alexander Markov c04461c16d [vm/bytecode] Fix allocation of temporary locals for StaticSet
Change-Id: I47fc4f5d462be30351f4828bf4354404c0ad7088
Reviewed-on: https://dart-review.googlesource.com/c/84300
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-13 20:19:16 +00:00
Alexander Markov 3c32b32d56 [vm/bytecode] Enable OSR for unoptimized code compiled from bytecode
In order to enable OSR, CheckStackOverflow IL instructions are attributed
with a non-zero loop depth. The original loop depth is passed as operand
of CheckStack bytecode instruction.

Change-Id: I771f59ba9f8d071680a3b7156be380e0f606b7b2
Reviewed-on: https://dart-review.googlesource.com/c/84081
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-11-12 19:04:54 +00:00
Régis Crelier 98a0309fbd [VM compiler] Reuse function type arguments to avoid instantiation at runtime, when possible.
Change-Id: Icfcbd165bb96cf83b7911c6c11a7daca17c6ba12
Reviewed-on: https://dart-review.googlesource.com/c/81701
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-10-30 18:38:37 +00:00
Alexander Markov 59e626e5c9 [vm/bytecode] Change encoding of MoveSpecial bytecode instruction
Previously MoveSpecial bytecode instruction used unsigned 8-bit A field
to encode target local variable index. This is too restrictive as we allow
signed 16-bit local variable indices.

After this change MoveSpecial has A_X encoding, with A field used for
special index (0 or 1), and signed 16-bit X field used for target local.

Change-Id: Ib87992e192b2923a39a9968913c39476947d3ea5
Reviewed-on: https://dart-review.googlesource.com/c/81440
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2018-10-25 19:07:19 +00:00
Alexander Markov c7c81af74e [vm/bytecode] Check for overflow of bytecode limits
Change-Id: I452596fb6f0fa72d76f26981adae2910ba1a179c
Reviewed-on: https://dart-review.googlesource.com/c/81336
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-10-25 00:10:24 +00:00
Samir Jindel 6efc58f069 [vm] Pass member name as a symbol in instantiateInvocation.
If we use `_InvocationMirror._withoutType`, the symbol for the member name is created dynamically and escapes obfuscation.
We need to create the member name symbol statically via a `const` constructor.

Change-Id: I11c0f745187f4ef1646be6d5348780f502393043
Reviewed-on: https://dart-review.googlesource.com/c/81264
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-24 10:13:13 +00:00
Alexander Markov 1d10e037ef [vm/bytecode] Remove unreachable bytecode
Change-Id: I29393604547038cf359b8e19ea48078dd0eea3b1
Reviewed-on: https://dart-review.googlesource.com/c/81201
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2018-10-23 23:26:13 +00:00
Alexander Markov 9406b7b44e [vm/bytecode] Add versioning to bytecode format
Change-Id: I35d86aec17aa0f6894a6380e4bb5ac7ca3092fac
Reviewed-on: https://dart-review.googlesource.com/c/80522
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-10-22 18:03:20 +00:00
Alexander Markov f921f203f4 [vm/bytecode] Fix constant evaluation of factory constructors in bytecode
This change extends the fix
https://github.com/dart-lang/sdk/commit/349adc5b1f14deb49f60c4afb917d0dfc1db4ae6
for bytecode pipeline.

Change-Id: Ib9e9d2f5c1790db33a16ff8d74951dd10edb0d0e
Reviewed-on: https://dart-review.googlesource.com/c/80266
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-10-16 17:31:07 +00:00
Peter von der Ahé 5b32ab3be6 Remove the word "strongMode" from some package:kernel libraries.
Temporarily using "legacyMode" instead, but I plan to rid these soon.

Change-Id: Iff8bcde03b6ebe4ad95f963f456c855e73e58926
Reviewed-on: https://dart-review.googlesource.com/c/79042
Auto-Submit: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-10-11 08:50:43 +00:00
Alexander Markov 5deb1c6e81 [vm] Remove strong mode and sync-async flags from pkg/vm
Change-Id: Icd2920274ca4c402b38e5774bb408d6b5e529169
Reviewed-on: https://dart-review.googlesource.com/c/79082
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-10-10 20:11:35 +00:00
Martin Kustermann 16ddfc1565 [VM] Use assert assignable implementation for explicit downcasts
This makes explicit downcasts more efficient by re-using the
optimizations we already have for implicit downcasts.

For implicit/explicit as checks we use the symbol to distinguish which
exception to throw if the check fails.  So this does not actually
require unification of _CastError and _TypeError.

Issue https://github.com/dart-lang/sdk/issues/34582
Issue https://github.com/dart-lang/sdk/issues/30632
Issue https://github.com/dart-lang/sdk/issues/30571

Change-Id: I7b8818d2698e249c90a3e1b8790bad69ada649a9
Reviewed-on: https://dart-review.googlesource.com/c/78748
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-10 12:36:42 +00:00
Alexander Markov 9db63ee729 [vm/bytecode] Set 'TypeEnvironment.thisType' when generating bytecode
This is needed for Expression.getStaticType() to work in certain
cases and improves recognition of int operations.

Change-Id: I80073a797a39ab5d6b3715940961a231e0a8ab10
Reviewed-on: https://dart-review.googlesource.com/c/78142
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-10-04 19:14:33 +00:00
Alexander Markov 6d0601a72b [vm/bytecode] Add bytecodes for int operations and '== null'
DeltaBlue performance in pure interpreted mode
(--enable-interpreter --compilation-counter-threshold=-1):
Before: DeltaBlue(RunTime): 269198.732 us.
After:  DeltaBlue(RunTime): 158216.34376923076 us. (-41.23%)

Change-Id: I9dea8d7949421986ee6fbdeae046fe4ef6d3227f
Reviewed-on: https://dart-review.googlesource.com/c/77231
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-10-03 15:45:36 +00:00
Alexander Markov deb0645654 [vm/bytecode] Cleanup unused bytecode instructions
Change-Id: I956525dbeb3fdcb4b65a5530dbb59a96b4a02e81
Reviewed-on: https://dart-review.googlesource.com/77224
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-28 21:23:22 +00:00
Alexander Markov 2aac05fe10 [vm/bytecode] Add specialized JumpIf* instructions
This change adds JumpIfEqStrict, JumpIfNeStrict, JumpIfTrue, JumpIfFalse,
JumpIfNull, JumpIfNotNull bytecode instructions. These instructions
supercede If*/Jump instruction patterns.

Change-Id: Icf9dc624001ce64d4b21409864591d693ead51d3
Reviewed-on: https://dart-review.googlesource.com/77011
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-28 16:29:23 +00:00
Alexander Markov 5d10974a89 [vm/bytecode] Use _simpleInstanceOf for certain 'is' checks in bytecode
DeltaBlue benchmark, platform with bytecode, pure interpreter mode
(--enable-interpreter --compilation-counter-threshold=-1), best of 5 runs:
Before: DeltaBlue(RunTime): 391061.47400000005 us.
After: DeltaBlue(RunTime): 285747.36557142856 us.

Change-Id: I875f227cf19e0f75687c13910b1d957ee595652b
Reviewed-on: https://dart-review.googlesource.com/76708
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-26 21:50:41 +00:00
Régis Crelier 79d639a3a8 [VM interpreter/bytecode] Modify argument order for AssertAssignable bytecode.
The new argument order matches the runtime call and requires less copying.
Simplify Function::HasCode()
Remove obsolete workaround when updating type test cache.

Change-Id: I57c988f97ee2259a22730f445f336cd2a085959e
Reviewed-on: https://dart-review.googlesource.com/76584
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-26 21:15:16 +00:00
Alexander Markov 62d154f6a3 [vm/bytecode] Record null-initialized fields in bytecode
If a field is initialized with null (either explicitly or implicitly),
field store can be omitted in bytecode. In such case, bytecode should
still convey the information about this initialization to VM for
field guards to work correctly.

Change-Id: I1fd45b858c3c521b97fa5dbffe0e15b1ea75d92f
Reviewed-on: https://dart-review.googlesource.com/76060
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-09-24 17:56:35 +00:00
Alexander Markov 76091c13db [vm/bytecode] Add PushNull, PushTrue, PushFalse and PushInt bytecodes
These bytecode instructions are added in order to shrink constant pools
and reduce time spent for reading constant pool entries.

Change-Id: I8522f73dc7a6236969ac0422c6cb89b945559b2d
Reviewed-on: https://dart-review.googlesource.com/75125
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-15 17:55:46 +00:00
Alexander Markov 3ba5aa8ba7 [vm/bytecode] Support SymbolConstant nodes in bytecode pipeline
After https://github.com/dart-lang/sdk/commit/609d2770bea3d4c9dc76b515a52ee325dfb5c50d
constant evaluator produces SymbolConstant nodes.

This CL adds handling of SymbolConstant nodes to bytecode generator by
emitting a new constant pool entry. Constant pool reader is adjusted to
read new constant pool entry.

Change-Id: Idc1e91e765014b3290d80e5a3743448b8a0f472c
Reviewed-on: https://dart-review.googlesource.com/74322
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-09-11 17:54:16 +00:00
Alexander Markov cdd18e6811 [vm/bytecode] Support dynamic invocation forwarders and omit checks in bytecode
This CL adds support for _dynamic_ calls (which are routed through
dynamic invocation forwarders) to bytecode pipeline.

This allows to skip argument type checks for non-covariant and
non-generic-convarint-impl parameters in bytecode when calling instance
members through known interface targets. In case of dynamic call, dynamic
invocation forwarders perform type checks which are otherwise skipped.

This CL also corrects argument type checks in forwarding stubs.
Forwarding stubs are synthetic methods, introduced by front-end to ensure
type safety if some of the argument type checks are skipped.
The specifics of forwarding stubs is that they should use parameter types
of a *target* of a stub for the argument type checks.

This change unifies how argument type checks are performed in bytecode
and in the VM in JIT mode. This allows to mix bytecode methods with
methods JIT-compiled from kernel AST in more cases.

Change-Id: I3a2720a488c8bbb91de1b189eb36ee8c51684a78
Reviewed-on: https://dart-review.googlesource.com/72543
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-06 17:23:12 +00:00
Alexander Markov 54dc63a5ec [vm/bytecode] Add eager bounds checks to partial instantiations in bytecode
This is the follow-up to
https://github.com/dart-lang/sdk/commit/dbe868de02d3b8e156c963d39f26fd95b6683e9b

Similarly to StreamingFlowGraphBuilder::BuildPartialTearoffInstantiation,
bytecode generator adds _boundsCheckForPartialInstantiation calls
to partial instantiations of tear-offs.

Fixes language_2/partial_instantiation_eager_bounds_check_test in bytecode mode.

Change-Id: I2daf1902aa3df99133b2a25f1413e1bac53b6c30
Reviewed-on: https://dart-review.googlesource.com/72549
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-31 22:55:48 +00:00
Alexander Markov a867e2cc59 [vm/bytecode] Avoid sorting named parameters in kernel AST when generating bytecode
When generating bytecode, kernel AST was modifed to sort optional named
parameters. This has unfortunate side-effect of breaking default
(non-interpreter) mode if it uses platform.dill with bytecode.

Bytecode generator is changed to avoid modifications to kernel AST.
Instead, sorted named parameters are kept on a side.

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

Change-Id: Iba473f09af0af515b2117e39d63363412433d538
Reviewed-on: https://dart-review.googlesource.com/72546
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-31 22:27:20 +00:00
Alexander Markov 1b13583ba8 [vm/bytecode] Keep original declaration order of named parameters in native wrappers
Native methods access their parameters using indices and expect named
parameters to be in the declaration order.

Bytecode generator always sorts named parameters, which is not valid
in native wrappers.

In this CL, the original order of parameters is saved and used
when pushing arguments in native wrappers.

Change-Id: I3fb60c21a484ccae7478b9e59ca16f8b0cde8fd5
Reviewed-on: https://dart-review.googlesource.com/71884
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-28 21:59:36 +00:00
Alexander Markov 52d33f0d5d [vm/kernel/bytecode] Support partially instantiated closures in bytecode
Generic closures should take delayed type arguments into account when
initializing type arguments in prologue.

Fixes language_2/instantiate_tearoff_test in bytecode mode.

Change-Id: I0ab07e759f3372ae9143a48f0b8b0fe4fab8a51a
Reviewed-on: https://dart-review.googlesource.com/71432
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-08-27 18:13:56 +00:00
Alexander Markov 1b89c785e1 [vm/kernel/bytecode] Duplicate receiver variable if it is captured
If receiver is captured, the variable is duplicated so top-level
members can access receiver as a local variable.

This is more efficient and allows uses of receiver in the prologue of
top-level member, before context is allocated and receiver is copied to
the context.

Change-Id: I5b13f692767c3aa445e558bff2bc3f8fbf016561
Reviewed-on: https://dart-review.googlesource.com/71431
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-27 17:41:58 +00:00
Alexander Markov 3e3459b0ab [vm/kernel/bytecode] Use default type args (bounds) in generic functions
This CL adds checking of number of passed function type arguments into
prologue of generic functions in bytecode. If type arguments are not
passed, then default type arguments (instantiated bounds) are used.

This mimics IL generated in StreamingFlowGraphBuilder::BuildDefaultTypeHandling.

In order to implement this check, a new bytecode instruction
JumpIfNotZeroTypeArgs is added to bytecode generator and interpreter.

Fixes language_2/function_apply_generic2_test in bytecode mode.

Change-Id: I70901c16b8bfc5f86623d51fccaf50f8969c587e
Reviewed-on: https://dart-review.googlesource.com/71387
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-24 15:55:05 +00:00
Alexander Markov 0554eeb4bb [vm/bytecode] Check number of arguments in closures without optional arguments
This CL adds EntryFixed bytecode instruction in bytecode generator and
interpreter. The new instruction is used instead of Entry in prologues of
closures with fixed arguments in order to check number of arguments.

Fixes language_2/closure_call_wrong_argument_count_test in bytecode mode.

Change-Id: I873166a73c5f33e7faca8739cd6f210370e81b2e
Reviewed-on: https://dart-review.googlesource.com/71231
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-22 23:20:26 +00:00
Alexander Markov cbe9ee5082 [vm/kernel/bytecode] Fix instantiation of function types with parameterized result type
Fixes language_2/type_variable_function_type_test in bytecode mode.

Change-Id: I307083b4469a2eb8cac3c41ccc908f6f3199573a
Reviewed-on: https://dart-review.googlesource.com/71200
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-22 19:12:38 +00:00
Alexander Markov 5a695abdfa [vm/kernel/bytecode] Do not copy captured top-level parameters in closures
Receiver and factory type arguments are implicit parameters which are
copied from original stack locations to a context if captured (along
with explicit parameters).

However, they were copied not only in top-level members, but also in
closures. So sometimes context was corrupted with unrelated values
taken from the stack (as closures do not receive these parameters
on the stack).

This CL removes incorrect copying of implicit parameters in closures.

Change-Id: I8d7d3992595f761f4ab7a1c8d16e0fc823fae22a
Reviewed-on: https://dart-review.googlesource.com/71101
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-22 15:50:56 +00:00
Alexander Markov 5d86b5e1b0 [vm/kernel/bytecode] Share contexts between scopes in bytecode
This optimization reduces number of context allocations and decreases
number of context levels, making access to captured variables more
efficient.

This change reduces number of context levels in synthetic bodies of
sync* methods to 1. This is important for correctness because
_SyncIterable::iterator clones unerlying sync* closure to create a new
Iterator using _Closure._clone(), and _Closure._clone() clones only
1 level of context.

Fixes language_2/syncstar_yield_test in bytecode mode.

Change-Id: I7a783702b024a7454253f7f4423ec4b2e08ef61f
Reviewed-on: https://dart-review.googlesource.com/70984
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-21 21:18:34 +00:00
Alexander Markov 701b13048b [vm/kernel/bytecode] Zap expression stack in try-catch handlers
Also, if return statement is used inside try/finally, its return value
is saved in a variable to avoid clobbering by statements in finally
block.

This CL fixes language_2/stack_overflow_test in bytecode mode.

Change-Id: If6a3981d9dc8673f6b990aa00200e1ab7298c6ac
Reviewed-on: https://dart-review.googlesource.com/70820
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-20 23:39:57 +00:00
Alexander Markov 5e0a28a384 [vm/kernel/bytecode] Support unsafeCast() intrinsic method in bytecode
This is the follow-up for 7708989538.

Change-Id: Ib313e823df8625a1dce9ff31749f83d44e2da539
Reviewed-on: https://dart-review.googlesource.com/70760
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-20 20:44:05 +00:00
Alexander Markov 9b3bda610b [vm/kernel/bytecode] Constant-evaluate default values of optional parameters of closures in bytecode
This constant evaluation is needed as default values of optional parameters
of closures can reference local const variables which are not available in
bytecode, so default value expressions can't be serialized without
enclosing AST.

Fixes test language_2/regress_18435_test in bytecode mode.

Change-Id: I1530c5bae058865de8f40d6f636dd747ba407cc5
Reviewed-on: https://dart-review.googlesource.com/70581
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-17 20:50:02 +00:00
Alexander Markov 4da7360d71 [vm/kernel/bytecode] Fix capturing of factory type arguments in bytecode
Change-Id: I3d1b1d78684b7a5f3c117ec24d7e406a7b4feabd
Reviewed-on: https://dart-review.googlesource.com/70560
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-17 19:10:08 +00:00
Alexander Markov 4e959af53d [vm/kernel/bytecode] Generate bytecode for platform when building SDK in --bytecode mode
Change-Id: Ib82765fa80a83d1434124e3fba9181a789a83932
Reviewed-on: https://dart-review.googlesource.com/69380
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-16 18:01:17 +00:00
Alexander Markov 2b8b955641 [vm/kernel/bytecode] Fix field initializers in constructors
Fix for failing test language_2/final_field_initialization_order_test.
Bytecode generator was incorrectly omitting field initializer if
constructor also has initializer for that field.

Change-Id: I046231865677e1e59122d4d61b238e52b88003b7
Reviewed-on: https://dart-review.googlesource.com/70140
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-15 15:40:54 +00:00
Alexander Markov feff33b892 [vm/kernel/bytecode] Implement overlapping of type arguments in bytecode
Instantiator type arguments are sometimes reused instead of doing
instantiation at run time. VM has a bunch of assertions to verify
that this optimization happened. In case of bytecode pipeline, decision
to reuse instantiator type arguments is done while generating bytecode.

For this optimization to correctly happen, bytecode generator
should be able to construct instantiator type arguments the same way
as VM does at run time. Besides flattening of type arguments of
superclasses, VM shrinks them by overlapping type parameters with
type arguments of a superclass (if they match). This CL implements
such overlapping in bytecode generator.

Also, --overlap_type_arguments VM option is removed, as disabling
of type arguments overlapping would break bytecode pipeline.

Change-Id: Ib276c0e688e0e86b44278d88a5c0af09dd342798
Reviewed-on: https://dart-review.googlesource.com/70060
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-14 21:51:17 +00:00
Alexander Markov 8c16c4daaf [vm/kernel/bytecode] Constant evaluate Symbol literals in bytecode
Now, instead of generating Symbol constant pool entries, bytecode generator
uses kernel-to-kernel constant evaluator to evaluate symbol literals.

Change-Id: I8dae4e388b6c1e8158ce39da792bb2e1cea2687a
Reviewed-on: https://dart-review.googlesource.com/69900
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-14 01:38:42 +00:00