Commit Graph

43 Commits

Author SHA1 Message Date
Samir Jindel e59a4a2b42 [vm/ffi] Call natives through stubs if write-protection is enabled without dual-mapping.
Addresses the Dart -> Native half of dartbug.com/37629

Change-Id: I242b7f3a14dd105334a8b6e5c089b173c398491e
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111280
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-08-07 11:37:20 +00:00
Clement Skau 8cce940579 [API] Makes Dart_InvokeVMServiceMethod errors more specific.
Specifies that the 'isolate' mentioned in the error message is always the
service isolate.
Also adds a specific error message for when the service isolate port isn't
found, which can indicate the service isn't there (yet?).

Change-Id: I1f29b7c4ccf4df2c3dbefafe05f410e4725488e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111426
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-07-31 12:21:24 +00:00
Samir Jindel dd306dd36f [vm/ffi] Remove hacks and instability from FFI GC tests.
This is based on https://dart-review.googlesource.com/c/sdk/+/100583/2,
but instead of relying on private symbols, we expose an API function which
is a no-op outside specific tests.

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

Change-Id: Ieb78caa2d14956a2b5f985533b9b73e941d2d9c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103801
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2019-06-06 15:52:12 +00:00
Alexander Markov e3edfd36b2 [vm/snapshots] Finalize and sort all classes in snapshots with compilation trace
This ensures that core-jit snapshots used in Fuchsia (built according
to the compilation trace) would have properly sorted cids without any
gaps with non-finalized classes. This enables merging of cid ranges in
more cases and more efficient cid checks.

Issue: https://github.com/dart-lang/sdk/issues/36428
Change-Id: I7b696ccb7d5ffa80f190bcfc9e1b7229937f16b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103403
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-05-22 16:01:07 +00:00
Matthew Dempsky a53c12d07a [vm] Use std::unique_ptr with Message
Message is a C++ type with a simple ownership model appropriate for
std::unique_ptr. This CL applies the following changes:

1. All uses of "new Message(...)" are replaced with
"Message::New(...)", which is effectively
"std::make_unique<Message>(...)". (The latter was only added in C++14,
but Dart still compiles in C++11 mode.)

2. All owning Message* are replaced with std::unique_ptr<Message>. The
notable exception is MessageQueue, which still uses raw Message*
internally to simplify the linked list handling.

3. All "delete message;" statements are removed.

4. Uses of "NULL" replaced with "nullptr" as necessary.

Change-Id: I05b5804289f2a225bfa05d3c1631129358fed373
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101222
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
2019-05-06 21:01:39 +00:00
Vyacheslav Egorov 1dd4559271 [vm] Add Native->VM transitions when dereferencing API handles.
For example setting return value unwraps handles and stores
raw pointer values to the stack which might race with GC
in another thread.

This CL adds assertions in helper methods from Api class which
unwrap API handles and fixes all places that were revealed by
those assertions.

Caveat: we still permit to check whether handle contains
Smi or not without entering VM state - because GC does not
change this property.

Bug: b/127482366
Change-Id: I59f08c2a91935995514fb70607c2777aa2844d94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95654
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-03-08 00:06:37 +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
Ryan Macnak 235a918233 [vm] Remove Dart_LoadScript, Dart_LoadLibrary, Dart_LoadSource, etc.
Change-Id: I9c19625702f1df48c03de2eb3a0f7bb581d2e0b3
Reviewed-on: https://dart-review.googlesource.com/c/79140
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-10-11 00:38:37 +00:00
Zach Anderson dba8b37d38 [vm] Benchmark for reading kernel bytecode
Change-Id: I07617a553193495fcc4fc0ce4a6382996ee7dc51
Reviewed-on: https://dart-review.googlesource.com/75821
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-09-24 15:54:49 +00:00
Martin Kustermann 4becf1aec3 [VM] Fix windows build after landing new navie embedder API
Change-Id: Ie726abe8038b873761e2f9f25de67a51c7c933fa
Reviewed-on: https://dart-review.googlesource.com/66564
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-07-25 12:34:59 +00:00
Martin Kustermann 33914226f2 [VM] Add Dart_InvokeVMServiceMethod() to dart_tools_api.h
This will allow any embedder to use a C++ API to talk to the vm-service.
Usecase is e.g. trigger a hot-reload without speaking websocket.

