Commit Graph

69 Commits

Author SHA1 Message Date
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 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 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
Daniel Hillerström 98a9adf696 Make constructor function types conform with the specification.
Prior to this CL the return type of any constructor function was
always void. According to the specification §9.3 the return type of a
constructor function ought to be its enclosing class.

Change-Id: I70d76cc354b7f118ce96bf4954daf7fe535eb7be
Reviewed-on: https://dart-review.googlesource.com/76160
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-09-26 09:39:11 +00:00
Alexander Markov 53497549ab [vm] Specialize 'new List()' on kernel AST
In VM, 'new List' is equivalent to either 'new _GrowableList' or
'new _List' depending on the number of arguments.
This change does the transformation early (on kernel AST), in order
to have specialized representation in TFA and in bytecode.

Change-Id: I46f0db8cc19efb3a53fdbe971ac26bdd2736fbda
Reviewed-on: https://dart-review.googlesource.com/76283
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-09-25 00:38:57 +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
Vyacheslav Egorov f8a3d802d0 Revert "[vm/kernel] Preserve strong mode types in async transformation"
This reverts commit eec96f9076.

Revert "[vm/kernel] In async transformation check if strongMode is on."

This reverts commit 348ed30efd.

Reason for revert: getStaticType is unreliable in Kernel

R=alexmarkov@google.com

Change-Id: I08b914f947a00923491bb610ed74d6348882554f
Reviewed-on: https://dart-review.googlesource.com/75220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-09-17 22:58:55 +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
Vyacheslav Egorov eec96f9076 [vm/kernel] Preserve strong mode types in async transformation
Async transformation uses dynamic variables in few places (e.g.
for temporaries and for incomming arguments) - which creates
not strongly typed AST with method invocations having dynamic
receivers and non-null interface targets at the same time.

To maintain strong typedness of the AST we insert unsafeCast
when accessing the temporaries.

Bug: https://github.com/dart-lang/sdk/issues/34463
Change-Id: I11e38c128645ebc8acb0c982a80fe4c5c4036673
Reviewed-on: https://dart-review.googlesource.com/75000
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 17:19:29 +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
Vyacheslav Egorov d01d6f454c [vm] Fix a bug in the specialization of implicit setters
CallSpecializer::TryInlineInstanceSetter was using IsReceiver to determine
type check could be skipped. However it is incorrect to use IsReceiver,
because it uses SSA notion of the receiver - rather than a syntactic
notion and all strong mode guarantees apply at syntactic level.

Additionally this CL expands support for exactness tracking to PropertySet
operations and uses it to eliminate checks on setters.

Change-Id: Idce559c4ca4c88f5788d3b6b9955b5af076bd7eb
Reviewed-on: https://dart-review.googlesource.com/72442
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-09-03 13:43:41 +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 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
Samir Jindel 2beb05b829 [vm] Re-land use of multiple entrypoints for closure calls.
Original patchset is in revision 1.

Change-Id: I29ab0dbc3711f99895fd4f04a49d4185463a1602
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,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/71241
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-23 17:54:19 +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 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
Samir Jindel 569290dbf5 Revert "[vm] Use multiple entrypoints to remove unnecessary checks on statically-typed closure calls."
This reverts commit 19126e861e.

Reason for revert: Breaks several bots.

Original change's description:
> [vm] Use multiple entrypoints to remove unnecessary checks on statically-typed closure calls.
> 
> Test Plan:
> 
> Behavioral correctness should be ensured by existing tests. Tests in vm/dart/entrypoints
> ensure that the unchecked entrypoint is used in cases where the optimization should trigger.
> 
> Bug: https://github.com/dart-lang/sdk/issues/31798
> 
> Change-Id: Id25ecba86e20c22f0678c12986ad620db312ddaa
> 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/69743
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

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

Change-Id: Ia33e9d141827d3c990c65d839333443c224dc85d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/31798
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/70920
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2018-08-21 17:10:56 +00:00
Samir Jindel 19126e861e [vm] Use multiple entrypoints to remove unnecessary checks on statically-typed closure calls.
Test Plan:

Behavioral correctness should be ensured by existing tests. Tests in vm/dart/entrypoints
ensure that the unchecked entrypoint is used in cases where the optimization should trigger.

Bug: https://github.com/dart-lang/sdk/issues/31798

Change-Id: Id25ecba86e20c22f0678c12986ad620db312ddaa
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/69743
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-08-21 16:00:57 +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
Vyacheslav Egorov aa8145a03d [vm/kernel] Add a transformation that annotates invocations with receiver type.
Currently we only annotate those call-sites that would result
in generic covariant checks performed on the callee side.

Bug: https://github.com/dart-lang/sdk/issues/31798
Change-Id: Ifcf60032036575f615015d716276484a7c1236b3
Reviewed-on: https://dart-review.googlesource.com/69580
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-08-16 12:30:56 +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
Alexander Markov 0d1abc535b [vm/kernel/bytecode] Initialize _Closure._delayed_type_arguments to Object::empty_type_arguments()
As TypeArguments == null means 'vector of all dynamic', VM uses special
object (Object::empty_type_arguments()) to indicate absence of
_Closure._delayed_type_arguments.

