Commit graph

39 commits

Author SHA1 Message Date
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
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
Ryan Macnak afdbce7b13 [vm, isolate] Send large TypedData as ExternalTypedData in isolate messages.
Be careful to free external data when reading or writing a message is interrupted, or releasing messaging without reading on shutdown.

Bug: https://github.com/dart-lang/sdk/issues/31959
Change-Id: Ia39acb9ca0e27cf9e8b83961741e5949b5930266
Reviewed-on: https://dart-review.googlesource.com/41561
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-02-21 18:57:14 +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
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
Ryan Macnak 2ec03cba70 Fix leak of message snapshot buffer when attempting to send an illegal object.
Fix leak with FLAG_enable_debug_break.

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

Review-Url: https://codereview.chromium.org/2629533002 .
2017-01-11 16:50:04 -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
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
Ryan Macnak 1e8fdaee68 Support for taking full snapshots from 'dart', not just 'dart_bootstrap'.
- Don't create rival copies of the predefined symbols in isolates in dart_bootstrap.
 - Don't do work to save these rival copies during symbol table compaction.
 - Create unified symbol table just before writing the vm isolate.
 - Create unified list of scripts to include in the vm isolate.
 - Ignore object ids of the old vm isolate when writing a new one.
 - Ensure token stream private keys are hashed.
 - Use the type of isolate we are writing instead of an object's current isolate to decide if vm isolate objects are written symbolically.

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org/1944213002 .
2016-05-10 10:13:33 -07:00
Zachary Anderson fa8a0613a3 Fold ApiObjectConverter use into ApiMessageReader
TODO from change on Friday.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1523013002 .
2015-12-14 11:12:25 -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 810823f8d5 Use the zone in ApiNativeScope for allocating objects in the ApiMessageReader instead of passing in an allocator.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1319583003 .
2015-08-25 14:48:41 -07:00
Siva Annamalai 969005dfe6 Fix for issue 23834 (https://github.com/dart-lang/sdk/issues/23834)
Script snapshots do not use VM isolate object indexes and hence we should not be accounting for max_vm_isolate_object_id.

This is related to the fix done in https://github.com/dart-lang/sdk/issues/23647

BUG=23834
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1234803008 .
2015-07-15 16:56:13 -07:00
Siva Annamalai 5e0a3d66e5 Move bootstrap scripts and token streams to the VM isolate so that they become read only objects. This reduces the per isolate heap size as follows:
Before the change:
Size of isolate snapshot = 780799
New space (0k of 1024k) Old space (758k of 1024k)

After the change:
Size of isolate snapshot = 279696
New space (0k of 1024k) Old space (602k of 1024k)

BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1151113002
2015-05-22 12:48:11 -07:00
asiva@google.com 05d7eb5dfa Move symbol table from per isolate snapshot to vm isolate snapshot, this reduces the per isolate initial heap size
from New space (0k of 1024k) Old space (1274k of 1536k)
to New space (0k of 1024k) Old space (756k of 1280k)

R=hausner@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45795 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-14 20:14:37 +00:00
srdjan@google.com 5ef243e688 Make sure Bigint._digits is always a Uint32List and bever null. Adapt type information for get:_digits.
R=regis@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40463 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-18 21:18:25 +00:00
regis@google.com 0220e41d72 New bigint implementation in the vm.
R=srdjan@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40061 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-09 21:47:44 +00:00
koda@google.com c645b0ab71 Object ids in snapshots are assigned sequentially, and can in many cases be omitted by the writer and inferred by the reader. The exceptions are the classes that are serialized in two steps (arrays and user-level Dart instances), where the second step must include the id.
For standalone, makes full snapshot 5% smaller, and startup ~1.5% faster when measured on a Nexus 10.

R=zra@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38261 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-15 21:47:00 +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
iposva@google.com 1836035266 - Modify dart_api.h to be a proper C API.
- Verify that dart_api.h can be used from C
  by changing the test_extension to be a pure C file.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23476 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-31 16:36:27 +00:00
sgjesse@google.com 6507357ca0 Add support for more typed data types on native ports
Renamed the kUint8Array type for a Dart_CObject structure to
kByteArray to support all typed data types. The specific type is
stored in a separate type field. No matter what the specific type is,
the length of the byte array is always in bytes.

R=ager@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21423 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 09:01:56 +00:00
sgjesse@google.com 52f54a2edd Add support for typed data views on native threads
The deserializer running outside the VM can now decode typed data
views. As the typed data views are implemented as normal Dart
instances and not a internal VM object the deserializer have been
expanded to process serialized objects of the type used to create
these views. The typed data object that the view is based on will
always be serialized as part of the message.

Currently only vews created with constructor Uint8List.view on top of
an Uint8List are supported.

R=ager@google.com

BUG=https://code.google.com/p/dart/issues/detail?id=9484

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21252 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 07:15:08 +00:00
asiva@google.com 01cc7d3cd2 - Canonicalize types, type_arguments only when the object is marked as being from the core libraries.
- adjust the snapshot write buffer growth policy
- turn off the heap growth rate adjustments when reading from a snapshot.
Review URL: https://codereview.chromium.org//12578009

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20423 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-22 22:43:46 +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
sgjesse@google.com d1076bd12b Deserialize same symbol as same Dart_CObject
When symbols are deserialized as part of a Dart_CObject the same
symbols are now turned into the same Dart_CObject objects.

R=ager@google.com

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15082 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-19 14:02:25 +00:00
sgjesse@google.com cde0bb06dd Add support for non ASCII strings when communicating with native ports
The string representation in a Dart_CObject strructure is now
UTF8. All strings read are now converted to UTF8 from either ASCII or
UTF16 serialization. All strings posted should be valid UTF8 and are
serialized as either ASCII or UTF16 depending on the content.

Proper andling of surrogate pairs is missing, but will be added when
https://codereview.chromium.org/11368138/ lands.

R=ager@google.com, erikcorry@google.com, asiva@google.com

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14887 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-14 13:01:57 +00:00
sgjesse@google.com b84841874d Support receiving GrowableObjectArray on native ports
Array literals are created as GrowableObjectArrays internally.

A GrowableObjectArray holds a length and a backing store. The backing
store is an array. When receiving a GrowableObjectArray an object is
created for holding the GrowableObjectArray. The the backing store has
been read the object holding the GrowableObjectArray is transformed
into an array with its content from the backing store.

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

BUG=dart:4993
TEST=runtime/vm/snapshot_test.cc/DartGeneratedArrayLiteralMessagesWithBackref,
     runtime/vm/snapshot_test.cc/DartGeneratedArrayLiteralMessages

Review URL: https://chromiumcodereview.appspot.com//10916207

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12197 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-11 14:37:07 +00:00
asiva@google.com b053301ccf Fix for issue 1204.
Do not allocate a buffer of 64KB by default when writing a message out. Start
with a much smaller buffer. FOr script and full snapshots the buffer
allocated remains 64 KB.
Review URL: https://chromiumcodereview.appspot.com//10908185

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12153 260f80e4-7a28-3924-810f-c04153c831b5
2012-09-11 02:06:59 +00:00
turnidge@google.com bd995a345e Avoid trusting the length encoded in the Snapshot if there is an
external length available.  We now pass a length with all messages in
the vm and verify that there is no mismatch with the length from the
Snapshot.

Fixed a bug in the use of ApiMessageReader.  We were always manually
adding Snapshot::kHeaderSize to the data, but neglecting to subtract
kHeaderSize from the message length.

Added FullSnapshotWriter and MessageWriter classes.
Review URL: https://chromiumcodereview.appspot.com//10829444

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11413 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-27 20:25:44 +00:00
asiva@google.com 05f310b207 Do not try to serialize VM objects, these are read only canonical objects and should be referred to using ids.
Turn VM symbols back on.
Review URL: https://chromiumcodereview.appspot.com//10834069

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10310 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-06 21:56:39 +00:00
iposva@google.com 5a05319599 - Avoid doubling 0 when trying to determine a new size for the
ApiMessageWriter forwarding list. 
- Use matching allocation calls in ApiMessageWriter.
- Sort list of source files.
Review URL: https://chromiumcodereview.appspot.com//10557043

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8817 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-18 20:01:28 +00:00
asiva@google.com c078663643 1. Remove recursion during snapshot writing and reading
2. set thread stack size to 128k
3. Fix the native message handler to ensure that it works with the new model of not recursively inlining objects.
Review URL: https://chromiumcodereview.appspot.com//10535066

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8517 260f80e4-7a28-3924-810f-c04153c831b5
2012-06-11 21:39:05 +00:00
ager@google.com 4a698f9fb3 Start 'fuzzing' of dart:io APIs and fix first issue found.
Deserialize unsupported Dart objects to Dart_CObject of type
kUnsupported instead of NULL pointers. That way the normal
Dart_CObject validation that tests for supported types will
work out of the box and not crash the VM.

R=sgjesse@google.com
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//10383179

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7645 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-15 10:40:44 +00:00
cshapiro@google.com 1472427af8 Revert "Revert "Implement {Int,Uint}{8,16,32,64} and Float{32,64} typed arrays.""
This reverts commit 63480a81fccbde001494dd535cd06a8fa02ed261.

Review URL: https://chromiumcodereview.appspot.com//10379018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7352 260f80e4-7a28-3924-810f-c04153c831b5
2012-05-04 23:16:09 +00:00
sgjesse@google.com 6512d83d74 Move MessageWriter from snapshot files to dart_api_message files
Also renamed MessageWriter to ApiMessageWriter

R=asiva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9407010

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4375 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-18 10:10:28 +00:00
sgjesse@google.com ff0a266e7e Add support for big integers to the native message format
Also fixed snapshotting of negative big integers.

R=asiva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9363023

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4078 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-09 14:09:03 +00:00
sgjesse@google.com 61b3c7435c Add support for medium integers to the native message format
R=asiva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9348048

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4073 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-09 10:21:38 +00:00
sgjesse@google.com ff3c5e88f1 Add support for byte arrays to native messages
R=asiva@google.com

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9348019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4071 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-09 09:34:31 +00:00
sgjesse@google.com 3481c5661a Decode the Dart message into a Dart_CMessage structure before calling the native port callback
The native port callback is now passed the message as a decodes
Dart_CMessage structure. The Dart_CMessage structure is allocated
in a zone and the callback receiving it should expect the
lifetime to be controlled by the caller.

Added support for zones which do not require a current
isolate. Changed the GrowableArray to support allocating in
aprovided zone instead of the zone for the current isolate.

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

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com//9325022

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4068 260f80e4-7a28-3924-810f-c04153c831b5
2012-02-09 08:47:19 +00:00