Commit Graph

42 Commits

Author SHA1 Message Date
Ryan Macnak 1d05591fbb [vm] Produce clearer error messages when operator new fails.
TEST=bots
Bug: https://github.com/dart-lang/sdk/issues/43642
Bug: https://github.com/dart-lang/sdk/issues/43862
Change-Id: I598a26a56762c141a1aef972f7d32f2c9594b244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171802
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-11-13 19:07:20 +00:00
Alexander Aprelev 9c4a322b08 Reland "[vm/isolates] Introduce fast isolate spawn in AOT."
This reverts commit 922ea3e9b6 in patchset 1, fix for assertion triggered in https://ci.chromium.org/b/8883214567628884960 in patchset 2, fix for deadlock around symbols table mutex in patchset 4.

Original commit description:

Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I655e337198214c9dfacbe76f7852b941b5a7e910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143462
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-17 03:02:27 +00:00
Alexander Aprelev 922ea3e9b6 Revert "Reland "[vm/isolates] Introduce fast isolate spawn in AOT.""
This reverts commit fdd7a2c616 as there
seem to be sporadic dartkp crashes like https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-product-x64/7454

Change-Id: I4218b8ff629630991ad1ff94f217489bb16228d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143383
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-14 20:37:29 +00:00
Alexander Aprelev fdd7a2c616 Reland "[vm/isolates] Introduce fast isolate spawn in AOT."
Original revert in patchset 1, fix for deadlock issue in patchset 2: avoid reentrant calls to RunWithStoppedMutator.
Further review comments addressed in successive patchsets.

This reverts commit 8ef508ba36.

Original commit description:

Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Change-Id: I6a0279d9812020ad7a5c2b7851980b6a29b95b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143327
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-14 18:42:45 +00:00
Alexander Aprelev 8ef508ba36 Revert "[vm/isolates] Introduce fast isolate spawn in AOT."
This reverts commit 61c0960a8b as it broke
vm-kernel-win-release-ia32 buildbot test https://ci.chromium.org/b/8883214567628884960

Change-Id: I6377fd622a3c7d808f46fd9c541c64d343ecc269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143260
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-12 15:59:41 +00:00
Alexander Aprelev 61c0960a8b [vm/isolates] Introduce fast isolate spawn in AOT.
Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I64c86525f4ef9cb30567a49a106bfe700355942b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136780
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-12 14:57:09 +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
Vyacheslav Egorov a9ce969e53 [vm] Decouple growable_array.h and zone.h from thread.h
- Introduce a slimmed down version of thread.h, which just depends on the
Zone and StackResource.
- Introduce a layering check that would prevent the coupling in the future.

This is the first step towards decoupling compiler from runtime.

There are multiple reasons to introduce the decoupling but the main
reason currently is to introduce a controlled surface through which
compiler reaches into runtime to catch any places where runtime word size
might influence the compiler and then enable building compiler that
targets 32-bit runtime but is embedded into a 64-bit runtime.

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

Change-Id: Id63ebbaddca55dd097298e51c90d957a73fa476e
Reviewed-on: https://dart-review.googlesource.com/c/87182
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-11 20:47:10 +00:00
Ryan Macnak 7514ce941e [vm] Assert handles are only allocated when the thread is preventing safepoints.
Threads in the native or blocked states don't prevent safepoints, so they may run concurrently with a safepoint operation like GC. It is not safe for handles to be allocated while the GC is visiting them, so these threads must not allocate handles. Assert only threads in the VM or generated states, which prevent safepoints until they check in, may allocate handles. (Generated code does not allocate handles, but leaf runtime entries remain in the generated state.)

Bug: https://github.com/dart-lang/sdk/issues/34883
Change-Id: I1a211778f7ef96b53a2405f0ee9dde7871b122b6
Reviewed-on: https://dart-review.googlesource.com/c/81540
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-10-31 19:51:52 +00:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Ivan Posva 9c0c6cb5c2 Add product mode:
- Add PRODUCT define and build mode to gyp configurations.
- Add product mode to test harness.
- Start to unify list of flags.
- Allow flags to be constant for particular build configurations.

