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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage( | 441 MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage( |
442 Message* message) { | 442 Message* message) { |
443 ASSERT(IsCurrentIsolate()); | 443 ASSERT(IsCurrentIsolate()); |
444 Thread* thread = Thread::Current(); | 444 Thread* thread = Thread::Current(); |
445 StackZone stack_zone(thread); | 445 StackZone stack_zone(thread); |
446 Zone* zone = stack_zone.GetZone(); | 446 Zone* zone = stack_zone.GetZone(); |
447 HandleScope handle_scope(thread); | 447 HandleScope handle_scope(thread); |
| 448 #ifndef PRODUCT |
448 TimelineDurationScope tds(thread, I->GetIsolateStream(), "HandleMessage"); | 449 TimelineDurationScope tds(thread, I->GetIsolateStream(), "HandleMessage"); |
449 tds.SetNumArguments(1); | 450 tds.SetNumArguments(1); |
450 tds.CopyArgument(0, "isolateName", I->name()); | 451 tds.CopyArgument(0, "isolateName", I->name()); |
| 452 #endif |
451 | 453 |
452 // If the message is in band we lookup the handler to dispatch to. If the | 454 // If the message is in band we lookup the handler to dispatch to. If the |
453 // receive port was closed, we drop the message without deserializing it. | 455 // receive port was closed, we drop the message without deserializing it. |
454 // Illegal port is a special case for artificially enqueued isolate library | 456 // Illegal port is a special case for artificially enqueued isolate library |
455 // messages which are handled in C++ code below. | 457 // messages which are handled in C++ code below. |
456 Object& msg_handler = Object::Handle(zone); | 458 Object& msg_handler = Object::Handle(zone); |
457 if (!message->IsOOB() && (message->dest_port() != Message::kIllegalPort)) { | 459 if (!message->IsOOB() && (message->dest_port() != Message::kIllegalPort)) { |
458 msg_handler = DartLibraryCalls::LookupHandler(message->dest_port()); | 460 msg_handler = DartLibraryCalls::LookupHandler(message->dest_port()); |
459 if (msg_handler.IsError()) { | 461 if (msg_handler.IsError()) { |
460 delete message; | 462 delete message; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 bool is_vm_isolate) { | 879 bool is_vm_isolate) { |
878 Isolate* result = new Isolate(api_flags); | 880 Isolate* result = new Isolate(api_flags); |
879 ASSERT(result != NULL); | 881 ASSERT(result != NULL); |
880 | 882 |
881 // Initialize metrics. | 883 // Initialize metrics. |
882 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ | 884 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ |
883 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); | 885 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); |
884 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); | 886 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); |
885 #undef ISOLATE_METRIC_INIT | 887 #undef ISOLATE_METRIC_INIT |
886 | 888 |
| 889 #ifndef PRODUCT |
887 // Initialize Timeline streams. | 890 // Initialize Timeline streams. |
888 #define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \ | 891 #define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \ |
889 result->stream_##name##_.Init(#name, \ | 892 result->stream_##name##_.Init(#name, \ |
890 enabled_by_default, \ | 893 enabled_by_default, \ |
891 Timeline::Stream##name##EnabledFlag()); | 894 Timeline::Stream##name##EnabledFlag()); |
892 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT); | 895 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT); |
893 #undef ISOLATE_TIMELINE_STREAM_INIT | 896 #undef ISOLATE_TIMELINE_STREAM_INIT |
| 897 #endif // !PRODUCT |
894 | 898 |
895 Heap::Init(result, | 899 Heap::Init(result, |
896 is_vm_isolate | 900 is_vm_isolate |
897 ? 0 // New gen size 0; VM isolate should only allocate in old. | 901 ? 0 // New gen size 0; VM isolate should only allocate in old. |
898 : FLAG_new_gen_semi_max_size * MBInWords, | 902 : FLAG_new_gen_semi_max_size * MBInWords, |
899 FLAG_old_gen_heap_size * MBInWords, | 903 FLAG_old_gen_heap_size * MBInWords, |
900 FLAG_external_max_size * MBInWords); | 904 FLAG_external_max_size * MBInWords); |
901 | 905 |
902 // TODO(5411455): For now just set the recently created isolate as | 906 // TODO(5411455): For now just set the recently created isolate as |
903 // the current isolate. | 907 // the current isolate. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (FLAG_support_debugger && !ServiceIsolate::IsServiceIsolate(this)) { | 1095 if (FLAG_support_debugger && !ServiceIsolate::IsServiceIsolate(this)) { |
1092 if (FLAG_pause_isolates_on_unhandled_exceptions) { | 1096 if (FLAG_pause_isolates_on_unhandled_exceptions) { |
1093 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions); | 1097 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions); |
1094 } | 1098 } |
1095 } | 1099 } |
1096 IsolateSpawnState* state = spawn_state(); | 1100 IsolateSpawnState* state = spawn_state(); |
1097 if (state != NULL) { | 1101 if (state != NULL) { |
1098 ASSERT(this == state->isolate()); | 1102 ASSERT(this == state->isolate()); |
1099 Run(); | 1103 Run(); |
1100 } | 1104 } |
1101 TimelineStream* stream = GetIsolateStream(); | 1105 #ifndef PRODUCT |
1102 ASSERT(stream != NULL); | 1106 if (FLAG_support_timeline) { |
1103 TimelineEvent* event = stream->StartEvent(); | 1107 TimelineStream* stream = GetIsolateStream(); |
1104 if (event != NULL) { | 1108 ASSERT(stream != NULL); |
1105 event->Instant("Runnable"); | 1109 TimelineEvent* event = stream->StartEvent(); |
1106 event->Complete(); | 1110 if (event != NULL) { |
| 1111 event->Instant("Runnable"); |
| 1112 event->Complete(); |
| 1113 } |
1107 } | 1114 } |
| 1115 #endif // !PRODUCT |
1108 if (FLAG_support_service && Service::isolate_stream.enabled()) { | 1116 if (FLAG_support_service && Service::isolate_stream.enabled()) { |
1109 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); | 1117 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); |
1110 Service::HandleEvent(&runnableEvent); | 1118 Service::HandleEvent(&runnableEvent); |
1111 } | 1119 } |
1112 return true; | 1120 return true; |
1113 } | 1121 } |
1114 | 1122 |
1115 | 1123 |
1116 bool Isolate::VerifyPauseCapability(const Object& capability) const { | 1124 bool Isolate::VerifyPauseCapability(const Object& capability) const { |
1117 return !capability.IsNull() && | 1125 return !capability.IsNull() && |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 debugger()->Shutdown(); | 1610 debugger()->Shutdown(); |
1603 } | 1611 } |
1604 | 1612 |
1605 | 1613 |
1606 // Close all the ports owned by this isolate. | 1614 // Close all the ports owned by this isolate. |
1607 PortMap::ClosePorts(message_handler()); | 1615 PortMap::ClosePorts(message_handler()); |
1608 | 1616 |
1609 // Fail fast if anybody tries to post any more messsages to this isolate. | 1617 // Fail fast if anybody tries to post any more messsages to this isolate. |
1610 delete message_handler(); | 1618 delete message_handler(); |
1611 set_message_handler(NULL); | 1619 set_message_handler(NULL); |
1612 | 1620 if (FLAG_support_timeline) { |
1613 // Before analyzing the isolate's timeline blocks- reclaim all cached blocks. | 1621 // Before analyzing the isolate's timeline blocks- reclaim all cached |
1614 Timeline::ReclaimCachedBlocksFromThreads(); | 1622 // blocks. |
| 1623 Timeline::ReclaimCachedBlocksFromThreads(); |
| 1624 } |
1615 | 1625 |
1616 // Dump all timing data for the isolate. | 1626 // Dump all timing data for the isolate. |
1617 if (FLAG_timing) { | 1627 #ifndef PRODUCT |
| 1628 if (FLAG_support_timeline && FLAG_timing) { |
1618 TimelinePauseTrace tpt; | 1629 TimelinePauseTrace tpt; |
1619 tpt.Print(); | 1630 tpt.Print(); |
1620 } | 1631 } |
| 1632 #endif // !PRODUCT |
1621 | 1633 |
1622 // Finalize any weak persistent handles with a non-null referent. | 1634 // Finalize any weak persistent handles with a non-null referent. |
1623 FinalizeWeakPersistentHandlesVisitor visitor; | 1635 FinalizeWeakPersistentHandlesVisitor visitor; |
1624 api_state()->weak_persistent_handles().VisitHandles(&visitor); | 1636 api_state()->weak_persistent_handles().VisitHandles(&visitor); |
1625 | 1637 |
1626 if (FLAG_trace_isolates) { | 1638 if (FLAG_trace_isolates) { |
1627 heap()->PrintSizes(); | 1639 heap()->PrintSizes(); |
1628 MegamorphicCacheTable::PrintSizes(this); | 1640 MegamorphicCacheTable::PrintSizes(this); |
1629 Symbols::DumpStats(); | 1641 Symbols::DumpStats(); |
1630 OS::Print("[-] Stopping isolate:\n" | 1642 OS::Print("[-] Stopping isolate:\n" |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 void IsolateSpawnState::DecrementSpawnCount() { | 2680 void IsolateSpawnState::DecrementSpawnCount() { |
2669 ASSERT(spawn_count_monitor_ != NULL); | 2681 ASSERT(spawn_count_monitor_ != NULL); |
2670 ASSERT(spawn_count_ != NULL); | 2682 ASSERT(spawn_count_ != NULL); |
2671 MonitorLocker ml(spawn_count_monitor_); | 2683 MonitorLocker ml(spawn_count_monitor_); |
2672 ASSERT(*spawn_count_ > 0); | 2684 ASSERT(*spawn_count_ > 0); |
2673 *spawn_count_ = *spawn_count_ - 1; | 2685 *spawn_count_ = *spawn_count_ - 1; |
2674 ml.Notify(); | 2686 ml.Notify(); |
2675 } | 2687 } |
2676 | 2688 |
2677 } // namespace dart | 2689 } // namespace dart |
OLD | NEW |