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 "platform/thread.h" | 10 #include "platform/thread.h" |
| 11 #include "vm/base_isolate.h" |
11 #include "vm/gc_callbacks.h" | 12 #include "vm/gc_callbacks.h" |
12 #include "vm/store_buffer.h" | 13 #include "vm/store_buffer.h" |
13 #include "vm/timer.h" | 14 #include "vm/timer.h" |
14 | 15 |
15 namespace dart { | 16 namespace dart { |
16 | 17 |
17 // Forward declarations. | 18 // Forward declarations. |
18 class ApiState; | 19 class ApiState; |
19 class CodeIndexTable; | 20 class CodeIndexTable; |
20 class Debugger; | 21 class Debugger; |
21 class HandleScope; | 22 class HandleScope; |
22 class HandleVisitor; | 23 class HandleVisitor; |
23 class Heap; | 24 class Heap; |
24 class LongJump; | 25 class LongJump; |
25 class MessageHandler; | 26 class MessageHandler; |
26 class Mutex; | 27 class Mutex; |
27 class ObjectPointerVisitor; | 28 class ObjectPointerVisitor; |
28 class ObjectStore; | 29 class ObjectStore; |
29 class RawContext; | 30 class RawContext; |
30 class RawError; | 31 class RawError; |
31 class StackResource; | 32 class StackResource; |
32 class StubCode; | 33 class StubCode; |
33 class Zone; | 34 class Zone; |
34 | 35 |
35 | 36 |
36 class Isolate { | 37 class Isolate : public BaseIsolate { |
37 public: | 38 public: |
38 ~Isolate(); | 39 ~Isolate(); |
39 | 40 |
40 static inline Isolate* Current() { | 41 static inline Isolate* Current() { |
41 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); | 42 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); |
42 } | 43 } |
43 | 44 |
44 static void SetCurrent(Isolate* isolate); | 45 static void SetCurrent(Isolate* isolate); |
45 | 46 |
46 static void InitOnce(); | 47 static void InitOnce(); |
(...skipping 29 matching lines...) Expand all Loading... |
76 Heap* heap() const { return heap_; } | 77 Heap* heap() const { return heap_; } |
77 void set_heap(Heap* value) { heap_ = value; } | 78 void set_heap(Heap* value) { heap_ = value; } |
78 static intptr_t heap_offset() { return OFFSET_OF(Isolate, heap_); } | 79 static intptr_t heap_offset() { return OFFSET_OF(Isolate, heap_); } |
79 | 80 |
80 ObjectStore* object_store() const { return object_store_; } | 81 ObjectStore* object_store() const { return object_store_; } |
81 void set_object_store(ObjectStore* value) { object_store_ = value; } | 82 void set_object_store(ObjectStore* value) { object_store_ = value; } |
82 static intptr_t object_store_offset() { | 83 static intptr_t object_store_offset() { |
83 return OFFSET_OF(Isolate, object_store_); | 84 return OFFSET_OF(Isolate, object_store_); |
84 } | 85 } |
85 | 86 |
86 StackResource* top_resource() const { return top_resource_; } | |
87 void set_top_resource(StackResource* value) { top_resource_ = value; } | |
88 | |
89 RawContext* top_context() const { return top_context_; } | 87 RawContext* top_context() const { return top_context_; } |
90 void set_top_context(RawContext* value) { top_context_ = value; } | 88 void set_top_context(RawContext* value) { top_context_ = value; } |
91 static intptr_t top_context_offset() { | 89 static intptr_t top_context_offset() { |
92 return OFFSET_OF(Isolate, top_context_); | 90 return OFFSET_OF(Isolate, top_context_); |
93 } | 91 } |
94 | 92 |
95 int32_t random_seed() const { return random_seed_; } | 93 int32_t random_seed() const { return random_seed_; } |
96 void set_random_seed(int32_t value) { random_seed_ = value; } | 94 void set_random_seed(int32_t value) { random_seed_ = value; } |
97 | 95 |
98 uword top_exit_frame_info() const { return top_exit_frame_info_; } | 96 uword top_exit_frame_info() const { return top_exit_frame_info_; } |
(...skipping 11 matching lines...) Expand all Loading... |
110 CodeIndexTable* code_index_table() const { return code_index_table_; } | 108 CodeIndexTable* code_index_table() const { return code_index_table_; } |
111 void set_code_index_table(CodeIndexTable* value) { | 109 void set_code_index_table(CodeIndexTable* value) { |
112 code_index_table_ = value; | 110 code_index_table_ = value; |
113 } | 111 } |
114 | 112 |
115 LongJump* long_jump_base() const { return long_jump_base_; } | 113 LongJump* long_jump_base() const { return long_jump_base_; } |
116 void set_long_jump_base(LongJump* value) { long_jump_base_ = value; } | 114 void set_long_jump_base(LongJump* value) { long_jump_base_ = value; } |
117 | 115 |
118 TimerList& timer_list() { return timer_list_; } | 116 TimerList& timer_list() { return timer_list_; } |
119 | 117 |
120 Zone* current_zone() const { return current_zone_; } | |
121 void set_current_zone(Zone* zone) { current_zone_ = zone; } | |
122 static intptr_t current_zone_offset() { | 118 static intptr_t current_zone_offset() { |
123 return OFFSET_OF(Isolate, current_zone_); | 119 return OFFSET_OF(Isolate, current_zone_); |
124 } | 120 } |
125 | 121 |
126 int32_t no_gc_scope_depth() const { | |
127 #if defined(DEBUG) | |
128 return no_gc_scope_depth_; | |
129 #else | |
130 return 0; | |
131 #endif | |
132 } | |
133 | |
134 void IncrementNoGCScopeDepth() { | |
135 #if defined(DEBUG) | |
136 ASSERT(no_gc_scope_depth_ < INT_MAX); | |
137 no_gc_scope_depth_ += 1; | |
138 #endif | |
139 } | |
140 | |
141 void DecrementNoGCScopeDepth() { | |
142 #if defined(DEBUG) | |
143 ASSERT(no_gc_scope_depth_ > 0); | |
144 no_gc_scope_depth_ -= 1; | |
145 #endif | |
146 } | |
147 | |
148 int32_t no_handle_scope_depth() const { | |
149 #if defined(DEBUG) | |
150 return no_handle_scope_depth_; | |
151 #else | |
152 return 0; | |
153 #endif | |
154 } | |
155 | |
156 void IncrementNoHandleScopeDepth() { | |
157 #if defined(DEBUG) | |
158 ASSERT(no_handle_scope_depth_ < INT_MAX); | |
159 no_handle_scope_depth_ += 1; | |
160 #endif | |
161 } | |
162 | |
163 void DecrementNoHandleScopeDepth() { | |
164 #if defined(DEBUG) | |
165 ASSERT(no_handle_scope_depth_ > 0); | |
166 no_handle_scope_depth_ -= 1; | |
167 #endif | |
168 } | |
169 | |
170 HandleScope* top_handle_scope() const { | |
171 #if defined(DEBUG) | |
172 return top_handle_scope_; | |
173 #else | |
174 return 0; | |
175 #endif | |
176 } | |
177 | |
178 void set_top_handle_scope(HandleScope* handle_scope) { | |
179 #if defined(DEBUG) | |
180 top_handle_scope_ = handle_scope; | |
181 #endif | |
182 } | |
183 | |
184 void set_init_callback_data(void* value) { | 122 void set_init_callback_data(void* value) { |
185 init_callback_data_ = value; | 123 init_callback_data_ = value; |
186 } | 124 } |
187 void* init_callback_data() const { | 125 void* init_callback_data() const { |
188 return init_callback_data_; | 126 return init_callback_data_; |
189 } | 127 } |
190 | 128 |
191 Dart_LibraryTagHandler library_tag_handler() const { | 129 Dart_LibraryTagHandler library_tag_handler() const { |
192 return library_tag_handler_; | 130 return library_tag_handler_; |
193 } | 131 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 static const uword kStackSizeBuffer = (128 * KB); | 194 static const uword kStackSizeBuffer = (128 * KB); |
257 static const uword kDefaultStackSize = (1 * MB); | 195 static const uword kDefaultStackSize = (1 * MB); |
258 | 196 |
259 static ThreadLocalKey isolate_key; | 197 static ThreadLocalKey isolate_key; |
260 StoreBufferBlock store_buffer_; | 198 StoreBufferBlock store_buffer_; |
261 Dart_MessageNotifyCallback message_notify_callback_; | 199 Dart_MessageNotifyCallback message_notify_callback_; |
262 char* name_; | 200 char* name_; |
263 Dart_Port main_port_; | 201 Dart_Port main_port_; |
264 Heap* heap_; | 202 Heap* heap_; |
265 ObjectStore* object_store_; | 203 ObjectStore* object_store_; |
266 StackResource* top_resource_; | |
267 RawContext* top_context_; | 204 RawContext* top_context_; |
268 Zone* current_zone_; | |
269 #if defined(DEBUG) | |
270 int32_t no_gc_scope_depth_; | |
271 int32_t no_handle_scope_depth_; | |
272 HandleScope* top_handle_scope_; | |
273 #endif | |
274 int32_t random_seed_; | 205 int32_t random_seed_; |
275 uword top_exit_frame_info_; | 206 uword top_exit_frame_info_; |
276 void* init_callback_data_; | 207 void* init_callback_data_; |
277 Dart_LibraryTagHandler library_tag_handler_; | 208 Dart_LibraryTagHandler library_tag_handler_; |
278 ApiState* api_state_; | 209 ApiState* api_state_; |
279 StubCode* stub_code_; | 210 StubCode* stub_code_; |
280 CodeIndexTable* code_index_table_; | 211 CodeIndexTable* code_index_table_; |
281 Debugger* debugger_; | 212 Debugger* debugger_; |
282 LongJump* long_jump_base_; | 213 LongJump* long_jump_base_; |
283 TimerList timer_list_; | 214 TimerList timer_list_; |
284 intptr_t ast_node_id_; | 215 intptr_t ast_node_id_; |
285 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. | 216 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
286 uword stack_limit_; | 217 uword stack_limit_; |
287 uword saved_stack_limit_; | 218 uword saved_stack_limit_; |
288 MessageHandler* message_handler_; | 219 MessageHandler* message_handler_; |
289 GcPrologueCallbacks gc_prologue_callbacks_; | 220 GcPrologueCallbacks gc_prologue_callbacks_; |
290 GcEpilogueCallbacks gc_epilogue_callbacks_; | 221 GcEpilogueCallbacks gc_epilogue_callbacks_; |
291 | 222 |
292 static Dart_IsolateCreateCallback create_callback_; | 223 static Dart_IsolateCreateCallback create_callback_; |
293 static Dart_IsolateInterruptCallback interrupt_callback_; | 224 static Dart_IsolateInterruptCallback interrupt_callback_; |
294 | 225 |
295 DISALLOW_COPY_AND_ASSIGN(Isolate); | 226 DISALLOW_COPY_AND_ASSIGN(Isolate); |
296 }; | 227 }; |
297 | 228 |
298 } // namespace dart | 229 } // namespace dart |
299 | 230 |
300 #endif // VM_ISOLATE_H_ | 231 #endif // VM_ISOLATE_H_ |
OLD | NEW |