R=fschneider@google.com

Review URL: https://codereview.chromium.org/1663863002 .
2016-02-03 21:10:30 -08:00
Srdjan Mitrovic caedcce440 Cleanups
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1411403002 .
2015-10-19 14:13:27 -07:00
Srdjan Mitrovic 53e814f0dd Move reusable handles from isolate to thread.
BUG=
R=koda@google.com

Review URL: https://codereview.chromium.org/1394673002 .
2015-10-09 10:10:34 -07:00
Ivan Posva 4bd7cdc75c - Ensure that HandleScope is initialized with a thread. (Remove
deprecated isolate based API.)
- Update all code impacted by this change. E.g. DARTSCOPE
- TEST_CASE now passes the current thread as a parameter to the   unit test.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1310463005 .
2015-09-01 17:18:55 -07:00
Daniel Andersson 3ab5fa1aaa Migrate handle scope fields to Thread.
This enables creating a HandleScope for any thread, and
is another step towards removing BaseIsolate.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1236403004 .
2015-07-16 19:17:30 -07:00
Daniel Andersson 649719278a Assert no VM handles are created in the zone that belongs to a ApiNativeScope.
Update snapshot_test, which was violating this principle.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1191443008.
2015-06-22 17:19:01 -07:00
koda@google.com 99127744c6 Add Zone-based handle allocation interface and reduce use of Isolate-based interfaces.
Remove deprecated Isolate-based BitVector constructor.

R=asiva@google.com

Review URL: https://codereview.chromium.org//868913002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43136 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-26 14:54:02 +00:00
iposva@google.com 043c80e0a9 - Ensure that BaseIsolate is only used to break the header include cycles.
R=asiva@google.com

Review URL: https://codereview.chromium.org//269023005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35770 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 21:45:38 +00:00
asiva@google.com 8c2df33d13 Use a bit in the handle structure to indicate if it is a prologue weak handle instead of the tagging the address.
R=koda@google.com

Review URL: https://codereview.chromium.org//208443002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34258 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-21 17:23:33 +00:00
asiva@google.com e380b175f8 Pass in the isolate parameter to the weak persistent callback handler so that
there is no need to access the current isolate in the callback and delete
path (this code is run while a GC is in progress).

See https://codereview.chromium.org/185643003/ for corresponding changes
in dartium

R=iposva@google.com

Review URL: https://codereview.chromium.org//186003002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33282 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-04 18:11:19 +00:00
asiva@google.com 8e0129970c Use a tag bit for indicating prologue weak persistent handles, this avoids
the costly lookup to determine if a handle is a prologue weak persistent
handle or a regular weak persistent handle in Dart_DeleteWeakPersistentHandle

R=iposva@google.com

Review URL: https://codereview.chromium.org//177093010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33254 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-04 00:35:45 +00:00
jacobr@google.com 605b33c1bc fix cpp11 compile errors
R=asiva@google.com

Review URL: https://codereview.chromium.org//23072026

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26387 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-20 20:24:11 +00:00
asiva@google.com 9e7f76623a Reuse the top ApiLocalScope so that we do not allocate and free an ApiLocalScope
for each Dart_EnterScope/Dart_ExitScope sequence.

The runtime of UseDartApi benchmark on linux ia32 improves from
187316 to 121083.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//19974002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25292 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-22 18:46:14 +00:00
asiva@google.com 8e27430ddd - Create isolate specific resuable handles and use them in the hot lookup paths.
- Create a ResuableHandleScope class which ensures that we do not end up
  recursively reusing handles leading to corruption.

This change shows Dart2JSCompileAll runtime change from 739931 to about
645035 on my local machine.

R=iposva@google.com

Review URL: https://codereview.chromium.org//16174008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24373 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-24 22:41:01 +00:00
asiva@google.com 37c551db05 - Remove the unvisited handles code from handles implementation as it is not
used anywhere
- Added IsFreeListElement to RawObject

