Commit Graph

2345 Commits

Author SHA1 Message Date
Alexander Markov 7b17602c74 [vm/bytecode] Include function name into source fingerprints
This change aligns BytecodeFingerprintHelper::CalculateFunctionFingerprint
with KernelFingerprintHelper::CalculateFunctionFingerprint.

Fixes vm/cc/FunctionSourceFingerprint with bytecode.

Change-Id: I72fd25cbd2d04935c30cfe52838ef5aa890e1291
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114750
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-28 20:32:51 +00:00
Alexander Markov 1017a562d7 [vm/bytecode] Fix crash while querying parameter descriptors for static implicit closure
Fixes https://github.com/dart-lang/sdk/issues/38035

Change-Id: Ib060a0b43ff0ca85d984642e9faca8fd966a1e62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114634
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-28 02:26:33 +00:00
Aart Bik 451a7dd4ea [vm/assembler] Add IMUL with implicit operands
Rationale:
Needed for an upcoming improvement of DIV/MOD by constant.

https://github.com/dart-lang/sdk/issues/37789

Change-Id: I3966049a3f14fd3becec797c4bc0038f2852bc1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114680
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-28 00:17:13 +00:00
Samir Jindel c7ac27bf50 [vm/ffi] Refactor and fix pipeline for force-optimized code.
Change-Id: I18429fcfe44065c73674c9a00977e222e5abb5de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114513
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2019-08-27 11:06:53 +00:00
Teagan Strickland 6c67280e44 [vm] Move C-string-based hash maps to hash_map.h.
Fixes assumption about pointer equality of keys.

Adds comment to document current assumption that multiple pairs
with equivalent keys are not inserted.

Change-Id: Ieb17d1b357f903dcc09274ac648c1a97e7ee85d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113686
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-27 09:52:13 +00:00
Martin Kustermann 4a01dc1341 [vm/compiler] Remove load_invalidation_gen logic
The `Isolate::IncrLoadingInvalidationGen()` function is no longer used
and the integer therefore stays always at 0.

Change-Id: I862d8b058db88400072a7d76a17baff2b7c2e16a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114323
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-08-27 09:41:24 +00:00
Aart Bik 64a42600ea [vm/compiler] Avoid unnessary checks on 64-bit
Rationale:
Follow up from two previous CLs. Use of 64-bit macro
(requested by Martin) and avoid unnessary check on
64-bit platforms (requested by Alex)

https://github.com/dart-lang/sdk/issues/37868
https://github.com/dart-lang/sdk/issues/37895

Change-Id: I80e6825953090f5079377d0452b70e48c5be92a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114550
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-08-26 20:34:22 +00:00
Aart Bik cebb64f249 [vm/compiler] Avoid deopt for non-clamping typed data
Rationale:
The recent introduction of non-SMI deopt to fix the
clamping bug is a bit too restrictive for the other,
truncating operations. In particular, we observed
a unnecessary regression in one of our performance
benchmarks.

https://github.com/dart-lang/sdk/issues/37868
https://github.com/dart-lang/sdk/issues/37895

Change-Id: Iabf59db5c50b775a717c6e961efb3a5f4b6a964e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114447
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-08-26 19:04:32 +00:00
Martin Kustermann 48f8454960 [vm] Force raw variables created during scope building to be on the stack
Fixes https://github.com/dart-lang/sdk/issues/37984

Change-Id: I9aa283becbb836d4a0480f954aaa6d387bbc1fdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114511
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-08-26 13:58:35 +00:00
Samir Jindel 43417df9c7 [vm/ffi] Fix crashes on stacktraces and debugging with force-optimized frames.
Issue https://github.com/dart-lang/sdk/issues/37910

Change-Id: I76630fbc6733712c8709b782619a76190c70bfd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113999
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-26 10:18:34 +00:00
Teagan Strickland ab54ea60e5 [vm/compiler] Add the framework for the IL deserializer.
This adds in a version of the IL deserializer that doesn't actually do
any deserialization yet.

