| 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 RUNTIME_VM_ISOLATE_H_ | 5 #ifndef RUNTIME_VM_ISOLATE_H_ |
| 6 #define RUNTIME_VM_ISOLATE_H_ | 6 #define RUNTIME_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/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 class StackResource; | 66 class StackResource; |
| 67 class StackZone; | 67 class StackZone; |
| 68 class StoreBuffer; | 68 class StoreBuffer; |
| 69 class StubCode; | 69 class StubCode; |
| 70 class ThreadRegistry; | 70 class ThreadRegistry; |
| 71 class UserTag; | 71 class UserTag; |
| 72 | 72 |
| 73 | 73 |
| 74 class PendingLazyDeopt { | 74 class PendingLazyDeopt { |
| 75 public: | 75 public: |
| 76 PendingLazyDeopt(uword fp, uword pc) : fp_(fp), pc_(pc) { } | 76 PendingLazyDeopt(uword fp, uword pc) : fp_(fp), pc_(pc) {} |
| 77 uword fp() { return fp_; } | 77 uword fp() { return fp_; } |
| 78 uword pc() { return pc_; } | 78 uword pc() { return pc_; } |
| 79 void set_pc(uword pc) { pc_ = pc; } | 79 void set_pc(uword pc) { pc_ = pc; } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 uword fp_; | 82 uword fp_; |
| 83 uword pc_; | 83 uword pc_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 | 86 |
| 87 class IsolateVisitor { | 87 class IsolateVisitor { |
| 88 public: | 88 public: |
| 89 IsolateVisitor() {} | 89 IsolateVisitor() {} |
| 90 virtual ~IsolateVisitor() {} | 90 virtual ~IsolateVisitor() {} |
| 91 | 91 |
| 92 virtual void VisitIsolate(Isolate* isolate) = 0; | 92 virtual void VisitIsolate(Isolate* isolate) = 0; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 DISALLOW_COPY_AND_ASSIGN(IsolateVisitor); | 95 DISALLOW_COPY_AND_ASSIGN(IsolateVisitor); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 | 98 |
| 99 // Disallow OOB message handling within this scope. | 99 // Disallow OOB message handling within this scope. |
| 100 class NoOOBMessageScope : public StackResource { | 100 class NoOOBMessageScope : public StackResource { |
| 101 public: | 101 public: |
| 102 explicit NoOOBMessageScope(Thread* thread); | 102 explicit NoOOBMessageScope(Thread* thread); |
| 103 ~NoOOBMessageScope(); | 103 ~NoOOBMessageScope(); |
| 104 |
| 104 private: | 105 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); | 106 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 | 109 |
| 109 // Disallow isolate reload. | 110 // Disallow isolate reload. |
| 110 class NoReloadScope : public StackResource { | 111 class NoReloadScope : public StackResource { |
| 111 public: | 112 public: |
| 112 NoReloadScope(Isolate* isolate, Thread* thread); | 113 NoReloadScope(Isolate* isolate, Thread* thread); |
| 113 ~NoReloadScope(); | 114 ~NoReloadScope(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 200 |
| 200 int64_t start_time() const { return start_time_; } | 201 int64_t start_time() const { return start_time_; } |
| 201 | 202 |
| 202 Dart_Port main_port() const { return main_port_; } | 203 Dart_Port main_port() const { return main_port_; } |
| 203 void set_main_port(Dart_Port port) { | 204 void set_main_port(Dart_Port port) { |
| 204 ASSERT(main_port_ == 0); // Only set main port once. | 205 ASSERT(main_port_ == 0); // Only set main port once. |
| 205 main_port_ = port; | 206 main_port_ = port; |
| 206 } | 207 } |
| 207 Dart_Port origin_id() const { return origin_id_; } | 208 Dart_Port origin_id() const { return origin_id_; } |
| 208 void set_origin_id(Dart_Port id) { | 209 void set_origin_id(Dart_Port id) { |
| 209 ASSERT((id == main_port_ && origin_id_ == 0) || | 210 ASSERT((id == main_port_ && origin_id_ == 0) || (origin_id_ == main_port_)); |
| 210 (origin_id_ == main_port_)); | |
| 211 origin_id_ = id; | 211 origin_id_ = id; |
| 212 } | 212 } |
| 213 void set_pause_capability(uint64_t value) { pause_capability_ = value; } | 213 void set_pause_capability(uint64_t value) { pause_capability_ = value; } |
| 214 uint64_t pause_capability() const { return pause_capability_; } | 214 uint64_t pause_capability() const { return pause_capability_; } |
| 215 void set_terminate_capability(uint64_t value) { | 215 void set_terminate_capability(uint64_t value) { |
| 216 terminate_capability_ = value; | 216 terminate_capability_ = value; |
| 217 } | 217 } |
| 218 uint64_t terminate_capability() const { return terminate_capability_; } | 218 uint64_t terminate_capability() const { return terminate_capability_; } |
| 219 | 219 |
| 220 void SendInternalLibMessage(LibMsgId msg_id, uint64_t capability); | 220 void SendInternalLibMessage(LibMsgId msg_id, uint64_t capability); |
| 221 | 221 |
| 222 Heap* heap() const { return heap_; } | 222 Heap* heap() const { return heap_; } |
| 223 void set_heap(Heap* value) { heap_ = value; } | 223 void set_heap(Heap* value) { heap_ = value; } |
| 224 | 224 |
| 225 ObjectStore* object_store() const { return object_store_; } | 225 ObjectStore* object_store() const { return object_store_; } |
| 226 void set_object_store(ObjectStore* value) { object_store_ = value; } | 226 void set_object_store(ObjectStore* value) { object_store_ = value; } |
| 227 static intptr_t object_store_offset() { | 227 static intptr_t object_store_offset() { |
| 228 return OFFSET_OF(Isolate, object_store_); | 228 return OFFSET_OF(Isolate, object_store_); |
| 229 } | 229 } |
| 230 | 230 |
| 231 ApiState* api_state() const { return api_state_; } | 231 ApiState* api_state() const { return api_state_; } |
| 232 void set_api_state(ApiState* value) { api_state_ = value; } | 232 void set_api_state(ApiState* value) { api_state_ = value; } |
| 233 | 233 |
| 234 void set_init_callback_data(void* value) { | 234 void set_init_callback_data(void* value) { init_callback_data_ = value; } |
| 235 init_callback_data_ = value; | 235 void* init_callback_data() const { return init_callback_data_; } |
| 236 } | |
| 237 void* init_callback_data() const { | |
| 238 return init_callback_data_; | |
| 239 } | |
| 240 | 236 |
| 241 Dart_EnvironmentCallback environment_callback() const { | 237 Dart_EnvironmentCallback environment_callback() const { |
| 242 return environment_callback_; | 238 return environment_callback_; |
| 243 } | 239 } |
| 244 void set_environment_callback(Dart_EnvironmentCallback value) { | 240 void set_environment_callback(Dart_EnvironmentCallback value) { |
| 245 environment_callback_ = value; | 241 environment_callback_ = value; |
| 246 } | 242 } |
| 247 | 243 |
| 248 Dart_LibraryTagHandler library_tag_handler() const { | 244 Dart_LibraryTagHandler library_tag_handler() const { |
| 249 return library_tag_handler_; | 245 return library_tag_handler_; |
| 250 } | 246 } |
| 251 void set_library_tag_handler(Dart_LibraryTagHandler value) { | 247 void set_library_tag_handler(Dart_LibraryTagHandler value) { |
| 252 library_tag_handler_ = value; | 248 library_tag_handler_ = value; |
| 253 } | 249 } |
| 254 | 250 |
| 255 void SetupInstructionsSnapshotPage( | 251 void SetupInstructionsSnapshotPage( |
| 256 const uint8_t* instructions_snapshot_buffer); | 252 const uint8_t* instructions_snapshot_buffer); |
| 257 void SetupDataSnapshotPage( | 253 void SetupDataSnapshotPage(const uint8_t* instructions_snapshot_buffer); |
| 258 const uint8_t* instructions_snapshot_buffer); | |
| 259 | 254 |
| 260 void ScheduleMessageInterrupts(); | 255 void ScheduleMessageInterrupts(); |
| 261 | 256 |
| 262 // Marks all libraries as loaded. | 257 // Marks all libraries as loaded. |
| 263 void DoneLoading(); | 258 void DoneLoading(); |
| 264 void DoneFinalizing(); | 259 void DoneFinalizing(); |
| 265 | 260 |
| 266 // By default the reload context is deleted. This parameter allows | 261 // By default the reload context is deleted. This parameter allows |
| 267 // the caller to delete is separately if it is still needed. | 262 // the caller to delete is separately if it is still needed. |
| 268 bool ReloadSources(JSONStream* js, | 263 bool ReloadSources(JSONStream* js, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 287 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } | 282 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } |
| 288 | 283 |
| 289 Mutex* mutex() const { return mutex_; } | 284 Mutex* mutex() const { return mutex_; } |
| 290 Mutex* symbols_mutex() const { return symbols_mutex_; } | 285 Mutex* symbols_mutex() const { return symbols_mutex_; } |
| 291 Mutex* type_canonicalization_mutex() const { | 286 Mutex* type_canonicalization_mutex() const { |
| 292 return type_canonicalization_mutex_; | 287 return type_canonicalization_mutex_; |
| 293 } | 288 } |
| 294 Mutex* constant_canonicalization_mutex() const { | 289 Mutex* constant_canonicalization_mutex() const { |
| 295 return constant_canonicalization_mutex_; | 290 return constant_canonicalization_mutex_; |
| 296 } | 291 } |
| 297 Mutex* megamorphic_lookup_mutex() const { | 292 Mutex* megamorphic_lookup_mutex() const { return megamorphic_lookup_mutex_; } |
| 298 return megamorphic_lookup_mutex_; | |
| 299 } | |
| 300 | 293 |
| 301 Debugger* debugger() const { | 294 Debugger* debugger() const { |
| 302 if (!FLAG_support_debugger) { | 295 if (!FLAG_support_debugger) { |
| 303 return NULL; | 296 return NULL; |
| 304 } | 297 } |
| 305 ASSERT(debugger_ != NULL); | 298 ASSERT(debugger_ != NULL); |
| 306 return debugger_; | 299 return debugger_; |
| 307 } | 300 } |
| 308 | 301 |
| 309 void set_single_step(bool value) { single_step_ = value; } | 302 void set_single_step(bool value) { single_step_ = value; } |
| 310 bool single_step() const { return single_step_; } | 303 bool single_step() const { return single_step_; } |
| 311 static intptr_t single_step_offset() { | 304 static intptr_t single_step_offset() { |
| 312 return OFFSET_OF(Isolate, single_step_); | 305 return OFFSET_OF(Isolate, single_step_); |
| 313 } | 306 } |
| 314 | 307 |
| 315 void set_has_compiled_code(bool value) { has_compiled_code_ = value; } | 308 void set_has_compiled_code(bool value) { has_compiled_code_ = value; } |
| 316 bool has_compiled_code() const { return has_compiled_code_; } | 309 bool has_compiled_code() const { return has_compiled_code_; } |
| 317 | 310 |
| 318 // Lets the embedder know that a service message resulted in a resume request. | 311 // Lets the embedder know that a service message resulted in a resume request. |
| 319 void SetResumeRequest() { | 312 void SetResumeRequest() { |
| 320 resume_request_ = true; | 313 resume_request_ = true; |
| 321 set_last_resume_timestamp(); | 314 set_last_resume_timestamp(); |
| 322 } | 315 } |
| 323 | 316 |
| 324 void set_last_resume_timestamp() { | 317 void set_last_resume_timestamp() { |
| 325 last_resume_timestamp_ = OS::GetCurrentTimeMillis(); | 318 last_resume_timestamp_ = OS::GetCurrentTimeMillis(); |
| 326 } | 319 } |
| 327 | 320 |
| 328 int64_t last_resume_timestamp() const { | 321 int64_t last_resume_timestamp() const { return last_resume_timestamp_; } |
| 329 return last_resume_timestamp_; | |
| 330 } | |
| 331 | 322 |
| 332 // Returns whether the vm service has requested that the debugger | 323 // Returns whether the vm service has requested that the debugger |
| 333 // resume execution. | 324 // resume execution. |
| 334 bool GetAndClearResumeRequest() { | 325 bool GetAndClearResumeRequest() { |
| 335 bool resume_request = resume_request_; | 326 bool resume_request = resume_request_; |
| 336 resume_request_ = false; | 327 resume_request_ = false; |
| 337 return resume_request; | 328 return resume_request; |
| 338 } | 329 } |
| 339 | 330 |
| 340 // Verify that the sender has the capability to pause or terminate the | 331 // Verify that the sender has the capability to pause or terminate the |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 return create_callback_; | 383 return create_callback_; |
| 393 } | 384 } |
| 394 | 385 |
| 395 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { | 386 static void SetShutdownCallback(Dart_IsolateShutdownCallback cb) { |
| 396 shutdown_callback_ = cb; | 387 shutdown_callback_ = cb; |
| 397 } | 388 } |
| 398 static Dart_IsolateShutdownCallback ShutdownCallback() { | 389 static Dart_IsolateShutdownCallback ShutdownCallback() { |
| 399 return shutdown_callback_; | 390 return shutdown_callback_; |
| 400 } | 391 } |
| 401 | 392 |
| 402 void set_object_id_ring(ObjectIdRing* ring) { | 393 void set_object_id_ring(ObjectIdRing* ring) { object_id_ring_ = ring; } |
| 403 object_id_ring_ = ring; | 394 ObjectIdRing* object_id_ring() { return object_id_ring_; } |
| 404 } | |
| 405 ObjectIdRing* object_id_ring() { | |
| 406 return object_id_ring_; | |
| 407 } | |
| 408 | 395 |
| 409 void AddPendingDeopt(uword fp, uword pc); | 396 void AddPendingDeopt(uword fp, uword pc); |
| 410 uword FindPendingDeopt(uword fp) const; | 397 uword FindPendingDeopt(uword fp) const; |
| 411 void ClearPendingDeoptsAtOrBelow(uword fp) const; | 398 void ClearPendingDeoptsAtOrBelow(uword fp) const; |
| 412 MallocGrowableArray<PendingLazyDeopt>* pending_deopts() const { | 399 MallocGrowableArray<PendingLazyDeopt>* pending_deopts() const { |
| 413 return pending_deopts_; | 400 return pending_deopts_; |
| 414 } | 401 } |
| 415 bool IsDeoptimizing() const { return deopt_context_ != NULL; } | 402 bool IsDeoptimizing() const { return deopt_context_ != NULL; } |
| 416 DeoptContext* deopt_context() const { return deopt_context_; } | 403 DeoptContext* deopt_context() const { return deopt_context_; } |
| 417 void set_deopt_context(DeoptContext* value) { | 404 void set_deopt_context(DeoptContext* value) { |
| 418 ASSERT(value == NULL || deopt_context_ == NULL); | 405 ASSERT(value == NULL || deopt_context_ == NULL); |
| 419 deopt_context_ = value; | 406 deopt_context_ = value; |
| 420 } | 407 } |
| 421 | 408 |
| 422 BackgroundCompiler* background_compiler() const { | 409 BackgroundCompiler* background_compiler() const { |
| 423 return background_compiler_; | 410 return background_compiler_; |
| 424 } | 411 } |
| 425 void set_background_compiler(BackgroundCompiler* value) { | 412 void set_background_compiler(BackgroundCompiler* value) { |
| 426 // Do not overwrite a background compiler (memory leak). | 413 // Do not overwrite a background compiler (memory leak). |
| 427 ASSERT((value == NULL) || (background_compiler_ == NULL)); | 414 ASSERT((value == NULL) || (background_compiler_ == NULL)); |
| 428 background_compiler_ = value; | 415 background_compiler_ = value; |
| 429 } | 416 } |
| 430 | 417 |
| 431 void enable_background_compiler() { | 418 void enable_background_compiler() { |
| 432 background_compiler_disabled_depth_--; | 419 background_compiler_disabled_depth_--; |
| 433 if (background_compiler_disabled_depth_ < 0) { | 420 if (background_compiler_disabled_depth_ < 0) { |
| 434 FATAL("Mismatched number of calls to disable_background_compiler and " | 421 FATAL( |
| 435 "enable_background_compiler."); | 422 "Mismatched number of calls to disable_background_compiler and " |
| 423 "enable_background_compiler."); |
| 436 } | 424 } |
| 437 } | 425 } |
| 438 | 426 |
| 439 void disable_background_compiler() { | 427 void disable_background_compiler() { background_compiler_disabled_depth_++; } |
| 440 background_compiler_disabled_depth_++; | |
| 441 } | |
| 442 | 428 |
| 443 bool is_background_compiler_disabled() const { | 429 bool is_background_compiler_disabled() const { |
| 444 return background_compiler_disabled_depth_ > 0; | 430 return background_compiler_disabled_depth_ > 0; |
| 445 } | 431 } |
| 446 | 432 |
| 447 void UpdateLastAllocationProfileAccumulatorResetTimestamp() { | 433 void UpdateLastAllocationProfileAccumulatorResetTimestamp() { |
| 448 last_allocationprofile_accumulator_reset_timestamp_ = | 434 last_allocationprofile_accumulator_reset_timestamp_ = |
| 449 OS::GetCurrentTimeMillis(); | 435 OS::GetCurrentTimeMillis(); |
| 450 } | 436 } |
| 451 | 437 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 478 | 464 |
| 479 #ifndef PRODUCT | 465 #ifndef PRODUCT |
| 480 void PrintJSON(JSONStream* stream, bool ref = true); | 466 void PrintJSON(JSONStream* stream, bool ref = true); |
| 481 #endif | 467 #endif |
| 482 | 468 |
| 483 // Mutator thread is used to aggregate compiler stats. | 469 // Mutator thread is used to aggregate compiler stats. |
| 484 CompilerStats* aggregate_compiler_stats() { | 470 CompilerStats* aggregate_compiler_stats() { |
| 485 return mutator_thread()->compiler_stats(); | 471 return mutator_thread()->compiler_stats(); |
| 486 } | 472 } |
| 487 | 473 |
| 488 VMTagCounters* vm_tag_counters() { | 474 VMTagCounters* vm_tag_counters() { return &vm_tag_counters_; } |
| 489 return &vm_tag_counters_; | |
| 490 } | |
| 491 | 475 |
| 492 bool IsReloading() const { | 476 bool IsReloading() const { return reload_context_ != NULL; } |
| 493 return reload_context_ != NULL; | |
| 494 } | |
| 495 | 477 |
| 496 IsolateReloadContext* reload_context() { | 478 IsolateReloadContext* reload_context() { return reload_context_; } |
| 497 return reload_context_; | |
| 498 } | |
| 499 | 479 |
| 500 void DeleteReloadContext(); | 480 void DeleteReloadContext(); |
| 501 | 481 |
| 502 bool HasAttemptedReload() const { | 482 bool HasAttemptedReload() const { return has_attempted_reload_; } |
| 503 return has_attempted_reload_; | |
| 504 } | |
| 505 | 483 |
| 506 bool CanReload() const; | 484 bool CanReload() const; |
| 507 | 485 |
| 508 void set_last_reload_timestamp(int64_t value) { | 486 void set_last_reload_timestamp(int64_t value) { |
| 509 last_reload_timestamp_ = value; | 487 last_reload_timestamp_ = value; |
| 510 } | 488 } |
| 511 int64_t last_reload_timestamp() const { | 489 int64_t last_reload_timestamp() const { return last_reload_timestamp_; } |
| 512 return last_reload_timestamp_; | |
| 513 } | |
| 514 | 490 |
| 515 bool IsPaused() const; | 491 bool IsPaused() const; |
| 516 | 492 |
| 517 bool should_pause_post_service_request() const { | 493 bool should_pause_post_service_request() const { |
| 518 return should_pause_post_service_request_; | 494 return should_pause_post_service_request_; |
| 519 } | 495 } |
| 520 void set_should_pause_post_service_request( | 496 void set_should_pause_post_service_request( |
| 521 bool should_pause_post_service_request) { | 497 bool should_pause_post_service_request) { |
| 522 should_pause_post_service_request_ = should_pause_post_service_request; | 498 should_pause_post_service_request_ = should_pause_post_service_request; |
| 523 } | 499 } |
| 524 | 500 |
| 525 void PausePostRequest(); | 501 void PausePostRequest(); |
| 526 | 502 |
| 527 uword user_tag() const { | 503 uword user_tag() const { return user_tag_; } |
| 528 return user_tag_; | 504 static intptr_t user_tag_offset() { return OFFSET_OF(Isolate, user_tag_); } |
| 529 } | |
| 530 static intptr_t user_tag_offset() { | |
| 531 return OFFSET_OF(Isolate, user_tag_); | |
| 532 } | |
| 533 static intptr_t current_tag_offset() { | 505 static intptr_t current_tag_offset() { |
| 534 return OFFSET_OF(Isolate, current_tag_); | 506 return OFFSET_OF(Isolate, current_tag_); |
| 535 } | 507 } |
| 536 static intptr_t default_tag_offset() { | 508 static intptr_t default_tag_offset() { |
| 537 return OFFSET_OF(Isolate, default_tag_); | 509 return OFFSET_OF(Isolate, default_tag_); |
| 538 } | 510 } |
| 539 | 511 |
| 540 #define ISOLATE_METRIC_ACCESSOR(type, variable, name, unit) \ | 512 #define ISOLATE_METRIC_ACCESSOR(type, variable, name, unit) \ |
| 541 type* Get##variable##Metric() { return &metric_##variable##_; } | 513 type* Get##variable##Metric() { return &metric_##variable##_; } |
| 542 ISOLATE_METRIC_LIST(ISOLATE_METRIC_ACCESSOR); | 514 ISOLATE_METRIC_LIST(ISOLATE_METRIC_ACCESSOR); |
| 543 #undef ISOLATE_METRIC_ACCESSOR | 515 #undef ISOLATE_METRIC_ACCESSOR |
| 544 | 516 |
| 545 static intptr_t IsolateListLength(); | 517 static intptr_t IsolateListLength(); |
| 546 | 518 |
| 547 RawGrowableObjectArray* tag_table() const { return tag_table_; } | 519 RawGrowableObjectArray* tag_table() const { return tag_table_; } |
| 548 void set_tag_table(const GrowableObjectArray& value); | 520 void set_tag_table(const GrowableObjectArray& value); |
| 549 | 521 |
| 550 RawUserTag* current_tag() const { return current_tag_; } | 522 RawUserTag* current_tag() const { return current_tag_; } |
| 551 void set_current_tag(const UserTag& tag); | 523 void set_current_tag(const UserTag& tag); |
| 552 | 524 |
| 553 RawUserTag* default_tag() const { return default_tag_; } | 525 RawUserTag* default_tag() const { return default_tag_; } |
| 554 void set_default_tag(const UserTag& tag); | 526 void set_default_tag(const UserTag& tag); |
| 555 | 527 |
| 556 void set_ic_miss_code(const Code& code); | 528 void set_ic_miss_code(const Code& code); |
| 557 | 529 |
| 558 Metric* metrics_list_head() { | 530 Metric* metrics_list_head() { return metrics_list_head_; } |
| 559 return metrics_list_head_; | |
| 560 } | |
| 561 | 531 |
| 562 void set_metrics_list_head(Metric* metric) { | 532 void set_metrics_list_head(Metric* metric) { metrics_list_head_ = metric; } |
| 563 metrics_list_head_ = metric; | |
| 564 } | |
| 565 | 533 |
| 566 RawGrowableObjectArray* deoptimized_code_array() const { | 534 RawGrowableObjectArray* deoptimized_code_array() const { |
| 567 return deoptimized_code_array_; | 535 return deoptimized_code_array_; |
| 568 } | 536 } |
| 569 void set_deoptimized_code_array(const GrowableObjectArray& value); | 537 void set_deoptimized_code_array(const GrowableObjectArray& value); |
| 570 void TrackDeoptimizedCode(const Code& code); | 538 void TrackDeoptimizedCode(const Code& code); |
| 571 | 539 |
| 572 // Also sends a paused at exit event over the service protocol. | 540 // Also sends a paused at exit event over the service protocol. |
| 573 void SetStickyError(RawError* sticky_error); | 541 void SetStickyError(RawError* sticky_error); |
| 574 | 542 |
| 575 RawError* sticky_error() const { return sticky_error_; } | 543 RawError* sticky_error() const { return sticky_error_; } |
| 576 void clear_sticky_error(); | 544 void clear_sticky_error(); |
| 577 | 545 |
| 578 bool compilation_allowed() const { return compilation_allowed_; } | 546 bool compilation_allowed() const { return compilation_allowed_; } |
| 579 void set_compilation_allowed(bool allowed) { | 547 void set_compilation_allowed(bool allowed) { compilation_allowed_ = allowed; } |
| 580 compilation_allowed_ = allowed; | |
| 581 } | |
| 582 | 548 |
| 583 // In precompilation we finalize all regular classes before compiling. | 549 // In precompilation we finalize all regular classes before compiling. |
| 584 bool all_classes_finalized() const { return all_classes_finalized_; } | 550 bool all_classes_finalized() const { return all_classes_finalized_; } |
| 585 void set_all_classes_finalized(bool value) { | 551 void set_all_classes_finalized(bool value) { all_classes_finalized_ = value; } |
| 586 all_classes_finalized_ = value; | |
| 587 } | |
| 588 | 552 |
| 589 // True during top level parsing. | 553 // True during top level parsing. |
| 590 bool IsTopLevelParsing() { | 554 bool IsTopLevelParsing() { |
| 591 const intptr_t value = | 555 const intptr_t value = |
| 592 AtomicOperations::LoadRelaxed(&top_level_parsing_count_); | 556 AtomicOperations::LoadRelaxed(&top_level_parsing_count_); |
| 593 ASSERT(value >= 0); | 557 ASSERT(value >= 0); |
| 594 return value > 0; | 558 return value > 0; |
| 595 } | 559 } |
| 596 | 560 |
| 597 void IncrTopLevelParsingCount() { | 561 void IncrTopLevelParsingCount() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 615 | 579 |
| 616 // Used by background compiler which field became boxed and must trigger | 580 // Used by background compiler which field became boxed and must trigger |
| 617 // deoptimization in the mutator thread. | 581 // deoptimization in the mutator thread. |
| 618 void AddDeoptimizingBoxedField(const Field& field); | 582 void AddDeoptimizingBoxedField(const Field& field); |
| 619 // Returns Field::null() if none available in the list. | 583 // Returns Field::null() if none available in the list. |
| 620 RawField* GetDeoptimizingBoxedField(); | 584 RawField* GetDeoptimizingBoxedField(); |
| 621 | 585 |
| 622 #ifndef PRODUCT | 586 #ifndef PRODUCT |
| 623 RawObject* InvokePendingServiceExtensionCalls(); | 587 RawObject* InvokePendingServiceExtensionCalls(); |
| 624 void AppendServiceExtensionCall(const Instance& closure, | 588 void AppendServiceExtensionCall(const Instance& closure, |
| 625 const String& method_name, | 589 const String& method_name, |
| 626 const Array& parameter_keys, | 590 const Array& parameter_keys, |
| 627 const Array& parameter_values, | 591 const Array& parameter_values, |
| 628 const Instance& reply_port, | 592 const Instance& reply_port, |
| 629 const Instance& id); | 593 const Instance& id); |
| 630 void RegisterServiceExtensionHandler(const String& name, | 594 void RegisterServiceExtensionHandler(const String& name, |
| 631 const Instance& closure); | 595 const Instance& closure); |
| 632 RawInstance* LookupServiceExtensionHandler(const String& name); | 596 RawInstance* LookupServiceExtensionHandler(const String& name); |
| 633 #endif | 597 #endif |
| 634 | 598 |
| 635 static void VisitIsolates(IsolateVisitor* visitor); | 599 static void VisitIsolates(IsolateVisitor* visitor); |
| 636 | 600 |
| 637 // Handle service messages until we are told to resume execution. | 601 // Handle service messages until we are told to resume execution. |
| 638 void PauseEventHandler(); | 602 void PauseEventHandler(); |
| 639 | 603 |
| 640 void AddClosureFunction(const Function& function) const; | 604 void AddClosureFunction(const Function& function) const; |
| 641 RawFunction* LookupClosureFunction(const Function& parent, | 605 RawFunction* LookupClosureFunction(const Function& parent, |
| 642 TokenPosition token_pos) const; | 606 TokenPosition token_pos) const; |
| 643 intptr_t FindClosureIndex(const Function& needle) const; | 607 intptr_t FindClosureIndex(const Function& needle) const; |
| 644 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; | 608 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; |
| 645 | 609 |
| 646 bool is_service_isolate() const { return is_service_isolate_; } | 610 bool is_service_isolate() const { return is_service_isolate_; } |
| 647 | 611 |
| 648 // Isolate-specific flag handling. | 612 // Isolate-specific flag handling. |
| 649 static void FlagsInitialize(Dart_IsolateFlags* api_flags); | 613 static void FlagsInitialize(Dart_IsolateFlags* api_flags); |
| 650 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; | 614 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; |
| 651 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); | 615 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); |
| 652 | 616 |
| 653 #if defined(PRODUCT) | 617 #if defined(PRODUCT) |
| 654 bool type_checks() const { return FLAG_enable_type_checks; } | 618 bool type_checks() const { return FLAG_enable_type_checks; } |
| 655 bool asserts() const { return FLAG_enable_asserts; } | 619 bool asserts() const { return FLAG_enable_asserts; } |
| 656 bool error_on_bad_type() const { return FLAG_error_on_bad_type; } | 620 bool error_on_bad_type() const { return FLAG_error_on_bad_type; } |
| 657 bool error_on_bad_override() const { return FLAG_error_on_bad_override; } | 621 bool error_on_bad_override() const { return FLAG_error_on_bad_override; } |
| 658 #else // defined(PRODUCT) | 622 #else // defined(PRODUCT) |
| 659 bool type_checks() const { return type_checks_; } | 623 bool type_checks() const { return type_checks_; } |
| 660 bool asserts() const { return asserts_; } | 624 bool asserts() const { return asserts_; } |
| 661 bool error_on_bad_type() const { return error_on_bad_type_; } | 625 bool error_on_bad_type() const { return error_on_bad_type_; } |
| 662 bool error_on_bad_override() const { return error_on_bad_override_; } | 626 bool error_on_bad_override() const { return error_on_bad_override_; } |
| 663 #endif // defined(PRODUCT) | 627 #endif // defined(PRODUCT) |
| 664 | 628 |
| 665 static void KillAllIsolates(LibMsgId msg_id); | 629 static void KillAllIsolates(LibMsgId msg_id); |
| 666 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); | 630 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); |
| 667 | 631 |
| 668 static void DisableIsolateCreation(); | 632 static void DisableIsolateCreation(); |
| 669 static void EnableIsolateCreation(); | 633 static void EnableIsolateCreation(); |
| 670 static bool IsolateCreationEnabled(); | 634 static bool IsolateCreationEnabled(); |
| 671 | 635 |
| 672 void StopBackgroundCompiler(); | 636 void StopBackgroundCompiler(); |
| 673 | 637 |
| 674 intptr_t reload_every_n_stack_overflow_checks() const { | 638 intptr_t reload_every_n_stack_overflow_checks() const { |
| 675 return reload_every_n_stack_overflow_checks_; | 639 return reload_every_n_stack_overflow_checks_; |
| 676 } | 640 } |
| 677 | 641 |
| 678 void MaybeIncreaseReloadEveryNStackOverflowChecks(); | 642 void MaybeIncreaseReloadEveryNStackOverflowChecks(); |
| 679 | 643 |
| 680 private: | 644 private: |
| 681 friend class Dart; // Init, InitOnce, Shutdown. | 645 friend class Dart; // Init, InitOnce, Shutdown. |
| 682 friend class IsolateKillerVisitor; // Kill(). | 646 friend class IsolateKillerVisitor; // Kill(). |
| 683 | 647 |
| 684 explicit Isolate(const Dart_IsolateFlags& api_flags); | 648 explicit Isolate(const Dart_IsolateFlags& api_flags); |
| 685 | 649 |
| 686 static void InitOnce(); | 650 static void InitOnce(); |
| 687 static Isolate* Init(const char* name_prefix, | 651 static Isolate* Init(const char* name_prefix, |
| 688 const Dart_IsolateFlags& api_flags, | 652 const Dart_IsolateFlags& api_flags, |
| 689 bool is_vm_isolate = false); | 653 bool is_vm_isolate = false); |
| 690 | 654 |
| 691 // The isolates_list_monitor_ should be held when calling Kill(). | 655 // The isolates_list_monitor_ should be held when calling Kill(). |
| 692 void KillLocked(LibMsgId msg_id); | 656 void KillLocked(LibMsgId msg_id); |
| 693 | 657 |
| 694 void LowLevelShutdown(); | 658 void LowLevelShutdown(); |
| 695 void Shutdown(); | 659 void Shutdown(); |
| 696 | 660 |
| 697 void BuildName(const char* name_prefix); | 661 void BuildName(const char* name_prefix); |
| 698 | 662 |
| 699 void ProfileIdle(); | 663 void ProfileIdle(); |
| 700 | 664 |
| 701 // Visit all object pointers. Caller must ensure concurrent sweeper is not | 665 // Visit all object pointers. Caller must ensure concurrent sweeper is not |
| 702 // running, and the visitor must not allocate. | 666 // running, and the visitor must not allocate. |
| 703 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); | 667 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); |
| 704 | 668 |
| 705 void set_user_tag(uword tag) { | 669 void set_user_tag(uword tag) { user_tag_ = tag; } |
| 706 user_tag_ = tag; | |
| 707 } | |
| 708 | 670 |
| 709 RawGrowableObjectArray* GetAndClearPendingServiceExtensionCalls(); | 671 RawGrowableObjectArray* GetAndClearPendingServiceExtensionCalls(); |
| 710 RawGrowableObjectArray* pending_service_extension_calls() const { | 672 RawGrowableObjectArray* pending_service_extension_calls() const { |
| 711 return pending_service_extension_calls_; | 673 return pending_service_extension_calls_; |
| 712 } | 674 } |
| 713 void set_pending_service_extension_calls(const GrowableObjectArray& value); | 675 void set_pending_service_extension_calls(const GrowableObjectArray& value); |
| 714 RawGrowableObjectArray* registered_service_extension_handlers() const { | 676 RawGrowableObjectArray* registered_service_extension_handlers() const { |
| 715 return registered_service_extension_handlers_; | 677 return registered_service_extension_handlers_; |
| 716 } | 678 } |
| 717 void set_registered_service_extension_handlers( | 679 void set_registered_service_extension_handlers( |
| 718 const GrowableObjectArray& value); | 680 const GrowableObjectArray& value); |
| 719 | 681 |
| 720 Monitor* threads_lock() const; | 682 Monitor* threads_lock() const; |
| 721 Thread* ScheduleThread(bool is_mutator, bool bypass_safepoint = false); | 683 Thread* ScheduleThread(bool is_mutator, bool bypass_safepoint = false); |
| 722 void UnscheduleThread( | 684 void UnscheduleThread(Thread* thread, |
| 723 Thread* thread, bool is_mutator, bool bypass_safepoint = false); | 685 bool is_mutator, |
| 686 bool bypass_safepoint = false); |
| 724 | 687 |
| 725 // DEPRECATED: Use Thread's methods instead. During migration, these default | 688 // DEPRECATED: Use Thread's methods instead. During migration, these default |
| 726 // to using the mutator thread (which must also be the current thread). | 689 // to using the mutator thread (which must also be the current thread). |
| 727 Zone* current_zone() const { | 690 Zone* current_zone() const { |
| 728 ASSERT(Thread::Current() == mutator_thread()); | 691 ASSERT(Thread::Current() == mutator_thread()); |
| 729 return mutator_thread()->zone(); | 692 return mutator_thread()->zone(); |
| 730 } | 693 } |
| 731 | 694 |
| 732 // Accessed from generated code: | 695 // Accessed from generated code: |
| 733 StoreBuffer* store_buffer_; | 696 StoreBuffer* store_buffer_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 754 void* init_callback_data_; | 717 void* init_callback_data_; |
| 755 Dart_EnvironmentCallback environment_callback_; | 718 Dart_EnvironmentCallback environment_callback_; |
| 756 Dart_LibraryTagHandler library_tag_handler_; | 719 Dart_LibraryTagHandler library_tag_handler_; |
| 757 ApiState* api_state_; | 720 ApiState* api_state_; |
| 758 Debugger* debugger_; | 721 Debugger* debugger_; |
| 759 bool resume_request_; | 722 bool resume_request_; |
| 760 int64_t last_resume_timestamp_; | 723 int64_t last_resume_timestamp_; |
| 761 bool has_compiled_code_; // Can check that no compilation occured. | 724 bool has_compiled_code_; // Can check that no compilation occured. |
| 762 Random random_; | 725 Random random_; |
| 763 Simulator* simulator_; | 726 Simulator* simulator_; |
| 764 Mutex* mutex_; // Protects compiler stats. | 727 Mutex* mutex_; // Protects compiler stats. |
| 765 Mutex* symbols_mutex_; // Protects concurrent access to the symbol table. | 728 Mutex* symbols_mutex_; // Protects concurrent access to the symbol table. |
| 766 Mutex* type_canonicalization_mutex_; // Protects type canonicalization. | 729 Mutex* type_canonicalization_mutex_; // Protects type canonicalization. |
| 767 Mutex* constant_canonicalization_mutex_; // Protects const canonicalization. | 730 Mutex* constant_canonicalization_mutex_; // Protects const canonicalization. |
| 768 Mutex* megamorphic_lookup_mutex_; // Protects megamorphic table lookup. | 731 Mutex* megamorphic_lookup_mutex_; // Protects megamorphic table lookup. |
| 769 MessageHandler* message_handler_; | 732 MessageHandler* message_handler_; |
| 770 IsolateSpawnState* spawn_state_; | 733 IsolateSpawnState* spawn_state_; |
| 771 bool is_runnable_; | 734 bool is_runnable_; |
| 772 Dart_GcPrologueCallback gc_prologue_callback_; | 735 Dart_GcPrologueCallback gc_prologue_callback_; |
| 773 Dart_GcEpilogueCallback gc_epilogue_callback_; | 736 Dart_GcEpilogueCallback gc_epilogue_callback_; |
| 774 intptr_t defer_finalization_count_; | 737 intptr_t defer_finalization_count_; |
| 775 MallocGrowableArray<PendingLazyDeopt>* pending_deopts_; | 738 MallocGrowableArray<PendingLazyDeopt>* pending_deopts_; |
| 776 DeoptContext* deopt_context_; | 739 DeoptContext* deopt_context_; |
| 777 | 740 |
| 778 bool is_service_isolate_; | 741 bool is_service_isolate_; |
| 779 | 742 |
| 780 // Isolate-specific flags. | 743 // Isolate-specific flags. |
| 781 NOT_IN_PRODUCT( | 744 #if !defined(PRODUCT) |
| 782 bool type_checks_; | 745 bool type_checks_; |
| 783 bool asserts_; | 746 bool asserts_; |
| 784 bool error_on_bad_type_; | 747 bool error_on_bad_type_; |
| 785 bool error_on_bad_override_; | 748 bool error_on_bad_override_; |
| 786 ) | 749 #endif // !defined(PRODUCT) |
| 787 | 750 |
| 788 // Timestamps of last operation via service. | 751 // Timestamps of last operation via service. |
| 789 int64_t last_allocationprofile_accumulator_reset_timestamp_; | 752 int64_t last_allocationprofile_accumulator_reset_timestamp_; |
| 790 int64_t last_allocationprofile_gc_timestamp_; | 753 int64_t last_allocationprofile_gc_timestamp_; |
| 791 | 754 |
| 792 // Ring buffer of objects assigned an id. | 755 // Ring buffer of objects assigned an id. |
| 793 ObjectIdRing* object_id_ring_; | 756 ObjectIdRing* object_id_ring_; |
| 794 | 757 |
| 795 VMTagCounters vm_tag_counters_; | 758 VMTagCounters vm_tag_counters_; |
| 796 RawGrowableObjectArray* tag_table_; | 759 RawGrowableObjectArray* tag_table_; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 static bool AddIsolateToList(Isolate* isolate); | 837 static bool AddIsolateToList(Isolate* isolate); |
| 875 static void RemoveIsolateFromList(Isolate* isolate); | 838 static void RemoveIsolateFromList(Isolate* isolate); |
| 876 | 839 |
| 877 // This monitor protects isolates_list_head_, and creation_enabled_. | 840 // This monitor protects isolates_list_head_, and creation_enabled_. |
| 878 static Monitor* isolates_list_monitor_; | 841 static Monitor* isolates_list_monitor_; |
| 879 static Isolate* isolates_list_head_; | 842 static Isolate* isolates_list_head_; |
| 880 static bool creation_enabled_; | 843 static bool creation_enabled_; |
| 881 | 844 |
| 882 #define REUSABLE_FRIEND_DECLARATION(name) \ | 845 #define REUSABLE_FRIEND_DECLARATION(name) \ |
| 883 friend class Reusable##name##HandleScope; | 846 friend class Reusable##name##HandleScope; |
| 884 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) | 847 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) |
| 885 #undef REUSABLE_FRIEND_DECLARATION | 848 #undef REUSABLE_FRIEND_DECLARATION |
| 886 | 849 |
| 887 friend class Become; // VisitObjectPointers | 850 friend class Become; // VisitObjectPointers |
| 888 friend class GCMarker; // VisitObjectPointers | 851 friend class GCMarker; // VisitObjectPointers |
| 889 friend class SafepointHandler; | 852 friend class SafepointHandler; |
| 890 friend class Scavenger; // VisitObjectPointers | 853 friend class Scavenger; // VisitObjectPointers |
| 891 friend class ServiceIsolate; | 854 friend class ServiceIsolate; |
| 892 friend class Thread; | 855 friend class Thread; |
| 893 friend class Timeline; | 856 friend class Timeline; |
| 894 friend class NoReloadScope; // reload_block | 857 friend class NoReloadScope; // reload_block |
| 895 | 858 |
| 896 | 859 |
| 897 DISALLOW_COPY_AND_ASSIGN(Isolate); | 860 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 intptr_t* spawn_count_; | 983 intptr_t* spawn_count_; |
| 1021 | 984 |
| 1022 Dart_IsolateFlags isolate_flags_; | 985 Dart_IsolateFlags isolate_flags_; |
| 1023 bool paused_; | 986 bool paused_; |
| 1024 bool errors_are_fatal_; | 987 bool errors_are_fatal_; |
| 1025 }; | 988 }; |
| 1026 | 989 |
| 1027 } // namespace dart | 990 } // namespace dart |
| 1028 | 991 |
| 1029 #endif // RUNTIME_VM_ISOLATE_H_ | 992 #endif // RUNTIME_VM_ISOLATE_H_ |
| OLD | NEW |