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 MessageQueue; | 25 class MessageQueue; |
25 class Mutex; | 26 class Mutex; |
26 class ObjectPointerVisitor; | 27 class ObjectPointerVisitor; |
27 class ObjectStore; | 28 class ObjectStore; |
28 class RawContext; | 29 class RawContext; |
29 class RawObject; | 30 class RawObject; |
30 class StackResource; | 31 class StackResource; |
31 class StubCode; | 32 class StubCode; |
32 class Zone; | 33 class Zone; |
33 | 34 |
34 class Isolate { | 35 class Isolate { |
35 public: | 36 public: |
36 ~Isolate(); | 37 ~Isolate(); |
37 | 38 |
38 static inline Isolate* Current(); | 39 static inline Isolate* Current(); |
39 static void SetCurrent(Isolate* isolate); | 40 static void SetCurrent(Isolate* isolate); |
40 | 41 |
41 static void InitOnce(); | 42 static void InitOnce(); |
42 static Isolate* Init(const char* name_prefix); | 43 static Isolate* Init(const char* name_prefix); |
43 void Shutdown(); | 44 void Shutdown(); |
44 | 45 |
45 // Visit all object pointers. | 46 // Visit all object pointers. |
46 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); | 47 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); |
47 | 48 |
48 void VisitWeakPersistentHandles(HandleVisitor* visitor); | 49 void VisitWeakPersistentHandles(HandleVisitor* visitor); |
49 | 50 |
50 StoreBufferBlock* store_buffer() { return &store_buffer_; } | 51 StoreBufferBlock* store_buffer() { return &store_buffer_; } |
51 | 52 |
52 Dart_PostMessageCallback post_message_callback() const { | 53 Dart_MessageNotifyCallback message_notify_callback() const { |
53 return post_message_callback_; | 54 return message_notify_callback_; |
54 } | 55 } |
55 void set_post_message_callback(Dart_PostMessageCallback value) { | 56 void set_message_notify_callback(Dart_MessageNotifyCallback value) { |
56 post_message_callback_ = value; | 57 message_notify_callback_ = value; |
57 } | |
58 | |
59 Dart_ClosePortCallback close_port_callback() const { | |
60 return close_port_callback_; | |
61 } | |
62 void set_close_port_callback(Dart_ClosePortCallback value) { | |
63 close_port_callback_ = value; | |
64 } | 58 } |
65 | 59 |
66 MessageQueue* message_queue() const { return message_queue_; } | 60 MessageQueue* message_queue() const { return message_queue_; } |
67 void set_message_queue(MessageQueue* value) { message_queue_ = value; } | 61 void set_message_queue(MessageQueue* value) { message_queue_ = value; } |
68 | 62 |
69 const char* name() const { return name_; } | 63 const char* name() const { return name_; } |
70 | 64 |
71 // The number of ports is only correct when read from the current | 65 // The number of ports is only correct when read from the current |
72 // isolate. This value is not protected from being updated | 66 // isolate. This value is not protected from being updated |
73 // concurrently. | 67 // concurrently. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 225 |
232 // The current stack limit. This may be overwritten with a special | 226 // The current stack limit. This may be overwritten with a special |
233 // value to trigger interrupts. | 227 // value to trigger interrupts. |
234 uword stack_limit() const { return stack_limit_; } | 228 uword stack_limit() const { return stack_limit_; } |
235 | 229 |
236 // The true stack limit for this isolate. This does not change | 230 // The true stack limit for this isolate. This does not change |
237 // after isolate initialization. | 231 // after isolate initialization. |
238 uword saved_stack_limit() const { return saved_stack_limit_; } | 232 uword saved_stack_limit() const { return saved_stack_limit_; } |
239 | 233 |
240 enum { | 234 enum { |
241 kInterruptsMask = 0x1, | 235 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. |
242 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. | 236 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. |
243 // More interrupt types will go here. | 237 |
| 238 kInterruptsMask = kApiInterrupt | kMessageInterrupt, |
244 }; | 239 }; |
245 | 240 |
246 void ScheduleInterrupts(uword interrupt_bits); | 241 void ScheduleInterrupts(uword interrupt_bits); |
247 uword GetAndClearInterrupts(); | 242 uword GetAndClearInterrupts(); |
248 | 243 |
| 244 void PostMessage(Message* message); |
| 245 void ClosePort(Dart_Port port); |
| 246 void CloseAllPorts(); |
| 247 |
249 // Returns null on success, unhandled exception on failure. | 248 // Returns null on success, unhandled exception on failure. |
250 RawObject* StandardRunLoop(); | 249 RawObject* StandardRunLoop(); |
251 | 250 |
252 intptr_t ast_node_id() const { return ast_node_id_; } | 251 intptr_t ast_node_id() const { return ast_node_id_; } |
253 void set_ast_node_id(int value) { ast_node_id_ = value; } | 252 void set_ast_node_id(int value) { ast_node_id_ = value; } |
254 | 253 |
255 Debugger* debugger() const { return debugger_; } | 254 Debugger* debugger() const { return debugger_; } |
256 | 255 |
257 static void SetCreateCallback(Dart_IsolateCreateCallback cback); | 256 static void SetCreateCallback(Dart_IsolateCreateCallback cback); |
258 static Dart_IsolateCreateCallback CreateCallback(); | 257 static Dart_IsolateCreateCallback CreateCallback(); |
259 | 258 |
260 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); | 259 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); |
261 static Dart_IsolateInterruptCallback InterruptCallback(); | 260 static Dart_IsolateInterruptCallback InterruptCallback(); |
262 | 261 |
263 private: | 262 private: |
264 Isolate(); | 263 Isolate(); |
265 | 264 |
266 void BuildName(const char* name_prefix); | 265 void BuildName(const char* name_prefix); |
267 void PrintInvokedFunctions(); | 266 void PrintInvokedFunctions(); |
268 | 267 |
269 static uword GetSpecifiedStackSize(); | 268 static uword GetSpecifiedStackSize(); |
270 | 269 |
271 static const uword kStackSizeBuffer = (128 * KB); | 270 static const uword kStackSizeBuffer = (128 * KB); |
272 static const uword kDefaultStackSize = (1 * MB); | 271 static const uword kDefaultStackSize = (1 * MB); |
273 | 272 |
274 StoreBufferBlock store_buffer_; | 273 StoreBufferBlock store_buffer_; |
275 MessageQueue* message_queue_; | 274 MessageQueue* message_queue_; |
276 Dart_PostMessageCallback post_message_callback_; | 275 Dart_MessageNotifyCallback message_notify_callback_; |
277 Dart_ClosePortCallback close_port_callback_; | |
278 char* name_; | 276 char* name_; |
279 intptr_t num_ports_; | 277 intptr_t num_ports_; |
280 intptr_t live_ports_; | 278 intptr_t live_ports_; |
281 Dart_Port main_port_; | 279 Dart_Port main_port_; |
282 Heap* heap_; | 280 Heap* heap_; |
283 ObjectStore* object_store_; | 281 ObjectStore* object_store_; |
284 StackResource* top_resource_; | 282 StackResource* top_resource_; |
285 RawContext* top_context_; | 283 RawContext* top_context_; |
286 Zone* current_zone_; | 284 Zone* current_zone_; |
287 #if defined(DEBUG) | 285 #if defined(DEBUG) |
(...skipping 29 matching lines...) Expand all Loading... |
317 #include "vm/isolate_linux.h" | 315 #include "vm/isolate_linux.h" |
318 #elif defined(TARGET_OS_MACOS) | 316 #elif defined(TARGET_OS_MACOS) |
319 #include "vm/isolate_macos.h" | 317 #include "vm/isolate_macos.h" |
320 #elif defined(TARGET_OS_WINDOWS) | 318 #elif defined(TARGET_OS_WINDOWS) |
321 #include "vm/isolate_win.h" | 319 #include "vm/isolate_win.h" |
322 #else | 320 #else |
323 #error Unknown target os. | 321 #error Unknown target os. |
324 #endif | 322 #endif |
325 | 323 |
326 #endif // VM_ISOLATE_H_ | 324 #endif // VM_ISOLATE_H_ |
OLD | NEW |