However, it adds in a couple of compile passes that passes the FlowGraph
for compiled functions through the serializer and deserializer.  If the
deserialization step succeeds, then the FlowGraph stored in the
CompilerPassState is replaced with the new FlowGraph for the rest of the
compiler.

Also change the default zone handling in the FlowGraphSerializer to use
the zone for the current thread, instead of the zone stored in the
FlowGraph, so that it is appropriately affected by StackZone uses.

Bug: https://github.com/dart-lang/sdk/issues/36882
Change-Id: I8fa1c7af434f724ccec45ddb73263f84730af5b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113184
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-08-26 08:58:23 +00:00
Alexander Markov 6ee9e67156 [vm/bytecode] Mark synthetic calls in source positions so debugger can skip them
Change-Id: I40ea385f650e04433ed404c51ee78e128f37445a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114303
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-08-23 17:06:11 +00:00
Alexander Markov d5a9a732a5 [vm/bytecode] Register closure functions in the object store's list of closures
Change-Id: I3917c1725d51b70dcf84f358a588a6cf79c452b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114041
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-08-22 23:54:42 +00:00
Alexander Markov 5e428ed638 [vm/bytecode] Fixes for expression evaluation
* Set parent for TypeParameters created in createExpressionEvaluationComponent.

* Resolve references from bytecode to an expression evaluation class
  using real class. Expression evaluation class could be referenced
  from type parameters.

* Avoid registering expression evaluation classes in hierarchy. They
  shouldn't be discovered through direct subclasses or implementors,
  as expression evaluation classes don't have cids.

* Add :function_type_arguments_var local variable to bytecode local
  variables info, so expression evaluation can find function type
  arguments which are in scope.

Change-Id: I515431a989b4d02af4ecf90579931dd59d3acadd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114182
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-22 22:53:12 +00:00
Ryan Macnak fdbc2920c7 [vm, bytecode] Use the global lookup cache for dynamic calls.
Removes all ICData from bytecode, avoding the need to clear bytecode when CIDs are reassigned.

Change-Id: I185f9f7acef6a32ef46adb73c6d2652bc1231bab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114053
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-22 21:43:43 +00:00
Régis Crelier 223724fa76 [vm/bytecode] Lookup source and line starts for bytecode scripts specifying uri only.
Collect token positions of field declared in bytecode.
Improve debugger debugging: Disassemble both bytecode and code when applicable.

Change-Id: I56188cf24ef4bfe8a93cce11c2f4505152abdd02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112680
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-22 18:31:18 +00:00
Ryan Macnak 0176526799 [vm, compiler] Always clone MegamorphicCaches before accessing on a background compiler thread.
This is to prevent the compiler from becoming confused by mutations from the Dart execution thread.

Bug: https://github.com/dart-lang/sdk/issues/37575
Bug: https://github.com/dart-lang/sdk/issues/37595
Change-Id: I43c42feff54d76b780beb6e8d627f1b1641f4bee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114054
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-22 18:26:39 +00:00
Samir Jindel bc16959fc7 Reland "[vm/ffi] Dispatch native callbacks through trampolines if we can't ensure callbacks will always be executable."
The original revision is in patchset 1.

Three bugs are fixed:

1. Fix SIMARM_X64 build: no need to generate trampolines for AOT or simulated JIT.
2. Hot-reload: Fix hot-reload: don't invalidate Code for force-optimized functions.
3. Windows: Provide shadow space to runtime routines.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-mac-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm_x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-win-release-x64-try
Change-Id: I326009cfacb51a84e9de4ddf9ff2d6d415460f91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113829
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-21 13:33:37 +00:00
Ryan Macnak 239a6d1449 [vm, bytecode] Annotate super calls and clear lookup caches on reload.
Fixes remaining vm/cc/IsolateReload tests.

Change-Id: I98999b6e1164a015dbd61674b70c771cd6c488b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-21 00:10:26 +00:00
Samir Jindel 663a8630e6 Revert "[vm/ffi] Dispatch native callbacks through trampolines if we can't ensure callbacks will always be executable."
This reverts commit bab592fd28.

