Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: runtime/vm/isolate.cc

Issue 1310463005: - Ensure that HandleScope is initialized with a thread. (Remove (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index 4d6c56c743ae95cd80433efb7132370acfa6ad6e..186810502a0f0c2e0dfaaae9e2876af9a7e4ee0a 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -418,9 +418,7 @@ bool IsolateMessageHandler::HandleMessage(Message* message) {
}
// Parse the message.
- MessageSnapshotReader reader(message->data(),
- message->len(),
- I, zone);
+ MessageSnapshotReader reader(message->data(), message->len(), thread);
const Object& msg_obj = Object::Handle(zone, reader.ReadObject());
if (msg_obj.IsError()) {
// An error occurred while reading the message.
@@ -510,7 +508,7 @@ void IsolateMessageHandler::NotifyPauseOnStart() {
if (Service::debug_stream.enabled()) {
StartIsolateScope start_isolate(isolate());
StackZone zone(I);
- HandleScope handle_scope(I);
+ HandleScope handle_scope(thread());
ServiceEvent pause_event(isolate(), ServiceEvent::kPauseStart);
Service::HandleEvent(&pause_event);
} else if (FLAG_trace_service) {
@@ -524,7 +522,7 @@ void IsolateMessageHandler::NotifyPauseOnExit() {
if (Service::debug_stream.enabled()) {
StartIsolateScope start_isolate(isolate());
StackZone zone(I);
- HandleScope handle_scope(I);
+ HandleScope handle_scope(thread());
ServiceEvent pause_event(isolate(), ServiceEvent::kPauseExit);
Service::HandleEvent(&pause_event);
} else if (FLAG_trace_service) {
@@ -1265,6 +1263,7 @@ static void StoreError(Isolate* isolate, const Object& obj) {
static bool RunIsolate(uword parameter) {
Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
IsolateSpawnState* state = NULL;
+ Thread* thread = Thread::Current();
{
// TODO(turnidge): Is this locking required here at all anymore?
MutexLocker ml(isolate->mutex());
@@ -1272,8 +1271,9 @@ static bool RunIsolate(uword parameter) {
}
{
StartIsolateScope start_scope(isolate);
+ ASSERT(thread->isolate() == isolate);
StackZone zone(isolate);
- HandleScope handle_scope(isolate);
+ HandleScope handle_scope(thread);
// If particular values were requested for this newly spawned isolate, then
// they are set here before the isolate starts executing user code.
@@ -1342,8 +1342,8 @@ static bool RunIsolate(uword parameter) {
const Array& args = Array::Handle(Array::New(7));
args.SetAt(0, SendPort::Handle(SendPort::New(state->parent_port())));
args.SetAt(1, Instance::Handle(func.ImplicitStaticClosure()));
- args.SetAt(2, Instance::Handle(state->BuildArgs(zone.GetZone())));
- args.SetAt(3, Instance::Handle(state->BuildMessage(zone.GetZone())));
+ args.SetAt(2, Instance::Handle(state->BuildArgs(thread)));
+ args.SetAt(3, Instance::Handle(state->BuildMessage(thread)));
args.SetAt(4, is_spawn_uri ? Bool::True() : Bool::False());
args.SetAt(5, ReceivePort::Handle(
ReceivePort::New(isolate->main_port(), true /* control port */)));
@@ -1370,9 +1370,11 @@ static void ShutdownIsolate(uword parameter) {
{
// Print the error if there is one. This may execute dart code to
// print the exception object, so we need to use a StartIsolateScope.
+ Thread* thread = Thread::Current();
StartIsolateScope start_scope(isolate);
+ ASSERT(thread->isolate() == isolate);
StackZone zone(isolate);
- HandleScope handle_scope(isolate);
+ HandleScope handle_scope(thread);
Error& error = Error::Handle();
error = isolate->object_store()->sticky_error();
if (!error.IsNull() && !error.IsUnwindError()) {
@@ -1493,11 +1495,13 @@ void Isolate::Shutdown() {
}
#endif // DEBUG
+ Thread* thread = Thread::Current();
+
// First, perform higher-level cleanup that may need to allocate.
{
// Ensure we have a zone and handle scope so that we can call VM functions.
StackZone stack_zone(this);
- HandleScope handle_scope(this);
+ HandleScope handle_scope(thread);
// Write out the coverage data if collection has been enabled.
CodeCoverage::Write(this);
@@ -1522,7 +1526,7 @@ void Isolate::Shutdown() {
// Ensure we have a zone and handle scope so that we can call VM functions,
// but we no longer allocate new heap objects.
StackZone stack_zone(this);
- HandleScope handle_scope(this);
+ HandleScope handle_scope(thread);
NoSafepointScope no_safepoint_scope;
if (compiler_stats_ != NULL) {
@@ -2153,20 +2157,17 @@ T* Isolate::AllocateReusableHandle() {
}
-static RawInstance* DeserializeObject(Isolate* isolate,
- Zone* zone,
+static RawInstance* DeserializeObject(Thread* thread,
uint8_t* obj_data,
intptr_t obj_len) {
if (obj_data == NULL) {
return Instance::null();
}
- MessageSnapshotReader reader(obj_data,
- obj_len,
- isolate,
- zone);
- const Object& obj = Object::Handle(isolate, reader.ReadObject());
+ MessageSnapshotReader reader(obj_data, obj_len, thread);
+ Zone* zone = thread->zone();
+ const Object& obj = Object::Handle(zone, reader.ReadObject());
ASSERT(!obj.IsError());
- Instance& instance = Instance::Handle(isolate);
+ Instance& instance = Instance::Handle(zone);
instance ^= obj.raw(); // Can't use Instance::Cast because may be null.
return instance.raw();
}
@@ -2341,14 +2342,13 @@ RawObject* IsolateSpawnState::ResolveFunction() {
}
-RawInstance* IsolateSpawnState::BuildArgs(Zone* zone) {
- return DeserializeObject(isolate_, zone,
- serialized_args_, serialized_args_len_);
+RawInstance* IsolateSpawnState::BuildArgs(Thread* thread) {
+ return DeserializeObject(thread, serialized_args_, serialized_args_len_);
}
-RawInstance* IsolateSpawnState::BuildMessage(Zone* zone) {
- return DeserializeObject(isolate_, zone,
+RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) {
+ return DeserializeObject(thread,
serialized_message_, serialized_message_len_);
}
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698