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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 444 |
445 | 445 |
446 MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage( | 446 MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage( |
447 Message* message) { | 447 Message* message) { |
448 ASSERT(IsCurrentIsolate()); | 448 ASSERT(IsCurrentIsolate()); |
449 Thread* thread = Thread::Current(); | 449 Thread* thread = Thread::Current(); |
450 StackZone stack_zone(thread); | 450 StackZone stack_zone(thread); |
451 Zone* zone = stack_zone.GetZone(); | 451 Zone* zone = stack_zone.GetZone(); |
452 HandleScope handle_scope(thread); | 452 HandleScope handle_scope(thread); |
453 #ifndef PRODUCT | 453 #ifndef PRODUCT |
454 TimelineDurationScope tds(thread, I->GetIsolateStream(), "HandleMessage"); | 454 TimelineDurationScope tds(thread, |
| 455 Timeline::GetIsolateStream(), |
| 456 "HandleMessage"); |
455 tds.SetNumArguments(1); | 457 tds.SetNumArguments(1); |
456 tds.CopyArgument(0, "isolateName", I->name()); | 458 tds.CopyArgument(0, "isolateName", I->name()); |
457 #endif | 459 #endif |
458 | 460 |
459 // If the message is in band we lookup the handler to dispatch to. If the | 461 // If the message is in band we lookup the handler to dispatch to. If the |
460 // receive port was closed, we drop the message without deserializing it. | 462 // receive port was closed, we drop the message without deserializing it. |
461 // Illegal port is a special case for artificially enqueued isolate library | 463 // Illegal port is a special case for artificially enqueued isolate library |
462 // messages which are handled in C++ code below. | 464 // messages which are handled in C++ code below. |
463 Object& msg_handler = Object::Handle(zone); | 465 Object& msg_handler = Object::Handle(zone); |
464 if (!message->IsOOB() && (message->dest_port() != Message::kIllegalPort)) { | 466 if (!message->IsOOB() && (message->dest_port() != Message::kIllegalPort)) { |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 bool is_vm_isolate) { | 898 bool is_vm_isolate) { |
897 Isolate* result = new Isolate(api_flags); | 899 Isolate* result = new Isolate(api_flags); |
898 ASSERT(result != NULL); | 900 ASSERT(result != NULL); |
899 | 901 |
900 // Initialize metrics. | 902 // Initialize metrics. |
901 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ | 903 #define ISOLATE_METRIC_INIT(type, variable, name, unit) \ |
902 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); | 904 result->metric_##variable##_.Init(result, name, NULL, Metric::unit); |
903 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); | 905 ISOLATE_METRIC_LIST(ISOLATE_METRIC_INIT); |
904 #undef ISOLATE_METRIC_INIT | 906 #undef ISOLATE_METRIC_INIT |
905 | 907 |
906 #ifndef PRODUCT | |
907 // Initialize Timeline streams. | |
908 Timeline::SetupIsolateStreams(result); | |
909 #endif // !PRODUCT | |
910 | |
911 Heap::Init(result, | 908 Heap::Init(result, |
912 is_vm_isolate | 909 is_vm_isolate |
913 ? 0 // New gen size 0; VM isolate should only allocate in old. | 910 ? 0 // New gen size 0; VM isolate should only allocate in old. |
914 : FLAG_new_gen_semi_max_size * MBInWords, | 911 : FLAG_new_gen_semi_max_size * MBInWords, |
915 FLAG_old_gen_heap_size * MBInWords, | 912 FLAG_old_gen_heap_size * MBInWords, |
916 FLAG_external_max_size * MBInWords); | 913 FLAG_external_max_size * MBInWords); |
917 | 914 |
918 // TODO(5411455): For now just set the recently created isolate as | 915 // TODO(5411455): For now just set the recently created isolate as |
919 // the current isolate. | 916 // the current isolate. |
920 if (!Thread::EnterIsolate(result)) { | 917 if (!Thread::EnterIsolate(result)) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions); | 1116 debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions); |
1120 } | 1117 } |
1121 } | 1118 } |
1122 IsolateSpawnState* state = spawn_state(); | 1119 IsolateSpawnState* state = spawn_state(); |
1123 if (state != NULL) { | 1120 if (state != NULL) { |
1124 ASSERT(this == state->isolate()); | 1121 ASSERT(this == state->isolate()); |
1125 Run(); | 1122 Run(); |
1126 } | 1123 } |
1127 #ifndef PRODUCT | 1124 #ifndef PRODUCT |
1128 if (FLAG_support_timeline) { | 1125 if (FLAG_support_timeline) { |
1129 TimelineStream* stream = GetIsolateStream(); | 1126 TimelineStream* stream = Timeline::GetIsolateStream(); |
1130 ASSERT(stream != NULL); | 1127 ASSERT(stream != NULL); |
1131 TimelineEvent* event = stream->StartEvent(); | 1128 TimelineEvent* event = stream->StartEvent(); |
1132 if (event != NULL) { | 1129 if (event != NULL) { |
1133 event->Instant("Runnable"); | 1130 event->Instant("Runnable"); |
1134 event->Complete(); | 1131 event->Complete(); |
1135 } | 1132 } |
1136 } | 1133 } |
1137 #endif // !PRODUCT | 1134 #endif // !PRODUCT |
1138 if (FLAG_support_service && Service::isolate_stream.enabled()) { | 1135 if (FLAG_support_service && Service::isolate_stream.enabled()) { |
1139 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); | 1136 ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); |
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2855 void IsolateSpawnState::DecrementSpawnCount() { | 2852 void IsolateSpawnState::DecrementSpawnCount() { |
2856 ASSERT(spawn_count_monitor_ != NULL); | 2853 ASSERT(spawn_count_monitor_ != NULL); |
2857 ASSERT(spawn_count_ != NULL); | 2854 ASSERT(spawn_count_ != NULL); |
2858 MonitorLocker ml(spawn_count_monitor_); | 2855 MonitorLocker ml(spawn_count_monitor_); |
2859 ASSERT(*spawn_count_ > 0); | 2856 ASSERT(*spawn_count_ > 0); |
2860 *spawn_count_ = *spawn_count_ - 1; | 2857 *spawn_count_ = *spawn_count_ - 1; |
2861 ml.Notify(); | 2858 ml.Notify(); |
2862 } | 2859 } |
2863 | 2860 |
2864 } // namespace dart | 2861 } // namespace dart |
OLD | NEW |