Reason for revert: Breaks SIMARM_X64 build and crashes in hot-reload.

Original change's description:
> [vm/ffi] Dispatch native callbacks through trampolines if we can't ensure callbacks will always be executable.
> 
> Issue https://github.com/dart-lang/sdk/issues/37629
> 
> Change-Id: Ib61c32bde5a8b38d90b4da77e27e3874b8bfb7e2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111432
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

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

Change-Id: Id7dc3068a97debc7a8f757df31ef33fb68bdcb44
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113827
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2019-08-20 16:27:32 +00:00
Samir Jindel e8c82c6784 [vm/ffi] Suppress irrelevant lint failures in FFI sources.
Change-Id: I63893f54a43e7ea5deb8e5e62a0f91e7d0c44d70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113826
Commit-Queue: Samir Jindel <sjindel@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-08-20 15:55:19 +00:00
Samir Jindel bab592fd28 [vm/ffi] Dispatch native callbacks through trampolines if we can't ensure callbacks will always be executable.
Issue https://github.com/dart-lang/sdk/issues/37629

Change-Id: Ib61c32bde5a8b38d90b4da77e27e3874b8bfb7e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111432
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-20 15:54:50 +00:00
Ryan Macnak 6e2b3f0326 [vm] Greatly reduce handle allocation during reload.
Saves 10ms from non-empty reloads of Flutter Gallery.

Change-Id: If9a1f9970d562f8fd7996de875dfe231350efaa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113282
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-08-20 00:49:52 +00:00
Martin Kustermann 8a9448138a [vm/compiler] Ensure the class check we insert is based on the same CidTargets we made the HasSingleTarget decision on
This is a temporary fix until we implement some abstraction to ensure the BG compiler
has always a consistent view of megamorphic caches it's interested in.

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

Change-Id: I98ec29db7a4ecd5776f724e11d50fb4535bacdd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113694
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-08-19 19:02:22 +00:00
Jens Johansen 2891ec679b [CFE/VM] Fix merge/typo for bump to kernel version 29
Before this fix, trying to run a dill with version 28 (with named types
in it) on a new VM would crash.

Change-Id: I47851c236332aa14511f595b4b129e6354b395a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113689
Commit-Queue: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-08-19 14:11:11 +00:00
Alexander Markov de45a3f765 [vm/bytecode] Fix vm/cc/TryCatchOptimizer unit tests
These tests look for local variables by names in LocalScope.
However, in bytecode we keep information about local variables only
for debugging and LocalScope objects are not created.

This change adds implementation of local variables lookup using bytecode
debugging information. In PRODUCT mode (which doesn't have debugging
information) these tests are disabled.

Change-Id: Ia5eafb440fa19bc1007582a360c36a87aa637e6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113271
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-16 23:38:40 +00:00
Alexander Markov ea7348c5f0 Revert "[vm/bytecode] Switch kernel service dill to bytecode if building Dart SDK with --bytecode"
This reverts commit beee442625.

Reason for revert: StackOverflow on language_2/deep_nesting_expression_test/01 in interpreted mode.

Original change's description:
> [vm/bytecode] Switch kernel service dill to bytecode if building Dart SDK with --bytecode
> 
> Temporary setting of FLAG_enable_interpreter is avoided in the VM unit tests as
> this flag is global and used by kernel service isolate while running tests.
> Flipping this flag causes assertion failures in kernel isolate's background compiler
> or infinite loop between LazyCompile stub and CompileFunction as AttachBytecode
> doesn't set entry point to InterpretCall.
> 
> The less intrusive way to ensure compilation of functions in unit tests is to set
> FLAG_compilation_counter_threshold to 0.
> 
> Change-Id: Ia46ff8d03d66ab8b147b9d89336548c4a9c29f5d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113123
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com

