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

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

Issue 584023004: Service isolate rework (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 85
86 const char* Dart::InitOnce(Dart_IsolateCreateCallback create, 86 const char* Dart::InitOnce(Dart_IsolateCreateCallback create,
87 Dart_IsolateInterruptCallback interrupt, 87 Dart_IsolateInterruptCallback interrupt,
88 Dart_IsolateUnhandledExceptionCallback unhandled, 88 Dart_IsolateUnhandledExceptionCallback unhandled,
89 Dart_IsolateShutdownCallback shutdown, 89 Dart_IsolateShutdownCallback shutdown,
90 Dart_FileOpenCallback file_open, 90 Dart_FileOpenCallback file_open,
91 Dart_FileReadCallback file_read, 91 Dart_FileReadCallback file_read,
92 Dart_FileWriteCallback file_write, 92 Dart_FileWriteCallback file_write,
93 Dart_FileCloseCallback file_close, 93 Dart_FileCloseCallback file_close,
94 Dart_EntropySource entropy_source, 94 Dart_EntropySource entropy_source) {
95 Dart_ServiceIsolateCreateCalback service_create) {
96 // TODO(iposva): Fix race condition here. 95 // TODO(iposva): Fix race condition here.
97 if (vm_isolate_ != NULL || !Flags::Initialized()) { 96 if (vm_isolate_ != NULL || !Flags::Initialized()) {
98 return "VM already initialized."; 97 return "VM already initialized.";
99 } 98 }
100 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); 99 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close);
101 Isolate::SetEntropySourceCallback(entropy_source); 100 Isolate::SetEntropySourceCallback(entropy_source);
102 OS::InitOnce(); 101 OS::InitOnce();
103 VirtualMemory::InitOnce(); 102 VirtualMemory::InitOnce();
104 Isolate::InitOnce(); 103 Isolate::InitOnce();
105 PortMap::InitOnce(); 104 PortMap::InitOnce();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 vm_isolate_->heap()->WriteProtect(true); 148 vm_isolate_->heap()->WriteProtect(true);
150 } 149 }
151 // There is a planned and known asymmetry here: We enter one scope for the VM 150 // There is a planned and known asymmetry here: We enter one scope for the VM
152 // isolate so that we can allocate the "persistent" scoped handles for the 151 // isolate so that we can allocate the "persistent" scoped handles for the
153 // predefined API values (such as Dart_True, Dart_False and Dart_Null). 152 // predefined API values (such as Dart_True, Dart_False and Dart_Null).
154 Dart_EnterScope(); 153 Dart_EnterScope();
155 Api::InitHandles(); 154 Api::InitHandles();
156 155
157 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. 156 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread.
158 Isolate::SetCreateCallback(create); 157 Isolate::SetCreateCallback(create);
159 Isolate::SetServiceCreateCallback(service_create);
160 Isolate::SetInterruptCallback(interrupt); 158 Isolate::SetInterruptCallback(interrupt);
161 Isolate::SetUnhandledExceptionCallback(unhandled); 159 Isolate::SetUnhandledExceptionCallback(unhandled);
162 Isolate::SetShutdownCallback(shutdown); 160 Isolate::SetShutdownCallback(shutdown);
161
162 Service::RunService();
163
163 return NULL; 164 return NULL;
164 } 165 }
165 166
166 167
167 const char* Dart::Cleanup() { 168 const char* Dart::Cleanup() {
168 #if 0 169 #if 0
169 // Ideally we should shutdown the VM isolate here, but the thread pool 170 // Ideally we should shutdown the VM isolate here, but the thread pool
170 // shutdown does not seem to ensure that all the threads have stopped 171 // shutdown does not seem to ensure that all the threads have stopped
171 // execution before it terminates, this results in racing isolates. 172 // execution before it terminates, this results in racing isolates.
172 if (vm_isolate_ == NULL) { 173 if (vm_isolate_ == NULL) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 266 }
266 isolate->megamorphic_cache_table()->InitMissHandler(); 267 isolate->megamorphic_cache_table()->InitMissHandler();
267 268
268 isolate->heap()->EnableGrowthControl(); 269 isolate->heap()->EnableGrowthControl();
269 isolate->set_init_callback_data(data); 270 isolate->set_init_callback_data(data);
270 Api::SetupAcquiredError(isolate); 271 Api::SetupAcquiredError(isolate);
271 if (FLAG_print_class_table) { 272 if (FLAG_print_class_table) {
272 isolate->class_table()->Print(); 273 isolate->class_table()->Print();
273 } 274 }
274 275
275
276 Service::SendIsolateStartupMessage(); 276 Service::SendIsolateStartupMessage();
277 // Create tag table. 277 // Create tag table.
278 isolate->set_tag_table( 278 isolate->set_tag_table(
279 GrowableObjectArray::Handle(GrowableObjectArray::New())); 279 GrowableObjectArray::Handle(GrowableObjectArray::New()));
280 // Set up default UserTag. 280 // Set up default UserTag.
281 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag()); 281 const UserTag& default_tag = UserTag::Handle(UserTag::DefaultTag());
282 isolate->set_current_tag(default_tag); 282 isolate->set_current_tag(default_tag);
283 283
284 Service::MaybeInjectVMServiceLibrary(isolate);
285
284 return Error::null(); 286 return Error::null();
285 } 287 }
286 288
287 289
288 void Dart::RunShutdownCallback() { 290 void Dart::RunShutdownCallback() {
289 Isolate* isolate = Isolate::Current(); 291 Isolate* isolate = Isolate::Current();
290 void* callback_data = isolate->init_callback_data(); 292 void* callback_data = isolate->init_callback_data();
291 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); 293 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback();
292 Service::SendIsolateShutdownMessage(); 294 Service::SendIsolateShutdownMessage();
293 if (callback != NULL) { 295 if (callback != NULL) {
(...skipping 15 matching lines...) Expand all
309 return predefined_handles_->handles_.AllocateScopedHandle(); 311 return predefined_handles_->handles_.AllocateScopedHandle();
310 } 312 }
311 313
312 314
313 bool Dart::IsReadOnlyHandle(uword address) { 315 bool Dart::IsReadOnlyHandle(uword address) {
314 ASSERT(predefined_handles_ != NULL); 316 ASSERT(predefined_handles_ != NULL);
315 return predefined_handles_->handles_.IsValidScopedHandle(address); 317 return predefined_handles_->handles_.IsValidScopedHandle(address);
316 } 318 }
317 319
318 } // namespace dart 320 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698