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 18 matching lines...) Expand all Loading... | |
29 class DeoptContext; | 29 class DeoptContext; |
30 class Field; | 30 class Field; |
31 class Function; | 31 class Function; |
32 class HandleScope; | 32 class HandleScope; |
33 class HandleVisitor; | 33 class HandleVisitor; |
34 class Heap; | 34 class Heap; |
35 class ICData; | 35 class ICData; |
36 class Instance; | 36 class Instance; |
37 class IsolateProfilerData; | 37 class IsolateProfilerData; |
38 class IsolateSpawnState; | 38 class IsolateSpawnState; |
39 class InterruptableThreadState; | |
39 class LongJumpScope; | 40 class LongJumpScope; |
40 class MessageHandler; | 41 class MessageHandler; |
41 class Mutex; | 42 class Mutex; |
42 class Object; | 43 class Object; |
43 class ObjectPointerVisitor; | 44 class ObjectPointerVisitor; |
44 class ObjectStore; | 45 class ObjectStore; |
45 class RawInstance; | 46 class RawInstance; |
46 class RawArray; | 47 class RawArray; |
47 class RawContext; | 48 class RawContext; |
48 class RawDouble; | 49 class RawDouble; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 } | 396 } |
396 | 397 |
397 Mutex* profiler_data_mutex() { | 398 Mutex* profiler_data_mutex() { |
398 return &profiler_data_mutex_; | 399 return &profiler_data_mutex_; |
399 } | 400 } |
400 | 401 |
401 void set_profiler_data(IsolateProfilerData* profiler_data) { | 402 void set_profiler_data(IsolateProfilerData* profiler_data) { |
402 profiler_data_ = profiler_data; | 403 profiler_data_ = profiler_data; |
403 } | 404 } |
404 | 405 |
405 IsolateProfilerData* profiler_data() { | 406 IsolateProfilerData* profiler_data() const { |
406 return profiler_data_; | 407 return profiler_data_; |
407 } | 408 } |
408 | 409 |
409 void PrintToJSONStream(JSONStream* stream); | 410 void PrintToJSONStream(JSONStream* stream); |
410 | 411 |
412 void set_thread_state(InterruptableThreadState* state) { | |
413 ASSERT((thread_state_ == NULL) || (state == NULL)); | |
414 thread_state_ = state; | |
415 } | |
416 | |
417 InterruptableThreadState* thread_state() const { | |
418 return thread_state_; | |
419 } | |
420 | |
411 private: | 421 private: |
412 Isolate(); | 422 Isolate(); |
413 | 423 |
414 void BuildName(const char* name_prefix); | 424 void BuildName(const char* name_prefix); |
415 void PrintInvokedFunctions(); | 425 void PrintInvokedFunctions(); |
416 | 426 |
417 template<class T> T* AllocateReusableHandle(); | 427 template<class T> T* AllocateReusableHandle(); |
418 | 428 |
419 static ThreadLocalKey isolate_key; | 429 static ThreadLocalKey isolate_key; |
420 | 430 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 // Status support. | 465 // Status support. |
456 char* stacktrace_; | 466 char* stacktrace_; |
457 intptr_t stack_frame_index_; | 467 intptr_t stack_frame_index_; |
458 ObjectHistogram* object_histogram_; | 468 ObjectHistogram* object_histogram_; |
459 | 469 |
460 // Ring buffer of objects assigned an id. | 470 // Ring buffer of objects assigned an id. |
461 ObjectIdRing* object_id_ring_; | 471 ObjectIdRing* object_id_ring_; |
462 | 472 |
463 IsolateProfilerData* profiler_data_; | 473 IsolateProfilerData* profiler_data_; |
464 Mutex profiler_data_mutex_; | 474 Mutex profiler_data_mutex_; |
475 InterruptableThreadState* thread_state_; | |
465 | 476 |
466 // Reusable handles support. | 477 // Reusable handles support. |
467 #define REUSABLE_HANDLE_FIELDS(object) \ | 478 #define REUSABLE_HANDLE_FIELDS(object) \ |
468 object* object##_handle_; \ | 479 object* object##_handle_; \ |
469 | 480 |
470 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_FIELDS) | 481 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_FIELDS) |
471 #undef REUSABLE_HANDLE_FIELDS | 482 #undef REUSABLE_HANDLE_FIELDS |
472 VMHandles reusable_handles_; | 483 VMHandles reusable_handles_; |
473 | 484 |
474 static Dart_IsolateCreateCallback create_callback_; | 485 static Dart_IsolateCreateCallback create_callback_; |
475 static Dart_IsolateInterruptCallback interrupt_callback_; | 486 static Dart_IsolateInterruptCallback interrupt_callback_; |
476 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; | 487 static Dart_IsolateUnhandledExceptionCallback unhandled_exception_callback_; |
477 static Dart_IsolateShutdownCallback shutdown_callback_; | 488 static Dart_IsolateShutdownCallback shutdown_callback_; |
478 static Dart_FileOpenCallback file_open_callback_; | 489 static Dart_FileOpenCallback file_open_callback_; |
479 static Dart_FileReadCallback file_read_callback_; | 490 static Dart_FileReadCallback file_read_callback_; |
480 static Dart_FileWriteCallback file_write_callback_; | 491 static Dart_FileWriteCallback file_write_callback_; |
481 static Dart_FileCloseCallback file_close_callback_; | 492 static Dart_FileCloseCallback file_close_callback_; |
482 static Dart_EntropySource entropy_source_callback_; | 493 static Dart_EntropySource entropy_source_callback_; |
483 static Dart_IsolateInterruptCallback vmstats_callback_; | 494 static Dart_IsolateInterruptCallback vmstats_callback_; |
484 static Dart_ServiceIsolateCreateCalback service_create_callback_; | 495 static Dart_ServiceIsolateCreateCalback service_create_callback_; |
485 | 496 |
497 // List of existing isolates. | |
498 static void IsolateCreated(Isolate* isolate); | |
499 static void IsolateShutdown(Isolate* isolate); | |
500 static void ResizeIsolates(intptr_t new_capacity); | |
501 static intptr_t FindIsolateIndex(Isolate* isolate); | |
502 static void CheckNoIsolateHasThreadData(InterruptableThreadState* state); | |
503 static Monitor* isolates_monitor_; | |
504 static Isolate** isolates_; | |
505 static intptr_t isolates_capacity_; | |
506 static intptr_t isolates_size_; | |
siva
2014/02/05 19:09:15
Why not just make the isolate list a singly linked
Cutch
2014/02/05 23:00:31
Done.
| |
507 | |
486 friend class ReusableHandleScope; | 508 friend class ReusableHandleScope; |
487 friend class ReusableObjectHandleScope; | 509 friend class ReusableObjectHandleScope; |
510 friend class ThreadInterrupter; | |
511 friend class ThreadInterrupterAndroid; | |
512 friend class ThreadInterrupterMacOS; | |
513 friend class ThreadInterrupterLinux; | |
514 friend class ThreadInterrupterWin; | |
siva
2014/02/05 19:09:15
Seems weird that you are having to friend a bunch
Cutch
2014/02/05 23:00:31
Done.
| |
515 | |
488 DISALLOW_COPY_AND_ASSIGN(Isolate); | 516 DISALLOW_COPY_AND_ASSIGN(Isolate); |
489 }; | 517 }; |
490 | 518 |
491 | 519 |
492 // When we need to execute code in an isolate, we use the | 520 // When we need to execute code in an isolate, we use the |
493 // StartIsolateScope. | 521 // StartIsolateScope. |
494 class StartIsolateScope { | 522 class StartIsolateScope { |
495 public: | 523 public: |
496 explicit StartIsolateScope(Isolate* new_isolate) | 524 explicit StartIsolateScope(Isolate* new_isolate) |
497 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { | 525 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 char* script_url_; | 605 char* script_url_; |
578 char* library_url_; | 606 char* library_url_; |
579 char* class_name_; | 607 char* class_name_; |
580 char* function_name_; | 608 char* function_name_; |
581 char* exception_callback_name_; | 609 char* exception_callback_name_; |
582 }; | 610 }; |
583 | 611 |
584 } // namespace dart | 612 } // namespace dart |
585 | 613 |
586 #endif // VM_ISOLATE_H_ | 614 #endif // VM_ISOLATE_H_ |
OLD | NEW |