Change-Id: I67cd03a56f9a2d29aa6597d38779e77ca3a16b18
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113480
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-16 22:39:52 +00:00
Alexander Markov beee442625 [vm/bytecode] Switch kernel service dill to bytecode if building Dart SDK with --bytecode
Temporary setting of FLAG_enable_interpreter is avoided in the VM unit tests as
this flag is global and used by kernel service isolate while running tests.
Flipping this flag causes assertion failures in kernel isolate's background compiler
or infinite loop between LazyCompile stub and CompileFunction as AttachBytecode
doesn't set entry point to InterpretCall.

The less intrusive way to ensure compilation of functions in unit tests is to set
FLAG_compilation_counter_threshold to 0.

Change-Id: Ia46ff8d03d66ab8b147b9d89336548c4a9c29f5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113123
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-08-16 20:53:10 +00:00
Johnni Winther eae781c73e [cfe] Add Field.isLate, VariableDeclaration.isLate and VariableDeclaration.isRequired
Add support for the `late` modifier on fields and local variables in
CFE, and `required` on named parameters When using the option
--enable-experiment=non-nullable the `isLate` and `isRequired` flags will be set
accordingly on Field and VariableDeclaration nodes.

Closes #37686
Closes #37684

Change-Id: If37fc93defdabc5cc974f3f068f57752a665f4cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113036
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2019-08-16 19:39:05 +00:00
Alexander Markov b4b1d5ddac [vm/bytecode] Avoid eagerly reading all bytecode in app-jit snapshots
Reading all bytecode results in significantly higher memory usage due to
more classes finalized and more Function, Field, OneByteString, ObjectPool
and Bytecode objects.

dart2js-compile/CompileHelloMemoryUse benchmark with bytecode:
heap.old.capacity.max 121.387 -> 112.016 MB

Change-Id: Ic702a1c61613e1fc0c2d1f0b3a972da238bab838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113140
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-16 19:31:40 +00:00
Régis Crelier f236abc902 [vm/bytecode] Emit DebugStepCheck calls when compiling bytecode.
Change-Id: I3a5afbdbefbf7c034e6ee01a6bcf5f6922fedf43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113261
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-16 02:38:52 +00:00
Aart Bik 1523fbd96e [vm/compiler] Fixed bug with clamping on 32-bit arch
Rationale:
Feel the power of value-guided fuzzing that, in combination
with new types, founds this issue in the graph intrinsifier.
The deopt on the speculative code for Smi was missing.

https://github.com/dart-lang/sdk/issues/37868

Change-Id: I9f310f62eb6cf1cdb3e39685caed5b7792024565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113203
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-08-15 21:05:02 +00:00
Teagan Strickland c30a2be812 [vm/compiler] Check current_ssa_temp_index in FlowGraphChecker.
Change-Id: I6da7fa6c37d65ce9d7c2adc4ee71ccc3d86e2ada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113027
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2019-08-15 07:39:54 +00:00
Aart Bik 2ea18498e9 [vm/compiler] Improve range analysis over MOD
Rationale:
Improves range analysis over MOD with the goal
of removing more bounds checks in a[i % length]
array accesses.

https://github.com/dart-lang/sdk/issues/37789

Change-Id: I1fb275d53a00400e2343628295fa010ac9b21786
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112933
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-08-14 17:44:09 +00:00
Ryan Macnak a2de29095e [vm] Implement fingerprints for bytecode functions.
To be used as an approximate check of the compatibility of closure contexts.

Change-Id: Ib5685cf652ddb86628e718bc4f18a81667515d04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112846
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-08-14 15:47:09 +00:00
Teagan Strickland 812796ff3d [vm/compiler] Make BlockScheduler AllStatic.
The FlowGraph on which to run is available at each method call site, so
we don't need to store it.

This also avoids issues in the future if we ever rebuild the FlowGraph
entirely during compilation, since we won't be using a BlockScheduler
object that caches an older version of the FlowGraph.

