Commit Graph

2008 Commits

Author SHA1 Message Date
Alexander Markov bab9d2ad05 [vm] Remember GenericCovariantImpl in TypeParameter
Previously, in order to get GenericCovariantImpl property of a type
parameter we had to (re-)read kernel.

This change is a preparation for decoupling flow graph building of
special functions from kernel reading.

Change-Id: I48b45d2cece683ac3a3bd0ed506ddfcc3c526826
Reviewed-on: https://dart-review.googlesource.com/c/94641
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-02-28 17:38:19 +00:00
Ben Konyi 4cff5a4fd6 [ VM / Service ] Dynamically load source from linked-in platform kernel
- Added `Dart_SetDartLibrarySourcesKernel` to the Dart embedding API.
- vm_platform_strong.dill now contains the Dart SDK sources
- If vm_platform_strong.dill is linked into the Dart binary, the first
  request for a Dart SDK Script object from the VM service will load the
  sources for the script from the linked in kernel buffer.

Change-Id: I664abe31f9378d25ec79c21edce0b237a278495d
Reviewed-on: https://dart-review.googlesource.com/c/93375
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-02-21 18:22:39 +00:00
Martin Kustermann d3fde891bf [VM] Fix deadlock between mutator and BG compiler
Here's how the deadlock can happen:

  * The vm-service background compiler asks all threads to go to a
    safepoint before it finalizes the code. Then it finalizes the
    code and notifies code observers. A code observer posts a
    message to the vm-service. Posting this message requires holding the
    monitor of the receiving isolate's message handler (see
    MessageHandler::PostMessage).

  * The vm-service mutator holds it's message handlers monitor and
    enters the isolate (see MessageHandler::HandleMessages). The
    StartIsolateScope schedules the mutator thread, which will in return
    see that BG compiler wants to safepoint, so it waits for BG compiler
    to finish.

At this point the mutator holds the MessageHandler's monitor and waits
for BG compiler to finish safepoint. The BG compiler tries to post a
message to the message handler (and the monitor is locked).

-> This CL ensures the BG compiler only arranges a safepoint before it
   starts creating the instructions object. It fills it in and exits the
   safepoint again.  Only then do we notify code observers.

Furthermore this CL ensures we transition out of VM to native state
before calling the Dart_PostCMessage() function.

Change-Id: I5320440d54ca303a1ccc7556600a42d37cd6e1de
Reviewed-on: https://dart-review.googlesource.com/c/93421
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-02-19 14:00:04 +00:00
Samir Jindel ae7bf9e999 [vm] Support closurization of methods through @pragma entry-points.
Fixes dartbug.com/35720.

Also enable native extensions in AOT.
Increases Flutter Gallery snapshot size by 0.19%.

Change-Id: I1b24c3b9a49a13fd48452e9a89595516a7f01780
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
Reviewed-on: https://dart-review.googlesource.com/c/92283
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-02-14 17:47:28 +00:00
Martin Kustermann 525b43d747 [vm] Decouple intrinsifier code from runtime
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface.

This CL decouples the hand-written intrinsifier code from the runtime:

  * the intrinsifier is split up into a GraphIntrinsifier and AsmIntrinsifier
  * the recognized methods list is moved to a separate .h file
  * all intrinsifier code is moved into dart::compiler namespace
  * the AsmIntrinsifier is only interacting with RT through runtime_api.h

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

Change-Id: I0a73ad620e051dd49c9db7da3241212b3b74ccdd
Reviewed-on: https://dart-review.googlesource.com/c/92740
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-02-13 17:22:56 +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
Ryan Macnak 78509055b6 [vm] Add names for more types to the V8 snapshot profile output.
Fix some types of base objects in the V8 snapshot profile output.

Rename ICData::ic_data_ to entries_ as it does not point to an ICData.

Change-Id: Ie80974e2eb741810a5f540dd40e5d60a519d8e4e
Reviewed-on: https://dart-review.googlesource.com/c/92665
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-12 17:54:58 +00:00
Martin Kustermann 660cf26dbb Reland "[vm] Decouple stub code from runtime"
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface.

