Commit Graph

68 Commits

Author SHA1 Message Date
Ryan Macnak 5bfb36daa3 [vm, compiler] Use leaf calls for exp and log.
We already do this for the other functions in dart:math.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/45414
Change-Id: Ic1fb1c7cdbbf39eaa4af645219874408988b740b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192522
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2021-03-22 23:14:25 +00:00
Vyacheslav Egorov d42de4ed06 [vm] Crash on impossible GDT null errors
This CL adds code to detect situations when we hit
null error through GDT call with non-null receiver.

We achieve this by making receiver's cid part of the
GDT calling convention and checking this cid
in runtime entry responsible for throwing the null
error.

This CL is an attempt to narrow down b/179632636
and collapse various impossible crash reports
into a single native crash cluster by crashing VM
instead of throwing a null error.

TEST=tested manually

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try
Change-Id: If2ed4646c4c0f403016266e4e83e296a7b234cb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191141
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-03-15 15:35:10 +00:00
Alexander Markov 36015bde54 [vm/nnbd] More detailed error messages for late field/variable errors
TEST=tests/language/nnbd/syntax/late_modifier_runtime_error_test.dart

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

Change-Id: I84727583a0b743c5c868921a6148b18f12eb68e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174842
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-12-03 02:29:38 +00:00
Alexander Markov 7588ed86de Remove bytecode mode from the VM
Change-Id: Ief167b7ffc128105a03cc225ab750234c9a6a7a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169147
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-10-28 17:42:35 +00:00
Alexander Markov 13aaaae1b2 [vm/compiler] Introduce AllocateTypedData IL instruction
This is the first step towards optimizing typed data array allocations,
which is useful for e.g. package:vector_math.

Opaque call to a typed data factory constructor is replaced with IL
instruction which doesn't have side-effects and doesn't prevent
other optimizations (e.g. load forwarding) from happening.

Asm intrinsics for typed data factories are replaced with stubs.

Issue: https://github.com/dart-lang/sdk/issues/43228
Change-Id: Icc7d4863f2f94ea5d8bb4620d041f7b6fe664098
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161840
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-09-16 03:16:42 +00:00
Tess Strickland 787446213c [vm/compiler] Move argument shape (not type) checks out of closures.
This CL performs the following checks in the invoke field dispatcher for
dynamic closure calls when lazy dispatchers are enabled:

* The provided function type arguments vector (if any) has the correct
  length.

* No function type arguments should be provided if the closure has
  delayed type arguments.

* All required arguments (positional in all modes, named in appropriate
  null safety modes) have been provided by the caller.

* If there are optional positional arguments, an appropriate number
  has been provided.

* If there are optional named arguments, their names are valid.

Since the runtime already handles checking the argument shapes when lazy
dispatchers are disabled, these checks are now completely removed from
closure bodies in all cases. Thus, the only remaining checks in closure
bodies are the type checks performed by AssertSubtype and
AssertAssignable when lazy dispatchers are enabled.

Changes in the Flutter Gallery:

* ARM7, release: -3.61% instructions, -2.19% total
* ARM7, sizeopt: -3.62% instructions, -2.55% total
* ARM8, release: -3.66% instructions, -1.98% total
* ARM8, sizeopt: -3.65% instructions, -2.37% total

Most of these changes are already exercised by existing tests such as
(but not limited to):

* corelib{,_2}/dynamic_nosuchmethod_test
* language{,_2}/call/call_test
* language{,_2}/closure/tearoff_dynamic_test
* language{,_2}/generic/function_bounds_test
* language{,_2}/parameter/named_with_conversions_test
* language{,_2}/vm/no_such_args_error_message_vm_test

I've added one test to specifically check the interaction between
dynamic calls and required named parameters. There is some coverage in
other NNBD tests, but those are not directly focused on testing this
specifically.

Other changes:

* Adds initial cached ranges for certain BinarySmiOp and ShiftIntegerOp
  instructions when the RHS is a constant, to avoid false negatives for
  deoptimization and throw checks prior to range analysis.

* Adds new slots for various Function fields.

* Adds the ability to define unboxed native slots, which are always
  unboxed after retrieval even in unoptimized code. In the first
  iteration, the backend only handles loads from Uint32 unboxed native
  slots. Part of https://github.com/dart-lang/sdk/issues/42793.