Change-Id: I5653e1230131fbada3fe01cfa6c1ac37846fccb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113024
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2019-08-14 10:52:14 +00:00
Alexander Markov 449446571f [vm/bytecode] Collect context levels for compiled code generated from bytecode
Change-Id: Ia2047440e05fce3263f8feb38be4cedd4357ab10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112920
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-13 20:32:49 +00:00
Alexander Markov 20407e28db [vm/compiler] Follow redefinitions in Value::NeedsWriteBarrier()
This is needed in order to account for redefinitions with less precise
type, such as AssertAssignable of Smi to a generic T.

x64, bytecode compiler:
CryptoDecrypt(RunTime): 8516.8 -> 8190.6 us

Change-Id: I8c5b8eb3efcc7ae1ccf204f5081772081be29c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112755
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-13 16:15:11 +00:00
Aart Bik b0968395f1 [vm/compiler] Minor heuristic change to reduce code size
Rationale:
Inlining constant constructors/mixin is practically always
profitable. So the heuristics have been changed to at least
consider these even at higher depth (note that they are of
course still subject to actual heuristics while inlining).

This brings back flutter gallery size to where it was
before mixins were introduced.

head:

VMIsolate(CodeSize): 4737
Isolate(CodeSize): 2005123                     101%
ReadOnlyData(CodeSize): 2212408                103%
Instructions(CodeSize): 7006928                100%
Total(CodeSize): 11229196                      101%

improved heuristic:

VMIsolate(CodeSize): 4737
Isolate(CodeSize): 1985691
ReadOnlyData(CodeSize): 2152880
Instructions(CodeSize): 6987616
Total(CodeSize): 11130924

https://github.com/dart-lang/sdk/issues/37126

Change-Id: I28de0fa6c92a785bbc47e9fa09ed55ae68593c0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112758
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-12 23:17:43 +00:00
Aart Bik a9f6e0302b [vm/compiler] Unify IsRedundant for JIT/AOT bounds checks
Rationale:
The range analysis carefully computes ranges on Smis such
that the results are valid for both JIT and AOT. So the
IsRedundant() tests between the speculative and non-speculative
bounds checks can be shared. This does not only reduce the
amount of code, but also improves actual bounds check elimination.

https://github.com/dart-lang/sdk/issues/37687

