Commit Graph

67 Commits

Author SHA1 Message Date
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
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
Dmitry Stefantsov 53321309da [kernel] Remove Vector-related Kernel nodes
They were supposed to be used as a part of the closure conversion pass,
which is now obsoleted.

Change-Id: Ie063f6c44487df7cd5d21895e8edc03251525d5f
Reviewed-on: https://dart-review.googlesource.com/68662
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2018-08-07 11:49:49 +00:00
Alexander Markov 1babc13b93 [vm/kernel/bytecode] Report compile-time errors from constant evaluation while generating bytecode
Change-Id: I931622f5e442a439f5bfa241aade686b1bc91afd
Reviewed-on: https://dart-review.googlesource.com/68222
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-08-03 19:21:17 +00:00
Alexander Markov 4ab8408e00 [vm/kernel/bytecode] Support partial tear-off instantiation constants in bytecode generator and bytecode reader
Change-Id: I24855274df292903646844bb56ece0c35a62e9ef
Reviewed-on: https://dart-review.googlesource.com/68300
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-02 23:32:43 +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 c5ac5c0a2c [vm/kernel/bytecode] Fix serialization of closures with type arguments
Before this change, ConstantClosureFunction was holding a clone of original
FunctionNode without body (in order to omit body during serialization).
It is not correct: original FunctionNode, which is used to generate
closure's bytecode may reference original type parameters and those
type parameters could be used in types written into constant pool.
A cloned FunctionNode has its own cloned copies of type parameters
and it does not provide a sufficient serialization/deserialization context.
This resulted in 'Type parameter T is not indexed' errors.

This CL fixes this problem by removing cloning. In order to avoid
serialization of the FunctionNode body, body is temporarily dropped
while writing ConstantClosureFunction.

Also, this CL fixes type finalization of signature types of closure functions
read from bytecode. If signature type is not finalized, VM crashes with
'../../runtime/vm/object.cc: 18580: error: expected: IsFinalized()'.

Change-Id: Id88e99609ee387352fc011a8c297024d05e24037
Reviewed-on: https://dart-review.googlesource.com/67960
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-08-02 00:12:14 +00:00
Alexander Markov fdf8e6f2bf [vm/kernel/bytecode] Omit 'is' checks of top types in bytecode generator
Assertion in Instance::IsInstanceOf() fails if trivial type tests like
'is dynamic' are not elided.

Change-Id: Ifaa654a613ccf2d7b56732e87a69b551ef643a92
Reviewed-on: https://dart-review.googlesource.com/67085
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-27 16:02:47 +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
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
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
Alexander Markov cdd2553a12 [vm/kernel/bytecode] Fix null handling in operator ==
Change-Id: I2de516b98c2e49baa65c725e85a696850318ee36
Reviewed-on: https://dart-review.googlesource.com/60801
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-18 22:20:41 +00:00
Alexander Markov 33feee3b03 [vm/kernel/bytecode] Fix arguments passing in native factory constructors
VM requires to pass null type arguments to factory constructors of
non-generic classes. This includes native implementation of native
factory constructors.

Bytecode generation for bodies of native factory constructors is fixed
to push this extra argument for NativeCall.

Change-Id: I741a783c6964da88ecd0bfd1d2ec4aa3b1868708
Reviewed-on: https://dart-review.googlesource.com/60200
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-06-13 22:28:04 +00:00
Alexander Markov 828a168622 [vm/kernel/bytecode] Generate bytecode for native methods
Change-Id: If47ef9ef4ff5ac3cb3f4f6737590370b647fc9ff
Reviewed-on: https://dart-review.googlesource.com/59180
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-06-13 01:16:03 +00:00