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

Unified Diff: runtime/vm/thread.cc

Issue 1226403003: Support per-thread zones and stack resources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add thread_registry.h Created 5 years, 5 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/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread.cc
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index f94015c9a05a54910b674b140df24aa05d87e411..a82c8b3a358dafbde915c9522441ccdfeb670f32 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -4,13 +4,15 @@
#include "vm/thread.h"
+#include "vm/growable_array.h"
#include "vm/isolate.h"
+#include "vm/lockers.h"
#include "vm/object.h"
#include "vm/os_thread.h"
#include "vm/profiler.h"
#include "vm/stub_code.h"
#include "vm/thread_interrupter.h"
-
+#include "vm/thread_registry.h"
namespace dart {
@@ -69,6 +71,7 @@ void Thread::CleanUp() {
Thread::Thread(bool init_vm_constants)
: isolate_(NULL),
store_buffer_block_(NULL) {
+ ClearState();
#define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \
member_name = default_init_value;
CACHED_CONSTANTS_LIST(DEFAULT_INIT)
@@ -93,6 +96,23 @@ CACHED_CONSTANTS_LIST(INIT_VALUE)
}
+void Thread::Schedule(Isolate* isolate) {
+ State st;
+ if (isolate->thread_registry()->RestoreStateTo(this, &st)) {
+ ASSERT(isolate->thread_registry()->Contains(this));
+ state_ = st;
+ }
+}
+
+
+void Thread::Unschedule() {
+ ThreadRegistry* reg = isolate_->thread_registry();
+ ASSERT(reg->Contains(this));
+ reg->SaveStateFrom(this, state_);
+ ClearState();
+}
+
+
void Thread::EnterIsolate(Isolate* isolate) {
Thread* thread = Thread::Current();
ASSERT(thread != NULL);
@@ -114,6 +134,7 @@ void Thread::EnterIsolate(Isolate* isolate) {
isolate->set_vm_tag(VMTag::kVMTagId);
ASSERT(thread->store_buffer_block_ == NULL);
thread->store_buffer_block_ = isolate->store_buffer()->PopBlock();
+ thread->Schedule(isolate);
}
@@ -122,6 +143,7 @@ void Thread::ExitIsolate() {
// TODO(koda): Audit callers; they should know whether they're in an isolate.
if (thread == NULL || thread->isolate() == NULL) return;
Isolate* isolate = thread->isolate();
+ thread->Unschedule();
StoreBufferBlock* block = thread->store_buffer_block_;
thread->store_buffer_block_ = NULL;
isolate->store_buffer()->PushBlock(block);
@@ -146,6 +168,7 @@ void Thread::EnterIsolateAsHelper(Isolate* isolate) {
// Do not update isolate->mutator_thread, but perform sanity check:
// this thread should not be both the main mutator and helper.
ASSERT(isolate->mutator_thread() != thread);
+ thread->Schedule(isolate);
}
@@ -156,6 +179,7 @@ void Thread::ExitIsolateAsHelper() {
ASSERT(thread->store_buffer_block_ == NULL);
Isolate* isolate = thread->isolate();
ASSERT(isolate != NULL);
+ thread->Unschedule();
thread->isolate_ = NULL;
ASSERT(isolate->mutator_thread() != thread);
}
« no previous file with comments | « runtime/vm/thread.h ('k') | runtime/vm/thread_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698