Change-Id: I883a16d4be4d3704cad3e42264e1f36a5afc3b89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112167
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-12 18:15:16 +00:00
Alexander Markov 261fd6266b [vm/bytecode] Enumerate modified libraries in bytecode for hot reload
This fixes certain vm/cc/IsolateReload tests which stopped working
after kernel AST was removed from kernel binaries with bytecode in kernel service
(in https://dart.googlesource.com/sdk/+/9b3c693335effe6d156df5d90ce59977985ea9f5).

Change-Id: Ibfaccf520d6d422f17c95d36db8e84980364263f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112660
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-10 19:50:45 +00:00
Alexander Markov f255c0c8d3 [vm/bytecode] Revise PushStatic bytecode instruction
PushStatic instruction expects field object to be pushed onto the stack.
This is useless, as PushStatic also references field with its D operand.
This change replaces PushStatic instruction with LoadStatic which doesn't
take field object on the stack, so PushConstant/PushStatic pair is replaced
with a single LoadStatic instruction.

This change also enables constant propagation of values of injected CID
fields, which are not known at bytecode generation time.

Change-Id: Ifbdd3aea2aab338f6c9ec3e5728948c4d8541a4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112489
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-08-09 21:02:31 +00:00
Daco Harkes 77f545bbc4 [vm/ffi] Fix instantiation and garbage collection of NativeType objects
Fixes: https://github.com/dart-lang/sdk/issues/37780

Change-Id: I04f5788ab2dbce13fd6bd906acb91b8acf6d7fb3
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try, app-kernel-linux-debug-x64-try, vm-kernel-linux-debug-simdbc64-try,vm-kernel-linux-debug-ia32-try,vm-dartkb-linux-debug-simarm64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-dartkb-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-ffi-android-product-arm-try,vm-dartkb-linux-release-x64-abi-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112390
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2019-08-09 16:47:24 +00:00
Alexander Markov dc2c942c7d [vm/bytecode] Avoid adding all ICData objects from constant pool
Code::ResetSwitchableCalls iterates all ICData objects and tries to find
corresponding PCs. Before this change, functions compiled from bytecode
had all ICData objects from constant pool in their ic_data_array().
This is a problem because constant pool is shared among closures, so it
could contain ICData objects for dynamic calls in other functions (closures),
so ResetSwitchableCalls won't be able to find their PCs.

The fix is to add ICData objects to ic_data_array only when generating
DynamicCall.

This change fixes the crash with the following call stack:

 dart::MatchesPattern(unsigned long, short const*, long)
 dart::CodePatcher::GetInstanceCallAt(unsigned long, dart::Code const&, dart::Object*)
 dart::Code::ResetSwitchableCalls(dart::Zone*) const
 ...
Change-Id: Ia578520513d928c4aa9156825a369934e4bb95b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112482
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-09 16:16:54 +00:00
Daco Harkes 51f4574e50 Reland "[vm/ffi] Support structs on 32bit architectures"
Fixes alignment checks on GCC <= 7 and Clang <= 7.

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

Original CL is in patchset 1.

Tested GCC 7 and Clang 7 behavior of alignof and offsetof manually (our CQ uses newer tooling).

Change-Id: I828b00ad3d36be68a0d28b0a710fea938ca17784
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try, app-kernel-linux-debug-x64-try, vm-kernel-linux-debug-simdbc64-try,vm-kernel-linux-debug-ia32-try,vm-dartkb-linux-debug-simarm64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-dartkb-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-ffi-android-product-arm-try,vm-dartkb-linux-release-x64-abi-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112254
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2019-08-09 14:14:32 +00:00
Régis Crelier 62325f95b4 [vm/bytecode] Collect more bytecode token positions for a given script.
Refactor Kernel::CollectTokenPositionsFor, but do not try to factorize code for
fields and functions, as too many handles would need to be passed around.

Bytecode reading creates duplicate script objects requiring scripts to be
matched by their url rather than by their raw address when collecting token
positions in bytecode. However, url comparison is not yet used, because
collecting token positions in the duplicated script 'dart:core/map.dart'
(in default mode) causes crashes in kernel reading. Will revisit.

Fix service test valid_source locations_test.dart and make sure fields
are properly reloaded, except fields injected by fasta.
Remove unused argument 'record' of KernelReaderHelper::ReadPosition().
Handle bytecode stub frame in IsAsyncMachinery() tester in debugger.

Change-Id: Ifbddcaec00e0696f7de13c5cf1e74380b31d2419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112402
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-08 23:21:12 +00:00
Aart Bik 82b06db952 [vm/compiler] Move more common code into type propagator
Rationale:
Since I was visiting the neighborhood anyway, I might
as well clean up a bit more code duplication. Now all
type propagation related code is in one file!
Change-Id: Idec49dd91a12b42c5371c132c571acca22d4b187
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112046
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-08 19:05:09 +00:00
Aart Bik 1b0469184e [vm/checker] Keep private method order consistent with header
Rationale:
Use a consistent order for methods in header and CC.
Change-Id: Idf887346aea402bae1a9804183f49ef10b2e04c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112272
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-08-08 16:29:41 +00:00
Alexander Markov 3f4ccc1076 [vm/bytecode] Replace dynamic with Object in bounds of type parameters
This is needed for function subtype checks and mimics the behavior of
kernel AST reader (TypeTranslator::LoadAndSetupTypeParameters).

Fixes the following tests in bytecode mode:
co19_2/Language/Generics/typedef_A04_t06
co19_2/Language/Generics/typedef_A04_t07

Change-Id: I70fc86e811e77b2adc31d7bfce9ba55c5838666f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112144
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-08-07 22:42:55 +00:00
Samir Jindel e59a4a2b42 [vm/ffi] Call natives through stubs if write-protection is enabled without dual-mapping.
Addresses the Dart -> Native half of dartbug.com/37629

Change-Id: I242b7f3a14dd105334a8b6e5c089b173c398491e
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111280
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-07 11:37:20 +00:00