This CL corrects bytecode to use Object::empty_type_arguments() (via new
constant pool entry EmptyTypeArguments) to initialize
_Closure._delayed_type_arguments when allocating a closure.

Change-Id: I9b00bc0606de85c02350c8eef08d8952c3e224ee
Reviewed-on: https://dart-review.googlesource.com/69840
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-13 22:46:59 +00:00
Alexander Markov 741f662a60 [vm/kernel/bytecode] Fix number of checked arguments in bytecode calls
Number of checked arguments is corrected in ICData objects created when
reading bytecode, both for instance and static calls.

InstanceCall1 and InstanceCall2 bytecode instructions are replaced with
InstanceCall which works for any number of checked arguments. This makes
decision on number of checked arguments internal to VM and it is no longer
exposed to bytecode.

Change-Id: I0bba01eca6347336f3832de863b2ce4715fda04a
Reviewed-on: https://dart-review.googlesource.com/69421
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-13 17:50:21 +00:00
Alexander Markov 98d07dd8bf [vm/kernel/bytecode] Minor fixes in bytecode generator
This CL contains 2 fixes:

* Instantiator type arguments for factory constructors are calculated
  using factory's type parameters and not class type parameters
  (as factory's body uses factory's type parameters in kernel AST)
  This improves reuse of instantiator type arguments in factory
  constructors (optimization).

* Result of _AssertionError::_throwNew call is dropped off the stack.
  Although control never returns from _throwNew, this fix is needed
  to maintain correct stack balance while compiling bytecode.

Change-Id: Ib781b0d790a89576ef62b768513663e7e509749c
Reviewed-on: https://dart-review.googlesource.com/69384
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-10 21:07:06 +00:00
Alexander Markov 88cba7d860 [vm/kernel/bytecode] Fix arguments descriptor for List._fromLiteral call in bytecode
Change-Id: I14a2f92f62918d04be7e7f60d0bc4625e3f85dfa
Reviewed-on: https://dart-review.googlesource.com/69041
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-09 03:47:28 +00:00
Alexander Markov 85d85246ad [vm/kernel/bytecode] Revise access to instance fields in bytecode
Constant pool:

* Field constant pool entry is renamed to StaticField
* FieldOffset constant pool entry is replaced with InstanceField.
  InstanceField occupies 2 slots for field offset and field object.
* ContextOffset constant pool entry is removed.
* TypeArgumentsFieldOffset is renamed to TypeArgumentsField

Bytecodes:

* LoadFieldTOS and StoreFieldTOS require InstanceField entry.
* New bytecodes added: LoadContextParent, StoreContextParent,
  LoadContextVar, StoreContextVar, LoadTypeArgumentsField.

This CL is a preparation for compilation of bytecodes related
to instance field accesses.

Change-Id: I1d6274e94bd7cd764e4fc83d9847daf4f21e5a25
Reviewed-on: https://dart-review.googlesource.com/68843
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-08-08 16:35:25 +00:00
Alexander Markov 884536dfaa [vm/kernel/bytecode] Fix bytecode generation for async closures
This CL fixes errors 'NoSuchMethodError: The getter 'dartAsyncMarker' was called on null.'
while generating bytecode for async closures.

Change-Id: I0e5726e4bf6a385772060b2ddba3cf762572538a
Reviewed-on: https://dart-review.googlesource.com/68003
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-02 16:10:19 +00:00
Alexander Markov ae001707b7 [vm/kernel/bytecode] Do not call getter for a static field initialized with double literal
Values of static fields with trivial initializers are pre-initialized
at load time, so such static fields do not have implicit getters.
Bytecode generator is fixed to treat double literal initializers as trivial
and avoid calling getters for such fields.

Also, this CL disables bytecode generation for static fields with trivial
initializers as their bytecode is not used.

Change-Id: I44b9d26ab2007e33d0d5b9f716e30848f0c38e8a
Reviewed-on: https://dart-review.googlesource.com/68005
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-02 16:10:02 +00:00
Alexander Markov 3f1bb85f17 [vm/kernel/bytecode] Do not generate InstantiateType for instantiated generic function types
InstantiateType bytecode can only be used on a non-instantiated type.
Type literals for generic function types without free type variables
(e.g. '<X>(dynamic, X) => X') are now generated using PushConstant.

Change-Id: I5c26751de4b47a0b98b075d8df85060bf78157d8
Reviewed-on: https://dart-review.googlesource.com/67980
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-02 00:36:30 +00:00
Alexander Markov b2716552cd [vm/kernel/bytecode] Fix type arguments for constant instances in bytecode
Change-Id: I31f3209988fd0bf51557e5ec3af8b01bceab286e
Reviewed-on: https://dart-review.googlesource.com/66413
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-25 16:26:54 +00:00
Alexander Markov 253660db21 [vm/kernel/bytecode] Support corner cases of super calls in bytecode generator
* Super tear-offs: 'super.foo' where foo() is a method.
* Super calls of abstract members (useful with super-mixins).

