From 465cf10a7ce04045b68ad4cf1995ed913a536386 Mon Sep 17 00:00:00 2001 From: Srdjan Mitrovic Date: Mon, 19 Oct 2015 10:27:36 -0700 Subject: [PATCH] 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 . --- runtime/lib/bool.cc | 2 +- runtime/lib/integers.cc | 2 +- runtime/lib/string.cc | 2 +- runtime/vm/benchmark_test.cc | 6 +-- runtime/vm/code_generator.cc | 2 +- runtime/vm/compiler.cc | 5 ++- runtime/vm/compiler.h | 2 +- runtime/vm/dart_api_impl.cc | 27 ++++++------ runtime/vm/dart_api_impl.h | 2 +- runtime/vm/debugger.cc | 4 +- runtime/vm/debugger.h | 5 ++- runtime/vm/isolate.cc | 11 +++-- runtime/vm/native_api_impl.cc | 11 +++-- runtime/vm/object.cc | 35 +++++++++------- runtime/vm/object.h | 6 +-- runtime/vm/service.cc | 78 ++++++++++++++++++----------------- runtime/vm/snapshot.cc | 16 +++---- 17 files changed, 113 insertions(+), 103 deletions(-) diff --git a/runtime/lib/bool.cc b/runtime/lib/bool.cc index 83d370f01be..b536ccfe289 100644 --- a/runtime/lib/bool.cc +++ b/runtime/lib/bool.cc @@ -21,7 +21,7 @@ DEFINE_NATIVE_ENTRY(Bool_fromEnvironment, 3) { GET_NATIVE_ARGUMENT(Bool, default_value, arguments->NativeArgAt(2)); // Call the embedder to supply us with the environment. const String& env_value = - String::Handle(Api::CallEnvironmentCallback(isolate, name)); + String::Handle(Api::CallEnvironmentCallback(thread, name)); if (!env_value.IsNull()) { if (Symbols::True().Equals(env_value)) { return Bool::True().raw(); diff --git a/runtime/lib/integers.cc b/runtime/lib/integers.cc index e8d655ca416..8deeee437b0 100644 --- a/runtime/lib/integers.cc +++ b/runtime/lib/integers.cc @@ -237,7 +237,7 @@ DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 3) { GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2)); // Call the embedder to supply us with the environment. const String& env_value = - String::Handle(Api::CallEnvironmentCallback(isolate, name)); + String::Handle(Api::CallEnvironmentCallback(thread, name)); if (!env_value.IsNull()) { const Integer& result = Integer::Handle(ParseInteger(env_value)); if (!result.IsNull()) { diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc index 2eae245fa67..62e5aacb324 100644 --- a/runtime/lib/string.cc +++ b/runtime/lib/string.cc @@ -20,7 +20,7 @@ DEFINE_NATIVE_ENTRY(String_fromEnvironment, 3) { GET_NATIVE_ARGUMENT(String, default_value, arguments->NativeArgAt(2)); // Call the embedder to supply us with the environment. const String& env_value = - String::Handle(Api::CallEnvironmentCallback(isolate, name)); + String::Handle(Api::CallEnvironmentCallback(thread, name)); if (!env_value.IsNull()) { return Symbols::New(env_value); } diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index 9fcb4d00fdc..1b22bc521a4 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -41,8 +41,7 @@ BENCHMARK(CorelibCompileAll) { bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); Timer timer(true, "Compile all of Core lib benchmark"); timer.Start(); - const Error& error = Error::Handle(benchmark->isolate()->current_zone(), - Library::CompileAll()); + const Error& error = Error::Handle(Library::CompileAll()); if (!error.IsNull()) { OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", error.ToErrorCString()); @@ -61,8 +60,7 @@ BENCHMARK(CorelibCompilerStats) { stats->EnableBenchmark(); Timer timer(true, "Compiler stats compiling all of Core lib"); timer.Start(); - const Error& error = Error::Handle(benchmark->isolate()->current_zone(), - Library::CompileAll()); + const Error& error = Error::Handle(Library::CompileAll()); if (!error.IsNull()) { OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", error.ToErrorCString()); diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc index 60a3ab301e2..41175a72f4e 100644 --- a/runtime/vm/code_generator.cc +++ b/runtime/vm/code_generator.cc @@ -1452,7 +1452,7 @@ DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { // prevent recursive triggering of function optimization. function.set_usage_counter(0); if (FLAG_background_compilation) { - BackgroundCompiler::EnsureInit(isolate); + BackgroundCompiler::EnsureInit(thread); ASSERT(isolate->background_compiler() != NULL); isolate->background_compiler()->CompileOptimized(function); // Continue in the same code. diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc index b573601298d..c42a34854aa 100644 --- a/runtime/vm/compiler.cc +++ b/runtime/vm/compiler.cc @@ -1569,15 +1569,16 @@ void BackgroundCompiler::Stop(BackgroundCompiler* task) { } -void BackgroundCompiler::EnsureInit(Isolate* isolate) { +void BackgroundCompiler::EnsureInit(Thread* thread) { bool start_task = false; + Isolate* isolate = thread->isolate(); { MutexLocker ml(isolate->mutex()); if (isolate->background_compiler() == NULL) { BackgroundCompiler* task = new BackgroundCompiler(isolate); isolate->set_background_compiler(task); isolate->set_background_compilation_queue(GrowableObjectArray::Handle( - isolate->current_zone(), GrowableObjectArray::New())); + thread->zone(), GrowableObjectArray::New())); start_task = true; } } diff --git a/runtime/vm/compiler.h b/runtime/vm/compiler.h index d91f4c659c8..28732f4ccbf 100644 --- a/runtime/vm/compiler.h +++ b/runtime/vm/compiler.h @@ -106,7 +106,7 @@ class Compiler : public AllStatic { // isolate. class BackgroundCompiler : public ThreadPool::Task { public: - static void EnsureInit(Isolate* isolate); + static void EnsureInit(Thread* thread); static void Stop(BackgroundCompiler* task); diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 6b0186cf0c2..c79748fd26e 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -4966,17 +4966,18 @@ DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args, // --- Environment --- -RawString* Api::CallEnvironmentCallback(Isolate* isolate, const String& name) { +RawString* Api::CallEnvironmentCallback(Thread* thread, const String& name) { + Isolate* isolate = thread->isolate(); Scope api_scope(isolate); Dart_EnvironmentCallback callback = isolate->environment_callback(); - String& result = String::Handle(isolate->current_zone()); + String& result = String::Handle(thread->zone()); if (callback != NULL) { Dart_Handle response = callback(Api::NewHandle(isolate, name.raw())); if (::Dart_IsString(response)) { result ^= Api::UnwrapHandle(response); } else if (::Dart_IsError(response)) { - const Object& error = - Object::Handle(isolate->current_zone(), Api::UnwrapHandle(response)); + const Object& error = Object::Handle( + thread->zone(), Api::UnwrapHandle(response)); Exceptions::ThrowArgumentError( String::Handle(String::New(Error::Cast(error).ToErrorCString()))); } else if (!::Dart_IsNull(response)) { @@ -5052,7 +5053,7 @@ DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( // NOTE: Need to pass 'result' as a parameter here in order to avoid // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' // which shows up because of the use of setjmp. -static void CompileSource(Isolate* isolate, +static void CompileSource(Thread* thread, const Library& lib, const Script& script, Dart_Handle* result) { @@ -5061,13 +5062,13 @@ static void CompileSource(Isolate* isolate, if (update_lib_status) { lib.SetLoadInProgress(); } - ASSERT(isolate != NULL); + ASSERT(thread != NULL); const Error& error = - Error::Handle(isolate->current_zone(), Compiler::Compile(lib, script)); + Error::Handle(thread->zone(), Compiler::Compile(lib, script)); if (error.IsNull()) { - *result = Api::NewHandle(isolate, lib.raw()); + *result = Api::NewHandle(thread->isolate(), lib.raw()); } else { - *result = Api::NewHandle(isolate, error.raw()); + *result = Api::NewHandle(thread->isolate(), error.raw()); // Compilation errors are not Dart instances, so just mark the library // as having failed to load without providing an error instance. lib.SetLoadError(Object::null_instance()); @@ -5116,7 +5117,7 @@ DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, Script::New(url_str, source_str, RawScript::kScriptTag)); script.SetLocationOffset(line_offset, column_offset); Dart_Handle result; - CompileSource(I, library, script, &result); + CompileSource(T, library, script, &result); return result; } @@ -5361,7 +5362,7 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Script::New(url_str, source_str, RawScript::kLibraryTag)); script.SetLocationOffset(line_offset, column_offset); Dart_Handle result; - CompileSource(I, library, script, &result); + CompileSource(T, library, script, &result); // Propagate the error out right now. if (::Dart_IsError(result)) { return result; @@ -5456,7 +5457,7 @@ DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, Script::New(url_str, source_str, RawScript::kSourceTag)); script.SetLocationOffset(line_offset, column_offset); Dart_Handle result; - CompileSource(I, lib, script, &result); + CompileSource(T, lib, script, &result); return result; } @@ -5485,7 +5486,7 @@ DART_EXPORT Dart_Handle Dart_LibraryLoadPatch(Dart_Handle library, const Script& script = Script::Handle(Z, Script::New(url_str, source_str, RawScript::kPatchTag)); Dart_Handle result; - CompileSource(I, lib, script, &result); + CompileSource(T, lib, script, &result); return result; } diff --git a/runtime/vm/dart_api_impl.h b/runtime/vm/dart_api_impl.h index 613778a93f3..dd5920d0539 100644 --- a/runtime/vm/dart_api_impl.h +++ b/runtime/vm/dart_api_impl.h @@ -269,7 +269,7 @@ class Api : AllStatic { static void SetWeakHandleReturnValue(NativeArguments* args, Dart_WeakPersistentHandle retval); - static RawString* CallEnvironmentCallback(Isolate* isolate, + static RawString* CallEnvironmentCallback(Thread* thread, const String& name); private: diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index a92b4d52380..79153f47459 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -2402,10 +2402,10 @@ void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, const String& prefix, bool include_private_fields) { DictionaryIterator it(lib); - Object& entry = Object::Handle(isolate_->current_zone()); + Object& entry = Object::Handle(zone()); Field& field = Field::Handle(zone()); String& field_name = String::Handle(zone()); - PassiveObject& field_value = PassiveObject::Handle(isolate_->current_zone()); + PassiveObject& field_value = PassiveObject::Handle(zone()); while (it.HasNext()) { entry = it.GetNext(); if (entry.IsField()) { diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h index a9d05472811..05155707f34 100644 --- a/runtime/vm/debugger.h +++ b/runtime/vm/debugger.h @@ -650,7 +650,10 @@ class Debugger { void HandleSteppingRequest(DebuggerStackTrace* stack_trace); - Zone* zone() const { return isolate_->current_zone(); } + Zone* zone() const { + ASSERT(isolate_->MutatorThreadIsCurrentThread()); + return isolate_->current_zone(); + } Isolate* isolate_; Dart_Port isolate_id_; // A unique ID for the isolate in the debugger. diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index da4c5d42556..b18b50c6017 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -217,7 +217,7 @@ const char* IsolateMessageHandler::name() const { // [ OOB dispatch, Isolate library dispatch, ] RawError* IsolateMessageHandler::HandleLibMessage(const Array& message) { if (message.Length() < 2) return Error::null(); - Zone* zone = I->current_zone(); + Zone* zone = T->zone(); const Object& type = Object::Handle(zone, message.At(1)); if (!type.IsSmi()) return Error::null(); const intptr_t msg_type = Smi::Cast(type).Value(); @@ -640,10 +640,10 @@ MessageHandler::MessageStatus IsolateMessageHandler::ProcessUnhandledException( } // Generate the error and stacktrace strings for the error message. - String& exc_str = String::Handle(I->current_zone()); - String& stacktrace_str = String::Handle(I->current_zone()); + String& exc_str = String::Handle(T->zone()); + String& stacktrace_str = String::Handle(T->zone()); if (result.IsUnhandledException()) { - Zone* zone = I->current_zone(); + Zone* zone = T->zone(); const UnhandledException& uhe = UnhandledException::Cast(result); const Instance& exception = Instance::Handle(zone, uhe.exception()); Object& tmp = Object::Handle(zone); @@ -1887,8 +1887,7 @@ void Isolate::PrintJSON(JSONStream* stream, bool ref) { vm_tag_counters()->PrintToJSONObject(&tagCounters); } if (object_store()->sticky_error() != Object::null()) { - Error& error = Error::Handle(current_zone(), - object_store()->sticky_error()); + Error& error = Error::Handle(object_store()->sticky_error()); ASSERT(!error.IsNull()); jsobj.AddProperty("error", error, false); } diff --git a/runtime/vm/native_api_impl.cc b/runtime/vm/native_api_impl.cc index ce055293cd8..9395bf3af89 100644 --- a/runtime/vm/native_api_impl.cc +++ b/runtime/vm/native_api_impl.cc @@ -69,14 +69,13 @@ DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) { // --- Verification tools --- -static void CompileAll(Isolate* isolate, Dart_Handle* result) { - ASSERT(isolate != NULL); - const Error& error = - Error::Handle(isolate->current_zone(), Library::CompileAll()); +static void CompileAll(Thread* thread, Dart_Handle* result) { + ASSERT(thread != NULL); + const Error& error = Error::Handle(thread->zone(), Library::CompileAll()); if (error.IsNull()) { *result = Api::Success(); } else { - *result = Api::NewHandle(isolate, error.raw()); + *result = Api::NewHandle(thread->isolate(), error.raw()); } } @@ -88,7 +87,7 @@ DART_EXPORT Dart_Handle Dart_CompileAll() { return result; } CHECK_CALLBACK_STATE(T); - CompileAll(I, &result); + CompileAll(T, &result); return result; } diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index f07b1314bbf..604b697fe55 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -17641,7 +17641,7 @@ bool Bigint::CheckAndCanonicalizeFields(const char** error_str) const { ASSERT(!digits_.IsNull()); set_digits(digits_); } else { - ASSERT(digits() == TypedData::EmptyUint32Array(Isolate::Current())); + ASSERT(digits() == TypedData::EmptyUint32Array(Thread::Current())); } return true; } @@ -17663,7 +17663,7 @@ RawBigint* Bigint::New(Heap::Space space) { result.SetNeg(false); result.SetUsed(0); result.set_digits( - TypedData::Handle(zone, TypedData::EmptyUint32Array(isolate))); + TypedData::Handle(zone, TypedData::EmptyUint32Array(thread))); return result.raw(); } @@ -17697,7 +17697,7 @@ RawBigint* Bigint::New(bool neg, intptr_t used, const TypedData& digits, } else { neg = false; result.set_digits( - TypedData::Handle(zone, TypedData::EmptyUint32Array(isolate))); + TypedData::Handle(zone, TypedData::EmptyUint32Array(thread))); } result.SetNeg(neg); result.SetUsed(used); @@ -20920,14 +20920,16 @@ RawTypedData* TypedData::New(intptr_t class_id, } -RawTypedData* TypedData::EmptyUint32Array(Isolate* isolate) { +RawTypedData* TypedData::EmptyUint32Array(Thread* thread) { + ASSERT(thread != NULL); + Isolate* isolate = thread->isolate(); ASSERT(isolate != NULL); ASSERT(isolate->object_store() != NULL); if (isolate->object_store()->empty_uint32_array() != TypedData::null()) { // Already created. return isolate->object_store()->empty_uint32_array(); } - const TypedData& array = TypedData::Handle(isolate->current_zone(), + const TypedData& array = TypedData::Handle(thread->zone(), TypedData::New(kTypedDataUint32ArrayCid, 0, Heap::kOld)); isolate->object_store()->set_empty_uint32_array(array); return array.raw(); @@ -21590,10 +21592,11 @@ void UserTag::MakeActive() const { RawUserTag* UserTag::New(const String& label, Heap::Space space) { - Isolate* isolate = Isolate::Current(); + Thread* thread = Thread::Current(); + Isolate* isolate = thread->isolate(); ASSERT(isolate->tag_table() != GrowableObjectArray::null()); // Canonicalize by name. - UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label)); + UserTag& result = UserTag::Handle(FindTagInIsolate(thread, label)); if (!result.IsNull()) { // Tag already exists, return existing instance. return result.raw(); @@ -21615,7 +21618,7 @@ RawUserTag* UserTag::New(const String& label, Heap::Space space) { result ^= raw; } result.set_label(label); - AddTagToIsolate(isolate, result); + AddTagToIsolate(thread, result); return result.raw(); } @@ -21638,12 +21641,14 @@ RawUserTag* UserTag::DefaultTag() { } -RawUserTag* UserTag::FindTagInIsolate(Isolate* isolate, const String& label) { +RawUserTag* UserTag::FindTagInIsolate(Thread* thread, const String& label) { + Isolate* isolate = thread->isolate(); + Zone* zone = thread->zone(); ASSERT(isolate->tag_table() != GrowableObjectArray::null()); const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( - isolate->current_zone(), isolate->tag_table()); - UserTag& other = UserTag::Handle(isolate->current_zone()); - String& tag_label = String::Handle(isolate->current_zone()); + zone, isolate->tag_table()); + UserTag& other = UserTag::Handle(zone); + String& tag_label = String::Handle(zone); for (intptr_t i = 0; i < tag_table.Length(); i++) { other ^= tag_table.At(i); ASSERT(!other.IsNull()); @@ -21657,10 +21662,12 @@ RawUserTag* UserTag::FindTagInIsolate(Isolate* isolate, const String& label) { } -void UserTag::AddTagToIsolate(Isolate* isolate, const UserTag& tag) { +void UserTag::AddTagToIsolate(Thread* thread, const UserTag& tag) { + Isolate* isolate = thread->isolate(); + Zone* zone = thread->zone(); ASSERT(isolate->tag_table() != GrowableObjectArray::null()); const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( - isolate->current_zone(), isolate->tag_table()); + zone, isolate->tag_table()); ASSERT(!TagTableIsFull(isolate)); #if defined(DEBUG) // Verify that no existing tag has the same tag id. diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 3006f28c5c2..d597bfc494f 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -7208,7 +7208,7 @@ class TypedData : public Instance { return RawObject::IsTypedDataClassId(cid); } - static RawTypedData* EmptyUint32Array(Isolate* isolate); + static RawTypedData* EmptyUint32Array(Thread* thread); protected: void SetLength(intptr_t value) const { @@ -7978,8 +7978,8 @@ class UserTag : public Instance { static RawUserTag* FindTagById(uword tag_id); private: - static RawUserTag* FindTagInIsolate(Isolate* isolate, const String& label); - static void AddTagToIsolate(Isolate* isolate, const UserTag& tag); + static RawUserTag* FindTagInIsolate(Thread* thread, const String& label); + static void AddTagToIsolate(Thread* thread, const UserTag& tag); void set_label(const String& tag_label) const { StorePointer(&raw_ptr()->label_, tag_label.raw()); diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 42e50a4a108..bd6a4198899 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -1101,7 +1101,7 @@ static bool ContainsNonInstance(const Object& obj) { } -static RawObject* LookupObjectId(Isolate* isolate, +static RawObject* LookupObjectId(Thread* thread, const char* arg, ObjectIdRing::LookupResult* kind) { *kind = ObjectIdRing::kValid; @@ -1113,7 +1113,7 @@ static RawObject* LookupObjectId(Isolate* isolate, *kind = ObjectIdRing::kInvalid; return Object::null(); } - const Integer& obj = Integer::Handle(isolate->current_zone(), + const Integer& obj = Integer::Handle(thread->zone(), Smi::New(static_cast(value))); return obj.raw(); } else if (strcmp(arg, "bool-true") == 0) { @@ -1124,7 +1124,7 @@ static RawObject* LookupObjectId(Isolate* isolate, return Object::null(); } - ObjectIdRing* ring = isolate->object_id_ring(); + ObjectIdRing* ring = thread->isolate()->object_id_ring(); ASSERT(ring != NULL); intptr_t id = -1; if (!GetIntegerId(arg, &id)) { @@ -1185,19 +1185,21 @@ static RawObject* LookupHeapObjectLibraries(Isolate* isolate, return Object::sentinel().raw(); } -static RawObject* LookupHeapObjectClasses(Isolate* isolate, +static RawObject* LookupHeapObjectClasses(Thread* thread, char** parts, int num_parts) { // Class ids look like: "classes/17" if (num_parts < 2) { return Object::sentinel().raw(); } + Isolate* isolate = thread->isolate(); + Zone* zone = thread->zone(); ClassTable* table = isolate->class_table(); intptr_t id; if (!GetIntegerId(parts[1], &id) || !table->IsValidIndex(id)) { return Object::sentinel().raw(); } - Class& cls = Class::Handle(table->At(id)); + Class& cls = Class::Handle(zone, table->At(id)); if (num_parts == 2) { return cls.raw(); } @@ -1210,7 +1212,7 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, if (!GetIntegerId(parts[3], &id)) { return Object::sentinel().raw(); } - Function& func = Function::Handle(); + Function& func = Function::Handle(zone); func ^= cls.ClosureFunctionFromIndex(id); if (func.IsNull()) { return Object::sentinel().raw(); @@ -1226,7 +1228,7 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, if (!GetIntegerId(parts[3], &id)) { return Object::sentinel().raw(); } - Field& field = Field::Handle(cls.FieldFromIndex(id)); + Field& field = Field::Handle(zone, cls.FieldFromIndex(id)); if (field.IsNull()) { return Object::sentinel().raw(); } @@ -1238,13 +1240,12 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, return Object::sentinel().raw(); } const char* encoded_id = parts[3]; - String& id = String::Handle(isolate->current_zone(), - String::New(encoded_id)); + String& id = String::Handle(zone, String::New(encoded_id)); id = String::DecodeIRI(id); if (id.IsNull()) { return Object::sentinel().raw(); } - Function& func = Function::Handle(cls.LookupFunction(id)); + Function& func = Function::Handle(zone, cls.LookupFunction(id)); if (func.IsNull()) { return Object::sentinel().raw(); } @@ -1259,7 +1260,7 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, if (!GetIntegerId(parts[3], &id)) { return Object::sentinel().raw(); } - Function& func = Function::Handle(); + Function& func = Function::Handle(zone); func ^= cls.ImplicitClosureFunctionFromIndex(id); if (func.IsNull()) { return Object::sentinel().raw(); @@ -1275,7 +1276,7 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, if (!GetIntegerId(parts[3], &id)) { return Object::sentinel().raw(); } - Function& func = Function::Handle(); + Function& func = Function::Handle(zone); func ^= cls.InvocationDispatcherFunctionFromIndex(id); if (func.IsNull()) { return Object::sentinel().raw(); @@ -1291,7 +1292,7 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, if (!GetIntegerId(parts[3], &id)) { return Object::sentinel().raw(); } - Type& type = Type::Handle(); + Type& type = Type::Handle(zone); type ^= cls.CanonicalTypeFromIndex(id); if (type.IsNull()) { return Object::sentinel().raw(); @@ -1304,8 +1305,9 @@ static RawObject* LookupHeapObjectClasses(Isolate* isolate, } -static RawObject* LookupHeapObjectTypeArguments(Isolate* isolate, - char** parts, int num_parts) { +static RawObject* LookupHeapObjectTypeArguments(Thread* thread, + char** parts, int num_parts) { + Isolate* isolate = thread->isolate(); // TypeArguments ids look like: "typearguments/17" if (num_parts < 2) { return Object::sentinel().raw(); @@ -1315,7 +1317,8 @@ static RawObject* LookupHeapObjectTypeArguments(Isolate* isolate, return Object::sentinel().raw(); } ObjectStore* object_store = isolate->object_store(); - const Array& table = Array::Handle(object_store->canonical_type_arguments()); + const Array& table = Array::Handle(thread->zone(), + object_store->canonical_type_arguments()); ASSERT(table.Length() > 0); const intptr_t table_size = table.Length() - 1; if ((id < 0) || (id >= table_size) || (table.At(id) == Object::null())) { @@ -1399,7 +1402,8 @@ static RawObject* LookupHeapObjectMessage(Isolate* isolate, static RawObject* LookupHeapObject(Isolate* isolate, const char* id_original, ObjectIdRing::LookupResult* result) { - char* id = Thread::Current()->zone()->MakeCopyOfString(id_original); + Thread* thread = Thread::Current(); + char* id = thread->zone()->MakeCopyOfString(id_original); // Parse the id by splitting at each '/'. const int MAX_PARTS = 8; @@ -1429,9 +1433,9 @@ static RawObject* LookupHeapObject(Isolate* isolate, if (strcmp(parts[0], "objects") == 0) { // Object ids look like "objects/1123" - Object& obj = Object::Handle(isolate->current_zone()); + Object& obj = Object::Handle(thread->zone()); ObjectIdRing::LookupResult lookup_result; - obj = LookupObjectId(isolate, parts[1], &lookup_result); + obj = LookupObjectId(thread, parts[1], &lookup_result); if (lookup_result != ObjectIdRing::kValid) { if (result != NULL) { *result = lookup_result; @@ -1443,9 +1447,9 @@ static RawObject* LookupHeapObject(Isolate* isolate, } else if (strcmp(parts[0], "libraries") == 0) { return LookupHeapObjectLibraries(isolate, parts, num_parts); } else if (strcmp(parts[0], "classes") == 0) { - return LookupHeapObjectClasses(isolate, parts, num_parts); + return LookupHeapObjectClasses(thread, parts, num_parts); } else if (strcmp(parts[0], "typearguments") == 0) { - return LookupHeapObjectTypeArguments(isolate, parts, num_parts); + return LookupHeapObjectTypeArguments(thread, parts, num_parts); } else if (strcmp(parts[0], "code") == 0) { return LookupHeapObjectCode(isolate, parts, num_parts); } else if (strcmp(parts[0], "messages") == 0) { @@ -1779,11 +1783,11 @@ static bool Evaluate(Isolate* isolate, JSONStream* js) { PrintMissingParamError(js, "expression"); return true; } - const String& expr_str = - String::Handle(isolate->current_zone(), String::New(expr)); + Zone* zone = Thread::Current()->zone(); + const String& expr_str = String::Handle(zone, String::New(expr)); ObjectIdRing::LookupResult lookup_result; - Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, - &lookup_result)); + Object& obj = Object::Handle(zone, LookupHeapObject(isolate, target_id, + &lookup_result)); if (obj.raw() == Object::sentinel().raw()) { if (lookup_result == ObjectIdRing::kCollected) { PrintSentinel(js, kCollectedSentinel); @@ -1796,29 +1800,27 @@ static bool Evaluate(Isolate* isolate, JSONStream* js) { } if (obj.IsLibrary()) { const Library& lib = Library::Cast(obj); - const Object& result = Object::Handle(lib.Evaluate(expr_str, - Array::empty_array(), - Array::empty_array())); + const Object& result = Object::Handle(zone, + lib.Evaluate(expr_str, Array::empty_array(), Array::empty_array())); result.PrintJSON(js, true); return true; } if (obj.IsClass()) { const Class& cls = Class::Cast(obj); - const Object& result = Object::Handle(cls.Evaluate(expr_str, - Array::empty_array(), - Array::empty_array())); + const Object& result = Object::Handle(zone, + cls.Evaluate(expr_str, Array::empty_array(), Array::empty_array())); result.PrintJSON(js, true); return true; } if ((obj.IsInstance() || obj.IsNull()) && !ContainsNonInstance(obj)) { // We don't use Instance::Cast here because it doesn't allow null. - Instance& instance = Instance::Handle(isolate->current_zone()); + Instance& instance = Instance::Handle(zone); instance ^= obj.raw(); const Object& result = - Object::Handle(instance.Evaluate(expr_str, - Array::empty_array(), - Array::empty_array())); + Object::Handle(zone, instance.Evaluate(expr_str, + Array::empty_array(), + Array::empty_array())); result.PrintJSON(js, true); return true; } @@ -1852,11 +1854,11 @@ static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { } ActivationFrame* frame = stack->FrameAt(framePos); + Zone* zone = Thread::Current()->zone(); const char* expr = js->LookupParam("expression"); - const String& expr_str = String::Handle(isolate->current_zone(), - String::New(expr)); + const String& expr_str = String::Handle(zone, String::New(expr)); - const Object& result = Object::Handle(frame->Evaluate(expr_str)); + const Object& result = Object::Handle(zone, frame->Evaluate(expr_str)); result.PrintJSON(js, true); return true; } diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index f121a0d4788..870b2ad8a14 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -1729,15 +1729,15 @@ bool SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) { // objects and their accompanying token streams. class ScriptVisitor : public ObjectVisitor { public: - explicit ScriptVisitor(Isolate* isolate) : - ObjectVisitor(isolate), - objHandle_(Object::Handle(isolate->current_zone())), + explicit ScriptVisitor(Thread* thread) : + ObjectVisitor(thread->isolate()), + objHandle_(Object::Handle(thread->zone())), count_(0), scripts_(NULL) {} - ScriptVisitor(Isolate* isolate, const Array* scripts) : - ObjectVisitor(isolate), - objHandle_(Object::Handle(isolate->current_zone())), + ScriptVisitor(Thread* thread, const Array* scripts) : + ObjectVisitor(thread->isolate()), + objHandle_(Object::Handle(thread->zone())), count_(0), scripts_(scripts) {} @@ -1797,11 +1797,11 @@ FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, // into an array so that we can write it out as part of the VM isolate // snapshot. We first count the number of script objects, allocate an array // and then fill it up with the script objects. - ScriptVisitor scripts_counter(isolate()); + ScriptVisitor scripts_counter(thread()); heap()->IterateOldObjects(&scripts_counter); intptr_t count = scripts_counter.count(); scripts_ = Array::New(count, Heap::kOld); - ScriptVisitor script_visitor(isolate(), &scripts_); + ScriptVisitor script_visitor(thread(), &scripts_); heap()->IterateOldObjects(&script_visitor); // Stash the symbol table away for writing and reading into the vm isolate,