This CL decouples the hand-written stub codes from the runtime. The
target architecture dependent stubs are moved to
dart::compiler::StubCodeCompiler which use dart::compiler::target:*
for accessing any runtime related code.

The generation of type testing stubs is moved to separate files for the
time being.

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

Change-Id: Icd0995b18a7bac496b1e12231cf437943f5c94f1
Reviewed-on: https://dart-review.googlesource.com/c/92720
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2019-02-12 13:52:28 +00:00
Ben Konyi 30f9143831 Revert "[vm] Decouple stub code from runtime." and "[VM/Decoupling] Follow-up change to decoupling of stub_code: Fix missing "!""
This reverts commits a8e2dfdb9b and 473c424fe2.

Change-Id: Id5f67541adcdcb4fa0900a34fa389149f556929f
Reviewed-on: https://dart-review.googlesource.com/c/92667
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2019-02-12 00:59:23 +00:00
Ryan Macnak 553e20863c [vm] Remove some dead code from the old front end.
Change-Id: I9c26cbc617b25dbd04e4dfd46a68307e88eec60e
Reviewed-on: https://dart-review.googlesource.com/c/92481
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-11 21:56:47 +00:00
Martin Kustermann a8e2dfdb9b [vm] Decouple stub code from runtime.
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface.

This CL decouples the hand-written stub codes from the runtime. The
target architecture dependent stubs are moved to
dart::compiler::StubCodeCompiler which use dart::compiler::target:*
for accessing any runtime related code.

The generation of type testing stubs is moved to separate files for the
time being.

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

Change-Id: I1b4f1cca0acb704b30b80eca7f634734772389b5
Reviewed-on: https://dart-review.googlesource.com/c/92138
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-02-11 11:24:00 +00:00
Ryan Macnak 3afac84840 [vm, aot] Remove KernelProgramInfo etc before Symbols::Compact.
Eliminates some symbols that were memory-reachable but not snapshot-reachable.

Compact the canonical type and type arguments tables along with the symbol table.


flutter_gallery, Android release
Total(CodeSize): 11158045 -> 11055480 (-0.92%)

Change-Id: I63bd1353906ea66c6f82a932cff57f7c25331200
Reviewed-on: https://dart-review.googlesource.com/c/92221
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-08 17:16:26 +00:00
Alexander Markov a0516965b4 [vm] Load top-level functions and variables lazily
LoadKernel part of startup: 409ms -> 196-210ms.
FinishTopLevelClassLoading: 15ms

Change-Id: If47f06fe235a70ed08e6a3d75e8f871edae5e45c
Reviewed-on: https://dart-review.googlesource.com/c/92155
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-02-07 18:12:34 +00:00
Zichang Guo 7e81f56ad7 Save Initializer for field and pass into debugger to enable breakpoint setting.
Change-Id: I9f7afcdd057f161873d3c6e47cb0ce171806f301
Reviewed-on: https://dart-review.googlesource.com/c/91120
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-02-06 03:20:35 +00:00
Alexander Markov 9afb65d7f1 [vm] Fixes for recursive class loading
In --compile-all mode with CL [1] when NoSuchMethodError was finalized
the following happened:

ClassFinalizer::FinalizeClass calls KernelLoader::FinishLoading,
which calls KernelLoader::LoadProcedure to load precedures,
which calls Library::GetMetadata, which runs Dart code and triggers
background compilation; BackgroundCompiler::Start calls finalization of
NoSuchMethodError class recursively.

FinalizeClass calls FinishLoading for the second time, but this time
background compilation is not invoked, FinishLoading completes
and all members are finalized. After returning from recursive finalization,
the first FinishLoading proceeds and overwrites already finalized
functions with freshly loaded non-finalized functions.
As class is already marked as finalized, functions are not finalized
for the second time, causing crash later.

This CL fixes 2 problems related to recursive class loading:

* When fields are loaded, they should replace previous fields
  rather than appending them. This ensures that recursive loading
  won't add several duplicate fields (potential problem).

