Chromium Code Reviews| 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 #include "vm/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/json.h" | 9 #include "platform/json.h" |
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 #include "vm/reusable_handles.h" | 28 #include "vm/reusable_handles.h" |
| 29 #include "vm/service.h" | 29 #include "vm/service.h" |
| 30 #include "vm/service_event.h" | 30 #include "vm/service_event.h" |
| 31 #include "vm/service_isolate.h" | 31 #include "vm/service_isolate.h" |
| 32 #include "vm/simulator.h" | 32 #include "vm/simulator.h" |
| 33 #include "vm/stack_frame.h" | 33 #include "vm/stack_frame.h" |
| 34 #include "vm/stub_code.h" | 34 #include "vm/stub_code.h" |
| 35 #include "vm/symbols.h" | 35 #include "vm/symbols.h" |
| 36 #include "vm/tags.h" | 36 #include "vm/tags.h" |
| 37 #include "vm/thread_interrupter.h" | 37 #include "vm/thread_interrupter.h" |
| 38 #include "vm/timeline.h" | |
| 38 #include "vm/timer.h" | 39 #include "vm/timer.h" |
| 39 #include "vm/visitor.h" | 40 #include "vm/visitor.h" |
| 40 | 41 |
| 41 | 42 |
| 42 namespace dart { | 43 namespace dart { |
| 43 | 44 |
| 44 DEFINE_FLAG(bool, trace_isolates, false, | 45 DEFINE_FLAG(bool, trace_isolates, false, |
| 45 "Trace isolate creation and shut down."); | 46 "Trace isolate creation and shut down."); |
| 46 DEFINE_FLAG(bool, pause_isolates_on_start, false, | 47 DEFINE_FLAG(bool, pause_isolates_on_start, false, |
| 47 "Pause isolates before starting."); | 48 "Pause isolates before starting."); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 edge_counter_increment_size_(-1), | 601 edge_counter_increment_size_(-1), |
| 601 compiler_stats_(NULL), | 602 compiler_stats_(NULL), |
| 602 is_service_isolate_(false), | 603 is_service_isolate_(false), |
| 603 log_(new class Log()), | 604 log_(new class Log()), |
| 604 stacktrace_(NULL), | 605 stacktrace_(NULL), |
| 605 stack_frame_index_(-1), | 606 stack_frame_index_(-1), |
| 606 last_allocationprofile_accumulator_reset_timestamp_(0), | 607 last_allocationprofile_accumulator_reset_timestamp_(0), |
| 607 last_allocationprofile_gc_timestamp_(0), | 608 last_allocationprofile_gc_timestamp_(0), |
| 608 object_id_ring_(NULL), | 609 object_id_ring_(NULL), |
| 609 trace_buffer_(NULL), | 610 trace_buffer_(NULL), |
| 611 timeline_event_buffer_(NULL), | |
| 610 profiler_data_(NULL), | 612 profiler_data_(NULL), |
| 611 thread_state_(NULL), | 613 thread_state_(NULL), |
| 612 tag_table_(GrowableObjectArray::null()), | 614 tag_table_(GrowableObjectArray::null()), |
| 613 current_tag_(UserTag::null()), | 615 current_tag_(UserTag::null()), |
| 614 default_tag_(UserTag::null()), | 616 default_tag_(UserTag::null()), |
| 615 deoptimized_code_array_(GrowableObjectArray::null()), | 617 deoptimized_code_array_(GrowableObjectArray::null()), |
| 616 metrics_list_head_(NULL), | 618 metrics_list_head_(NULL), |
| 617 cha_(NULL), | 619 cha_(NULL), |
| 618 next_(NULL), | 620 next_(NULL), |
| 619 pause_loop_monitor_(NULL), | 621 pause_loop_monitor_(NULL), |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 647 delete log_; | 649 delete log_; |
| 648 log_ = NULL; | 650 log_ = NULL; |
| 649 delete object_id_ring_; | 651 delete object_id_ring_; |
| 650 object_id_ring_ = NULL; | 652 object_id_ring_ = NULL; |
| 651 delete pause_loop_monitor_; | 653 delete pause_loop_monitor_; |
| 652 pause_loop_monitor_ = NULL; | 654 pause_loop_monitor_ = NULL; |
| 653 if (compiler_stats_ != NULL) { | 655 if (compiler_stats_ != NULL) { |
| 654 delete compiler_stats_; | 656 delete compiler_stats_; |
| 655 compiler_stats_ = NULL; | 657 compiler_stats_ = NULL; |
| 656 } | 658 } |
| 659 RemoveTimelineEventBuffer(); | |
| 657 } | 660 } |
| 658 | 661 |
| 659 | 662 |
| 660 #if defined(DEBUG) | 663 #if defined(DEBUG) |
| 661 bool Isolate::IsIsolateOf(Thread* thread) { | 664 bool Isolate::IsIsolateOf(Thread* thread) { |
| 662 return this == thread->isolate(); | 665 return this == thread->isolate(); |
| 663 } | 666 } |
| 664 #endif // DEBUG | 667 #endif // DEBUG |
| 665 | 668 |
| 666 | 669 |
| 667 void Isolate::InitOnce() { | 670 void Isolate::InitOnce() { |
| 668 create_callback_ = NULL; | 671 create_callback_ = NULL; |
| 669 isolates_list_monitor_ = new Monitor(); | 672 isolates_list_monitor_ = new Monitor(); |
| 670 ASSERT(isolates_list_monitor_ != NULL); | 673 ASSERT(isolates_list_monitor_ != NULL); |
| 671 } | 674 } |
| 672 | 675 |
| 673 | 676 |
| 674 Isolate* Isolate::Init(const char* name_prefix, bool is_vm_isolate) { | 677 Isolate* Isolate::Init(const char* name_prefix, bool is_vm_isolate) { |
| 675 Isolate* result = new Isolate(); | 678 Isolate* result = new Isolate(); |
| 676 ASSERT(result != NULL); | 679 ASSERT(result != NULL); |
| 677 | 680 |
| 678 // Initialize metrics. | 681 // Initialize metrics. |
| 679 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ | 682 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ |
| 680 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); | 683 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); |
| 681 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); | 684 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); |
| 682 #undef ISOLATE_METRIC_INIT | 685 #undef ISOLATE_METRIC_INIT |
| 683 | 686 |
| 687 // Initialize Timeline streams. | |
| 688 #define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \ | |
| 689 result->stream_##name##_.Init(#name, enabled_by_default); | |
| 690 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT); | |
| 691 #undef ISOLATE_TIMELINE_STREAM_INIT | |
| 692 | |
| 684 // TODO(5411455): For now just set the recently created isolate as | 693 // TODO(5411455): For now just set the recently created isolate as |
| 685 // the current isolate. | 694 // the current isolate. |
| 686 Thread::EnterIsolate(result); | 695 Thread::EnterIsolate(result); |
| 687 | 696 |
| 688 // Setup the isolate specific resuable handles. | 697 // Setup the isolate specific resuable handles. |
| 689 #define REUSABLE_HANDLE_ALLOCATION(object) \ | 698 #define REUSABLE_HANDLE_ALLOCATION(object) \ |
| 690 result->object##_handle_ = result->AllocateReusableHandle<object>(); | 699 result->object##_handle_ = result->AllocateReusableHandle<object>(); |
| 691 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) | 700 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) |
| 692 #undef REUSABLE_HANDLE_ALLOCATION | 701 #undef REUSABLE_HANDLE_ALLOCATION |
| 693 | 702 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1387 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 1396 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
| 1388 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); | 1397 api_state()->prologue_weak_persistent_handles().VisitHandles(&visitor); |
| 1389 | 1398 |
| 1390 if (FLAG_trace_isolates) { | 1399 if (FLAG_trace_isolates) { |
| 1391 heap()->PrintSizes(); | 1400 heap()->PrintSizes(); |
| 1392 megamorphic_cache_table()->PrintSizes(); | 1401 megamorphic_cache_table()->PrintSizes(); |
| 1393 Symbols::DumpStats(); | 1402 Symbols::DumpStats(); |
| 1394 OS::Print("[-] Stopping isolate:\n" | 1403 OS::Print("[-] Stopping isolate:\n" |
| 1395 "\tisolate: %s\n", name()); | 1404 "\tisolate: %s\n", name()); |
| 1396 } | 1405 } |
| 1406 | |
| 1407 if (timeline_event_buffer_ != NULL) { | |
|
rmacnak
2015/06/08 22:11:30
Behind a flag.
| |
| 1408 timeline_event_buffer_->Dump(); | |
| 1409 } | |
| 1397 } | 1410 } |
| 1398 | 1411 |
| 1399 // TODO(5411455): For now just make sure there are no current isolates | 1412 // TODO(5411455): For now just make sure there are no current isolates |
| 1400 // as we are shutting down the isolate. | 1413 // as we are shutting down the isolate. |
| 1401 Thread::ExitIsolate(); | 1414 Thread::ExitIsolate(); |
| 1402 Profiler::ShutdownProfilingForIsolate(this); | 1415 Profiler::ShutdownProfilingForIsolate(this); |
| 1403 } | 1416 } |
| 1404 | 1417 |
| 1405 | 1418 |
| 1406 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; | 1419 Dart_IsolateCreateCallback Isolate::create_callback_ = NULL; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1485 } | 1498 } |
| 1486 | 1499 |
| 1487 | 1500 |
| 1488 void Isolate::VisitPrologueWeakPersistentHandles(HandleVisitor* visitor) { | 1501 void Isolate::VisitPrologueWeakPersistentHandles(HandleVisitor* visitor) { |
| 1489 if (api_state() != NULL) { | 1502 if (api_state() != NULL) { |
| 1490 api_state()->VisitPrologueWeakHandles(visitor); | 1503 api_state()->VisitPrologueWeakHandles(visitor); |
| 1491 } | 1504 } |
| 1492 } | 1505 } |
| 1493 | 1506 |
| 1494 | 1507 |
| 1508 void Isolate::SetTimelineEventBuffer( | |
| 1509 TimelineEventBuffer* timeline_event_buffer) { | |
| 1510 #define ISOLATE_TIMELINE_STREAM_SET_BUFFER(name, enabled_by_default) \ | |
| 1511 stream_##name##_.set_buffer(timeline_event_buffer); | |
| 1512 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_SET_BUFFER) | |
| 1513 #undef ISOLATE_TIMELINE_STREAM_SET_BUFFER | |
| 1514 timeline_event_buffer_ = timeline_event_buffer; | |
| 1515 } | |
| 1516 | |
| 1517 void Isolate::RemoveTimelineEventBuffer() { | |
| 1518 SetTimelineEventBuffer(NULL); | |
| 1519 delete timeline_event_buffer_; | |
| 1520 } | |
| 1521 | |
| 1522 | |
| 1495 void Isolate::PrintJSON(JSONStream* stream, bool ref) { | 1523 void Isolate::PrintJSON(JSONStream* stream, bool ref) { |
| 1496 JSONObject jsobj(stream); | 1524 JSONObject jsobj(stream); |
| 1497 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); | 1525 jsobj.AddProperty("type", (ref ? "@Isolate" : "Isolate")); |
| 1498 jsobj.AddFixedServiceId("isolates/%" Pd "", | 1526 jsobj.AddFixedServiceId("isolates/%" Pd "", |
| 1499 static_cast<intptr_t>(main_port())); | 1527 static_cast<intptr_t>(main_port())); |
| 1500 | 1528 |
| 1501 jsobj.AddProperty("name", debugger_name()); | 1529 jsobj.AddProperty("name", debugger_name()); |
| 1502 jsobj.AddPropertyF("number", "%" Pd "", | 1530 jsobj.AddPropertyF("number", "%" Pd "", |
| 1503 static_cast<intptr_t>(main_port())); | 1531 static_cast<intptr_t>(main_port())); |
| 1504 if (ref) { | 1532 if (ref) { |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 serialized_message_, serialized_message_len_); | 1993 serialized_message_, serialized_message_len_); |
| 1966 } | 1994 } |
| 1967 | 1995 |
| 1968 | 1996 |
| 1969 void IsolateSpawnState::Cleanup() { | 1997 void IsolateSpawnState::Cleanup() { |
| 1970 SwitchIsolateScope switch_scope(I); | 1998 SwitchIsolateScope switch_scope(I); |
| 1971 Dart::ShutdownIsolate(); | 1999 Dart::ShutdownIsolate(); |
| 1972 } | 2000 } |
| 1973 | 2001 |
| 1974 } // namespace dart | 2002 } // namespace dart |
| OLD | NEW |