Change-Id: Ia54e5a73a0f0a4899e3e6d60694af0b394efb993
Reviewed-on: https://dart-review.googlesource.com/66384
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-07-25 12:06:55 +00:00
Ryan Macnak ebdc8abaae [vm, service] Avoid double TLS creating timeline events for API functions.
Add timeline events for Dart_CompileAll and Dart_ParseAll.

Change-Id: I184319aadfe18a6e51cb44c2ab77fb95f452f6de
Reviewed-on: https://dart-review.googlesource.com/43242
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-02-23 01:31:38 +00:00
Ryan Macnak 3f40488ec4 [vm, isolate] Refactor isolate message snapshotting to centralize construction of the Message.
Remove unused special case in ApiMessageWriter for lists of int.

This is in preparation for ensuring we always free any external data that ends up in an isolate message.

Bug: https://github.com/dart-lang/sdk/issues/31959
Change-Id: I999656fc11d2aee9aebe70852be5bb075f234b4d
Reviewed-on: https://dart-review.googlesource.com/41020
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-02-14 00:28:01 +00:00
Ryan Macnak 958a4ebdc8 Misc missing API errors for AOT runtime.
Change-Id: I5742bd1600fcb6b22351fdfc6bb38139dc007352
Reviewed-on: https://dart-review.googlesource.com/26421
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-12-07 17:49:39 +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
Vyacheslav Egorov 9bae50bf47 VM: [Kernel] Revert changes to the native ports that introduced peers.
The problem with these changes was that closed ports still continue to receive
messages and as a result we start using dead peer objects.

Fixing that would require more intrusive changes into message handler implementation - so instead we are reverting the changes and restoring manual PORT -> PEER mapping.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2666063002 .
2017-01-31 10:30:15 +01:00
Vyacheslav Egorov 43a0500e37 VM: [Kernel] Fix bootstraping when Kernel isolate is used.
We must bootstrap from Kernel instead of Source when running with --dfe

BUG=
R=asiva@google.com, kustermann@google.com

Review-Url: https://codereview.chromium.org/2651633002 .
2017-01-30 20:52:59 +01:00
Ryan Macnak cbf3eaeb90 Fix various memory leaks in unit tests detected by a new version of ASAN.
R=zra@google.com

Review-Url: https://codereview.chromium.org/2620413002 .
2017-01-11 11:12:40 -08: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
Siva Annamalai 12f86594ec Add --parse-all option in order to benchmark and measure the scanner/parser performance.
R=hausner@google.com

Review URL: https://codereview.chromium.org/2327693002 .
2016-09-23 15:20:39 -07:00
Todd Turnidge f8ff7bd5c4 Delete NativeMessageHandler once a native port closes.
Closes #27002

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2217693002 .
2016-08-04 15:34:24 -07:00
John McCutchan 757b7d094c Revert "Fix NativeMessageHandler leak"
This reverts commit 425efb9808.

BUG=

Review URL: https://codereview.chromium.org/2207663002 .
2016-08-02 11:33:12 -07:00
John McCutchan 425efb9808 Fix NativeMessageHandler leak
Fixes #27002

R=zra@google.com

Review URL: https://codereview.chromium.org/2200903002 .
2016-08-02 11:08:18 -07:00
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

The ThreadRegistry class now contains only the thread list for an isolate and the functionality of scheduling a thread onto an Isolate and unscheduling it from teh isolate. We could fold this functionality into the Isolate class in a different CL.

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

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
Zachary Anderson ad0e9622e9 Fix build
TBR

Review URL: https://codereview.chromium.org/1519333002 .
2015-12-11 19:45:17 -08:00
Zachary Anderson a0970835f0 Adds a special case for sending an int over a port with the native API.
This improves dart <=> C++ IPC round-trip-times for Mojo by 10-20%.

BUG=

Review URL: https://codereview.chromium.org/1499853004 .
2015-12-11 16:07:16 -08:00
Siva Annamalai 01b69ebabc Move ApiLocalScope out of class ApiState into class Thread so that the API local handles and zone etc. are thread specific instead of being Isolate specific.
R=zra@google.com

