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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. | 266 kStoreBufferInterrupt = 0x4, // An interrupt to process the store buffer. |
267 kVmStatusInterrupt = 0x8, // An interrupt to process a status request. | 267 kVmStatusInterrupt = 0x8, // An interrupt to process a status request. |
268 | 268 |
269 kInterruptsMask = | 269 kInterruptsMask = |
270 kApiInterrupt | | 270 kApiInterrupt | |
271 kMessageInterrupt | | 271 kMessageInterrupt | |
272 kStoreBufferInterrupt | | 272 kStoreBufferInterrupt | |
273 kVmStatusInterrupt, | 273 kVmStatusInterrupt, |
274 }; | 274 }; |
275 | 275 |
| 276 enum IsolateRunState { |
| 277 kIsolateWaiting = 0, // The isolate is waiting for code to execute. |
| 278 kIsolateRunning, // The isolate is executing code. |
| 279 }; |
| 280 |
276 void ScheduleInterrupts(uword interrupt_bits); | 281 void ScheduleInterrupts(uword interrupt_bits); |
277 uword GetAndClearInterrupts(); | 282 uword GetAndClearInterrupts(); |
278 | 283 |
279 bool MakeRunnable(); | 284 bool MakeRunnable(); |
280 void Run(); | 285 void Run(); |
281 | 286 |
282 MessageHandler* message_handler() const { return message_handler_; } | 287 MessageHandler* message_handler() const { return message_handler_; } |
283 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 288 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
284 | 289 |
285 bool is_runnable() const { return is_runnable_; } | 290 bool is_runnable() const { return is_runnable_; } |
286 void set_is_runnable(bool value) { is_runnable_ = value; } | 291 void set_is_runnable(bool value) { is_runnable_ = value; } |
287 | 292 |
| 293 IsolateRunState running_state() const { return running_state_; } |
| 294 void set_running_state(IsolateRunState value) { running_state_ = value; } |
| 295 |
288 uword spawn_data() const { return spawn_data_; } | 296 uword spawn_data() const { return spawn_data_; } |
289 void set_spawn_data(uword value) { spawn_data_ = value; } | 297 void set_spawn_data(uword value) { spawn_data_ = value; } |
290 | 298 |
291 static const intptr_t kNoDeoptId = -1; | 299 static const intptr_t kNoDeoptId = -1; |
292 static const intptr_t kDeoptIdStep = 2; | 300 static const intptr_t kDeoptIdStep = 2; |
293 static const intptr_t kDeoptIdBeforeOffset = 0; | 301 static const intptr_t kDeoptIdBeforeOffset = 0; |
294 static const intptr_t kDeoptIdAfterOffset = 1; | 302 static const intptr_t kDeoptIdAfterOffset = 1; |
295 intptr_t deopt_id() const { return deopt_id_; } | 303 intptr_t deopt_id() const { return deopt_id_; } |
296 void set_deopt_id(int value) { | 304 void set_deopt_id(int value) { |
297 ASSERT(value >= 0); | 305 ASSERT(value >= 0); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 LongJump* long_jump_base_; | 493 LongJump* long_jump_base_; |
486 TimerList timer_list_; | 494 TimerList timer_list_; |
487 intptr_t deopt_id_; | 495 intptr_t deopt_id_; |
488 RawArray* ic_data_array_; | 496 RawArray* ic_data_array_; |
489 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. | 497 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
490 uword stack_limit_; | 498 uword stack_limit_; |
491 uword saved_stack_limit_; | 499 uword saved_stack_limit_; |
492 MessageHandler* message_handler_; | 500 MessageHandler* message_handler_; |
493 uword spawn_data_; | 501 uword spawn_data_; |
494 bool is_runnable_; | 502 bool is_runnable_; |
| 503 IsolateRunState running_state_; |
495 GcPrologueCallbacks gc_prologue_callbacks_; | 504 GcPrologueCallbacks gc_prologue_callbacks_; |
496 GcEpilogueCallbacks gc_epilogue_callbacks_; | 505 GcEpilogueCallbacks gc_epilogue_callbacks_; |
497 | 506 |
498 // Deoptimization support. | 507 // Deoptimization support. |
499 intptr_t* deopt_cpu_registers_copy_; | 508 intptr_t* deopt_cpu_registers_copy_; |
500 fpu_register_t* deopt_fpu_registers_copy_; | 509 fpu_register_t* deopt_fpu_registers_copy_; |
501 intptr_t* deopt_frame_copy_; | 510 intptr_t* deopt_frame_copy_; |
502 intptr_t deopt_frame_copy_size_; | 511 intptr_t deopt_frame_copy_size_; |
503 DeferredObject* deferred_objects_; | 512 DeferredObject* deferred_objects_; |
504 | 513 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 void Cleanup(); | 609 void Cleanup(); |
601 | 610 |
602 private: | 611 private: |
603 Isolate* isolate_; | 612 Isolate* isolate_; |
604 char* script_url_; | 613 char* script_url_; |
605 char* library_url_; | 614 char* library_url_; |
606 char* function_name_; | 615 char* function_name_; |
607 char* exception_callback_name_; | 616 char* exception_callback_name_; |
608 }; | 617 }; |
609 | 618 |
| 619 |
| 620 class IsolateRunStateManager : public StackResource { |
| 621 public: |
| 622 explicit IsolateRunStateManager() |
| 623 : StackResource(Isolate::Current()), |
| 624 saved_state_(Isolate::kIsolateWaiting) { |
| 625 saved_state_ = reinterpret_cast<Isolate*>(isolate())->running_state(); |
| 626 } |
| 627 |
| 628 virtual ~IsolateRunStateManager() { |
| 629 reinterpret_cast<Isolate*>(isolate())->set_running_state(saved_state_); |
| 630 } |
| 631 |
| 632 void SetRunState(Isolate::IsolateRunState run_state) { |
| 633 reinterpret_cast<Isolate*>(isolate())->set_running_state(run_state); |
| 634 } |
| 635 |
| 636 private: |
| 637 Isolate::IsolateRunState saved_state_; |
| 638 |
| 639 DISALLOW_COPY_AND_ASSIGN(IsolateRunStateManager); |
| 640 }; |
| 641 |
610 } // namespace dart | 642 } // namespace dart |
611 | 643 |
612 #endif // VM_ISOLATE_H_ | 644 #endif // VM_ISOLATE_H_ |
OLD | NEW |