* Removed the special handling for loading from non-nullable int fields
  in AOT compilation. Instead, their treatment is unified with the
  treatment of the new unboxed native fields, since the source field is
  always unboxed and the result of the load is also always unboxed, as
  code involving them is always optimized.

Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: Ia02aa3e872c1fefd906fd67b55021ea1797556e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155604
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-17 08:58:08 +00:00
Ryan Macnak c5a94db091 [vm] Initial implementation of deferred loading.
(Assignment of libraries to loading units is already done in the kernel generation step.)

After compiling and before serializing, we walk the program and for each Code we assign its Instructions, CodeSourceMap and CompressedStackMap to the loading unit of that Code's defining library. Deduplication may cause Instructions, CodeSourceMaps and CompressedStackMaps to belong to more than one loading unit; in this case the objects are assigned to the root loading unit. Later they can be more precisely assigned to the dominating loading unit.

All objects except some Instructions, CodeSourceMaps and CompressedStackMaps belong to the root loading unit's snapshot. This snapshot is written like an unsplit snapshot, except that when serializing Code, we will write a reference to a stub or null when the Code's Instructions, CodeSourceMap or CompressedStackMap belongs to a non-root loading unit. The snapshots of non-root loading units contain these deferred objects and references to the corresponding Code objects to patch. The types of objects we defer (Instructions, CodeSourceMaps and CompressedStackMaps) usually represent 70+% of the snapshot size.

Bare instructions mode must be disabled when splitting because we cannot have PC-relative calls between loading units. Later we can re-enable this for calls within loading units.

Broken: Compactor probably crashes we can now have an unbounded number of image pages and the compactor assumes a fixed number.

Embedder's guide:

At compile-time, gen_snapshot should be passed --loading_unit_manifest with a path, which will enable splitting and output a mapping from loading unit ids to snapshot output paths.

At runtime, sometime during isolate startup, an embedder should call Dart_SetDeferredLoadHandler, probably near an existing call to Dart_SetLibraryTagHandler. The callback is given a loading unit id, and should eventually call Dart_DeferredLoadComplete[Error].

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: Ib597eb87c8cd634416d5ee1f00629c5550aebb00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152427
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-07-17 19:29:47 +00:00
Alexander Markov 06a8cc8dea [vm/nnbd] Use separate runtime entry for throwing _CastError in null check operator
Previously, NullError runtime entry was used both to throw
NoSuchMethodError and _CastError. _CastError was used if selector is
null. However, with --dwarf-stack-traces CodeSourceMap is not preserved
and selector is not available, so wrong exception type was thrown.

This is fixed by introducing separate NullCastError runtime entry along
with corresponding shared stubs.

NullErrorSlowPath is extended to support 3 exception types
(NoSuchMethodError, ArgumentError and CastError).
NullArgErrorSlowPath is removed as it duplicates NullErrorSlowPath.

Fixes vm/dart/null_checks_with_dwarf_stack_traces_test
Fixes https://github.com/dart-lang/sdk/issues/42149

Change-Id: I4f2b34ad2b161459491de60d8737bb4f87117336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153040
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-01 20:52:34 +00:00
Ryan Macnak ea87c9b01a [vm] Remove the Stop stub and runtime entry.
Assembler::Stop("message") used to pass a C string pointer to the runtime to print. This mechanism did not account for relocation needed by AppJIT and AppAOT, and now only a trap instruction is used.

Change-Id: I70f3374abb9f9e649027f7417c66d7079c56ff63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152582
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-06-25 23:22:02 +00:00
Daco Harkes 6544c69e23 [vm/ffi] Convert Objects to Dart_Handles in FFI calls
This includes support for calling Dart_PropagateError in native code
when doing FFI calls, and catching uncaught exceptions with Dart_IsError
when doing FFI callbacks.

The support for Dart_PropagateError adds a catch entry to the FFI
trampoline, which prevents inlining these trampolines in AOT. This
regresses the FfiCall benchmarks by 1-2% in AOT.

In addition, Dart_PropagateError requires maintaining a bit whether we
entered native/VM code from generated code through FFI or not. That way
we can do the proper transition on the exception path. When entering
generated code, we store this bit on the stack, right after the entry
frame.

Design: http://go/dart-ffi-handles

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

