| 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" |
| 11 #include "vm/base_isolate.h" | 11 #include "vm/base_isolate.h" |
| 12 #include "vm/class_table.h" | 12 #include "vm/class_table.h" |
| 13 #include "vm/gc_callbacks.h" | 13 #include "vm/gc_callbacks.h" |
| 14 #include "vm/handles.h" |
| 14 #include "vm/megamorphic_cache_table.h" | 15 #include "vm/megamorphic_cache_table.h" |
| 15 #include "vm/store_buffer.h" | 16 #include "vm/store_buffer.h" |
| 16 #include "vm/timer.h" | 17 #include "vm/timer.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| 19 | 20 |
| 20 // Forward declarations. | 21 // Forward declarations. |
| 22 class AbstractType; |
| 21 class ApiState; | 23 class ApiState; |
| 24 class Array; |
| 25 class Class; |
| 22 class CodeIndexTable; | 26 class CodeIndexTable; |
| 23 class Debugger; | 27 class Debugger; |
| 28 class Field; |
| 24 class Function; | 29 class Function; |
| 25 class HandleScope; | 30 class HandleScope; |
| 26 class HandleVisitor; | 31 class HandleVisitor; |
| 27 class Heap; | 32 class Heap; |
| 28 class ICData; | 33 class ICData; |
| 29 class Instance; | 34 class Instance; |
| 30 class LongJump; | 35 class LongJump; |
| 31 class MessageHandler; | 36 class MessageHandler; |
| 32 class Mutex; | 37 class Mutex; |
| 38 class Object; |
| 33 class ObjectPointerVisitor; | 39 class ObjectPointerVisitor; |
| 34 class ObjectStore; | 40 class ObjectStore; |
| 35 class RawInstance; | 41 class RawInstance; |
| 36 class RawArray; | 42 class RawArray; |
| 37 class RawContext; | 43 class RawContext; |
| 38 class RawDouble; | 44 class RawDouble; |
| 39 class RawMint; | 45 class RawMint; |
| 40 class RawObject; | 46 class RawObject; |
| 41 class RawInteger; | 47 class RawInteger; |
| 42 class RawError; | 48 class RawError; |
| 49 class RawFloat32x4; |
| 50 class RawUint32x4; |
| 43 class Simulator; | 51 class Simulator; |
| 44 class StackResource; | 52 class StackResource; |
| 45 class StackZone; | 53 class StackZone; |
| 46 class StubCode; | 54 class StubCode; |
| 47 class RawFloat32x4; | 55 class TypeArguments; |
| 48 class RawUint32x4; | 56 class TypeParameter; |
| 49 class ObjectHistogram; | 57 class ObjectHistogram; |
| 50 | 58 |
| 51 | 59 |
| 52 // Used by the deoptimization infrastructure to defer allocation of unboxed | 60 // Used by the deoptimization infrastructure to defer allocation of unboxed |
| 53 // objects until frame is fully rewritten and GC is safe. | 61 // objects until frame is fully rewritten and GC is safe. |
| 54 // Describes a stack slot that should be populated with a reference to the | 62 // Describes a stack slot that should be populated with a reference to the |
| 55 // materialized object. | 63 // materialized object. |
| 56 class DeferredSlot { | 64 class DeferredSlot { |
| 57 public: | 65 public: |
| 58 DeferredSlot(RawInstance** slot, DeferredSlot* next) | 66 DeferredSlot(RawInstance** slot, DeferredSlot* next) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Field, value pairs. | 219 // Field, value pairs. |
| 212 RawObject** args_; | 220 RawObject** args_; |
| 213 | 221 |
| 214 // Object materialized from this description. | 222 // Object materialized from this description. |
| 215 const Instance* object_; | 223 const Instance* object_; |
| 216 | 224 |
| 217 DISALLOW_COPY_AND_ASSIGN(DeferredObject); | 225 DISALLOW_COPY_AND_ASSIGN(DeferredObject); |
| 218 }; | 226 }; |
| 219 | 227 |
| 220 | 228 |
| 229 #define REUSABLE_HANDLE_LIST(V) \ |
| 230 V(Object) \ |
| 231 V(Array) \ |
| 232 V(String) \ |
| 233 V(Instance) \ |
| 234 V(Function) \ |
| 235 V(Field) \ |
| 236 V(Class) \ |
| 237 V(AbstractType) \ |
| 238 V(TypeParameter) \ |
| 239 V(TypeArguments) \ |
| 240 |
| 241 |
| 221 class Isolate : public BaseIsolate { | 242 class Isolate : public BaseIsolate { |
| 222 public: | 243 public: |
| 223 ~Isolate(); | 244 ~Isolate(); |
| 224 | 245 |
| 225 static inline Isolate* Current() { | 246 static inline Isolate* Current() { |
| 226 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); | 247 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); |
| 227 } | 248 } |
| 228 | 249 |
| 229 static void SetCurrent(Isolate* isolate); | 250 static void SetCurrent(Isolate* isolate); |
| 230 | 251 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 595 } |
| 575 | 596 |
| 576 // Populate all deferred slots that contain boxes for double, mint, simd | 597 // Populate all deferred slots that contain boxes for double, mint, simd |
| 577 // values. | 598 // values. |
| 578 void MaterializeDeferredBoxes(); | 599 void MaterializeDeferredBoxes(); |
| 579 | 600 |
| 580 // Populate all slots containing references to objects which allocations | 601 // Populate all slots containing references to objects which allocations |
| 581 // were eliminated by AllocationSinking pass. | 602 // were eliminated by AllocationSinking pass. |
| 582 void MaterializeDeferredObjects(); | 603 void MaterializeDeferredObjects(); |
| 583 | 604 |
| 605 #define REUSABLE_HANDLE_ACCESSORS(object) \ |
| 606 object& object##Handle() { \ |
| 607 ASSERT(object##_handle_ != NULL); \ |
| 608 return *object##_handle_; \ |
| 609 } \ |
| 610 |
| 611 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ACCESSORS) |
| 612 #undef REUSABLE_HANDLE_ACCESSORS |
| 613 |
| 584 static char* GetStatus(const char* request); | 614 static char* GetStatus(const char* request); |
| 585 | 615 |
| 586 private: | 616 private: |
| 587 Isolate(); | 617 Isolate(); |
| 588 | 618 |
| 589 void BuildName(const char* name_prefix); | 619 void BuildName(const char* name_prefix); |
| 590 void PrintInvokedFunctions(); | 620 void PrintInvokedFunctions(); |
| 591 | 621 |
| 592 static bool FetchStacktrace(); | 622 static bool FetchStacktrace(); |
| 593 static bool FetchStackFrameDetails(); | 623 static bool FetchStackFrameDetails(); |
| 594 char* GetStatusDetails(); | 624 char* GetStatusDetails(); |
| 595 char* GetStatusStacktrace(); | 625 char* GetStatusStacktrace(); |
| 596 char* GetStatusStackFrame(intptr_t index); | 626 char* GetStatusStackFrame(intptr_t index); |
| 597 char* DoStacktraceInterrupt(Dart_IsolateInterruptCallback cb); | 627 char* DoStacktraceInterrupt(Dart_IsolateInterruptCallback cb); |
| 628 template<class T> T* AllocateReusableHandle(); |
| 598 | 629 |
| 599 static ThreadLocalKey isolate_key; | 630 static ThreadLocalKey isolate_key; |
| 600 StoreBuffer store_buffer_; | 631 StoreBuffer store_buffer_; |
| 601 ClassTable class_table_; | 632 ClassTable class_table_; |
| 602 MegamorphicCacheTable megamorphic_cache_table_; | 633 MegamorphicCacheTable megamorphic_cache_table_; |
| 603 Dart_MessageNotifyCallback message_notify_callback_; | 634 Dart_MessageNotifyCallback message_notify_callback_; |
| 604 char* name_; | 635 char* name_; |
| 605 int64_t start_time_; | 636 int64_t start_time_; |
| 606 Dart_Port main_port_; | 637 Dart_Port main_port_; |
| 607 Heap* heap_; | 638 Heap* heap_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 636 DeferredSlot* deferred_object_refs_; | 667 DeferredSlot* deferred_object_refs_; |
| 637 | 668 |
| 638 intptr_t deferred_objects_count_; | 669 intptr_t deferred_objects_count_; |
| 639 DeferredObject** deferred_objects_; | 670 DeferredObject** deferred_objects_; |
| 640 | 671 |
| 641 // Status support. | 672 // Status support. |
| 642 char* stacktrace_; | 673 char* stacktrace_; |
| 643 intptr_t stack_frame_index_; | 674 intptr_t stack_frame_index_; |
| 644 ObjectHistogram* object_histogram_; | 675 ObjectHistogram* object_histogram_; |
| 645 | 676 |
| 677 // Reusable handles support. |
| 678 #define REUSABLE_HANDLE_FIELDS(object) \ |
| 679 object* object##_handle_; \ |
| 680 |
| 681 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_FIELDS) |
| 682 #undef REUSABLE_HANDLE_FIELDS |
| 683 VMHandles handles_; |
| 684 |
| 646 static Dart_IsolateCreateCallback create_callback_; | 685 static Dart_IsolateCreateCallback create_callback_; |
| 647 static Dart_IsolateInterruptCallback interrupt_callback_; | 686 static Dart_IsolateInterruptCallback interrupt_callback_; |
| 648 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; | 687 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; |
| 649 static Dart_IsolateShutdownCallback shutdown_callback_; | 688 static Dart_IsolateShutdownCallback shutdown_callback_; |
| 650 static Dart_FileOpenCallback file_open_callback_; | 689 static Dart_FileOpenCallback file_open_callback_; |
| 651 static Dart_FileReadCallback file_read_callback_; | 690 static Dart_FileReadCallback file_read_callback_; |
| 652 static Dart_FileWriteCallback file_write_callback_; | 691 static Dart_FileWriteCallback file_write_callback_; |
| 653 static Dart_FileCloseCallback file_close_callback_; | 692 static Dart_FileCloseCallback file_close_callback_; |
| 654 static Dart_IsolateInterruptCallback vmstats_callback_; | 693 static Dart_IsolateInterruptCallback vmstats_callback_; |
| 655 | 694 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 803 |
| 765 private: | 804 private: |
| 766 Isolate::IsolateRunState saved_state_; | 805 Isolate::IsolateRunState saved_state_; |
| 767 | 806 |
| 768 DISALLOW_COPY_AND_ASSIGN(IsolateRunStateManager); | 807 DISALLOW_COPY_AND_ASSIGN(IsolateRunStateManager); |
| 769 }; | 808 }; |
| 770 | 809 |
| 771 } // namespace dart | 810 } // namespace dart |
| 772 | 811 |
| 773 #endif // VM_ISOLATE_H_ | 812 #endif // VM_ISOLATE_H_ |
| OLD | NEW |