* IsLoaded flag is added to a class and checked after loading each
  procedure. If class happens to be loaded already, then FinishLoading
  should return immediately, discarding its loaded functions.
  This prevents overwriting finalized functions with freshly loaded.

Also, this change adds guard against repeated class loading (may happen
during recursive attempts of class finalization).

[1] https://dart-review.googlesource.com/c/sdk/+/91108

Change-Id: I5279a73f56fde26a8d9068912b3e08829ceaa4a8
Reviewed-on: https://dart-review.googlesource.com/c/91981
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-02-05 18:43:05 +00:00
Alexander Markov b59d5a2be9 [vm] Relax assertion about duplicated direct implementors
When mixin application is transformed, mixin is added to the end of
interfaces list. This may cause assertion failure if the same class
is used as mixin and mentioned among implemented interfaces.
This CL relaxes that assertion for mixins as this duplication is very
rare and seems harmless.

Note that it would not be valid to remove duplicated interface/mixin
from the list of interfaces, as it would break dart:mirrors in this case:
dart:mirrors needs to reflect duplicated interface/mixin both in
ClassMirror.superinterfaces (which is populated from the
list of interfaces without last element) and ClassMirror.mixin (the last
element in the list of interfaces).

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

Change-Id: I9b986f7759a76cb6f963ebd837e9ea26f6242f8e
Reviewed-on: https://dart-review.googlesource.com/c/91961
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-02-05 00:35:02 +00:00
Ryan Macnak db7f848632 [vm] Remove dead BigInt code.
Change-Id: I2b7169c2cd0ea62849e67e8f34808bf566cde2fe
Reviewed-on: https://dart-review.googlesource.com/c/91944
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-04 22:40:42 +00:00
Ryan Macnak e717ecdc92 [vm] Maintain view-ness of bytecode instructions in snapshots.
Change-Id: Ieb032d55e5b8bab08e7eb3445a356068384dca28
Reviewed-on: https://dart-review.googlesource.com/c/91682
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-31 20:10:58 +00:00
Samir Jindel 267e91a0ea Re-land "[vm] Prevent access to non-annotated members through native API."
Two fixes:

  - Make entrypoints_verification_test work on configurations where CFE compilation
    is separate from execution.
  - Add missing entry-point annotation for Windows.

The original revision is in patchset 1.

Change-Id: I6c4b52b1bae7bc730546dad6a3e31d8625f850b1
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
Reviewed-on: https://dart-review.googlesource.com/c/90942
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-01-29 15:10:34 +00:00
Vyacheslav Egorov f496e538f4 [vm] Decouple assemblers from runtime.
This is the next step towards preventing compiler from directly peeking
into runtime and instead interact with runtime through a well defined
surface. The goal of the refactoring to locate all places where compiler
accesses some runtime information and partion those accesses into two
categories:

- creating objects in the host runtime (e.g. allocating strings, numbers, etc)
during compilation;
- accessing properties of the target runtime (e.g. offsets of fields) to
embed those into the generated code;

This change introduces dart::compiler and dart::compiler::target namespaces.

All code in the compiler will gradually be moved into dart::compiler namespace.
One of the motivations for this change is to be able to prevent access to
globally defined host constants like kWordSize by shadowing them in the
dart::compiler namespace.

The nested namespace dart::compiler::target hosts all information about
target runtime that compiler could access, e.g. compiler::target::kWordSize
defines word size of the target which will eventually be made different
from the host kWordSize (defined by dart::kWordSize).

The API for compiler to runtime interaction is placed into compiler_api.h.

Note that we still permit runtime to access compiler internals directly -
this is not going to be decoupled as part of this work.

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

Change-Id: If4396d295879391becfa6c38d4802bbff81f5b20
Reviewed-on: https://dart-review.googlesource.com/c/90242
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-25 16:45:13 +00:00
Ryan Macnak b6b4836d1d [vm] Reference type test stubs through Code; use the type as the owner of a type test stub.
Directly referencing VM isolate instructions from an isolate snapshot causes the instructions to be copied into the isolate's image page because instructions do not use the indirection of the ref array. Duplicating the instructions caused TypeTestingStubFinder::LookupByAddresss to be unable to identity the duplicate copies of the VM isolate type testing stubs.

