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

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

Issue 1041523002: Refactor Thread lifecycle interface, add Thread::Enter/ExitIsolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/code_observers.h" 7 #include "vm/code_observers.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 #endif 140 #endif
141 Object::FinalizeVMIsolate(vm_isolate_); 141 Object::FinalizeVMIsolate(vm_isolate_);
142 } 142 }
143 // There is a planned and known asymmetry here: We enter one scope for the VM 143 // There is a planned and known asymmetry here: We enter one scope for the VM
144 // isolate so that we can allocate the "persistent" scoped handles for the 144 // isolate so that we can allocate the "persistent" scoped handles for the
145 // predefined API values (such as Dart_True, Dart_False and Dart_Null). 145 // predefined API values (such as Dart_True, Dart_False and Dart_Null).
146 Dart_EnterScope(); 146 Dart_EnterScope();
147 Api::InitHandles(); 147 Api::InitHandles();
148 148
149 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. 149 Thread::ExitIsolate(); // Unregister the VM isolate from this thread.
150 Isolate::SetCreateCallback(create); 150 Isolate::SetCreateCallback(create);
151 Isolate::SetInterruptCallback(interrupt); 151 Isolate::SetInterruptCallback(interrupt);
152 Isolate::SetUnhandledExceptionCallback(unhandled); 152 Isolate::SetUnhandledExceptionCallback(unhandled);
153 Isolate::SetShutdownCallback(shutdown); 153 Isolate::SetShutdownCallback(shutdown);
154 154
155 ServiceIsolate::Run(); 155 ServiceIsolate::Run();
156 156
157 return NULL; 157 return NULL;
158 } 158 }
159 159
160 160
161 const char* Dart::Cleanup() { 161 const char* Dart::Cleanup() {
162 // Shutdown the service isolate before shutting down the thread pool. 162 // Shutdown the service isolate before shutting down the thread pool.
163 ServiceIsolate::Shutdown(); 163 ServiceIsolate::Shutdown();
164 #if 0 164 #if 0
165 // Ideally we should shutdown the VM isolate here, but the thread pool 165 // Ideally we should shutdown the VM isolate here, but the thread pool
166 // shutdown does not seem to ensure that all the threads have stopped 166 // shutdown does not seem to ensure that all the threads have stopped
167 // execution before it terminates, this results in racing isolates. 167 // execution before it terminates, this results in racing isolates.
168 if (vm_isolate_ == NULL) { 168 if (vm_isolate_ == NULL) {
169 return "VM already terminated."; 169 return "VM already terminated.";
170 } 170 }
171 171
172 ASSERT(Isolate::Current() == NULL); 172 ASSERT(Isolate::Current() == NULL);
173 173
174 delete thread_pool_; 174 delete thread_pool_;
175 thread_pool_ = NULL; 175 thread_pool_ = NULL;
176 176
177 // Set the VM isolate as current isolate. 177 // Set the VM isolate as current isolate.
178 Isolate::SetCurrent(vm_isolate_); 178 Thread::EnterIsolate(vm_isolate_);
179 179
180 // There is a planned and known asymmetry here: We exit one scope for the VM 180 // There is a planned and known asymmetry here: We exit one scope for the VM
181 // isolate to account for the scope that was entered in Dart_InitOnce. 181 // isolate to account for the scope that was entered in Dart_InitOnce.
182 Dart_ExitScope(); 182 Dart_ExitScope();
183 183
184 ShutdownIsolate(); 184 ShutdownIsolate();
185 vm_isolate_ = NULL; 185 vm_isolate_ = NULL;
186 186
187 TargetCPUFeatures::Cleanup(); 187 TargetCPUFeatures::Cleanup();
188 #endif 188 #endif
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return predefined_handles_->handles_.AllocateScopedHandle(); 313 return predefined_handles_->handles_.AllocateScopedHandle();
314 } 314 }
315 315
316 316
317 bool Dart::IsReadOnlyHandle(uword address) { 317 bool Dart::IsReadOnlyHandle(uword address) {
318 ASSERT(predefined_handles_ != NULL); 318 ASSERT(predefined_handles_ != NULL);
319 return predefined_handles_->handles_.IsValidScopedHandle(address); 319 return predefined_handles_->handles_.IsValidScopedHandle(address);
320 } 320 }
321 321
322 } // namespace dart 322 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | runtime/vm/dart_api_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698