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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 class Zone; | 32 class Zone; |
33 | 33 |
34 class Isolate { | 34 class Isolate { |
35 public: | 35 public: |
36 ~Isolate(); | 36 ~Isolate(); |
37 | 37 |
38 static inline Isolate* Current(); | 38 static inline Isolate* Current(); |
39 static void SetCurrent(Isolate* isolate); | 39 static void SetCurrent(Isolate* isolate); |
40 | 40 |
41 static void InitOnce(); | 41 static void InitOnce(); |
42 static Isolate* Init(); | 42 static Isolate* Init(const char* name_prefix); |
43 void Shutdown(); | 43 void Shutdown(); |
44 | 44 |
45 // Visit all object pointers. | 45 // Visit all object pointers. |
46 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); | 46 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); |
47 | 47 |
48 void VisitWeakPersistentHandles(HandleVisitor* visitor); | 48 void VisitWeakPersistentHandles(HandleVisitor* visitor); |
49 | 49 |
50 StoreBufferBlock* store_buffer() { return &store_buffer_; } | 50 StoreBufferBlock* store_buffer() { return &store_buffer_; } |
51 | 51 |
52 Dart_PostMessageCallback post_message_callback() const { | 52 Dart_PostMessageCallback post_message_callback() const { |
53 return post_message_callback_; | 53 return post_message_callback_; |
54 } | 54 } |
55 void set_post_message_callback(Dart_PostMessageCallback value) { | 55 void set_post_message_callback(Dart_PostMessageCallback value) { |
56 post_message_callback_ = value; | 56 post_message_callback_ = value; |
57 } | 57 } |
58 | 58 |
59 Dart_ClosePortCallback close_port_callback() const { | 59 Dart_ClosePortCallback close_port_callback() const { |
60 return close_port_callback_; | 60 return close_port_callback_; |
61 } | 61 } |
62 void set_close_port_callback(Dart_ClosePortCallback value) { | 62 void set_close_port_callback(Dart_ClosePortCallback value) { |
63 close_port_callback_ = value; | 63 close_port_callback_ = value; |
64 } | 64 } |
65 | 65 |
66 MessageQueue* message_queue() const { return message_queue_; } | 66 MessageQueue* message_queue() const { return message_queue_; } |
67 void set_message_queue(MessageQueue* value) { message_queue_ = value; } | 67 void set_message_queue(MessageQueue* value) { message_queue_ = value; } |
68 | 68 |
| 69 const char* name() const { return name_; } |
| 70 |
69 // The number of ports is only correct when read from the current | 71 // The number of ports is only correct when read from the current |
70 // isolate. This value is not protected from being updated | 72 // isolate. This value is not protected from being updated |
71 // concurrently. | 73 // concurrently. |
72 intptr_t num_ports() const { return num_ports_; } | 74 intptr_t num_ports() const { return num_ports_; } |
73 void increment_num_ports() { | 75 void increment_num_ports() { |
74 ASSERT(this == Isolate::Current()); | 76 ASSERT(this == Isolate::Current()); |
75 num_ports_++; | 77 num_ports_++; |
76 } | 78 } |
77 void decrement_num_ports() { | 79 void decrement_num_ports() { |
78 ASSERT(this == Isolate::Current()); | 80 ASSERT(this == Isolate::Current()); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 256 |
255 static void SetCreateCallback(Dart_IsolateCreateCallback cback); | 257 static void SetCreateCallback(Dart_IsolateCreateCallback cback); |
256 static Dart_IsolateCreateCallback CreateCallback(); | 258 static Dart_IsolateCreateCallback CreateCallback(); |
257 | 259 |
258 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); | 260 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); |
259 static Dart_IsolateInterruptCallback InterruptCallback(); | 261 static Dart_IsolateInterruptCallback InterruptCallback(); |
260 | 262 |
261 private: | 263 private: |
262 Isolate(); | 264 Isolate(); |
263 | 265 |
| 266 void BuildName(const char* name_prefix); |
264 void PrintInvokedFunctions(); | 267 void PrintInvokedFunctions(); |
265 | 268 |
266 static uword GetSpecifiedStackSize(); | 269 static uword GetSpecifiedStackSize(); |
267 | 270 |
268 static const uword kStackSizeBuffer = (128 * KB); | 271 static const uword kStackSizeBuffer = (128 * KB); |
269 static const uword kDefaultStackSize = (1 * MB); | 272 static const uword kDefaultStackSize = (1 * MB); |
270 | 273 |
271 StoreBufferBlock store_buffer_; | 274 StoreBufferBlock store_buffer_; |
272 MessageQueue* message_queue_; | 275 MessageQueue* message_queue_; |
273 Dart_PostMessageCallback post_message_callback_; | 276 Dart_PostMessageCallback post_message_callback_; |
274 Dart_ClosePortCallback close_port_callback_; | 277 Dart_ClosePortCallback close_port_callback_; |
| 278 char* name_; |
275 intptr_t num_ports_; | 279 intptr_t num_ports_; |
276 intptr_t live_ports_; | 280 intptr_t live_ports_; |
277 Dart_Port main_port_; | 281 Dart_Port main_port_; |
278 Heap* heap_; | 282 Heap* heap_; |
279 ObjectStore* object_store_; | 283 ObjectStore* object_store_; |
280 StackResource* top_resource_; | 284 StackResource* top_resource_; |
281 RawContext* top_context_; | 285 RawContext* top_context_; |
282 Zone* current_zone_; | 286 Zone* current_zone_; |
283 #if defined(DEBUG) | 287 #if defined(DEBUG) |
284 int32_t no_gc_scope_depth_; | 288 int32_t no_gc_scope_depth_; |
(...skipping 28 matching lines...) Expand all Loading... |
313 #include "vm/isolate_linux.h" | 317 #include "vm/isolate_linux.h" |
314 #elif defined(TARGET_OS_MACOS) | 318 #elif defined(TARGET_OS_MACOS) |
315 #include "vm/isolate_macos.h" | 319 #include "vm/isolate_macos.h" |
316 #elif defined(TARGET_OS_WINDOWS) | 320 #elif defined(TARGET_OS_WINDOWS) |
317 #include "vm/isolate_win.h" | 321 #include "vm/isolate_win.h" |
318 #else | 322 #else |
319 #error Unknown target os. | 323 #error Unknown target os. |
320 #endif | 324 #endif |
321 | 325 |
322 #endif // VM_ISOLATE_H_ | 326 #endif // VM_ISOLATE_H_ |
OLD | NEW |