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

Unified Diff: runtime/vm/thread.cc

Issue 1210033007: Cache some global constants in Thread, to allow access via THR register. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unused define. 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') | no next file » | 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 ba6db93eacd7aeb166d49bbcbba0c59c8719d911..27031776ecedf0de1483151aa3dbb60b47bc2a6f 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -5,8 +5,10 @@
#include "vm/thread.h"
#include "vm/isolate.h"
+#include "vm/object.h"
#include "vm/os_thread.h"
#include "vm/profiler.h"
+#include "vm/stub_code.h"
#include "vm/thread_interrupter.h"
@@ -23,10 +25,21 @@ static void DeleteThread(void* thread) {
}
-void Thread::InitOnce() {
+void Thread::InitOnceBeforeIsolate() {
ASSERT(thread_key_ == OSThread::kUnsetThreadLocalKey);
thread_key_ = OSThread::CreateThreadLocal(DeleteThread);
ASSERT(thread_key_ != OSThread::kUnsetThreadLocalKey);
+ ASSERT(Thread::Current() == NULL);
+ // Postpone initialization of VM constants for this first thread.
+ SetCurrent(new Thread(false));
+}
+
+
+void Thread::InitOnceAfterObjectAndStubCode() {
+ Thread* thread = Thread::Current();
+ ASSERT(thread != NULL);
+ ASSERT(thread->isolate() == Dart::vm_isolate());
+ thread->InitVMConstants();
}
@@ -53,6 +66,31 @@ void Thread::CleanUp() {
#endif
+Thread::Thread(bool init_vm_constants)
+ : isolate_(NULL),
+ store_buffer_block_(NULL),
+ object_null_(NULL),
+ bool_true_(NULL),
+ bool_false_(NULL),
+ update_store_buffer_entry_point_(0) {
+ if (init_vm_constants) {
+ InitVMConstants();
+ }
+}
+
+
+void Thread::InitVMConstants() {
+ ASSERT(object_null_ == NULL);
+ object_null_ = Object::null();
+ ASSERT(bool_true_ == NULL);
+ bool_true_ = Object::bool_true().raw();
+ ASSERT(bool_false_ == NULL);
+ bool_false_ = Object::bool_false().raw();
+ ASSERT(update_store_buffer_entry_point_ == 0);
+ update_store_buffer_entry_point_ = StubCode::UpdateStoreBufferEntryPoint();
+}
+
+
void Thread::EnterIsolate(Isolate* isolate) {
Thread* thread = Thread::Current();
ASSERT(thread != NULL);
« no previous file with comments | « runtime/vm/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698