Skip to content

Commit 0f76981

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[vm/concurrency] Change references to class_table/object_store/heap from Isolate to IsolateGroup
As part of making the compiler and other subsystems independent of `Isolate` we have to move various state from `Isolate` to `IsolateGroup`. The class_table and object_store were already moved to `IsolateGroup`. This CL only replaces usages of `Isolate::{object_store,class_table}` with the equivalent in `IsolateGroup`. Issue #36097 TEST=Pure refactoring - relying on existing test coverage. Change-Id: I34a0682d715b054d6c5faff077a513980f59a348 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177126 Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 80c307f commit 0f76981

File tree

117 files changed

+1476
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1476
-1433
lines changed

runtime/lib/ffi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ DEFINE_NATIVE_ENTRY(Ffi_asExternalTypedData, 0, 2) {
222222
}
223223

224224
const auto& typed_data_class =
225-
Class::Handle(zone, isolate->class_table()->At(cid));
225+
Class::Handle(zone, isolate->group()->class_table()->At(cid));
226226
const auto& error =
227227
Error::Handle(zone, typed_data_class.EnsureIsAllocateFinalized(thread));
228228
if (!error.IsNull()) {

runtime/lib/isolate.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static ObjectPtr ValidateMessageObject(Zone* zone,
163163
if (!obj.raw()->IsHeapObject() || obj.raw()->ptr()->IsCanonical()) {
164164
return obj.raw();
165165
}
166-
ClassTable* class_table = isolate->class_table();
166+
ClassTable* class_table = isolate->group()->class_table();
167167

168168
Class& klass = Class::Handle(zone);
169169
Closure& closure = Closure::Handle(zone);
@@ -457,7 +457,7 @@ IsolateSpawnState::~IsolateSpawnState() {
457457

458458
ObjectPtr IsolateSpawnState::ResolveFunction() {
459459
Thread* thread = Thread::Current();
460-
Isolate* I = thread->isolate();
460+
auto IG = thread->isolate_group();
461461
Zone* zone = thread->zone();
462462

463463
const String& func_name = String::Handle(zone, String::New(function_name()));
@@ -466,7 +466,7 @@ ObjectPtr IsolateSpawnState::ResolveFunction() {
466466
// Handle spawnUri lookup rules.
467467
// Check whether the root library defines a main function.
468468
const Library& lib =
469-
Library::Handle(zone, I->object_store()->root_library());
469+
Library::Handle(zone, IG->object_store()->root_library());
470470
Function& func = Function::Handle(zone, lib.LookupLocalFunction(func_name));
471471
if (func.IsNull()) {
472472
// Check whether main is reexported from the root library.
@@ -934,7 +934,7 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 0, 12) {
934934

935935
// Canonicalize the uri with respect to the current isolate.
936936
const Library& root_lib =
937-
Library::Handle(isolate->object_store()->root_library());
937+
Library::Handle(isolate->group()->object_store()->root_library());
938938
char* error = NULL;
939939
const char* canonical_uri = CanonicalizeUri(thread, root_lib, uri, &error);
940940
if (canonical_uri == NULL) {
@@ -988,7 +988,7 @@ DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0, 0) {
988988

989989
DEFINE_NATIVE_ENTRY(Isolate_getCurrentRootUriStr, 0, 0) {
990990
const Library& root_lib =
991-
Library::Handle(zone, isolate->object_store()->root_library());
991+
Library::Handle(zone, isolate->group()->object_store()->root_library());
992992
return root_lib.url();
993993
}
994994

@@ -1071,8 +1071,8 @@ DEFINE_NATIVE_ENTRY(TransferableTypedData_factory, 0, 2) {
10711071

10721072
uint8_t* data = reinterpret_cast<uint8_t*>(::malloc(total_bytes));
10731073
if (data == nullptr) {
1074-
const Instance& exception =
1075-
Instance::Handle(thread->isolate()->object_store()->out_of_memory());
1074+
const Instance& exception = Instance::Handle(
1075+
thread->isolate_group()->object_store()->out_of_memory());
10761076
Exceptions::Throw(thread, exception);
10771077
UNREACHABLE();
10781078
}
@@ -1122,7 +1122,7 @@ DEFINE_NATIVE_ENTRY(TransferableTypedData_materialize, 0, 1) {
11221122
const ExternalTypedData& typed_data = ExternalTypedData::Handle(
11231123
ExternalTypedData::New(kExternalTypedDataUint8ArrayCid, data, length,
11241124
thread->heap()->SpaceForExternal(length)));
1125-
FinalizablePersistentHandle::New(thread->isolate(), typed_data,
1125+
FinalizablePersistentHandle::New(thread->isolate_group(), typed_data,
11261126
/* peer= */ data,
11271127
&ExternalTypedDataFinalizer, length,
11281128
/*auto_delete=*/true);

runtime/lib/mirrors.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ static InstancePtr CreateIsolateMirror() {
585585
Thread* thread = Thread::Current();
586586
Isolate* isolate = thread->isolate();
587587
const String& debug_name = String::Handle(String::New(isolate->name()));
588-
const Library& root_library =
589-
Library::Handle(thread->zone(), isolate->object_store()->root_library());
588+
const Library& root_library = Library::Handle(
589+
thread->zone(), isolate->group()->object_store()->root_library());
590590
const Instance& root_library_mirror =
591591
Instance::Handle(CreateLibraryMirror(thread, root_library));
592592

@@ -649,8 +649,8 @@ static AbstractTypePtr InstantiateType(const AbstractType& type,
649649
}
650650

651651
DEFINE_NATIVE_ENTRY(MirrorSystem_libraries, 0, 0) {
652-
const GrowableObjectArray& libraries =
653-
GrowableObjectArray::Handle(zone, isolate->object_store()->libraries());
652+
const GrowableObjectArray& libraries = GrowableObjectArray::Handle(
653+
zone, isolate->group()->object_store()->libraries());
654654

655655
const intptr_t num_libraries = libraries.Length();
656656
const GrowableObjectArray& library_mirrors = GrowableObjectArray::Handle(
@@ -696,11 +696,11 @@ DEFINE_NATIVE_ENTRY(IsolateMirror_loadUri, 0, 1) {
696696
} else {
697697
isolate->BlockClassFinalization();
698698
const Object& result = Object::Handle(
699-
zone,
700-
isolate->CallTagHandler(
701-
Dart_kCanonicalizeUrl,
702-
Library::Handle(zone, isolate->object_store()->root_library()),
703-
uri));
699+
zone, isolate->CallTagHandler(
700+
Dart_kCanonicalizeUrl,
701+
Library::Handle(
702+
zone, isolate->group()->object_store()->root_library()),
703+
uri));
704704
isolate->UnblockClassFinalization();
705705
if (result.IsError()) {
706706
if (result.IsLanguageError()) {
@@ -726,7 +726,8 @@ DEFINE_NATIVE_ENTRY(IsolateMirror_loadUri, 0, 1) {
726726
Object& result = Object::Handle(
727727
zone, isolate->CallTagHandler(
728728
Dart_kImportTag,
729-
Library::Handle(zone, isolate->object_store()->root_library()),
729+
Library::Handle(
730+
zone, isolate->group()->object_store()->root_library()),
730731
canonical_uri));
731732
isolate->UnblockClassFinalization();
732733
if (result.IsError()) {
@@ -1289,8 +1290,8 @@ DEFINE_NATIVE_ENTRY(ClosureMirror_function, 0, 1) {
12891290
// The 'instantiator' created below should not be a type, but two type
12901291
// argument vectors: instantiator_type_arguments and
12911292
// function_type_arguments.
1292-
const Class& cls =
1293-
Class::Handle(Isolate::Current()->object_store()->object_class());
1293+
const Class& cls = Class::Handle(
1294+
IsolateGroup::Current()->object_store()->object_class());
12941295
instantiator = Type::New(cls, arguments, TokenPosition::kNoSource);
12951296
instantiator.SetIsFinalized();
12961297
}

runtime/lib/object.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ DEFINE_NATIVE_ENTRY(Object_getHash, 0, 1) {
4040
#if defined(HASH_IN_OBJECT_HEADER)
4141
return Smi::New(Object::GetCachedHash(arguments->NativeArgAt(0)));
4242
#else
43-
Heap* heap = isolate->heap();
43+
Heap* heap = isolate->group()->heap();
4444
ASSERT(arguments->NativeArgAt(0)->IsDartInstance());
4545
return Smi::New(heap->GetHash(arguments->NativeArgAt(0)));
4646
#endif
@@ -53,7 +53,7 @@ DEFINE_NATIVE_ENTRY(Object_setHash, 0, 2) {
5353
#else
5454
const Instance& instance =
5555
Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
56-
Heap* heap = isolate->heap();
56+
Heap* heap = isolate->group()->heap();
5757
heap->SetHash(instance.raw(), hash.Value());
5858
#endif
5959
return Object::null();
@@ -221,7 +221,8 @@ DEFINE_NATIVE_ENTRY(LibraryPrefix_loadingUnit, 0, 1) {
221221

222222
DEFINE_NATIVE_ENTRY(LibraryPrefix_issueLoad, 0, 1) {
223223
const Smi& id = Smi::CheckedHandle(zone, arguments->NativeArgAt(0));
224-
Array& units = Array::Handle(zone, isolate->object_store()->loading_units());
224+
Array& units =
225+
Array::Handle(zone, isolate->group()->object_store()->loading_units());
225226
if (units.IsNull()) {
226227
// Not actually split.
227228
const Library& lib = Library::Handle(zone, Library::CoreLibrary());
@@ -259,7 +260,7 @@ DEFINE_NATIVE_ENTRY(Internal_reachabilityFence, 0, 1) {
259260
}
260261

261262
DEFINE_NATIVE_ENTRY(Internal_collectAllGarbage, 0, 0) {
262-
isolate->heap()->CollectAllGarbage();
263+
isolate->group()->heap()->CollectAllGarbage();
263264
return Object::null();
264265
}
265266

runtime/lib/string.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ DEFINE_NATIVE_ENTRY(OneByteString_splitWithCharCode, 0, 2) {
282282
Heap::kNew);
283283
result.Add(str);
284284
result.SetTypeArguments(TypeArguments::Handle(
285-
zone, isolate->object_store()->type_argument_string()));
285+
zone, isolate->group()->object_store()->type_argument_string()));
286286
return result.raw();
287287
}
288288

@@ -292,8 +292,8 @@ DEFINE_NATIVE_ENTRY(Internal_allocateOneByteString, 0, 1) {
292292
if ((length < 0) || (length > OneByteString::kMaxElements)) {
293293
// Assume that negative lengths are the result of wrapping in code in
294294
// string_patch.dart.
295-
const Instance& exception =
296-
Instance::Handle(thread->isolate()->object_store()->out_of_memory());
295+
const Instance& exception = Instance::Handle(
296+
thread->isolate_group()->object_store()->out_of_memory());
297297
Exceptions::Throw(thread, exception);
298298
UNREACHABLE();
299299
}
@@ -306,8 +306,8 @@ DEFINE_NATIVE_ENTRY(Internal_allocateTwoByteString, 0, 1) {
306306
if ((length < 0) || (length > TwoByteString::kMaxElements)) {
307307
// Assume that negative lengths are the result of wrapping in code in
308308
// string_patch.dart.
309-
const Instance& exception =
310-
Instance::Handle(thread->isolate()->object_store()->out_of_memory());
309+
const Instance& exception = Instance::Handle(
310+
thread->isolate_group()->object_store()->out_of_memory());
311311
Exceptions::Throw(thread, exception);
312312
UNREACHABLE();
313313
}

runtime/vm/bootstrap.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void Finish(Thread* thread) {
4848
// Eagerly compile the _Closure class as it is the class of all closure
4949
// instances. This allows us to just finalize function types without going
5050
// through the hoops of trying to compile their scope class.
51-
ObjectStore* object_store = thread->isolate()->object_store();
51+
ObjectStore* object_store = thread->isolate_group()->object_store();
5252
Zone* zone = thread->zone();
5353
Class& cls = Class::Handle(zone, object_store->closure_class());
5454
cls.EnsureIsFinalized(thread);
@@ -111,7 +111,6 @@ static ErrorPtr BootstrapFromKernel(Thread* thread,
111111
if (setjmp(*jump.Set()) == 0) {
112112
kernel::KernelLoader loader(program.get(), /*uri_to_source_table=*/nullptr);
113113

114-
auto isolate = thread->isolate();
115114
auto isolate_group = thread->isolate_group();
116115

117116
if (isolate_group->obfuscate()) {
@@ -122,7 +121,7 @@ static ErrorPtr BootstrapFromKernel(Thread* thread,
122121
Library& library = Library::Handle(zone);
123122
for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) {
124123
ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
125-
library = isolate->object_store()->bootstrap_library(id);
124+
library = isolate_group->object_store()->bootstrap_library(id);
126125
loader.LoadLibrary(library);
127126
}
128127

@@ -141,7 +140,7 @@ static ErrorPtr BootstrapFromKernel(Thread* thread,
141140
const auto& dart_builtin =
142141
String::Handle(zone, String::New("dart:_builtin"));
143142
library = Library::LookupLibrary(thread, dart_builtin);
144-
isolate->object_store()->set_builtin_library(library);
143+
isolate_group->object_store()->set_builtin_library(library);
145144

146145
if (FLAG_precompiled_mode) {
147146
loader.ReadLoadingUnits();
@@ -158,7 +157,7 @@ static ErrorPtr BootstrapFromKernel(Thread* thread,
158157
ErrorPtr Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer,
159158
intptr_t kernel_buffer_size) {
160159
Thread* thread = Thread::Current();
161-
Isolate* isolate = thread->isolate();
160+
auto isolate_group = thread->isolate_group();
162161
Zone* zone = thread->zone();
163162
String& uri = String::Handle(zone);
164163
Library& lib = Library::Handle(zone);
@@ -169,13 +168,13 @@ ErrorPtr Bootstrap::DoBootstrapping(const uint8_t* kernel_buffer,
169168
for (intptr_t i = 0; i < kBootstrapLibraryCount; ++i) {
170169
ObjectStore::BootstrapLibraryId id = bootstrap_libraries[i].index;
171170
uri = Symbols::New(thread, bootstrap_libraries[i].uri);
172-
lib = isolate->object_store()->bootstrap_library(id);
171+
lib = isolate_group->object_store()->bootstrap_library(id);
173172
ASSERT(lib.raw() == Library::LookupLibrary(thread, uri));
174173
if (lib.IsNull()) {
175174
lib = Library::NewLibraryHelper(uri, false);
176175
lib.SetLoadRequested();
177176
lib.Register(thread);
178-
isolate->object_store()->set_bootstrap_library(id, lib);
177+
isolate_group->object_store()->set_bootstrap_library(id, lib);
179178
}
180179
}
181180

0 commit comments

Comments
 (0)