OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_ISOLATE_H_ | 5 #ifndef VM_ISOLATE_H_ |
6 #define VM_ISOLATE_H_ | 6 #define VM_ISOLATE_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/store_buffer.h" | 10 #include "vm/store_buffer.h" |
11 #include "vm/timer.h" | 11 #include "vm/timer.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class ApiState; | 16 class ApiState; |
17 class BigintStore; | 17 class BigintStore; |
18 class CodeIndexTable; | 18 class CodeIndexTable; |
19 class Debugger; | 19 class Debugger; |
20 class HandleScope; | 20 class HandleScope; |
21 class HandleVisitor; | 21 class HandleVisitor; |
22 class Heap; | 22 class Heap; |
23 class LongJump; | 23 class LongJump; |
24 class Message; | 24 class MessageHandler; |
25 class MessageQueue; | |
26 class Mutex; | 25 class Mutex; |
27 class ObjectPointerVisitor; | 26 class ObjectPointerVisitor; |
28 class ObjectStore; | 27 class ObjectStore; |
29 class RawContext; | 28 class RawContext; |
30 class RawObject; | 29 class RawObject; |
31 class StackResource; | 30 class StackResource; |
32 class StubCode; | 31 class StubCode; |
33 class Zone; | 32 class Zone; |
34 | 33 |
35 class Isolate { | 34 class Isolate { |
(...skipping 14 matching lines...) Expand all Loading... |
50 | 49 |
51 StoreBufferBlock* store_buffer() { return &store_buffer_; } | 50 StoreBufferBlock* store_buffer() { return &store_buffer_; } |
52 | 51 |
53 Dart_MessageNotifyCallback message_notify_callback() const { | 52 Dart_MessageNotifyCallback message_notify_callback() const { |
54 return message_notify_callback_; | 53 return message_notify_callback_; |
55 } | 54 } |
56 void set_message_notify_callback(Dart_MessageNotifyCallback value) { | 55 void set_message_notify_callback(Dart_MessageNotifyCallback value) { |
57 message_notify_callback_ = value; | 56 message_notify_callback_ = value; |
58 } | 57 } |
59 | 58 |
60 MessageQueue* message_queue() const { return message_queue_; } | |
61 void set_message_queue(MessageQueue* value) { message_queue_ = value; } | |
62 | |
63 const char* name() const { return name_; } | 59 const char* name() const { return name_; } |
64 | 60 |
65 // The number of ports is only correct when read from the current | |
66 // isolate. This value is not protected from being updated | |
67 // concurrently. | |
68 intptr_t num_ports() const { return num_ports_; } | |
69 void increment_num_ports() { | |
70 ASSERT(this == Isolate::Current()); | |
71 num_ports_++; | |
72 } | |
73 void decrement_num_ports() { | |
74 ASSERT(this == Isolate::Current()); | |
75 num_ports_--; | |
76 } | |
77 | |
78 intptr_t live_ports() const { return live_ports_; } | |
79 void increment_live_ports() { | |
80 ASSERT(this == Isolate::Current()); | |
81 live_ports_++; | |
82 } | |
83 void decrement_live_ports() { | |
84 ASSERT(this == Isolate::Current()); | |
85 live_ports_--; | |
86 } | |
87 | |
88 Dart_Port main_port() { return main_port_; } | 61 Dart_Port main_port() { return main_port_; } |
89 void set_main_port(Dart_Port port) { | 62 void set_main_port(Dart_Port port) { |
90 ASSERT(main_port_ == 0); // Only set main port once. | 63 ASSERT(main_port_ == 0); // Only set main port once. |
91 main_port_ = port; | 64 main_port_ = port; |
92 } | 65 } |
93 | 66 |
94 Heap* heap() const { return heap_; } | 67 Heap* heap() const { return heap_; } |
95 void set_heap(Heap* value) { heap_ = value; } | 68 void set_heap(Heap* value) { heap_ = value; } |
96 static intptr_t heap_offset() { return OFFSET_OF(Isolate, heap_); } | 69 static intptr_t heap_offset() { return OFFSET_OF(Isolate, heap_); } |
97 | 70 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 enum { | 207 enum { |
235 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. | 208 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. |
236 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. | 209 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. |
237 | 210 |
238 kInterruptsMask = kApiInterrupt | kMessageInterrupt, | 211 kInterruptsMask = kApiInterrupt | kMessageInterrupt, |
239 }; | 212 }; |
240 | 213 |
241 void ScheduleInterrupts(uword interrupt_bits); | 214 void ScheduleInterrupts(uword interrupt_bits); |
242 uword GetAndClearInterrupts(); | 215 uword GetAndClearInterrupts(); |
243 | 216 |
244 void PostMessage(Message* message); | 217 MessageHandler* message_handler() const { return message_handler_; } |
245 void ClosePort(Dart_Port port); | 218 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
246 void CloseAllPorts(); | |
247 | 219 |
248 // Returns null on success, unhandled exception on failure. | 220 // Returns null on success, unhandled exception on failure. |
249 RawObject* StandardRunLoop(); | 221 RawObject* StandardRunLoop(); |
250 | 222 |
251 intptr_t ast_node_id() const { return ast_node_id_; } | 223 intptr_t ast_node_id() const { return ast_node_id_; } |
252 void set_ast_node_id(int value) { ast_node_id_ = value; } | 224 void set_ast_node_id(int value) { ast_node_id_ = value; } |
253 | 225 |
254 Debugger* debugger() const { return debugger_; } | 226 Debugger* debugger() const { return debugger_; } |
255 | 227 |
256 static void SetCreateCallback(Dart_IsolateCreateCallback cback); | 228 static void SetCreateCallback(Dart_IsolateCreateCallback cback); |
257 static Dart_IsolateCreateCallback CreateCallback(); | 229 static Dart_IsolateCreateCallback CreateCallback(); |
258 | 230 |
259 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); | 231 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); |
260 static Dart_IsolateInterruptCallback InterruptCallback(); | 232 static Dart_IsolateInterruptCallback InterruptCallback(); |
261 | 233 |
262 private: | 234 private: |
263 Isolate(); | 235 Isolate(); |
264 | 236 |
265 void BuildName(const char* name_prefix); | 237 void BuildName(const char* name_prefix); |
266 void PrintInvokedFunctions(); | 238 void PrintInvokedFunctions(); |
267 | 239 |
268 static uword GetSpecifiedStackSize(); | 240 static uword GetSpecifiedStackSize(); |
269 | 241 |
270 static const uword kStackSizeBuffer = (128 * KB); | 242 static const uword kStackSizeBuffer = (128 * KB); |
271 static const uword kDefaultStackSize = (1 * MB); | 243 static const uword kDefaultStackSize = (1 * MB); |
272 | 244 |
273 StoreBufferBlock store_buffer_; | 245 StoreBufferBlock store_buffer_; |
274 MessageQueue* message_queue_; | |
275 Dart_MessageNotifyCallback message_notify_callback_; | 246 Dart_MessageNotifyCallback message_notify_callback_; |
276 char* name_; | 247 char* name_; |
277 intptr_t num_ports_; | |
278 intptr_t live_ports_; | |
279 Dart_Port main_port_; | 248 Dart_Port main_port_; |
280 Heap* heap_; | 249 Heap* heap_; |
281 ObjectStore* object_store_; | 250 ObjectStore* object_store_; |
282 StackResource* top_resource_; | 251 StackResource* top_resource_; |
283 RawContext* top_context_; | 252 RawContext* top_context_; |
284 Zone* current_zone_; | 253 Zone* current_zone_; |
285 #if defined(DEBUG) | 254 #if defined(DEBUG) |
286 int32_t no_gc_scope_depth_; | 255 int32_t no_gc_scope_depth_; |
287 int32_t no_handle_scope_depth_; | 256 int32_t no_handle_scope_depth_; |
288 HandleScope* top_handle_scope_; | 257 HandleScope* top_handle_scope_; |
289 #endif | 258 #endif |
290 int32_t random_seed_; | 259 int32_t random_seed_; |
291 BigintStore* bigint_store_; | 260 BigintStore* bigint_store_; |
292 uword top_exit_frame_info_; | 261 uword top_exit_frame_info_; |
293 void* init_callback_data_; | 262 void* init_callback_data_; |
294 Dart_LibraryTagHandler library_tag_handler_; | 263 Dart_LibraryTagHandler library_tag_handler_; |
295 ApiState* api_state_; | 264 ApiState* api_state_; |
296 StubCode* stub_code_; | 265 StubCode* stub_code_; |
297 CodeIndexTable* code_index_table_; | 266 CodeIndexTable* code_index_table_; |
298 Debugger* debugger_; | 267 Debugger* debugger_; |
299 LongJump* long_jump_base_; | 268 LongJump* long_jump_base_; |
300 TimerList timer_list_; | 269 TimerList timer_list_; |
301 intptr_t ast_node_id_; | 270 intptr_t ast_node_id_; |
302 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. | 271 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
303 uword stack_limit_; | 272 uword stack_limit_; |
304 uword saved_stack_limit_; | 273 uword saved_stack_limit_; |
| 274 MessageHandler* message_handler_; |
305 | 275 |
306 static Dart_IsolateCreateCallback create_callback_; | 276 static Dart_IsolateCreateCallback create_callback_; |
307 static Dart_IsolateInterruptCallback interrupt_callback_; | 277 static Dart_IsolateInterruptCallback interrupt_callback_; |
308 | 278 |
309 DISALLOW_COPY_AND_ASSIGN(Isolate); | 279 DISALLOW_COPY_AND_ASSIGN(Isolate); |
310 }; | 280 }; |
311 | 281 |
312 } // namespace dart | 282 } // namespace dart |
313 | 283 |
314 #if defined(TARGET_OS_LINUX) | 284 #if defined(TARGET_OS_LINUX) |
315 #include "vm/isolate_linux.h" | 285 #include "vm/isolate_linux.h" |
316 #elif defined(TARGET_OS_MACOS) | 286 #elif defined(TARGET_OS_MACOS) |
317 #include "vm/isolate_macos.h" | 287 #include "vm/isolate_macos.h" |
318 #elif defined(TARGET_OS_WINDOWS) | 288 #elif defined(TARGET_OS_WINDOWS) |
319 #include "vm/isolate_win.h" | 289 #include "vm/isolate_win.h" |
320 #else | 290 #else |
321 #error Unknown target os. | 291 #error Unknown target os. |
322 #endif | 292 #endif |
323 | 293 |
324 #endif // VM_ISOLATE_H_ | 294 #endif // VM_ISOLATE_H_ |
OLD | NEW |