Review URL: https://codereview.chromium.org/1473403003 .
2015-11-25 11:07:22 -08:00
Siva Annamalai 9e19d236ca - Add an OSThread structure which is the generic TLS structure for all C++
fields in a thread (i.e fields that are not Dart VM related)
- Split the Thread structure to be a pure Dart per thread structure and add
  a pointer to os_thread which points to the OSThread structure
- Change Schedule/UnSchedule to set the Dart Thread structure as the TLS of
  the thread when it is inside the Dart world and reset the TLS back to the
  OSThread strcuture when is exits the Dart World.
- Moved the stack_base and few stack size related functions to OSThread from Isolate

R=johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1439483003 .
2015-11-19 13:45:10 -08:00
Srdjan Mitrovic 465cf10a7c Remove some Isolate::current_zone() calls, as it gets the zone from mutator thread not the current thread
BUG=
R=zra@google.com

Review URL: https://codereview.chromium.org/1414493003 .
2015-10-19 10:27:36 -07:00
Srdjan Mitrovic ab20fa00da Move no_callback_scope_depth_ and cha_ from isolate -> thread
Add checks for background compilation:
- Dart code may not be invoked
- Object allocation must happen in old space

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1401413002 .
2015-10-13 14:29:43 -07:00
Srdjan Mitrovic 8d618766a8 Remove isolate argument from handle allocation: Part II
BUG=
R=regis@google.com

Review URL: https://codereview.chromium.org/1389353004 .
2015-10-12 14:06:50 -07:00
Ryan Macnak 0ed4d44a99 Toward precompiled snapshots.
Gets as far as encountering null Instructions in the first Dart_Invoke after loading the snapshot.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1318803002 .
2015-09-02 16:15:02 -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
Ryan Macnak 8a3e134502 Non-tree-shaking --precompile.
R=srdjan@google.com

Review URL: https://codereview.chromium.org//1261673004 .
2015-07-30 15:29:19 -07:00
John McCutchan 51d8bae199 Revert "Hide Isolate pointer from embedder"
This reverts commit 014e694ba7.

Revert "Fix fall out from hide isolate pointer change"

This reverts commit 966aafbc81.

Revert "Fix build"

This reverts commit d7b03ba7b0.

BUG=

Review URL: https://codereview.chromium.org//1140263005
2015-05-19 11:41:42 -07:00
John McCutchan 014e694ba7 Hide Isolate pointer from embedder
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1130753006
2015-05-18 14:06:10 -07:00
koda@google.com f4419287aa Prepares for multiple threads by further decoupling Thread from Isolate.
- Replace Isolate::SetCurrent with more explicit Thread::Enter/ExitIsolate.
- Lazily initialize Thread instances when entering an isolate, to avoid new API calls for embedders.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44835 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-01 17:48:11 +00:00
asiva@google.com 97b903c665 Fix for issue 19817
- do not try to finalize classes on every Dart API call which could
  potentially result in calls to dart code
- Invoke Dart_FinalizeLoading after all loads are done to ensure that
  classes are finalized

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38471 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-22 20:08:15 +00:00
iposva@google.com 9f6006f8c8 Fix dartbug.com/19998
- Do not attempt to interact with files if hooks are not installed.
- Remove obsolete code observers.
- Remove obsolete API functions.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38226 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-15 09:14:40 +00:00
iposva@google.com 781f737c6a First round of http://dartbug.com/15922:
- Address warnings about 64-bit to 32-bit conversions.
- Remove heap profiler.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31867 260f80e4-7a28-3924-810f-c04153c831b5
2014-01-16 05:05:35 +00:00
iposva@google.com 1e8061f060 - Remove the reply_port from the VM internal message object.
- Adjust all the uses of this API.

R=johnmccutchan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31205 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-17 21:11:18 +00:00
srdjan@google.com 2b9fad92c7 In preparation of inlining remainder and modulo binary Smi operations:
- Add REM token
- Fix checking of function fingerprints.
- Remove unused intrinsic for remainder (the function gets inlined and intrinsic is not generated)

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29929 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-05 19:27:46 +00:00
asiva@google.com 51651ee00b Split dart_api.h into multiple parts:
dart_api.h - Has the core API functions
dart_mirrors_api.h - Has API functions to support Mirrors or reflection
dart_native_api.h - Has parts which support the native message handling,
                    profilling and other internal tools

R=sgjesse@google.com, vsm@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24062 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-14 23:47:40 +00:00