Skip to content

Commit 5e77a23

Browse files
mralephCommit Queue
authored andcommitted
[vm] Carry over argdescriptors from vm-isolate
When bootstrapping isolate group copy over immutable list constants from vm-isolate. These are used to represent argdescriptors used in stubs generated into vm-isolate. Copying them over into freshly created isolate group allows us to reuse them instead of creating new ones with the same content. TEST=ci Change-Id: I0c6c89b190868cc8a295041da6c794d322b1788f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/438521 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
1 parent 1e9e0b1 commit 5e77a23

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

runtime/vm/object.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,8 +1808,11 @@ ErrorPtr Object::Init(IsolateGroup* isolate_group,
18081808
SafepointWriteRwLocker ml(thread, isolate_group->program_lock());
18091809

18101810
Class& cls = Class::Handle(zone);
1811+
Class& vm_isolate_cls = Class::Handle(zone);
18111812
Type& type = Type::Handle(zone);
1813+
Object& obj = Object::Handle(zone);
18121814
Array& array = Array::Handle(zone);
1815+
Array& array2 = Array::Handle(zone);
18131816
WeakArray& weak_array = WeakArray::Handle(zone);
18141817
Library& lib = Library::Handle(zone);
18151818
TypeArguments& type_args = TypeArguments::Handle(zone);
@@ -1938,6 +1941,24 @@ ErrorPtr Object::Init(IsolateGroup* isolate_group,
19381941
pending_classes.Add(cls);
19391942

19401943
cls = Class::New<Array, RTN::Array>(kImmutableArrayCid, isolate_group);
1944+
1945+
// Carry over immutable array constants from vm-isolate: vm-isolate contains
1946+
// stubs and those use argument descriptor objects represented as
1947+
// canonical immutable arrays. To avoid duplicating these again prepopulate
1948+
// constants set by copying it over from vm-isolate.
1949+
vm_isolate_cls =
1950+
Dart::vm_isolate_group()->object_store()->immutable_array_class();
1951+
array = vm_isolate_cls.constants();
1952+
if (!array.IsNull()) {
1953+
const auto length = array.Length();
1954+
array2 = Array::New(length, Heap::kOld);
1955+
for (intptr_t i = 0; i < length; i++) {
1956+
obj = array.At(i);
1957+
array2.SetAt(i, obj);
1958+
}
1959+
cls.set_constants(array2);
1960+
}
1961+
19411962
object_store->set_immutable_array_class(cls);
19421963
cls.set_type_arguments_field_offset(Array::type_arguments_offset(),
19431964
RTN::Array::type_arguments_offset());

0 commit comments

Comments
 (0)