| 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/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 | 703 |
| 704 // Gets called from debug stub when code reaches a breakpoint | 704 // Gets called from debug stub when code reaches a breakpoint |
| 705 // set on a runtime stub call. | 705 // set on a runtime stub call. |
| 706 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { | 706 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { |
| 707 DartFrameIterator iterator; | 707 DartFrameIterator iterator; |
| 708 StackFrame* caller_frame = iterator.NextFrame(); | 708 StackFrame* caller_frame = iterator.NextFrame(); |
| 709 ASSERT(caller_frame != NULL); | 709 ASSERT(caller_frame != NULL); |
| 710 const Code& orig_stub = Code::Handle( | 710 const Code& orig_stub = Code::Handle( |
| 711 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); | 711 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); |
| 712 isolate->debugger()->SignalBpReached(); | 712 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); |
| 713 if (!error.IsNull()) { |
| 714 Exceptions::PropagateError(error); |
| 715 UNREACHABLE(); |
| 716 } |
| 713 arguments.SetReturn(orig_stub); | 717 arguments.SetReturn(orig_stub); |
| 714 } | 718 } |
| 715 | 719 |
| 716 | 720 |
| 717 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { | 721 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { |
| 718 isolate->debugger()->DebuggerStepCallback(); | 722 const Error& error = |
| 723 Error::Handle(isolate->debugger()->DebuggerStepCallback()); |
| 724 if (!error.IsNull()) { |
| 725 Exceptions::PropagateError(error); |
| 726 UNREACHABLE(); |
| 727 } |
| 719 } | 728 } |
| 720 | 729 |
| 721 | 730 |
| 722 // An instance call of the form o.f(...) could not be resolved. Check if | 731 // An instance call of the form o.f(...) could not be resolved. Check if |
| 723 // there is a getter with the same name. If so, invoke it. If the value is | 732 // there is a getter with the same name. If so, invoke it. If the value is |
| 724 // a closure, invoke it with the given arguments. If the value is a | 733 // a closure, invoke it with the given arguments. If the value is a |
| 725 // non-closure, attempt to invoke "call" on it. | 734 // non-closure, attempt to invoke "call" on it. |
| 726 static bool ResolveCallThroughGetter(const Instance& receiver, | 735 static bool ResolveCallThroughGetter(const Instance& receiver, |
| 727 const Class& receiver_class, | 736 const Class& receiver_class, |
| 728 const String& target_name, | 737 const String& target_name, |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // Variable locations and number are unknown when 'always_optimize'. | 1349 // Variable locations and number are unknown when 'always_optimize'. |
| 1341 const int num_vars = | 1350 const int num_vars = |
| 1342 Compiler::always_optimize() ? 0 : frame->NumLocalVariables(); | 1351 Compiler::always_optimize() ? 0 : frame->NumLocalVariables(); |
| 1343 intptr_t unused; | 1352 intptr_t unused; |
| 1344 for (intptr_t v = 0; v < num_vars; v++) { | 1353 for (intptr_t v = 0; v < num_vars; v++) { |
| 1345 frame->VariableAt(v, &var_name, &unused, &unused, &var_value); | 1354 frame->VariableAt(v, &var_name, &unused, &unused, &var_value); |
| 1346 } | 1355 } |
| 1347 } | 1356 } |
| 1348 } | 1357 } |
| 1349 | 1358 |
| 1350 uword interrupt_bits = isolate->GetAndClearInterrupts(); | 1359 const Error& error = Error::Handle(isolate->HandleInterrupts()); |
| 1351 if ((interrupt_bits & Isolate::kVMInterrupt) != 0) { | 1360 if (!error.IsNull()) { |
| 1352 isolate->thread_registry()->CheckSafepoint(); | 1361 Exceptions::PropagateError(error); |
| 1353 if (isolate->store_buffer()->Overflowed()) { | 1362 UNREACHABLE(); |
| 1354 if (FLAG_verbose_gc) { | |
| 1355 OS::PrintErr("Scavenge scheduled by store buffer overflow.\n"); | |
| 1356 } | |
| 1357 isolate->heap()->CollectGarbage(Heap::kNew); | |
| 1358 } | |
| 1359 } | |
| 1360 if ((interrupt_bits & Isolate::kMessageInterrupt) != 0) { | |
| 1361 bool ok = isolate->message_handler()->HandleOOBMessages(); | |
| 1362 if (!ok) { | |
| 1363 // False result from HandleOOBMessages signals that the isolate should | |
| 1364 // be terminating. | |
| 1365 const String& msg = String::Handle(String::New("isolate terminated")); | |
| 1366 const UnwindError& error = UnwindError::Handle(UnwindError::New(msg)); | |
| 1367 Exceptions::PropagateError(error); | |
| 1368 UNREACHABLE(); | |
| 1369 } | |
| 1370 } | |
| 1371 if ((interrupt_bits & Isolate::kApiInterrupt) != 0) { | |
| 1372 // Signal isolate interrupt event. | |
| 1373 Debugger::SignalIsolateInterrupted(); | |
| 1374 | |
| 1375 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback(); | |
| 1376 if (callback != NULL) { | |
| 1377 if ((*callback)()) { | |
| 1378 return; | |
| 1379 } else { | |
| 1380 // TODO(turnidge): Unwind the stack. | |
| 1381 UNIMPLEMENTED(); | |
| 1382 } | |
| 1383 } | |
| 1384 } | 1363 } |
| 1385 | 1364 |
| 1386 if ((stack_overflow_flags & Isolate::kOsrRequest) != 0) { | 1365 if ((stack_overflow_flags & Isolate::kOsrRequest) != 0) { |
| 1387 ASSERT(FLAG_use_osr); | 1366 ASSERT(FLAG_use_osr); |
| 1388 DartFrameIterator iterator; | 1367 DartFrameIterator iterator; |
| 1389 StackFrame* frame = iterator.NextFrame(); | 1368 StackFrame* frame = iterator.NextFrame(); |
| 1390 ASSERT(frame != NULL); | 1369 ASSERT(frame != NULL); |
| 1391 const Code& code = Code::ZoneHandle(frame->LookupDartCode()); | 1370 const Code& code = Code::ZoneHandle(frame->LookupDartCode()); |
| 1392 ASSERT(!code.IsNull()); | 1371 ASSERT(!code.IsNull()); |
| 1393 const Function& function = Function::Handle(code.function()); | 1372 const Function& function = Function::Handle(code.function()); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1825 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
| 1847 const TypedData& new_data = | 1826 const TypedData& new_data = |
| 1848 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1827 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
| 1849 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1828 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
| 1850 typed_data_cell.SetAt(0, new_data); | 1829 typed_data_cell.SetAt(0, new_data); |
| 1851 arguments.SetReturn(new_data); | 1830 arguments.SetReturn(new_data); |
| 1852 } | 1831 } |
| 1853 | 1832 |
| 1854 | 1833 |
| 1855 } // namespace dart | 1834 } // namespace dart |
| OLD | NEW |