| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 <limits.h> | 8 #include <limits.h> |
| 9 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| 11 #include "vm/assert.h" | 11 #include "vm/assert.h" |
| 12 #include "vm/store_buffer.h" | 12 #include "vm/store_buffer.h" |
| 13 #include "vm/timer.h" | 13 #include "vm/timer.h" |
| 14 | 14 |
| 15 namespace dart { | 15 namespace dart { |
| 16 | 16 |
| 17 // Forward declarations. | 17 // Forward declarations. |
| 18 class ApiState; | 18 class ApiState; |
| 19 class BigintStore; | 19 class BigintStore; |
| 20 class CodeIndexTable; | 20 class CodeIndexTable; |
| 21 class Debugger; | 21 class Debugger; |
| 22 class HandleScope; | 22 class HandleScope; |
| 23 class Heap; | 23 class Heap; |
| 24 class LongJump; | 24 class LongJump; |
| 25 class MessageQueue; | 25 class MessageQueue; |
| 26 class Monitor; | 26 class Mutex; |
| 27 class ObjectPointerVisitor; | 27 class ObjectPointerVisitor; |
| 28 class ObjectStore; | 28 class ObjectStore; |
| 29 class RawContext; | 29 class RawContext; |
| 30 class StackResource; | 30 class StackResource; |
| 31 class StubCode; | 31 class StubCode; |
| 32 class Zone; | 32 class Zone; |
| 33 | 33 |
| 34 class Isolate { | 34 class Isolate { |
| 35 public: | 35 public: |
| 36 ~Isolate(); | 36 ~Isolate(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return init_callback_data_; | 211 return init_callback_data_; |
| 212 } | 212 } |
| 213 | 213 |
| 214 Dart_LibraryTagHandler library_tag_handler() const { | 214 Dart_LibraryTagHandler library_tag_handler() const { |
| 215 return library_tag_handler_; | 215 return library_tag_handler_; |
| 216 } | 216 } |
| 217 void set_library_tag_handler(Dart_LibraryTagHandler value) { | 217 void set_library_tag_handler(Dart_LibraryTagHandler value) { |
| 218 library_tag_handler_ = value; | 218 library_tag_handler_ = value; |
| 219 } | 219 } |
| 220 | 220 |
| 221 static void SetCreateCallback(Dart_IsolateCreateCallback cback); | 221 void SetStackLimit(uword value); |
| 222 static Dart_IsolateCreateCallback CreateCallback(); | 222 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); |
| 223 | 223 |
| 224 uword stack_limit_address() const { | 224 uword stack_limit_address() const { |
| 225 return reinterpret_cast<uword>(&stack_limit_); | 225 return reinterpret_cast<uword>(&stack_limit_); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void SetStackLimit(uword value); | 228 // The current stack limit. This may be overwritten with a special |
| 229 // value to trigger interrupts. |
| 229 uword stack_limit() const { return stack_limit_; } | 230 uword stack_limit() const { return stack_limit_; } |
| 230 | 231 |
| 231 void SetStackLimitFromCurrentTOS(uword isolate_stack_top); | 232 // The true stack limit for this isolate. This does not change |
| 233 // after isolate initialization. |
| 234 uword saved_stack_limit() const { return saved_stack_limit_; } |
| 235 |
| 236 enum { |
| 237 kInterruptsMask = 0x1, |
| 238 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. |
| 239 // More interrupt types will go here. |
| 240 }; |
| 241 |
| 242 void ScheduleInterrupts(uword interrupt_bits); |
| 243 uword GetAndClearInterrupts(); |
| 232 | 244 |
| 233 void StandardRunLoop(); | 245 void StandardRunLoop(); |
| 234 | 246 |
| 235 intptr_t ast_node_id() const { return ast_node_id_; } | 247 intptr_t ast_node_id() const { return ast_node_id_; } |
| 236 void set_ast_node_id(int value) { ast_node_id_ = value; } | 248 void set_ast_node_id(int value) { ast_node_id_ = value; } |
| 237 | 249 |
| 238 Debugger* debugger() const { return debugger_; } | 250 Debugger* debugger() const { return debugger_; } |
| 239 | 251 |
| 252 static void SetCreateCallback(Dart_IsolateCreateCallback cback); |
| 253 static Dart_IsolateCreateCallback CreateCallback(); |
| 254 |
| 255 static void SetInterruptCallback(Dart_IsolateInterruptCallback cback); |
| 256 static Dart_IsolateInterruptCallback InterruptCallback(); |
| 257 |
| 240 private: | 258 private: |
| 241 Isolate(); | 259 Isolate(); |
| 242 | 260 |
| 243 void PrintInvokedFunctions(); | 261 void PrintInvokedFunctions(); |
| 244 | 262 |
| 245 static uword GetSpecifiedStackSize(); | 263 static uword GetSpecifiedStackSize(); |
| 246 | 264 |
| 247 static const uword kStackSizeBuffer = (128 * KB); | 265 static const uword kStackSizeBuffer = (128 * KB); |
| 248 static const uword kDefaultStackSize = (1 * MB); | 266 static const uword kDefaultStackSize = (1 * MB); |
| 249 | 267 |
| 250 StoreBufferBlock store_buffer_; | 268 StoreBufferBlock store_buffer_; |
| 251 Monitor* monitor_; | |
| 252 MessageQueue* message_queue_; | 269 MessageQueue* message_queue_; |
| 253 Dart_PostMessageCallback post_message_callback_; | 270 Dart_PostMessageCallback post_message_callback_; |
| 254 Dart_ClosePortCallback close_port_callback_; | 271 Dart_ClosePortCallback close_port_callback_; |
| 255 intptr_t num_ports_; | 272 intptr_t num_ports_; |
| 256 intptr_t live_ports_; | 273 intptr_t live_ports_; |
| 257 Dart_Port main_port_; | 274 Dart_Port main_port_; |
| 258 Heap* heap_; | 275 Heap* heap_; |
| 259 ObjectStore* object_store_; | 276 ObjectStore* object_store_; |
| 260 StackResource* top_resource_; | 277 StackResource* top_resource_; |
| 261 RawContext* top_context_; | 278 RawContext* top_context_; |
| 262 Zone* current_zone_; | 279 Zone* current_zone_; |
| 263 #if defined(DEBUG) | 280 #if defined(DEBUG) |
| 264 int32_t no_gc_scope_depth_; | 281 int32_t no_gc_scope_depth_; |
| 265 int32_t no_handle_scope_depth_; | 282 int32_t no_handle_scope_depth_; |
| 266 HandleScope* top_handle_scope_; | 283 HandleScope* top_handle_scope_; |
| 267 #endif | 284 #endif |
| 268 int32_t random_seed_; | 285 int32_t random_seed_; |
| 269 BigintStore* bigint_store_; | 286 BigintStore* bigint_store_; |
| 270 uword top_exit_frame_info_; | 287 uword top_exit_frame_info_; |
| 271 void* init_callback_data_; | 288 void* init_callback_data_; |
| 272 Dart_LibraryTagHandler library_tag_handler_; | 289 Dart_LibraryTagHandler library_tag_handler_; |
| 273 ApiState* api_state_; | 290 ApiState* api_state_; |
| 274 StubCode* stub_code_; | 291 StubCode* stub_code_; |
| 275 CodeIndexTable* code_index_table_; | 292 CodeIndexTable* code_index_table_; |
| 276 Debugger* debugger_; | 293 Debugger* debugger_; |
| 277 LongJump* long_jump_base_; | 294 LongJump* long_jump_base_; |
| 278 TimerList timer_list_; | 295 TimerList timer_list_; |
| 296 intptr_t ast_node_id_; |
| 297 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
| 279 uword stack_limit_; | 298 uword stack_limit_; |
| 280 intptr_t ast_node_id_; | 299 uword saved_stack_limit_; |
| 281 | 300 |
| 282 static Dart_IsolateCreateCallback create_callback_; | 301 static Dart_IsolateCreateCallback create_callback_; |
| 302 static Dart_IsolateInterruptCallback interrupt_callback_; |
| 283 | 303 |
| 284 DISALLOW_COPY_AND_ASSIGN(Isolate); | 304 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 285 }; | 305 }; |
| 286 | 306 |
| 287 } // namespace dart | 307 } // namespace dart |
| 288 | 308 |
| 289 #if defined(TARGET_OS_LINUX) | 309 #if defined(TARGET_OS_LINUX) |
| 290 #include "vm/isolate_linux.h" | 310 #include "vm/isolate_linux.h" |
| 291 #elif defined(TARGET_OS_MACOS) | 311 #elif defined(TARGET_OS_MACOS) |
| 292 #include "vm/isolate_macos.h" | 312 #include "vm/isolate_macos.h" |
| 293 #elif defined(TARGET_OS_WINDOWS) | 313 #elif defined(TARGET_OS_WINDOWS) |
| 294 #include "vm/isolate_win.h" | 314 #include "vm/isolate_win.h" |
| 295 #else | 315 #else |
| 296 #error Unknown target os. | 316 #error Unknown target os. |
| 297 #endif | 317 #endif |
| 298 | 318 |
| 299 #endif // VM_ISOLATE_H_ | 319 #endif // VM_ISOLATE_H_ |
| OLD | NEW |