R=hausner@google.com

Review URL: https://codereview.chromium.org//15995034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23710 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-06 18:47:51 +00:00
asiva@google.com a02f310d91 Added code to trace zone and handles creation/deletion under flags
--trace-zone and trace-handles
Review URL: https://codereview.chromium.org//11879005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17001 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-12 00:33:16 +00:00
asiva@google.com 4c069867e4 - Make Boolean 'true' and 'false' singleton VM isolate objects.
- Change all uses of it
Review URL: https://codereview.chromium.org//11745022

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16623 260f80e4-7a28-3924-810f-c04153c831b5
2013-01-04 01:52:05 +00:00
asiva@google.com 7ea520f10f Create read only handles for empty_array and sentinel objects
(trying out a basic framework and will extend it to others once this
works).
Review URL: https://codereview.chromium.org//11648006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16416 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-21 02:33:05 +00:00
cshapiro@google.com 49f6f9f36d Merge the Merlin heap tracing to top-of-trunk.
Review URL: https://codereview.chromium.org//11428067

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16199 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-15 19:58:45 +00:00
asiva@google.com d5f055b605 - Create frame work for adding read only handles for symbols in the VM isolate
- Make the symbol corresponding to "." use this frame work and change code
  which was creating a handle to use the read only handle instead.
  (Once we agree on this frame work we could create similar read only handles
   for the frequently used symbols)
Review URL: https://codereview.chromium.org//11469036

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15920 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-10 18:24:34 +00:00
tball@google.com 2cd8436c5a Changed StackZone and ApiZone to be containers for Zone.
BUG=

Review URL: https://codereview.chromium.org//11028145

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13707 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-16 22:05:40 +00:00
iposva@google.com d8f4530942 - Remove redundant assertion.
- Add flag --verify-handles to enable checking when assigning to handles.
Review URL: https://chromiumcodereview.appspot.com//10872043

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11250 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-23 18:55:42 +00:00
asiva@google.com 85ae592bc6 - Use NoHandleScope in leaf methods
- have a no parameter constructor for NoHandleScope so that we can use that
  in optimized mode when the Isolate is not available.
Review URL: https://chromiumcodereview.appspot.com//10579035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8955 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-21 00:02:55 +00:00
turnidge@google.com 5f30febb45 Inline the StackResource constructor/destructor.
This yields a 29% improvement on the Benchmark_UseDartApi microbenchmark.

To do this, I had to split a few fields from Isolate into a
BaseIsolate class.  Sort of yucky.
Review URL: https://chromiumcodereview.appspot.com//10008030

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@6288 260f80e4-7a28-3924-810f-c04153c831b5
2012-04-06 18:00:51 +00:00
cshapiro@google.com 917bbbfc39 Provide API support for weak handles and post-mortem finalization.
In addition, this change separates the storage of weak persistent
handles from ordinary persistent handles.  An ordinary persistent
handle now stores no other data than the raw pointer value.

Review URL: http://codereview.chromium.org//9148051

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3273 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-13 01:23:42 +00:00
asiva@google.com 34a115ad57 - Pass in the isolate parameter when creating handles.
- Store the current isolate pointer in the snapshot reader object and use it instead of calling Isolate::Current() during the deserializing process.
Review URL: http://codereview.chromium.org//9124012

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3160 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-10 18:47:38 +00:00
cshapiro@google.com 32f55ce37b Implement weak persistent handles in the Dart API.
Review URL: http://codereview.chromium.org//8984006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2607 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-20 01:44:53 +00:00
asiva@google.com 4aacd28754 Make the implicit constructor private for zone, handlescope and nohandlescope classes.
Review URL: http://codereview.chromium.org//8562008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1718 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-21 21:07:40 +00:00
asiva@google.com 5cf3ad018a Changes to pass the current isolate to all runtime and native calls.
Review URL: http://codereview.chromium.org//8528010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1499 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-12 05:55:22 +00:00
dgrove@google.com 4c0f559d23 Initial checkin.
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-05 05:20:07 +00:00