Change-Id: Idfd7ff69132fb29cc730931a4113d914d4437396
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145591
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-12 11:14:22 +00:00
Ryan Macnak 2fa4d3e4d8 [vm, gc] Account for AllocateArray or CloneContext returning objects that have already been added to the remembered set.
Bug: b/156940113
Change-Id: Id212f9826b83981346ea4fbb1ef80a115e831a10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148506
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-19 17:47:11 +00:00
Alexander Markov 994f454996 [vm/nnbd] Call field initializer from stubs for late instance fields
This change introduces 2 new stubs, InitLateInstanceField and
InitLateFinalInstanceField. Those stubs call field initializer
directly without going to runtime.

Fixes the regressions on Uri.pathSegments.easy and Uri.pathSegments.hard.normalized
benchmarks with NNBD SDK after https://dart-review.googlesource.com/c/sdk/+/143189.

Change-Id: I6bde7a98010ac1321a95eda8b0f125105f3993c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144807
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-28 21:35:23 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Alexander Aprelev 80ae6ed91d [vm/aot-switchable-calls] Introduce single runtime entry for all switchable calls
Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I0198fd0328945b04e4f2254bacac25b41038e78c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138361
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-04 15:03:48 +00:00
Régis Crelier 482ae8cb5b [VM/nnbd] Implement weak and strong mode type checking in runtime.
This does not yet include checking of required named parameters.
Also, inlined type testing code, type testing stubs, and type propagation are
not yet updated.

Change-Id: If6d8996635474e349d28b7fd207d724838d08881
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129922
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-06 22:32:19 +00:00
Victor Lima 98c13ba18f [vm/precomp] Reduce arm-32 code size in BoxInt64Instr
Change-Id: Id544f20493c0baffb154ee1ea235247ddd844a60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127146
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-10 15:28:45 +00:00
Ryan Macnak d96cd87896 [vm, reload] Initialize new fields in existing instances lazily.
Change-Id: I29c52feba2a404a7910888ce2bbb46e9aa8dd50f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123547
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-01 20:06:52 +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
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
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 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
Alexander Markov 1eb1520702 [vm/bytecode] Prevent triggering optimizing compilation from interpreter
Previously, in rare cases it was possible that interpreter would trigger
optimizing compilation (if function usage counter reached threshold
in the interpreter once again after unoptimized compilation finished).

