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 "vm/class_table.h" | 10 #include "vm/class_table.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class HandleVisitor; | 24 class HandleVisitor; |
25 class Heap; | 25 class Heap; |
26 class ICData; | 26 class ICData; |
27 class LongJump; | 27 class LongJump; |
28 class MessageHandler; | 28 class MessageHandler; |
29 class Mutex; | 29 class Mutex; |
30 class ObjectPointerVisitor; | 30 class ObjectPointerVisitor; |
31 class ObjectStore; | 31 class ObjectStore; |
32 class RawArray; | 32 class RawArray; |
33 class RawContext; | 33 class RawContext; |
| 34 class RawDouble; |
34 class RawError; | 35 class RawError; |
35 class StackResource; | 36 class StackResource; |
36 class StubCode; | 37 class StubCode; |
37 class Zone; | 38 class Zone; |
38 | 39 |
| 40 |
| 41 // Used by the deoptimization infrastructure to defer allocation of Double |
| 42 // objects until frame is fully rewritten and GC is safe. |
| 43 // See callers of Isolate::DeferDoubleMaterialization. |
| 44 class DeferredDouble { |
| 45 public: |
| 46 DeferredDouble(double value, RawDouble** slot, DeferredDouble* next) |
| 47 : value_(value), slot_(slot), next_(next) { } |
| 48 |
| 49 double value() const { return value_; } |
| 50 RawDouble** slot() const { return slot_; } |
| 51 DeferredDouble* next() const { return next_; } |
| 52 |
| 53 private: |
| 54 const double value_; |
| 55 RawDouble** const slot_; |
| 56 DeferredDouble* const next_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(DeferredDouble); |
| 59 }; |
| 60 |
| 61 |
39 class Isolate : public BaseIsolate { | 62 class Isolate : public BaseIsolate { |
40 public: | 63 public: |
41 ~Isolate(); | 64 ~Isolate(); |
42 | 65 |
43 static inline Isolate* Current() { | 66 static inline Isolate* Current() { |
44 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); | 67 return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key)); |
45 } | 68 } |
46 | 69 |
47 static void SetCurrent(Isolate* isolate); | 70 static void SetCurrent(Isolate* isolate); |
48 | 71 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return interrupt_callback_; | 236 return interrupt_callback_; |
214 } | 237 } |
215 | 238 |
216 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { | 239 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { |
217 shutdown_callback_ = cb; | 240 shutdown_callback_ = cb; |
218 } | 241 } |
219 static Dart_IsolateShutdownCallback ShutdownCallback() { | 242 static Dart_IsolateShutdownCallback ShutdownCallback() { |
220 return shutdown_callback_; | 243 return shutdown_callback_; |
221 } | 244 } |
222 | 245 |
223 intptr_t* deopt_registers_copy() const { return deopt_registers_copy_; } | 246 intptr_t* deopt_cpu_registers_copy() const { |
224 void set_deopt_registers_copy(intptr_t* value) { | 247 return deopt_cpu_registers_copy_; |
225 ASSERT((value == NULL) || (deopt_registers_copy_ == NULL)); | 248 } |
226 deopt_registers_copy_ = value; | 249 void set_deopt_cpu_registers_copy(intptr_t* value) { |
| 250 ASSERT((value == NULL) || (deopt_cpu_registers_copy_ == NULL)); |
| 251 deopt_cpu_registers_copy_ = value; |
| 252 } |
| 253 double* deopt_xmm_registers_copy() const { |
| 254 return deopt_xmm_registers_copy_; |
| 255 } |
| 256 void set_deopt_xmm_registers_copy(double* value) { |
| 257 ASSERT((value == NULL) || (deopt_xmm_registers_copy_ == NULL)); |
| 258 deopt_xmm_registers_copy_ = value; |
227 } | 259 } |
228 intptr_t* deopt_frame_copy() const { return deopt_frame_copy_; } | 260 intptr_t* deopt_frame_copy() const { return deopt_frame_copy_; } |
229 void SetDeoptFrameCopy(intptr_t* value, intptr_t size) { | 261 void SetDeoptFrameCopy(intptr_t* value, intptr_t size) { |
230 ASSERT((value == NULL) || (size > 0)); | 262 ASSERT((value == NULL) || (size > 0)); |
231 ASSERT((value == NULL) || (deopt_frame_copy_ == NULL)); | 263 ASSERT((value == NULL) || (deopt_frame_copy_ == NULL)); |
232 deopt_frame_copy_ = value; | 264 deopt_frame_copy_ = value; |
233 deopt_frame_copy_size_ = size; | 265 deopt_frame_copy_size_ = size; |
234 } | 266 } |
235 intptr_t deopt_frame_copy_size() const { return deopt_frame_copy_size_; } | 267 intptr_t deopt_frame_copy_size() const { return deopt_frame_copy_size_; } |
236 | 268 |
| 269 void DeferDoubleMaterialization(double value, RawDouble** slot) { |
| 270 deferred_doubles_ = new DeferredDouble( |
| 271 value, slot, deferred_doubles_); |
| 272 } |
| 273 |
| 274 DeferredDouble* DetachDeferredDoubles() { |
| 275 DeferredDouble* list = deferred_doubles_; |
| 276 deferred_doubles_ = NULL; |
| 277 return list; |
| 278 } |
| 279 |
237 private: | 280 private: |
238 Isolate(); | 281 Isolate(); |
239 | 282 |
240 void BuildName(const char* name_prefix); | 283 void BuildName(const char* name_prefix); |
241 void PrintInvokedFunctions(); | 284 void PrintInvokedFunctions(); |
242 | 285 |
243 static uword GetSpecifiedStackSize(); | 286 static uword GetSpecifiedStackSize(); |
244 | 287 |
245 static const intptr_t kStackSizeBuffer = (16 * KB); | 288 static const intptr_t kStackSizeBuffer = (16 * KB); |
246 | 289 |
(...skipping 19 matching lines...) Expand all Loading... |
266 intptr_t deopt_id_; | 309 intptr_t deopt_id_; |
267 RawArray* ic_data_array_; | 310 RawArray* ic_data_array_; |
268 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. | 311 Mutex* mutex_; // protects stack_limit_ and saved_stack_limit_. |
269 uword stack_limit_; | 312 uword stack_limit_; |
270 uword saved_stack_limit_; | 313 uword saved_stack_limit_; |
271 MessageHandler* message_handler_; | 314 MessageHandler* message_handler_; |
272 uword spawn_data_; | 315 uword spawn_data_; |
273 GcPrologueCallbacks gc_prologue_callbacks_; | 316 GcPrologueCallbacks gc_prologue_callbacks_; |
274 GcEpilogueCallbacks gc_epilogue_callbacks_; | 317 GcEpilogueCallbacks gc_epilogue_callbacks_; |
275 // Deoptimization support. | 318 // Deoptimization support. |
276 intptr_t* deopt_registers_copy_; | 319 intptr_t* deopt_cpu_registers_copy_; |
| 320 double* deopt_xmm_registers_copy_; |
277 intptr_t* deopt_frame_copy_; | 321 intptr_t* deopt_frame_copy_; |
278 intptr_t deopt_frame_copy_size_; | 322 intptr_t deopt_frame_copy_size_; |
| 323 DeferredDouble* deferred_doubles_; |
279 | 324 |
280 static Dart_IsolateCreateCallback create_callback_; | 325 static Dart_IsolateCreateCallback create_callback_; |
281 static Dart_IsolateInterruptCallback interrupt_callback_; | 326 static Dart_IsolateInterruptCallback interrupt_callback_; |
282 static Dart_IsolateShutdownCallback shutdown_callback_; | 327 static Dart_IsolateShutdownCallback shutdown_callback_; |
283 | 328 |
284 DISALLOW_COPY_AND_ASSIGN(Isolate); | 329 DISALLOW_COPY_AND_ASSIGN(Isolate); |
285 }; | 330 }; |
286 | 331 |
287 // When we need to execute code in an isolate, we use the | 332 // When we need to execute code in an isolate, we use the |
288 // StartIsolateScope. | 333 // StartIsolateScope. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 Isolate* new_isolate_; | 389 Isolate* new_isolate_; |
345 Isolate* saved_isolate_; | 390 Isolate* saved_isolate_; |
346 uword saved_stack_limit_; | 391 uword saved_stack_limit_; |
347 | 392 |
348 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope); | 393 DISALLOW_COPY_AND_ASSIGN(SwitchIsolateScope); |
349 }; | 394 }; |
350 | 395 |
351 } // namespace dart | 396 } // namespace dart |
352 | 397 |
353 #endif // VM_ISOLATE_H_ | 398 #endif // VM_ISOLATE_H_ |
OLD | NEW |