OLD | NEW |
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 #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 "platform/thread.h" | 10 #include "platform/thread.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 uword saved_stack_limit() const { return saved_stack_limit_; } | 255 uword saved_stack_limit() const { return saved_stack_limit_; } |
256 | 256 |
257 static uword GetSpecifiedStackSize(); | 257 static uword GetSpecifiedStackSize(); |
258 | 258 |
259 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize); | 259 static const intptr_t kStackSizeBuffer = (4 * KB * kWordSize); |
260 | 260 |
261 enum { | 261 enum { |
262 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. | 262 kApiInterrupt = 0x1, // An interrupt from Dart_InterruptIsolate. |
263 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. | 263 kMessageInterrupt = 0x2, // An interrupt to process an out of band message. |
264 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. | 264 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. |
265 kVmStatusInterrupt = 0x8, // An interrupt to process a status request. | |
266 | 265 |
267 kInterruptsMask = | 266 kInterruptsMask = |
268 kApiInterrupt | | 267 kApiInterrupt | |
269 kMessageInterrupt | | 268 kMessageInterrupt | |
270 kStoreBufferInterrupt | | 269 kStoreBufferInterrupt, |
271 kVmStatusInterrupt, | |
272 }; | 270 }; |
273 | 271 |
274 void ScheduleInterrupts(uword interrupt_bits); | 272 void ScheduleInterrupts(uword interrupt_bits); |
275 uword GetAndClearInterrupts(); | 273 uword GetAndClearInterrupts(); |
276 | 274 |
277 MessageHandler* message_handler() const { return message_handler_; } | 275 MessageHandler* message_handler() const { return message_handler_; } |
278 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 276 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
279 | 277 |
280 uword spawn_data() const { return spawn_data_; } | 278 uword spawn_data() const { return spawn_data_; } |
281 void set_spawn_data(uword value) { spawn_data_ = value; } | 279 void set_spawn_data(uword value) { spawn_data_ = value; } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return create_callback_; | 313 return create_callback_; |
316 } | 314 } |
317 | 315 |
318 static void SetInterruptCallback(Dart_IsolateInterruptCallback cb) { | 316 static void SetInterruptCallback(Dart_IsolateInterruptCallback cb) { |
319 interrupt_callback_ = cb; | 317 interrupt_callback_ = cb; |
320 } | 318 } |
321 static Dart_IsolateInterruptCallback InterruptCallback() { | 319 static Dart_IsolateInterruptCallback InterruptCallback() { |
322 return interrupt_callback_; | 320 return interrupt_callback_; |
323 } | 321 } |
324 | 322 |
325 static void SetVmStatsCallback(Dart_IsolateInterruptCallback cb) { | |
326 vmstats_callback_ = cb; | |
327 } | |
328 static Dart_IsolateInterruptCallback VmStatsCallback() { | |
329 return vmstats_callback_; | |
330 } | |
331 | |
332 static void SetUnhandledExceptionCallback( | 323 static void SetUnhandledExceptionCallback( |
333 Dart_IsolateUnhandledExceptionCallback cb) { | 324 Dart_IsolateUnhandledExceptionCallback cb) { |
334 unhandled_exception_callback_ = cb; | 325 unhandled_exception_callback_ = cb; |
335 } | 326 } |
336 static Dart_IsolateUnhandledExceptionCallback UnhandledExceptionCallback() { | 327 static Dart_IsolateUnhandledExceptionCallback UnhandledExceptionCallback() { |
337 return unhandled_exception_callback_; | 328 return unhandled_exception_callback_; |
338 } | 329 } |
339 | 330 |
340 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { | 331 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { |
341 shutdown_callback_ = cb; | 332 shutdown_callback_ = cb; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 412 } |
422 | 413 |
423 static char* GetStatus(const char* request); | 414 static char* GetStatus(const char* request); |
424 | 415 |
425 private: | 416 private: |
426 Isolate(); | 417 Isolate(); |
427 | 418 |
428 void BuildName(const char* name_prefix); | 419 void BuildName(const char* name_prefix); |
429 void PrintInvokedFunctions(); | 420 void PrintInvokedFunctions(); |
430 | 421 |
431 static bool FetchStacktrace(); | |
432 static bool FetchStackFrameDetails(); | |
433 char* GetStatusDetails(); | |
434 char* GetStatusStacktrace(); | |
435 char* GetStatusStackFrame(intptr_t index); | |
436 char* DoStacktraceInterrupt(Dart_IsolateInterruptCallback cb); | |
437 | |
438 static ThreadLocalKey isolate_key; | 422 static ThreadLocalKey isolate_key; |
439 StoreBufferBlock store_buffer_block_; | 423 StoreBufferBlock store_buffer_block_; |
440 StoreBuffer store_buffer_; | 424 StoreBuffer store_buffer_; |
441 ClassTable class_table_; | 425 ClassTable class_table_; |
442 MegamorphicCacheTable megamorphic_cache_table_; | 426 MegamorphicCacheTable megamorphic_cache_table_; |
443 Dart_MessageNotifyCallback message_notify_callback_; | 427 Dart_MessageNotifyCallback message_notify_callback_; |
444 char* name_; | 428 char* name_; |
445 int64_t start_time_; | 429 int64_t start_time_; |
446 Dart_Port main_port_; | 430 Dart_Port main_port_; |
447 Heap* heap_; | 431 Heap* heap_; |
(...skipping 18 matching lines...) Expand all Loading... |
466 GcPrologueCallbacks gc_prologue_callbacks_; | 450 GcPrologueCallbacks gc_prologue_callbacks_; |
467 GcEpilogueCallbacks gc_epilogue_callbacks_; | 451 GcEpilogueCallbacks gc_epilogue_callbacks_; |
468 | 452 |
469 // Deoptimization support. | 453 // Deoptimization support. |
470 intptr_t* deopt_cpu_registers_copy_; | 454 intptr_t* deopt_cpu_registers_copy_; |
471 fpu_register_t* deopt_fpu_registers_copy_; | 455 fpu_register_t* deopt_fpu_registers_copy_; |
472 intptr_t* deopt_frame_copy_; | 456 intptr_t* deopt_frame_copy_; |
473 intptr_t deopt_frame_copy_size_; | 457 intptr_t deopt_frame_copy_size_; |
474 DeferredObject* deferred_objects_; | 458 DeferredObject* deferred_objects_; |
475 | 459 |
476 // Status support. | |
477 char* stacktrace_; | |
478 intptr_t stack_frame_index_; | |
479 | |
480 static Dart_IsolateCreateCallback create_callback_; | 460 static Dart_IsolateCreateCallback create_callback_; |
481 static Dart_IsolateInterruptCallback interrupt_callback_; | 461 static Dart_IsolateInterruptCallback interrupt_callback_; |
482 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; | 462 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; |
483 static Dart_IsolateShutdownCallback shutdown_callback_; | 463 static Dart_IsolateShutdownCallback shutdown_callback_; |
484 static Dart_FileOpenCallback file_open_callback_; | 464 static Dart_FileOpenCallback file_open_callback_; |
485 static Dart_FileWriteCallback file_write_callback_; | 465 static Dart_FileWriteCallback file_write_callback_; |
486 static Dart_FileCloseCallback file_close_callback_; | 466 static Dart_FileCloseCallback file_close_callback_; |
487 static Dart_IsolateInterruptCallback vmstats_callback_; | |
488 | 467 |
489 DISALLOW_COPY_AND_ASSIGN(Isolate); | 468 DISALLOW_COPY_AND_ASSIGN(Isolate); |
490 }; | 469 }; |
491 | 470 |
492 // When we need to execute code in an isolate, we use the | 471 // When we need to execute code in an isolate, we use the |
493 // StartIsolateScope. | 472 // StartIsolateScope. |
494 class StartIsolateScope { | 473 class StartIsolateScope { |
495 public: | 474 public: |
496 explicit StartIsolateScope(Isolate* new_isolate) | 475 explicit StartIsolateScope(Isolate* new_isolate) |
497 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { | 476 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 Isolate* new_isolate_; | 528 Isolate* new_isolate_; |
550 Isolate* saved_isolate_; | 529 Isolate* saved_isolate_; |
551 uword saved_stack_limit_; | 530 uword saved_stack_limit_; |
552 | 531 |
553 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope); | 532 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope); |
554 }; | 533 }; |
555 | 534 |
556 } // namespace dart | 535 } // namespace dart |
557 | 536 |
558 #endif // VM_ISOLATE_H_ | 537 #endif // VM_ISOLATE_H_ |
OLD | NEW |