This results in producing optimized code without any feedback (as
unoptimized code hasn't executed).

Change-Id: Ibd52b7dfe3a808ade97c02e743b40aa466b1e3c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108687
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-07-11 17:45:49 +00:00
Ryan Macnak 1e24fe7d69 [vm, compiler] Specialize unoptimized monomorphic and megamorphic calls.
dart-bytecode, arm64:            +4.742% geomean
dart-bytecode-jit-unopt, arm64: +12.73% geomean
dart2js-compile, x64:            +3.635% geomean

In the polymorphic and unlinked cases, call to a stub the does a linear scan against an ICData.

In the monomorphic case, call to a prologue of the expected target function that checks the expected receiver class. There is additional indirection in the JIT version compared to the AOT version to also tick a usage counter so the inliner can make good decisions.

In the megamorphic case, call to a stub that does a hash table lookup against a MegamorphicCache.

Megamorphic call sites face a loss of precision in usage counts. The call site count is not recorded and the usage counter of the target function is used as an approximation.

Monomorphic and megamorphic calls sites are reset to the polymorphic/unlinked state on hot reload.

Monomorphic and megamorphic calls sites do not check the stepping state, so they are reset to the polymorphic/unlinked state when stepping begins and disabled.

Back-edges now increment the usage counter in addition to checking it. This ensures function with loops containing monomorphic calls will eventually cross the optimization threshold.

Fixed backwards use of kMonomorphicEntryOffset and kPolymorphicEntryOffset.

Fixed C stack overflow when bouncing between the KBC interpreter and a simulator.

Bug: https://github.com/dart-lang/sdk/issues/26780
Bug: https://github.com/dart-lang/sdk/issues/36409
Bug: https://github.com/dart-lang/sdk/issues/36731
Change-Id: I78a49cccd962703a459288e71ce246ed845df474
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102820
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-06-12 21:56:53 +00:00
Samir Jindel 225a301637 [vm/ffi] Re-land "[vm/ffi] FFI callbacks on X64."
There are minor fixes for dartkb and windows.
The original revision is in patchset 1.

Change-Id: I9ab6e5fdb33fb4e84ea520c283fe94323616a8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103129
Commit-Queue: Samir Jindel <sjindel@google.com>
Auto-Submit: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-05-24 02:39:13 +00:00
Samir Jindel ed169c4bb0 Revert "[vm/ffi] FFI callbacks on X64."
This reverts commit be209f7846.

Reason for revert: failures on dartkb and windows bots

Original change's description:
> [vm/ffi] FFI callbacks on X64.
> 
> For context on the design, see go/dart-ffi-callbacks
> 
> Change-Id: I2482e3c932e73f9a4c00fa7e218ff85f9328fc51
> Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-simdbc64-try, vm-kernel-linux-release-simdbc64-try, vm-kernel-mac-debug-simdbc64-try, vm-kernel-mac-release-simdbc64-try, vm-kernel-reload-mac-debug-simdbc64-try, vm-kernel-reload-mac-release-simdbc64-try, vm-kernel-linux-debug-ia32-try, vm-dartkb-linux-debug-simarm64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100240
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Daco Harkes <dacoharkes@google.com>

TBR=sjindel@google.com,ajcbik@google.com,dacoharkes@google.com

Change-Id: I4cb3d93675d68a51ac9e125ad1d572c47e8b5903
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-simdbc64-try, vm-kernel-linux-release-simdbc64-try, vm-kernel-mac-debug-simdbc64-try, vm-kernel-mac-release-simdbc64-try, vm-kernel-reload-mac-debug-simdbc64-try, vm-kernel-reload-mac-release-simdbc64-try, vm-kernel-linux-debug-ia32-try, vm-dartkb-linux-debug-simarm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102983
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
2019-05-18 15:29:19 +00:00
Samir Jindel be209f7846 [vm/ffi] FFI callbacks on X64.
For context on the design, see go/dart-ffi-callbacks

Change-Id: I2482e3c932e73f9a4c00fa7e218ff85f9328fc51
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-simdbc64-try, vm-kernel-linux-release-simdbc64-try, vm-kernel-mac-debug-simdbc64-try, vm-kernel-mac-release-simdbc64-try, vm-kernel-reload-mac-debug-simdbc64-try, vm-kernel-reload-mac-release-simdbc64-try, vm-kernel-linux-debug-ia32-try, vm-dartkb-linux-debug-simarm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100240
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-05-18 06:15:46 +00:00
Stevie Strickland 4028fec3b5 Reland "[vm] Finish adding support for ECMAScript 2018 features."
This work pulls in v8 support for these features with
appropriate changes for Dart and closes
https://github.com/dart-lang/sdk/issues/34935.

This adds support for the following features:

* Interpreting patterns as Unicode patterns instead of
  BMP patterns
* the dotAll flag (`/s`) for changing the behavior
  of '.' to also match line terminators
* Escapes for character classes described by Unicode
  property groups (e.g., \p{Greek} to match all Greek
  characters, or \P{Greek} for all non-Greek characters).

The following TC39 proposals describe some of the added features:

* https://github.com/tc39/proposal-regexp-dotall-flag
* https://github.com/tc39/proposal-regexp-unicode-property-escapes

These additional changes are included:

* Extends named capture group names to include the full
  range of identifier characters supported by ECMAScript,
  not just ASCII.
* Changing the RegExp interface to return RegExpMatch
  objects, not Match objects, so that downcasting is
  not necessary to use named capture groups from Dart

**Note**: The changes to the RegExp interface are a
breaking change for implementers of the RegExp interface.
Current users of the RegExp interface (i.e., code using Dart
RegExp objects) will not be affected.

Change-Id: Ie62e6082a0e2fedc1680ef2576ce0c6db80fc19a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100641
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Stevie Strickland <sstrickl@google.com>
2019-04-29 09:11:48 +00:00
Keerti Parthasarathy 9238e25305 Revert "[vm] Finish adding support for ECMAScript 2018 features."
This reverts commit 5ebb640a67.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> [vm] Finish adding support for ECMAScript 2018 features.
> 
> This work pulls in v8 support for these features with
> appropriate changes for Dart and closes
> https://github.com/dart-lang/sdk/issues/34935.
> 
> This adds support for the following features:
> 
> * Interpreting patterns as Unicode patterns instead of
>   BMP patterns
> * the dotAll flag (`/s`) for changing the behavior
>   of '.' to also match line terminators
> * Escapes for character classes described by Unicode
>   property groups (e.g., \p{Greek} to match all Greek
>   characters, or \P{Greek} for all non-Greek characters).
> 
> The following TC39 proposals describe some of the added features:
> 
> * https://github.com/tc39/proposal-regexp-dotall-flag
> * https://github.com/tc39/proposal-regexp-unicode-property-escapes
> 
> These additional changes are included:
> 
> * Extends named capture group names to include the full
>   range of identifier characters supported by ECMAScript,
>   not just ASCII.
> * Changing the RegExp interface to return RegExpMatch
>   objects, not Match objects, so that downcasting is
>   not necessary to use named capture groups from Dart
> 
> **Note**: The changes to the RegExp interface are a
> breaking change for implementers of the RegExp interface.
> Current users of the RegExp interface (i.e., code using Dart
> RegExp objects) will not be affected.
> 
> Change-Id: I0709ed0a8d5db36680e32bbad585594857b9ace4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95651
> Commit-Queue: Stevie Strickland <sstrickl@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=lrn@google.com,kustermann@google.com,jmesserly@google.com,johnniwinther@google.com,sstrickl@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I1eda0fee4fd9e94df095944049833a67b07277e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100560
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2019-04-25 14:29:51 +00:00
Ryan Macnak 225516466f [vm, interpreter] noSuchMethod dispatchers as a bytecode.
Change-Id: I0e105a56b733322737b6f22a7641f7c6b8afac79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100283
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-24 22:58:35 +00:00
Stevie Strickland 5ebb640a67 [vm] Finish adding support for ECMAScript 2018 features.
This work pulls in v8 support for these features with
appropriate changes for Dart and closes
https://github.com/dart-lang/sdk/issues/34935.

This adds support for the following features:

* Interpreting patterns as Unicode patterns instead of
  BMP patterns
* the dotAll flag (`/s`) for changing the behavior
  of '.' to also match line terminators
* Escapes for character classes described by Unicode
  property groups (e.g., \p{Greek} to match all Greek
  characters, or \P{Greek} for all non-Greek characters).

The following TC39 proposals describe some of the added features:

* https://github.com/tc39/proposal-regexp-dotall-flag
* https://github.com/tc39/proposal-regexp-unicode-property-escapes

These additional changes are included:

* Extends named capture group names to include the full
  range of identifier characters supported by ECMAScript,
  not just ASCII.
* Changing the RegExp interface to return RegExpMatch
  objects, not Match objects, so that downcasting is
  not necessary to use named capture groups from Dart

**Note**: The changes to the RegExp interface are a
breaking change for implementers of the RegExp interface.
Current users of the RegExp interface (i.e., code using Dart
RegExp objects) will not be affected.

Change-Id: I0709ed0a8d5db36680e32bbad585594857b9ace4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95651
Commit-Queue: Stevie Strickland <sstrickl@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-04-24 09:24:16 +00:00
Martin Kustermann ce9a1e2b54 [vm/compiler] Fix write-barrier elimination issue
The slow patch code of allocation stubs goes to runtime to allocate
objects/contexts/arrays.  Those native calls seemingly guaranteed that
an object is new-or-remembered.

Though the runtime can actually allocate a new object and it can get
moved to old space right before returning to the continuation of slow
path allocation.

This causes us to have a newly allocated object which is not in the
remembered set.

This CL moves the code for "new-or-remembered guarantee" from
runtime_entry.cc to the call-sites in allocation stubs.

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

Change-Id: Ieef9232b4c50fdd84ad81dd8f77697bf0c4775ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99143
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-04-12 09:22:17 +00:00
Samir Jindel a7a87df513 [vm/ffi] Replicate transition to/from native code around FFI calls.
Change-Id: I49be874b47b63a0863ed58d26f417cb957b89380
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98463
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-04-11 11:59:54 +00:00
Ryan Macnak f819c866e7 [vm, interpreter] Handle method extractors as a bytecode.
Bug: https://github.com/dart-lang/sdk/issues/36410
Change-Id: Ifb803d88456227ce03f43b285b4d950c75ae379e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98947
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-04-10 18:24:36 +00:00
Régis Crelier c403804d9c [vm/interpreter] Take arg desc into consideration when resolving call method in invoke field dispatchers.
Add regression test.
This fixes issue 36084.
Issue 36293 filed against ddc, which fails on the new test.

Change-Id: I1112572d72671fbc1d78a768ee85affff41951a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97142
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-03-21 18:51:22 +00:00
Daco Harkes 7d46d4b5cb [vm / library] Foreign function interface prototype
Prototype for `dart:ffi` on Linux/MacOS x64 in JIT mode.
`dart:ffi` is experimental and its API is likely to change in the future.
Progress and design decisions are tracked in https://github.com/dart-lang/sdk/projects/13


issue: https://github.com/dart-lang/sdk/issues/34452
Change-Id: Ifa4566388e42c8757f154741d11e303465ef305d
Cq-Include-Trybots: luci.dart.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-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try, vm-kernel-mac-debug-x64-try, vm-kernel-asan-linux-release-x64
Reviewed-on: https://dart-review.googlesource.com/c/80124
Reviewed-by: Samir Jindel <sjindel@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2019-02-13 12:42:47 +00:00
Régis Crelier 25851db73d [vm/bytecode] Replace InstanceCall instruction with InterfaceCall and DynamicCall.
Dispatch interface calls via hashtable rather than inline cache.
InterfaceCall doesn't need to take arguments descriptor into account
when doing method lookup.

Change-Id: I30eae6ea638d1d2ad2cf3ff073c653fee3377f31
Reviewed-on: https://dart-review.googlesource.com/c/86106
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-12-14 16:51:51 +00:00
Ryan Macnak 30b0b9b723 [vm] Code size reductions:
- Remove dead Isolate::IsTopLevelParsing.
 - Remove dead TraceFunctionEntry/Exit.
 - Migrate more tracing flags to flag_list.h to allow code elimination in non-debug modes.
 - Require an explicit Zone parameter for CheckedHandles.
 - Remove side-effects from RuntimeEntry constructor.

out/ProductX64/exe.stripped/dart_precompiled_runtime 4063464 -> 4046952 (-16k)

Change-Id: Iffd3de25a03d2354cdecf2d79aa761c33ab08bd3
Reviewed-on: https://dart-review.googlesource.com/c/83120
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-08 02:02:39 +00:00
Ryan Macnak 04941b5507 [vm, gc] For large arrays (arrays on a large heap page), use a card-based remembered set.
Bug: https://github.com/dart-lang/sdk/issues/30433
Change-Id: I7c710d9e36ab593295d00fc5e9e72a86a1b843af
Reviewed-on: https://dart-review.googlesource.com/c/63688
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-05 22:03:34 +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
Ryan Macnak 93dcfaa289 [vm, gc] Concurrent marking.
Fall back to parallel marking
 - on IA32 (barrier unimplemented)
 - when write_protect_code is enabled (protection dependency on marking state unimplemented)

Bug: https://github.com/dart-lang/sdk/issues/34002
Change-Id: If093f24e4dc6bf29f407cc45e95bb2274fc53dcf
Reviewed-on: https://dart-review.googlesource.com/71389
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-09-21 21:30:33 +00:00
Aart Bik 8bad5c7b29 [vm/compiler] Non-speculative X64 long division/remainder.
Rationale:
Having a non-speculative implementation avoids deopting
under JIT and enables AOT.

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

Change-Id: Ib38200502f5a8f63912ff5d7a808ea6e27f9001d
Reviewed-on: https://dart-review.googlesource.com/67502
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-08-01 00:13:55 +00:00
Régis Crelier c7ed22a5d8 [VM interpreter] Support "invoke field dispatcher' and 'method extractor' functions without jitting them.
Change-Id: I78bbb34d13b643507a3eaa483ce111d20db1f5b6
Reviewed-on: https://dart-review.googlesource.com/66406
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-07-25 18:58:34 +00:00
Régis Crelier 25ff988071 [VM interpeter] Allocate a SubtypeTestCache and use it in interpreted implicit setter.
Change-Id: I1c18ff79bf9b56b650a51c193fa0759d00470786
Reviewed-on: https://dart-review.googlesource.com/65483
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-07-19 15:52:17 +00:00
Régis Crelier f793a60790 [VM interpreter] Improve transition from jitted code to interpreted code.
Arguments are not copied anymore into an array allocated for each transition.

Change-Id: Ib9e708737de6cc0d221c53f2b003e0d4040b17fc
Reviewed-on: https://dart-review.googlesource.com/64664
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-07-12 18:58:24 +00:00
Alexander Markov c4d6ac0cbe [vm/compiler/aot] Implement non-speculative int64 shift operation
Closes https://github.com/dart-lang/sdk/issues/33364

Change-Id: I9432d82a1ee58fbbdc1b54b810a71c2c7ddd8fce
Reviewed-on: https://dart-review.googlesource.com/59821
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-06-22 15:43:28 +00:00
Alexander Markov c3b5939965 [vm] Remove --limit-ints-to-64-bits option and old _Bigint class
Closes https://github.com/dart-lang/sdk/issues/33306

Change-Id: I7088d8b7143edbe24f5cefe4be037ad2006e0625
Reviewed-on: https://dart-review.googlesource.com/58101
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-06-04 20:10:40 +00:00
Régis Crelier 41fcbd097c [VM runtime] Initial version of Kernel Bytecode interpreter in VM runtime.
Not fully working yet, only x64, no gc, no frame walking, etc...

Change-Id: I4d8357f6d46371bf21c3d54266cfe26163e3c8dc
Reviewed-on: https://dart-review.googlesource.com/50021
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-09 20:29:27 +00:00
Samir Jindel f5fc335a4c [kernel] Check bounds of type arguments in strong mode.
Change-Id: I2cb230db322cc26fb62e932b40882200de38c3d4
Reviewed-on: https://dart-review.googlesource.com/24180
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-12-01 14:55:56 +00:00
Alexander Markov 0af232924c [VM, Compiler] Add initial implementation of check null instruction
This CL introduces new IL instruction, CheckNullInstr, for testing
if an object is null. This instruction will be used to ensure
correctness when AOT relies on strong mode types, which are nullable
by default (unless proven otherwise).

Code generation of CheckNullInstr is implemented without major code
duplication between different CPUs using common macro-assembler
pseudo-instructions implemented by all platforms.

Also, code generation of GenericCheckBoundInstr is refactored in
the similar way.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: I35e9b556302fe7db98ce5167b3601f08ddbee642
Reviewed-on: https://dart-review.googlesource.com/4540
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-09-12 19:25:43 +00:00
Vyacheslav Egorov 7887c34a29 VM(RegExp): Allow OSR optimization of RegExp :matcher functions.
Previously these functions would only contain a single CheckStackOverflowInstr
in a backtracking block and that CheckStackOverflowInstr would have a zero
loop_depth - which means it would not be considered eligable for OSR.

This change:

* adds CheckStackOverflowInstr with non-zero loop_depth in two other places
  (Boyer-Moore lookahead skip loop and greedy loop) where loops arise in the
  generated IL;
* sets non-zero loop depth on the CheckStackOverflowInstr in the backtracking
  block;
* adds a flag on CheckStackOverflowInstr that allows optimizing compiler to
  optimize away those checks that were inserted solely to serve as OSR entries.
* ensures that IR generated by IRRegExpMacroAssembler is OSR compatible:
  * GraphEntryInstr has correct osr_id;
  * GraphEntry and normal entry have different block ids (B0 and B1 - instead of B0 and B0);
  * unreachable blocks are pruned and GraphEntry is rewired to point to OSR entry;
  * IRRegExpMacroAssembler::GrowStack should not assume that  stack_array_cell and :stack
    are always in sync, because :stack can come from OSR or deoptimization why stack_array_cell
    is a constant associated with a particular Code object.
* refactors the way the RegExp stack was growing: instead of having a special instruction
  just emit a call to a Dart function;
* refactors the way block pruning for OSR is done by consolidating duplicated code
  in a single function.

We allow the optimizing compiler to remove preemption checks from
non-backtracking loops in the regexp code because those loops
unlike backtracking have guaranteed O(input_length) time
complexity.

Performance Implications
------------------------

This change improves performance of regexps in cases where regexp spends a lot
of time in the first invocation (either due to backtracking or due to long non
matching prefix) by allowing VM to optimize the :matcher while :matcher is
running.

For example on regex-redux[1] benchmark it improves Dart performance by 3x
(from ~18s to ~6s on my Mac Book Pro).

CL history
----------

This relands commit d87cc52c3e.

Original code review: https://codereview.chromium.org/2950783003/

[1] https://benchmarksgame.alioth.debian.org/u64q/program.php?test=regexredux&lang=dart&id=2

R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2951053003 .
2017-06-23 12:51:53 +02:00