Commit Graph

102 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
Ryan Macnak ac4fd50446 [vm, compiler] Check for length overflow when eliminating write barriers for variable-length objects.
Bug: https://github.com/dart-lang/sdk/issues/36778
Change-Id: I03bd00dd5a035309807e16911dcd7602b4de5e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100900
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
2019-04-30 21:36:07 +00:00
Ryan Macnak 971f4845d7 [build] Remove last platform -> vm and bin -> vm dependencies. Fix some ODR violations.
Change some static_libraries to source_sets to make ODR violations link-time errors.

This is needed to enable (stop suppressing) -fvisibility=hidden in Fuchsia product builds.

Change-Id: I699cec8d4b516beab9cebf9db0a522a7ff99e004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99822
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-22 20:15:43 +00:00
Martin Kustermann d445d29fa3 [VM] Define layout of _*ArrayView/_ByteDataView in C+++
This removes the 3 fields from the classes in Dart and instead describes
the layout in C++ via a RawTypedDataView class (as already do with
normal RawTypedData). The existing "semi" TypedDataView handle class is
changed to be a real handle class.

This decreases performance of some microbenchmarks due to field guards
not being used anymore (before the JIT could add a field guard to view classes
guarding that only normal typed data is used as backing store (and not e.g. external
typed data)

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

Change-Id: I7a0022b843a4c0fa69f53dedcc4c7bd2117cdc37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96806
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-15 21:24:15 +00:00
Ryan Macnak 2f25dcda16 [vm] Remove script snapshots.
Change-Id: I5bc692b754c0909de4aa5f05af81b074578b16f4
Reviewed-on: https://dart-review.googlesource.com/76706
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-09-26 22:49:27 +00:00
Ryan Macnak 5993d0e6a2 [vm] Check for NULL finalizers in Dart_PostCObject.
Bug: https://github.com/dart-lang/sdk/issues/33781
Change-Id: I05e36bc3f285dcc6ccb02bc7a171f6bc687dc3c1
Reviewed-on: https://dart-review.googlesource.com/64464
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-07-11 17:16:34 +00:00
Ryan Macnak 7d7e7c268e [vm] Work around interaction between type and instance canonicalization in isolate messages.
Type canonicalization is deferred between in may involve cycles. Instances are canonicalized eagerly, but their type arguments are not necessarily canonical yet, which can lead to incorrect canonicalization of the instance.

The work around is to include the most popular type arguments in the serializer's set of base objects, bypassing deferred canonicalization. Other type arguments will continue to fail.

Bug: https://github.com/dart-lang/sdk/issues/33430
Change-Id: Ia992b3ebc2974b54acb5c88b3e1d836f6ec1f1b8
Reviewed-on: https://dart-review.googlesource.com/61721
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-06-21 23:45:05 +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
Johnni Winther 5b626c2a40 Revert "[vm, isolate] Send large TypedData as ExternalTypedData in isolate messages."
This reverts commit ddafb88794.

Change-Id: I5bf56c82e4f6ad43ab9460220bc17476596a0530
Reviewed-on: https://dart-review.googlesource.com/37760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2018-01-31 10:22:35 +00:00
Ryan Macnak ddafb88794 [vm, isolate] Send large TypedData as ExternalTypedData in isolate messages.
Bug: https://github.com/dart-lang/sdk/issues/31959
Change-Id: I7235d24e29b72bc9849d726b63f0d4c38633e803
Reviewed-on: https://dart-review.googlesource.com/37423
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-01-30 23:48:01 +00:00
Vyacheslav Egorov 08d2841def [VM] Fix deserialization of arrays with type arguments in ApiMessageReader.
A placeholder object must be created and registered via AddBackRef(...) *before*
any inner objects are deserialized otherwise NextAvailableObjectId() might
reuse current object id for an inner object with omitted object id leading
to inconsistent back references state.

Also handle kObjectType in ReadIndexedObject allowing it to deserialize things
like <Object>[...].

This bug was revealed by trying out to run VMService isolate in Kernel mode
with strong mode enabled leading to arrays that had no type arguments have
(inferred) type arguments.

R=kustermann@google.com
BUG=

Review-Url: https://codereview.chromium.org/3003333002 .
2017-08-25 11:51:23 +02: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
Todd Turnidge bbc2ac93a3 Start adding vm/cc tests for rewind functionality.
These will make it easier to debug rewind on simdbc64.

BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2662333002 .
2017-01-31 12:02:26 -08: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
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 89e81a4620 Handle empty string messages in Dart_PostCObject
R=asiva@google.com

Review URL: https://codereview.chromium.org/2278763002 .
2016-08-25 12:39:35 -07:00
Ryan Macnak 4b369f6a0c Remove dead full snapshot support from the recursive descent serializer.
R=asiva@google.com

Review URL: https://codereview.chromium.org/2161853002 .
2016-07-19 17:50:49 -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
Florian Schneider fbdce6a59e VM: Const-correctness fixes.
Three types of fixes:
1. Remove redundant const_cast
2. Remove const_cast by adding const when appropiate.
3. Remove const_cast by removing const (e.g. places where we call free with it)

For now I only fixed places where the fix is local enough - i.e. does not require
changed a large amount of code.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1526123002 .
2015-12-15 19:24:40 +01: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
Siva Annamalai f92f63baa5 1. Do not mark an object by storing the object id used during serialization in the object header.
2. Removed all the GC task locking code which was needed to ensure that a garbage collection was not in progress when writing a message as the message writer was manipulating the object header

3. Use the rawobject => object_id hash map to store and retrieve the object id for an object.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1399663002 .
2015-10-13 15:26:04 -07:00
Siva Annamalai 02c702bf92 1. Write the backing data array of a GrowableObjectArray as a reference
2. Cleanup and refactor WriteObjectRef and WriteObjectInlined and pass as_reference as a parameter to the WriteTo function to allow respective types to deal with it.
3. Added a as_reference parameter to the ReadFrom functions (currently the parameter is not used but the next round of changes will cleanup ReadObjectRef and ReadObjectInlined similarly).

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1388543008 .
2015-10-12 12:45:59 -07: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 e61f1dc8ce 1. Reclaim the CreatedFromSnapshot bit and use the bit to indicate VM heap object.
2. Cleanup calls to set_tags when reading objects from a snapshot.

3. Fixes issue 21816

R=regis@google.com

Review URL: https://codereview.chromium.org//1221503004 .
2015-08-10 11:02:31 -07:00
Siva Annamalai 521dee763c 1. Fix the type arguments recursion problem that gets introduced when canonicalization of type arguments is deferred while reading a script snapshot. This problem was shows up as random stack overflow crashes when running pub
2. Patching of the type arguments field in a GrowableObjectArray was missed

BUG=23930
R=regis@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org//1276753002 .
2015-08-06 10:55:48 -07:00
Todd Turnidge 53dbc3764d Support sending and receiving Capability objects from C code.
BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1267603003 .
2015-07-30 14:07:36 -07:00
Siva Annamalai b0c9f2ef9b Fix for issue 23244
Refactoring of WriteObjectImpl and ReadObjectImpl to enable inlining of canonical objects in the snapshot stream.

BUG=23244
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1260033004 .
2015-07-28 10:52:05 -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 b810ff86f9 Fix build bot error.
BUG=

Review URL: https://codereview.chromium.org//1153853002
2015-05-22 12:59:46 -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
asiva@google.com ca1c3241c4 Fix for issue 21398.
Accept only 'literal-like' objects when sending messages to isolates
spawned using spawnURI. Allow all objects for isolates spawned using
spawnFunction.

R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42793 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-12 23:14:30 +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
zra@google.com c686b2c624 Finishes removing intptr_t from raw object fields.
Also removes {Read,Write}IntptrValue from the snapshot reader and writer.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40048 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-09 19:51:22 +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
fschneider@google.com bd110db87a Use range information for optimizing integer boxing and fix bug in range analysis.
1. When the input to a BoxInteger operation is in smi-range, we can eliminate
the range check and just perform a smi-tag operation on the input.

2. There was a bug in checking for smi-overflow for range boundaries: Calling Smi::IsValid
with a int64_t argument resulted in silent truncation of the input and therefore a wrong result.

Compiling with -Wconversion would have caught this, but currently we cannot compile with this flag
because of too many broken places.

Instead, I removed Smi::IsValid64 and created one variant Smi::IsValid that is specialized for the
input type with a template parameter. This way calling Smi::IsValid is always safe and will never
 result in silent alteration of the input argument.

R=vegorov@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37657 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-24 13:41:48 +00:00
zra@google.com 2ab7fa6c72 Omits size bits when writing RawObject tags to a snapshot.
Makes snapshot ~30KB smaller.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37626 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-23 22:18:04 +00:00
zra@google.com 1dc0e2331b Removes open arrays (e.g. data[0]) from raw objects.
Replaces them with data() methods as in RawArray.

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

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37450 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-18 15:58:16 +00:00
zra@google.com 86ca6ef5a6 Adds an assertion to limit snapshot intptr_t size.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37196 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-10 20:15:49 +00:00
iposva@google.com fd8565b071 - Add a minimal implementation of Capability.
- Make RawReceivePort and SendPort VM internal objects.
- Rationalize the creation of ports and their handling within the VM.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35325 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-23 19:44:03 +00:00
iposva@google.com dd7d6dd375 - Handle doubles transferred in message snapshots specially.
- Do not encode doubles using integer compression.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34681 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-03 00:58:14 +00:00
ajohnsen@google.com a3e5a06a90 Speed up snapshots of *int8lists, by using memmove.
BUG=https://code.google.com/p/dart/issues/detail?id=17951
R=asiva@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34649 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-02 15:53:23 +00:00
regis@google.com 6650adae3b Write the type arguments instantiations field to full snapshots only.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32524 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-10 23:37:06 +00:00
regis@google.com 61ba258618 Fix snapshotting of TypeArguments.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32457 260f80e4-7a28-3924-810f-c04153c831b5
2014-02-07 23:02:54 +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
asiva@google.com 48e5bebfe3 Compute next field offset correctly.
R=iposva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29818 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-04 16:51:48 +00:00
sgjesse@google.com 2f27215203 Remove the reply port form the native isolate handler
The handler function for a native isolate no longer gets an explicit
reply port. Instead the reply port must be sent as part of the message
if required.

The Dart_CObject structure now exposes the send ports in a message to
a native isolate.

R=asiva@google.com, floitsch@google.com, whesse@google.com
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29418 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-29 08:45:32 +00:00