Fixes identity of StubCode::*TypeTest broken by duplication in snapshot.
Fixes generating AppJIT snapshots after loading from AppJIT snapshots.
Fixes attribution of ticks for type test stubs in the AOT profiler.

Change-Id: I9879a85bd548e694ee36e14f795898582ccdddb0
Reviewed-on: https://dart-review.googlesource.com/c/90501
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-23 22:59:47 +00:00
Régis Crelier 27316cc97b Revert "[vm] Prevent access to non-annotated members through native API."
This reverts commit 0203243381.

Reason for revert: breaking several bots

Original change's description:
> [vm] Prevent access to non-annotated members through native API.
> 
> We will issue warnings and throw an API error when the native API is used to access members which were not appropriately
> annotated as entry-points, if the flag "--verify-entry-points" is passed.
> 
> Also, fixes Class::Invoke against fields (isn't allowed through native API but
> could be allowed with mirrors, and is inconsistent with Library::Invoke behavior).
> 
> I've checked locally that this would have caught the bug in
> "Wrap the user entrypoint function in a zone with native exception callback. (#7512)".
> 
> Change-Id: I617c71e1965457c956c97761359765bb9bb18c1c
> 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
> Reviewed-on: https://dart-review.googlesource.com/c/90060
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

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

Change-Id: I554b389780e4ba652183c044b040b0c524beb5c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
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
Reviewed-on: https://dart-review.googlesource.com/c/90841
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-01-23 20:37:22 +00:00
Samir Jindel 0203243381 [vm] Prevent access to non-annotated members through native API.
We will issue warnings and throw an API error when the native API is used to access members which were not appropriately
annotated as entry-points, if the flag "--verify-entry-points" is passed.

Also, fixes Class::Invoke against fields (isn't allowed through native API but
could be allowed with mirrors, and is inconsistent with Library::Invoke behavior).

I've checked locally that this would have caught the bug in
"Wrap the user entrypoint function in a zone with native exception callback. (#7512)".

Change-Id: I617c71e1965457c956c97761359765bb9bb18c1c
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
Reviewed-on: https://dart-review.googlesource.com/c/90060
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-01-23 19:04:26 +00:00
Ryan Macnak a353b1172a [vm, compiler] Remove TAG_IC_DATA, which has since been subsumed by RebindRule.
Change-Id: Iaef4ba625aaa789dacb34efdb3de3c8ab8c15498
Reviewed-on: https://dart-review.googlesource.com/c/89901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-01-16 22:33:01 +00:00
Ryan Macnak c34f1b4890 [vm] Bind static calls before saving JIT snapshots.
Change-Id: I11bbd7168513d2edf5b3ef4c77236e647bc9941c
Reviewed-on: https://dart-review.googlesource.com/c/88902
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-10 22:33:22 +00:00
Ryan Macnak 8da53e3120 [vm] Add Dart_SaveTypeFeedback and Dart_LoadTypeFeedback.
Change-Id: I8c20271b20638972b28299f0488e7f3dd37f8797
Reviewed-on: https://dart-review.googlesource.com/c/88604
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-10 01:04:11 +00:00
Martin Kustermann 3c662736d9 [VM] Ensure PP is restored when returning from runtime calls in bare instructions mode.
Now that we have a moving GC it's no longer sufficient to rely on callee-saving
behavior of PP.

This change also ensures that all calls go through RuntimeEntry::Call() .

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

Change-Id: I159986dc18a9b201175fd4a7064a24a1533790ef
Reviewed-on: https://dart-review.googlesource.com/c/88711
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-01-09 08:34:55 +00:00
Alexander Markov 13a689f0fd [vm] Remove unnecessary class finalization
Change-Id: I4c51328af5f32fdb3c3065293e82993220b57b9d
Reviewed-on: https://dart-review.googlesource.com/c/88745
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-01-08 23:56:23 +00:00
Ryan Macnak efdbeb8059 [vm] Repair JIT snapshots generated from gen_snapshot.
Bare-metal relocation processing was removing the static call table, which is needed at runtime for JIT code.

