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

Unified Diff: runtime/vm/dart.cc

Issue 1439483003: - Add an OSThread structure which is the generic TLS structure for all C++ (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review Created 5 years, 1 month 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/lib/timeline.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart.cc
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 14ff0e798884a2db91ca67bd87f34aed2b15b04a..8935ed07d622b6d503e38f180a47129b2d897a84 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -90,11 +90,8 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
Isolate::SetEntropySourceCallback(entropy_source);
OS::InitOnce();
VirtualMemory::InitOnce();
- Thread::InitOnceBeforeIsolate();
- Thread::EnsureInit();
+ OSThread::InitOnce();
Timeline::InitOnce();
- Thread* thread = Thread::Current();
- thread->set_name("Dart_Initialize");
TimelineDurationScope tds(Timeline::GetVMStream(),
"Dart::InitOnce");
Isolate::InitOnce();
@@ -108,7 +105,6 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
Metric::InitOnce();
StoreBuffer::InitOnce();
MarkingStack::InitOnce();
- Thread::EnsureInit();
#if defined(USING_SIMULATOR)
Simulator::InitOnce();
@@ -120,8 +116,6 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
ASSERT(thread_pool_ == NULL);
thread_pool_ = new ThreadPool();
{
- Thread* T = Thread::Current();
- ASSERT(T != NULL);
ASSERT(vm_isolate_ == NULL);
ASSERT(Flags::Initialized());
const bool is_vm_isolate = true;
@@ -137,6 +131,8 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
ASSERT(vm_isolate_ == Isolate::Current());
ASSERT(vm_isolate_ == Thread::Current()->isolate());
+ Thread* T = Thread::Current();
+ ASSERT(T != NULL);
StackZone zone(T);
HandleScope handle_scope(T);
Object::InitNull(vm_isolate_);
@@ -180,7 +176,9 @@ const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot,
} else {
Symbols::InitOnce(vm_isolate_);
}
- Thread::InitOnceAfterObjectAndStubCode();
+ // We need to initialize the constants here for the vm isolate thread due to
+ // bootstrapping issues.
+ T->InitVMConstants();
Scanner::InitOnce();
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
// Dart VM requires at least SSE2.
@@ -250,7 +248,6 @@ const char* Dart::Cleanup() {
thread_pool_ = NULL;
// Set the VM isolate as current isolate.
- Thread::EnsureInit();
Thread::EnterIsolate(vm_isolate_);
ShutdownIsolate();
@@ -260,7 +257,12 @@ const char* Dart::Cleanup() {
TargetCPUFeatures::Cleanup();
StoreBuffer::ShutDown();
- Thread::Shutdown();
+ // Delete the current thread's TLS and set it's TLS to null.
+ // If it is the last thread then the destructor would call
+ // OSThread::Cleanup.
+ OSThread* os_thread = OSThread::Current();
+ OSThread::SetCurrent(NULL);
+ delete os_thread;
} else {
// Shutdown the service isolate.
ServiceIsolate::Shutdown();
« no previous file with comments | « runtime/lib/timeline.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698