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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 | 511 |
512 bool IsolateMessageHandler::ProcessUnhandledException(const Error& result) { | 512 bool IsolateMessageHandler::ProcessUnhandledException(const Error& result) { |
513 // Notify the debugger about specific unhandled exceptions which are withheld | 513 // Notify the debugger about specific unhandled exceptions which are withheld |
514 // when being thrown. | 514 // when being thrown. |
515 if (result.IsUnhandledException()) { | 515 if (result.IsUnhandledException()) { |
516 const UnhandledException& error = UnhandledException::Cast(result); | 516 const UnhandledException& error = UnhandledException::Cast(result); |
517 RawInstance* exception = error.exception(); | 517 RawInstance* exception = error.exception(); |
518 if ((exception == I->object_store()->out_of_memory()) || | 518 if ((exception == I->object_store()->out_of_memory()) || |
519 (exception == I->object_store()->stack_overflow())) { | 519 (exception == I->object_store()->stack_overflow())) { |
520 // We didn't notify the debugger when the stack was full. Do it now. | 520 // We didn't notify the debugger when the stack was full. Do it now. |
521 ASSERT(I->debugger() != NULL); | |
521 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); | 522 I->debugger()->SignalExceptionThrown(Instance::Handle(exception)); |
522 } | 523 } |
523 } | 524 } |
524 | 525 |
525 // Invoke the isolate's unhandled exception callback if there is one. | 526 // Invoke the isolate's unhandled exception callback if there is one. |
526 if (Isolate::UnhandledExceptionCallback() != NULL) { | 527 if (Isolate::UnhandledExceptionCallback() != NULL) { |
527 Dart_EnterScope(); | 528 Dart_EnterScope(); |
528 Dart_Handle error = Api::NewHandle(I, result.raw()); | 529 Dart_Handle error = Api::NewHandle(I, result.raw()); |
529 (Isolate::UnhandledExceptionCallback())(error); | 530 (Isolate::UnhandledExceptionCallback())(error); |
530 Dart_ExitScope(); | 531 Dart_ExitScope(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 #if defined(DEBUG) | 769 #if defined(DEBUG) |
769 // Verify that we are never reusing a live origin id. | 770 // Verify that we are never reusing a live origin id. |
770 VerifyOriginId id_verifier(result->main_port()); | 771 VerifyOriginId id_verifier(result->main_port()); |
771 Isolate::VisitIsolates(&id_verifier); | 772 Isolate::VisitIsolates(&id_verifier); |
772 #endif | 773 #endif |
773 result->set_origin_id(result->main_port()); | 774 result->set_origin_id(result->main_port()); |
774 result->set_pause_capability(result->random()->NextUInt64()); | 775 result->set_pause_capability(result->random()->NextUInt64()); |
775 result->set_terminate_capability(result->random()->NextUInt64()); | 776 result->set_terminate_capability(result->random()->NextUInt64()); |
776 | 777 |
777 result->BuildName(name_prefix); | 778 result->BuildName(name_prefix); |
778 result->debugger_ = new Debugger(); | 779 if (!is_vm_isolate) { |
779 result->debugger_->Initialize(result); | 780 result->debugger_ = new Debugger(); |
781 result->debugger_->Initialize(result); | |
782 } | |
780 if (FLAG_trace_isolates) { | 783 if (FLAG_trace_isolates) { |
781 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { | 784 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { |
782 OS::Print("[+] Starting isolate:\n" | 785 OS::Print("[+] Starting isolate:\n" |
783 "\tisolate: %s\n", result->name()); | 786 "\tisolate: %s\n", result->name()); |
784 } | 787 } |
785 } | 788 } |
786 if (FLAG_compiler_stats) { | 789 if (FLAG_compiler_stats) { |
787 result->compiler_stats_ = new CompilerStats(result); | 790 result->compiler_stats_ = new CompilerStats(result); |
788 } | 791 } |
789 ObjectIdRing::Init(result); | 792 ObjectIdRing::Init(result); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 Function& func = Function::Handle(isolate); | 1217 Function& func = Function::Handle(isolate); |
1215 func ^= result.raw(); | 1218 func ^= result.raw(); |
1216 | 1219 |
1217 // TODO(turnidge): Currently we need a way to force a one-time | 1220 // TODO(turnidge): Currently we need a way to force a one-time |
1218 // breakpoint for all spawned isolates to support isolate | 1221 // breakpoint for all spawned isolates to support isolate |
1219 // debugging. Remove this once the vmservice becomes the standard | 1222 // debugging. Remove this once the vmservice becomes the standard |
1220 // way to debug. Set the breakpoint on the static function instead | 1223 // way to debug. Set the breakpoint on the static function instead |
1221 // of its implicit closure function because that latter is merely | 1224 // of its implicit closure function because that latter is merely |
1222 // a dispatcher that is marked as undebuggable. | 1225 // a dispatcher that is marked as undebuggable. |
1223 if (FLAG_break_at_isolate_spawn) { | 1226 if (FLAG_break_at_isolate_spawn) { |
1227 ASSERT(isolate->debugger() != NULL); | |
1224 isolate->debugger()->OneTimeBreakAtEntry(func); | 1228 isolate->debugger()->OneTimeBreakAtEntry(func); |
1225 } | 1229 } |
1226 | 1230 |
1227 func = func.ImplicitClosureFunction(); | 1231 func = func.ImplicitClosureFunction(); |
1228 | 1232 |
1229 const Array& capabilities = Array::Handle(Array::New(2)); | 1233 const Array& capabilities = Array::Handle(Array::New(2)); |
1230 Capability& capability = Capability::Handle(); | 1234 Capability& capability = Capability::Handle(); |
1231 capability = Capability::New(isolate->pause_capability()); | 1235 capability = Capability::New(isolate->pause_capability()); |
1232 capabilities.SetAt(0, capability); | 1236 capabilities.SetAt(0, capability); |
1233 // Check whether this isolate should be started in paused state. | 1237 // Check whether this isolate should be started in paused state. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 if (compiler_stats_ != NULL) { | 1422 if (compiler_stats_ != NULL) { |
1419 compiler_stats()->Print(); | 1423 compiler_stats()->Print(); |
1420 } | 1424 } |
1421 | 1425 |
1422 // Notify exit listeners that this isolate is shutting down. | 1426 // Notify exit listeners that this isolate is shutting down. |
1423 if (object_store() != NULL) { | 1427 if (object_store() != NULL) { |
1424 NotifyExitListeners(); | 1428 NotifyExitListeners(); |
1425 } | 1429 } |
1426 | 1430 |
1427 // Clean up debugger resources. | 1431 // Clean up debugger resources. |
1428 debugger()->Shutdown(); | 1432 if (debugger() != NULL) { |
1433 debugger()->Shutdown(); | |
1434 } | |
1429 | 1435 |
1430 // Close all the ports owned by this isolate. | 1436 // Close all the ports owned by this isolate. |
1431 PortMap::ClosePorts(message_handler()); | 1437 PortMap::ClosePorts(message_handler()); |
1432 | 1438 |
1433 // Fail fast if anybody tries to post any more messsages to this isolate. | 1439 // Fail fast if anybody tries to post any more messsages to this isolate. |
1434 delete message_handler(); | 1440 delete message_handler(); |
1435 set_message_handler(NULL); | 1441 set_message_handler(NULL); |
1436 | 1442 |
1437 // Dump all accumulated timer data for the isolate. | 1443 // Dump all accumulated timer data for the isolate. |
1438 timer_list_.ReportTimers(); | 1444 timer_list_.ReportTimers(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); | 1525 visitor->VisitPointer(reinterpret_cast<RawObject**>(&default_tag_)); |
1520 | 1526 |
1521 // Visit the tag table which is stored in the isolate. | 1527 // Visit the tag table which is stored in the isolate. |
1522 visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); | 1528 visitor->VisitPointer(reinterpret_cast<RawObject**>(&tag_table_)); |
1523 | 1529 |
1524 // Visit the deoptimized code array which is stored in the isolate. | 1530 // Visit the deoptimized code array which is stored in the isolate. |
1525 visitor->VisitPointer( | 1531 visitor->VisitPointer( |
1526 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); | 1532 reinterpret_cast<RawObject**>(&deoptimized_code_array_)); |
1527 | 1533 |
1528 // Visit objects in the debugger. | 1534 // Visit objects in the debugger. |
1535 ASSERT(debugger() != NULL); | |
Ivan Posva
2015/06/16 16:31:15
if (debugger() != NULL) {
...
}
Since we are vi
| |
1529 debugger()->VisitObjectPointers(visitor); | 1536 debugger()->VisitObjectPointers(visitor); |
1530 | 1537 |
1531 // Visit objects that are being used for deoptimization. | 1538 // Visit objects that are being used for deoptimization. |
1532 if (deopt_context() != NULL) { | 1539 if (deopt_context() != NULL) { |
1533 deopt_context()->VisitObjectPointers(visitor); | 1540 deopt_context()->VisitObjectPointers(visitor); |
1534 } | 1541 } |
1535 } | 1542 } |
1536 | 1543 |
1537 | 1544 |
1538 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 1545 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1575 } | 1582 } |
1576 { | 1583 { |
1577 JSONObject jsheap(&jsobj, "_heaps"); | 1584 JSONObject jsheap(&jsobj, "_heaps"); |
1578 heap()->PrintToJSONObject(Heap::kNew, &jsheap); | 1585 heap()->PrintToJSONObject(Heap::kNew, &jsheap); |
1579 heap()->PrintToJSONObject(Heap::kOld, &jsheap); | 1586 heap()->PrintToJSONObject(Heap::kOld, &jsheap); |
1580 } | 1587 } |
1581 | 1588 |
1582 jsobj.AddProperty("livePorts", message_handler()->live_ports()); | 1589 jsobj.AddProperty("livePorts", message_handler()->live_ports()); |
1583 jsobj.AddProperty("pauseOnExit", message_handler()->pause_on_exit()); | 1590 jsobj.AddProperty("pauseOnExit", message_handler()->pause_on_exit()); |
1584 | 1591 |
1592 ASSERT(debugger() != NULL); | |
Ivan Posva
2015/06/16 16:31:15
We should allow printing of the VM isolate.
| |
1585 if (message_handler()->paused_on_start()) { | 1593 if (message_handler()->paused_on_start()) { |
1586 ASSERT(debugger()->PauseEvent() == NULL); | 1594 ASSERT(debugger()->PauseEvent() == NULL); |
1587 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); | 1595 ServiceEvent pause_event(this, ServiceEvent::kPauseStart); |
1588 jsobj.AddProperty("pauseEvent", &pause_event); | 1596 jsobj.AddProperty("pauseEvent", &pause_event); |
1589 } else if (message_handler()->paused_on_exit()) { | 1597 } else if (message_handler()->paused_on_exit()) { |
1590 ASSERT(debugger()->PauseEvent() == NULL); | 1598 ASSERT(debugger()->PauseEvent() == NULL); |
1591 ServiceEvent pause_event(this, ServiceEvent::kPauseExit); | 1599 ServiceEvent pause_event(this, ServiceEvent::kPauseExit); |
1592 jsobj.AddProperty("pauseEvent", &pause_event); | 1600 jsobj.AddProperty("pauseEvent", &pause_event); |
1593 } else if (debugger()->PauseEvent() != NULL) { | 1601 } else if (debugger()->PauseEvent() != NULL) { |
1594 ServiceEvent pause_event(debugger()->PauseEvent()); | 1602 ServiceEvent pause_event(debugger()->PauseEvent()); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2026 serialized_message_, serialized_message_len_); | 2034 serialized_message_, serialized_message_len_); |
2027 } | 2035 } |
2028 | 2036 |
2029 | 2037 |
2030 void IsolateSpawnState::Cleanup() { | 2038 void IsolateSpawnState::Cleanup() { |
2031 SwitchIsolateScope switch_scope(I); | 2039 SwitchIsolateScope switch_scope(I); |
2032 Dart::ShutdownIsolate(); | 2040 Dart::ShutdownIsolate(); |
2033 } | 2041 } |
2034 | 2042 |
2035 } // namespace dart | 2043 } // namespace dart |
OLD | NEW |