Change-Id: Iab9a5a9256afd5f3985e8311a0131471cd04932d
Reviewed-on: https://dart-review.googlesource.com/c/88762
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-01-08 22:52:13 +00:00
asiva a69e73e42a [VM / Runtime] Remove more dead code
Remove ValidatePostFinalizePatch and SetRefinalizeAfterPatch which are
not used anymore

Remove RawClass::kRefinalizeAfterPatch bit

Change-Id: I289df7ffe3e3017335510b5c14331254ca73c503
Reviewed-on: https://dart-review.googlesource.com/c/88621
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-01-08 01:26:18 +00:00
asiva 2427a69e14 [VM/Runtime] Refactoring sources to enable interpreter only builds.
The interpreter only build of the Dart VM should not be including any
sources from the 'compiler' directory.
First part of restructuring sources to enable an interpreter only build
of the VM
- Move CompileClass from compiler.cc file to class_finalizer.cc

Change-Id: I8743c6537ed2d63e6991d78949f858a1ae506121
Reviewed-on: https://dart-review.googlesource.com/c/87987
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-01-07 18:49:17 +00:00
asiva d9ac2704f8 [VM / Runtime] Remove Class::ApplyPatch which is dead code now.
All application of patches is now done in the front end there
are no callers to Class::ApplyPatch, deleting it.

Change-Id: I84857ea49463faea8df6ce1ce88c0f704a893e65
Reviewed-on: https://dart-review.googlesource.com/c/88426
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-01-04 22:36:28 +00:00
Régis Crelier 08492f41cd [VM Runtime] Removed 'IsMoreSpecificThan' support in the VM.
In Dart2, the type relation "is more specific than" is no different than "is
subtype of". Since Dart1 is not supported anymore, type checking in the runtime
can be simplified and cleaned up.

Change-Id: I8e95b9e47146315c9a6f6c29b732ecbeb4e9ae97
Reviewed-on: https://dart-review.googlesource.com/c/88221
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-01-03 00:41:20 +00:00
Liam Appelbe 28fb42cc5b [VM] Filter noSuchMethod forwarders from coverage reports
Closes https://github.com/dart-lang/sdk/issues/35453

Bug: https://github.com/dart-lang/sdk/issues/35453
Change-Id: I763d705b9b3968452d569cf30b05ef4de25995b1
Reviewed-on: https://dart-review.googlesource.com/c/88121
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2018-12-28 23:31:54 +00:00
Régis Crelier a94137136f [vm] Propagate failure to instantiate bogus signature to optimizing compiler.
This is a follow up to change https://dart-review.googlesource.com/c/sdk/+/87500
The regression test is expanded to cover the new case.
Unrelated change: properly recognize TypeRef as function type.

Change-Id: Ibfb4c18825f70433766a1151f087db5fab52a1ca
Reviewed-on: https://dart-review.googlesource.com/c/87704
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2018-12-19 21:47:34 +00:00
Régis Crelier 1a260925ef [vm] Unify CanonicalType and DeclarationType on 'Class' VM class.
CanonicalType is a leftover method/field from the time classes were keeping
track of their own canonical types and is still used for non-generic classes.
DeclarationType is more general and can be used where CanonicalType is used.
The field canonical_type_ is renamed to declaration_type_ and now caches the
DeclarationType.

Change-Id: I585c7bc2d3ae760a4a0e783bc77fb8d8efdbf682
Reviewed-on: https://dart-review.googlesource.com/c/87482
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-12-19 18:46:39 +00:00
Daco Harkes 78fb462332 [vm] documentation of TypeArguments vs arguments
Change-Id: I1bae456f70c79ac7c56c380b106e9ac8c89eaef6
Reviewed-on: https://dart-review.googlesource.com/c/87584
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2018-12-18 17:13:13 +00:00
Vyacheslav Egorov 7840675171 [vm] Fix vm/cc/ICDataTest: use release-store/acquire-load for array of ICData objects.
Previous the test was accessing this array without any synchronization
meaning that stores of new ICData objects into this array could
be observed too early, before ICData object itself is initialized.

