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

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

Issue 125103004: Move service into VM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
11 #include "vm/freelist.h" 11 #include "vm/freelist.h"
12 #include "vm/handles.h" 12 #include "vm/handles.h"
13 #include "vm/heap.h" 13 #include "vm/heap.h"
14 #include "vm/isolate.h" 14 #include "vm/isolate.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_store.h" 16 #include "vm/object_store.h"
17 #include "vm/object_id_ring.h" 17 #include "vm/object_id_ring.h"
18 #include "vm/port.h" 18 #include "vm/port.h"
19 #include "vm/profiler.h" 19 #include "vm/profiler.h"
20 #include "vm/service.h"
20 #include "vm/simulator.h" 21 #include "vm/simulator.h"
21 #include "vm/snapshot.h" 22 #include "vm/snapshot.h"
22 #include "vm/stub_code.h" 23 #include "vm/stub_code.h"
23 #include "vm/symbols.h" 24 #include "vm/symbols.h"
24 #include "vm/thread_interrupter.h" 25 #include "vm/thread_interrupter.h"
25 #include "vm/thread_pool.h" 26 #include "vm/thread_pool.h"
26 #include "vm/virtual_memory.h" 27 #include "vm/virtual_memory.h"
27 #include "vm/zone.h" 28 #include "vm/zone.h"
28 29
29 namespace dart { 30 namespace dart {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 79
79 const char* Dart::InitOnce(Dart_IsolateCreateCallback create, 80 const char* Dart::InitOnce(Dart_IsolateCreateCallback create,
80 Dart_IsolateInterruptCallback interrupt, 81 Dart_IsolateInterruptCallback interrupt,
81 Dart_IsolateUnhandledExceptionCallback unhandled, 82 Dart_IsolateUnhandledExceptionCallback unhandled,
82 Dart_IsolateShutdownCallback shutdown, 83 Dart_IsolateShutdownCallback shutdown,
83 Dart_FileOpenCallback file_open, 84 Dart_FileOpenCallback file_open,
84 Dart_FileReadCallback file_read, 85 Dart_FileReadCallback file_read,
85 Dart_FileWriteCallback file_write, 86 Dart_FileWriteCallback file_write,
86 Dart_FileCloseCallback file_close, 87 Dart_FileCloseCallback file_close,
87 Dart_EntropySource entropy_source) { 88 Dart_EntropySource entropy_source,
89 Dart_ServiceIsolateCreateCalback service_create) {
88 // TODO(iposva): Fix race condition here. 90 // TODO(iposva): Fix race condition here.
89 if (vm_isolate_ != NULL || !Flags::Initialized()) { 91 if (vm_isolate_ != NULL || !Flags::Initialized()) {
90 return "VM already initialized."; 92 return "VM already initialized.";
91 } 93 }
92 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close); 94 Isolate::SetFileCallbacks(file_open, file_read, file_write, file_close);
93 Isolate::SetEntropySourceCallback(entropy_source); 95 Isolate::SetEntropySourceCallback(entropy_source);
94 OS::InitOnce(); 96 OS::InitOnce();
95 VirtualMemory::InitOnce(); 97 VirtualMemory::InitOnce();
96 Isolate::InitOnce(); 98 Isolate::InitOnce();
97 PortMap::InitOnce(); 99 PortMap::InitOnce();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 vm_isolate_->heap()->WriteProtect(true); 136 vm_isolate_->heap()->WriteProtect(true);
135 } 137 }
136 // There is a planned and known asymmetry here: We enter one scope for the VM 138 // There is a planned and known asymmetry here: We enter one scope for the VM
137 // isolate so that we can allocate the "persistent" scoped handles for the 139 // isolate so that we can allocate the "persistent" scoped handles for the
138 // predefined API values (such as Dart_True, Dart_False and Dart_Null). 140 // predefined API values (such as Dart_True, Dart_False and Dart_Null).
139 Dart_EnterScope(); 141 Dart_EnterScope();
140 Api::InitHandles(); 142 Api::InitHandles();
141 143
142 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread. 144 Isolate::SetCurrent(NULL); // Unregister the VM isolate from this thread.
143 Isolate::SetCreateCallback(create); 145 Isolate::SetCreateCallback(create);
146 Isolate::SetServiceCreateCallback(service_create);
144 Isolate::SetInterruptCallback(interrupt); 147 Isolate::SetInterruptCallback(interrupt);
145 Isolate::SetUnhandledExceptionCallback(unhandled); 148 Isolate::SetUnhandledExceptionCallback(unhandled);
146 Isolate::SetShutdownCallback(shutdown); 149 Isolate::SetShutdownCallback(shutdown);
147 return NULL; 150 return NULL;
148 } 151 }
149 152
150 153
151 const char* Dart::Cleanup() { 154 const char* Dart::Cleanup() {
152 #if 0 155 #if 0
153 // Ideally we should shutdown the VM isolate here, but the thread pool 156 // Ideally we should shutdown the VM isolate here, but the thread pool
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 240 }
238 } 241 }
239 isolate->megamorphic_cache_table()->InitMissHandler(); 242 isolate->megamorphic_cache_table()->InitMissHandler();
240 243
241 isolate->heap()->EnableGrowthControl(); 244 isolate->heap()->EnableGrowthControl();
242 isolate->set_init_callback_data(data); 245 isolate->set_init_callback_data(data);
243 Api::SetupAcquiredError(isolate); 246 Api::SetupAcquiredError(isolate);
244 if (FLAG_print_class_table) { 247 if (FLAG_print_class_table) {
245 isolate->class_table()->Print(); 248 isolate->class_table()->Print();
246 } 249 }
250 Service::SendIsolateStartupMessage();
247 return Error::null(); 251 return Error::null();
248 } 252 }
249 253
250 254
251 void Dart::RunShutdownCallback() { 255 void Dart::RunShutdownCallback() {
252 Isolate* isolate = Isolate::Current(); 256 Isolate* isolate = Isolate::Current();
253 void* callback_data = isolate->init_callback_data(); 257 void* callback_data = isolate->init_callback_data();
254 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback(); 258 Dart_IsolateShutdownCallback callback = Isolate::ShutdownCallback();
259 Service::SendIsolateShutdownMessage();
255 if (callback != NULL) { 260 if (callback != NULL) {
256 (callback)(callback_data); 261 (callback)(callback_data);
257 } 262 }
258 } 263 }
259 264
260 265
261 void Dart::ShutdownIsolate() { 266 void Dart::ShutdownIsolate() {
262 Isolate* isolate = Isolate::Current(); 267 Isolate* isolate = Isolate::Current();
263 isolate->Shutdown(); 268 isolate->Shutdown();
264 delete isolate; 269 delete isolate;
265 } 270 }
266 271
267 272
268 uword Dart::AllocateReadOnlyHandle() { 273 uword Dart::AllocateReadOnlyHandle() {
269 ASSERT(Isolate::Current() == Dart::vm_isolate()); 274 ASSERT(Isolate::Current() == Dart::vm_isolate());
270 ASSERT(predefined_handles_ != NULL); 275 ASSERT(predefined_handles_ != NULL);
271 return predefined_handles_->handles_.AllocateScopedHandle(); 276 return predefined_handles_->handles_.AllocateScopedHandle();
272 } 277 }
273 278
274 279
275 bool Dart::IsReadOnlyHandle(uword address) { 280 bool Dart::IsReadOnlyHandle(uword address) {
276 ASSERT(predefined_handles_ != NULL); 281 ASSERT(predefined_handles_ != NULL);
277 return predefined_handles_->handles_.IsValidScopedHandle(address); 282 return predefined_handles_->handles_.IsValidScopedHandle(address);
278 } 283 }
279 284
280 } // namespace dart 285 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698