Change-Id: I373b11c9773c7535e703cdc4e1bb9e632eef8dd2
Reviewed-on: https://dart-review.googlesource.com/64980
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-17 20:23:50 +00:00
Jens Johansen 1467909921 Call _completeOnAsyncReturn instead of .complete directly
The VM debugger expects _completeOnAsyncReturn to be called when
returning from an async function for stepping out of the async function
to work.

This CL does just that.

Note that `_completeOnAsyncReturn` only exists in the VM, but as
the async transformation is only run for the VM target that shouldn't
be a problem.

Change-Id: Id71344310de918f743dcb1ad66e165fc649516ba
Reviewed-on: https://dart-review.googlesource.com/63383
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2018-07-03 06:24:49 +00:00
Alexander Markov 1b66c0a78c [vm/kernel/bytecode] Remove extra pushes/drops for Set expressions with unused result
Also, bytecode generation of DirectPropertySet and SuperPropertySet is
corrected in case result is used.

Change-Id: I680645f961d9c471579dcbdc9a5b7544cbc9e188
Reviewed-on: https://dart-review.googlesource.com/63343
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-02 18:27:23 +00:00
Alexander Markov 095bd354d4 [vm/kernel/bytecode] Fix handling of function type arguments parameter
This CL fixes number of fixed parameters in EntryOptional bytecode
and adds generation of CheckFunctionTypeArgs bytecode.

Change-Id: I3f9ccc86cb622291b2c58b5a4dbf47bb614380f2
Reviewed-on: https://dart-review.googlesource.com/62963
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-29 00:01:58 +00:00
Alexander Markov 5f0c0dcfbc [vm/kernel/bytecode] Omit source positions from bytecode when testing
Bytecode for 'assert' statement includes source positions, which are
different on Linux and Windows due to different newline characters.
This causes bytecode generator tests to fail on Windows, as expected
output includes source positions calculated on Linux.

To avoid these failures, new flag 'omitSourcePositions' is added
to bytecode generator and used in the bytecode generator test.

Change-Id: I296c9a70fa5f389b30a8982152513fdd57447c08
Reviewed-on: https://dart-review.googlesource.com/62880
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-28 17:59:27 +00:00
Alexander Markov 0e7e0c945a [vm/kernel/bytecode] Generate argument checks after allocating initial context
Argument type checks could use receiver to get instantiator type
arguments. Receiver could be captured and allocated in a context.
So initial context should be allocated before doing argument type
checks.

This CL also removes useless storing of uninitialized (null) context into
'parent' when allocating initial context.

Change-Id: Iec41f1bd474ba8cfccc360b96b3461fe760edddb
Reviewed-on: https://dart-review.googlesource.com/62706
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-27 21:51:41 +00:00
Alexander Markov c53952a46d [vm/kernel/bytecode] Generate bytecode for assertions, bool checks
In addition:

* Use InstanceCall1 instead of InstanceCall2 for now as InstanceCall2
  requires ICData objects with 2 checked arguments.

* Remove try-catch around bytecode generation as all operations are
  supported and silent fallback is no longer needed.

Change-Id: Iead5a4997450cc47ef3bb3221647e733b7a72b62
Reviewed-on: https://dart-review.googlesource.com/62443
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-26 23:07:18 +00:00
Alexander Markov a93e303f3f [vm/kernel/bytecode] Bytecode generation for rarely used operations
Change-Id: Ie5154207b4763d950707b267803a688d4b3e0487
Reviewed-on: https://dart-review.googlesource.com/62002
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-25 17:51:44 +00:00
Alexander Markov fa19575a54 [vm/kernel/bytecode] Inline list of types into TypeArgumentsForInstanceAllocation constant pool entry
Change-Id: I24a2fda84aa04a081c27427a7c84077101594421
Reviewed-on: https://dart-review.googlesource.com/61308
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-20 23:52:12 +00:00
Alexander Markov f6871d2305 [vm/kernel/bytecode] Fix generation of InstantiateTypeArgumentsTOS bytecode
Change-Id: I1c4f503cc664d678815e45628a8a14044b00f55f
Reviewed-on: https://dart-review.googlesource.com/61312
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-20 22:24:52 +00:00
Alexander Markov 6182b7215d [vm/kernel/bytecode] Fix passing of type arguments
* Argument count corrected when calling generic instance method
  (type arguments should be counted in a total arguments count in
  InstanceCall1 instruction).

* Argument count corrected in ArgDesc when calling Map._fromLiteral
  factory constructor.

* Type parameters of a factory constructor are treated as class type
  parameters to ensure that instantiator type arguments are pushed.
  This is needed as VM converts type parameters of factory constructors
  into the class type parameters (they are distinct in kernel).

* Implicit parameter for passing type arguments to factory constructors
  is now handled separately from function type arguments.
  It is used as instantiator type arguments for instantiating types.
  Unlike function type arguments, this parameter can be captured.

Change-Id: I25086a0df9cebca0b01e837e1c81b7f18b2d2270
Reviewed-on: https://dart-review.googlesource.com/61115
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-20 21:02:52 +00:00