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

Unified Diff: runtime/vm/thread.cc

Issue 1225933002: Remove fixed contant pool entries by caching some global constants in Thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments 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..195642a1f848c92173ab2ae39d28eea8ba720609 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,28 @@ void Thread::CleanUp() {
#endif
+Thread::Thread(bool init_vm_constants)
+ : isolate_(NULL),
+ store_buffer_block_(NULL) {
+#define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \
+ member_name = default_init_value;
koda 2015/07/08 13:13:10 Too much indentation.
Florian Schneider 2015/07/08 13:31:35 Done.
+CACHED_CONSTANTS_LIST(DEFAULT_INIT)
+#undef DEFAULT_INIT
+ if (init_vm_constants) {
+ InitVMConstants();
+ }
+}
+
+
+void Thread::InitVMConstants() {
+#define INIT_VALUE(type_name, member_name, init_expr, default_init_value) \
+ ASSERT(member_name == default_init_value); \
+ member_name = init_expr;
koda 2015/07/08 13:13:10 For the objects, we should probably ASSERT they ar
Florian Schneider 2015/07/08 13:31:35 Done. Asserting using IsVMHeapObject does not wor
koda 2015/07/08 13:45:55 Ah. This should go away soon, but for now you can
koda 2015/07/08 13:54:26 ... although at second thought, that might actuall
+CACHED_CONSTANTS_LIST(INIT_VALUE)
+#undef INIT_VALUE
+}
+
+
void Thread::EnterIsolate(Isolate* isolate) {
Thread* thread = Thread::Current();
ASSERT(thread != NULL);
@@ -168,4 +203,23 @@ void Thread::set_cha(CHA* value) {
isolate_->cha_ = value;
}
+
+bool Thread::CanLoadFromThread(const Object& object) {
+#define CHECK_OBJECT(type_name, member_name, expr, default_init_value) \
+ if (object.raw() == expr) return true;
+CACHED_VM_OBJECTS_LIST(CHECK_OBJECT)
+#undef CHECK_OBJECT
+ return false;
+}
+
+
+intptr_t Thread::OffsetFromThread(const Object& object) {
+#define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \
+ if (object.raw() == expr) return Thread::member_name##offset();
+CACHED_VM_OBJECTS_LIST(COMPUTE_OFFSET)
+#undef COMPUTE_OFFSET
+ UNREACHABLE();
+ return -1;
+}
+
} // namespace dart
« 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