Also add release/acquire in the code that attaches ICData map to
the function - to ensure that if compiler thread sees ICData map
then it is guaranteed to be fully initialized.

Closes #34999

Change-Id: I95ba857122e2a5afed90b1518d591282e8255002
Reviewed-on: https://dart-review.googlesource.com/c/87583
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-12-18 16:46:03 +00:00
Martin Kustermann 5054079c7a [VM] Bare instructions - Part 6: Get rid of CODE_REG indirection in CallThroughCode/CallThroughFunction stubs
If the --use-bare-instructions flag is enabled we will:

  * Not load CODE_REG inside CallThroughCode (polymorphic case)

  * Not load CODE_REG inside CallThroughFunction (megamorphic case)

  * Store the EntryPoint of the function in the MegamorphicCache tables
    (instead of a Function pointer)

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

Change-Id: I8aca689dc4e92ece897972da4ae202338527ac62
Reviewed-on: https://dart-review.googlesource.com/c/86928
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-14 16:52:41 +00:00
Martin Kustermann 28f8c96abe [VM] Bare instructions - Part 5: Get rid of CODE_REG indirection in SwitchableCalls
If the --use-bare-instructions flag is enabled we will:

  * Make call sites load the target directly from the pool (instead of
    the code object) - this saves one instruction (and an indirect load)

  * Ensure the object pool will have direct entry addresses by:

     - Letting the clustered snapshot reader change any StubCode::UnlinkedCall()
       in the object pool by it's monomorphic entry
     - Change the code patcher to patch SwitchableCalls by writing the
       monomorphic entry into the pool (instead of the code object)

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

Change-Id: I4e41fc8e4461bde477cc559a6a4fccaaf3a350b5
Reviewed-on: https://dart-review.googlesource.com/c/86160
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-14 16:11:53 +00:00
Martin Kustermann f205292227 [VM] Bare instructions - Part 4: Add --use-bare-instructions flag to AOT compiler & runtime
This is the final CL which adds a new --use-bare-instructions flag to
the VM.

If this flag is set during AOT compilation, we will:

  * Build one global object pool (abbr: GOP) which all code objects
    share. This gop will be stored in the object store.  The PP register
    is populated in the enter dart stub and it is restored when
    returning from native calls.

  * Gets rid of the CODE_REG/PP slots from the dart frames. Instead the
    compiled code uses the global object pool, which is always in PP.

  * Starts emitting pc-relative calls for calls between two dart
    functions or when invoking a stub.
    Limitation: We only emit pc-relative calls between two code objects
    in the same isolate (this is because the image writer is writing
    instruction objects for vm-isolate/main-isolate seperately)

  * We do compile-time relocation of those static calls after the
    precompiler has finished its work, but before writing the snapshot.
    This patches all the instruction objects with pc-relative calls to
    have the right .text distance.

  * We emit a sorted list of code objects in ObjectStore::reverse_code_table,
    which will be used by the AOT runtime to go back from PC to Code
    objects (where all metadata, e.g. stack maps, catch entry moves, pc
    descriptors are available).

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

Change-Id: I6c5dd2b1571e3a889b27e804a24c2986c71e03b6
Reviewed-on: https://dart-review.googlesource.com/c/85769
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-14 16:03:04 +00:00
Régis Crelier cb8c0ab8f5 [vm] Remove MixinAppType VM class and VM code supporting type resolution.
In Dart2, mixin application classes are generated by kernel and type resolution
is performed by kernel. In Dart1, using the VM parser, these tasks were done
during class and type finalization.

