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

Side by Side Diff: runtime/vm/thread.cc

Issue 1387643002: Move vm_tags from isolate to thread, since we may have multiple threads in same isolate (GC, backgr… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: More comment cleanups Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/thread.h" 5 #include "vm/thread.h"
6 6
7 #include "vm/growable_array.h" 7 #include "vm/growable_array.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 #endif 106 #endif
107 107
108 108
109 Thread::Thread(bool init_vm_constants) 109 Thread::Thread(bool init_vm_constants)
110 : id_(OSThread::GetCurrentThreadId()), 110 : id_(OSThread::GetCurrentThreadId()),
111 thread_interrupt_callback_(NULL), 111 thread_interrupt_callback_(NULL),
112 thread_interrupt_data_(NULL), 112 thread_interrupt_data_(NULL),
113 isolate_(NULL), 113 isolate_(NULL),
114 heap_(NULL), 114 heap_(NULL),
115 store_buffer_block_(NULL), 115 store_buffer_block_(NULL),
116 log_(new class Log()) { 116 log_(new class Log()),
117 vm_tag_(0) {
117 ClearState(); 118 ClearState();
118 119
119 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \ 120 #define DEFAULT_INIT(type_name, member_name, init_expr, default_init_value) \
120 member_name = default_init_value; 121 member_name = default_init_value;
121 CACHED_CONSTANTS_LIST(DEFAULT_INIT) 122 CACHED_CONSTANTS_LIST(DEFAULT_INIT)
122 #undef DEFAULT_INIT 123 #undef DEFAULT_INIT
123 124
124 #define DEFAULT_INIT(name) \ 125 #define DEFAULT_INIT(name) \
125 name##_entry_point_ = 0; 126 name##_entry_point_ = 0;
126 RUNTIME_ENTRY_LIST(DEFAULT_INIT) 127 RUNTIME_ENTRY_LIST(DEFAULT_INIT)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 182 }
182 183
183 184
184 void Thread::EnterIsolate(Isolate* isolate) { 185 void Thread::EnterIsolate(Isolate* isolate) {
185 Thread* thread = Thread::Current(); 186 Thread* thread = Thread::Current();
186 ASSERT(thread != NULL); 187 ASSERT(thread != NULL);
187 ASSERT(thread->isolate() == NULL); 188 ASSERT(thread->isolate() == NULL);
188 ASSERT(!isolate->HasMutatorThread()); 189 ASSERT(!isolate->HasMutatorThread());
189 thread->isolate_ = isolate; 190 thread->isolate_ = isolate;
190 isolate->MakeCurrentThreadMutator(thread); 191 isolate->MakeCurrentThreadMutator(thread);
191 isolate->set_vm_tag(VMTag::kVMTagId); 192 thread->set_vm_tag(VMTag::kVMTagId);
192 ASSERT(thread->store_buffer_block_ == NULL); 193 ASSERT(thread->store_buffer_block_ == NULL);
193 thread->StoreBufferAcquire(); 194 thread->StoreBufferAcquire();
194 ASSERT(isolate->heap() != NULL); 195 ASSERT(isolate->heap() != NULL);
195 thread->heap_ = isolate->heap(); 196 thread->heap_ = isolate->heap();
196 thread->Schedule(isolate); 197 thread->Schedule(isolate);
197 // TODO(koda): Migrate profiler interface to use Thread. 198 // TODO(koda): Migrate profiler interface to use Thread.
198 Profiler::BeginExecution(isolate); 199 Profiler::BeginExecution(isolate);
199 } 200 }
200 201
201 202
202 void Thread::ExitIsolate() { 203 void Thread::ExitIsolate() {
203 Thread* thread = Thread::Current(); 204 Thread* thread = Thread::Current();
204 // TODO(koda): Audit callers; they should know whether they're in an isolate. 205 // TODO(koda): Audit callers; they should know whether they're in an isolate.
205 if (thread == NULL || thread->isolate() == NULL) return; 206 if (thread == NULL || thread->isolate() == NULL) return;
206 Isolate* isolate = thread->isolate(); 207 Isolate* isolate = thread->isolate();
207 Profiler::EndExecution(isolate); 208 Profiler::EndExecution(isolate);
208 thread->Unschedule(); 209 thread->Unschedule();
209 // TODO(koda): Move store_buffer_block_ into State. 210 // TODO(koda): Move store_buffer_block_ into State.
210 thread->StoreBufferRelease(); 211 thread->StoreBufferRelease();
211 if (isolate->is_runnable()) { 212 if (isolate->is_runnable()) {
212 isolate->set_vm_tag(VMTag::kIdleTagId); 213 thread->set_vm_tag(VMTag::kIdleTagId);
213 } else { 214 } else {
214 isolate->set_vm_tag(VMTag::kLoadWaitTagId); 215 thread->set_vm_tag(VMTag::kLoadWaitTagId);
215 } 216 }
216 isolate->ClearMutatorThread(); 217 isolate->ClearMutatorThread();
217 thread->isolate_ = NULL; 218 thread->isolate_ = NULL;
218 ASSERT(Isolate::Current() == NULL); 219 ASSERT(Isolate::Current() == NULL);
219 thread->heap_ = NULL; 220 thread->heap_ = NULL;
220 } 221 }
221 222
222 223
223 void Thread::EnterIsolateAsHelper(Isolate* isolate, bool bypass_safepoint) { 224 void Thread::EnterIsolateAsHelper(Isolate* isolate, bool bypass_safepoint) {
224 Thread* thread = Thread::Current(); 225 Thread* thread = Thread::Current();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 return Thread::name##_entry_point_offset(); \ 377 return Thread::name##_entry_point_offset(); \
377 } 378 }
378 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) 379 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET)
379 #undef COMPUTE_OFFSET 380 #undef COMPUTE_OFFSET
380 381
381 UNREACHABLE(); 382 UNREACHABLE();
382 return -1; 383 return -1;
383 } 384 }
384 385
385 } // namespace dart 386 } // namespace dart
OLDNEW
« 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