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

Unified Diff: runtime/vm/thread.h

Issue 1037453002: Split Thread/Isolate instances, but still maintain 1:1 relationship. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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
Index: runtime/vm/thread.h
===================================================================
--- runtime/vm/thread.h (revision 44671)
+++ runtime/vm/thread.h (working copy)
@@ -5,48 +5,48 @@
#ifndef VM_THREAD_H_
#define VM_THREAD_H_
-#include "vm/isolate.h"
+#include "vm/base_isolate.h"
+#include "vm/globals.h"
+#include "vm/os_thread.h"
namespace dart {
+class CHA;
+class Isolate;
+
// A VM thread; may be executing Dart code or performing helper tasks like
// garbage collection or compilation.
class Thread {
public:
+ explicit Thread(Isolate* isolate)
+ : isolate_(isolate),
+ cha_(NULL) {}
+
+ static void InitOnce();
+
static Thread* Current() {
- // For now, there is still just one thread per isolate, and the Thread
- // class just aliases the Isolate*. Once all interfaces and uses have been
- // updated to distinguish between isolates and threads, Thread will get its
- // own thread-local storage key and fields.
- return reinterpret_cast<Thread*>(Isolate::Current());
+ return reinterpret_cast<Thread*>(OSThread::GetThreadLocal(thread_key));
}
- // TODO(koda): Remove after pivoting to Thread* in native/runtime entries.
- static Thread* CurrentFromCurrentIsolate(BaseIsolate* isolate) {
- ASSERT(Isolate::Current() == isolate);
- return reinterpret_cast<Thread*>(isolate);
- }
+ static void SetCurrent(Thread* current);
// The topmost zone used for allocation in this thread.
Zone* zone() {
- return reinterpret_cast<BaseIsolate*>(this)->current_zone();
+ return reinterpret_cast<BaseIsolate*>(isolate())->current_zone();
}
- // The isolate that this thread is operating on.
- Isolate* isolate() { return reinterpret_cast<Isolate*>(this); }
- const Isolate* isolate() const {
- return reinterpret_cast<const Isolate*>(this);
- }
+ // The isolate that this thread is operating on, or NULL if none.
+ Isolate* isolate() const { return isolate_; }
- // The log for this thread.
- class Log* Log() {
- return reinterpret_cast<Isolate*>(this)->Log();
- }
-
// The (topmost) CHA for the compilation in this thread.
- CHA* cha() const { return isolate()->cha(); }
- void set_cha(CHA* value) { isolate()->set_cha(value); }
+ CHA* cha() const { return cha_; }
+ void set_cha(CHA* value) { cha_ = value; }
private:
+ static ThreadLocalKey thread_key;
Ivan Posva 2015/03/26 14:36:52 thread_key_
+
+ Isolate* isolate_;
+ CHA* cha_;
+
DISALLOW_COPY_AND_ASSIGN(Thread);
};
« runtime/vm/isolate.h ('K') | « runtime/vm/runtime_entry.h ('k') | runtime/vm/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698