Change-Id: I927b1446d906ffd76ed9591c96e0d974df09f3bf
Reviewed-on: https://dart-review.googlesource.com/c/87025
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-12-13 20:18:36 +00:00
Aart Bik ddf3c5ee8c [vm/compiler] proper reason for deopt stub
Rationale:
Reporting check-class instead of the proper unbox
yields an incorrect compiler diagnostic, which may
obscure subsequent debugging.

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

Change-Id: I99358ef3432e77b4432d9a96755747eaadc27067
Reviewed-on: https://dart-review.googlesource.com/c/87161
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2018-12-13 18:35:24 +00:00
Martin Kustermann 2440a32461 [VM] Bare instructions - Part 3: Add support for building a PC -> Code mapping table
This CL adds a [ReversePcLookupCache] which, based on a list of code
objects, builds up a binary searchable table for mapping PCs to Code
objects (where all the metadata is available, like stackmaps, ...).

This CL also adds stack walking support for "bare instruction" frames.

In a later part we will start emitting the sorted list of code objects
(via the new field in the object store) under a flag.

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

Change-Id: I3c06c12bc0fb266dc1bd843a4a11b5208773151d
Reviewed-on: https://dart-review.googlesource.com/c/85746
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-13 17:45:02 +00:00
Ryan Macnak 0b1935ca70 [vm] Remove hash-by-address from the ObjectPool builder.
Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I345be6d3f1d4680bd247225cb714017ac16501ec
Reviewed-on: https://dart-review.googlesource.com/c/85649
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-12-13 01:30:54 +00:00
Régis Crelier 5f36c5f9d8 [vm] Delete BoundedType class in VM.
In Dart2, type bounds checking is either performed by the common front-end or
by explicitly generated code, but not by type finalization or runtime anymore,
as it was done in Dart1.
Consequently, the class BoundedType is not needed anymore, and malbounded or
malformed types are not seen by the runtime either.

Change-Id: I5d6e4c68d153d6730fa7ff7f6d9dcfa611299c16
Reviewed-on: https://dart-review.googlesource.com/c/86687
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2018-12-10 23:15:27 +00:00
Stevie Strickland 40be306fb0 [gardening] Always copy ICData prior to write.
To do this, we create a new Truncate() methods for Arrays, truncate
the ICData array to either 1 (just sentinel) or 2 (SMI + sentinel)
entries in Reset(), and change FindFreeIndex() to instead be
GrowFreeIndex() (which always copies).

Closes #35010.

Change-Id: Ia30f4b490cf9420caef843d7fcde9f461d15a206
Reviewed-on: https://dart-review.googlesource.com/c/86563
Commit-Queue: Stevie Strickland <sstrickl@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-10 17:09:21 +00:00
Samir Jindel 921e62f1bf [vm] Introduce multiple entrypoints to AOT.
Cq-Include-Trybots: luci.dart.try:vm-kernel-win-release-x64-try, vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-win-release-x64-try
Change-Id: I8643033febf9bdc57c8298dca5f43346fb8bf6d1
Reviewed-on: https://dart-review.googlesource.com/c/80304
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-12-07 13:19:24 +00:00
Ryan Macnak 07f43510a2 [vm] Fix some cases of dropped errors and confusion between Exceptions::PropagateError and LongJumpScope::Jump.
Assert against Exceptions::PropagateError skipping over LongJumpScopes and LongJumpScope::Jump skipping over exit frames.

Bug: https://github.com/dart-lang/sdk/issues/35224
Change-Id: I67004a73265882191cb1945cb5a049559b747e89
Reviewed-on: https://dart-review.googlesource.com/c/85411
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-12-05 18:57:02 +00:00
Alexander Markov 9f49b47823 [vm/bytecode] Revise representation of objects and strings in bytecode
This is a major revamp of bytecode metadata format. Now bytecode has
its own serialization mechanisms.

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

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

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

Benchmarks:
GenKernelKernelReadAllBytecode (Intel Core i5) +29.84%
GenKernelKernelReadAllBytecode (Intel Xeon) +28.74%
Change-Id: I4b80009733a8f8c038264af74f97c4e094b9e311
Reviewed-on: https://dart-review.googlesource.com/c/85469
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-12-03 19:08:42 +00:00