| 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 static void CheckResultError(const Object& result) { | 698 static void CheckResultError(const Object& result) { |
| 699 if (result.IsError()) { | 699 if (result.IsError()) { |
| 700 Exceptions::PropagateError(Error::Cast(result)); | 700 Exceptions::PropagateError(Error::Cast(result)); |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 | 704 |
| 705 // Gets called from debug stub when code reaches a breakpoint | 705 // Gets called from debug stub when code reaches a breakpoint |
| 706 // set on a runtime stub call. | 706 // set on a runtime stub call. |
| 707 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { | 707 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { |
| 708 #ifndef PRODUCT |
| 708 DartFrameIterator iterator; | 709 DartFrameIterator iterator; |
| 709 StackFrame* caller_frame = iterator.NextFrame(); | 710 StackFrame* caller_frame = iterator.NextFrame(); |
| 710 ASSERT(caller_frame != NULL); | 711 ASSERT(caller_frame != NULL); |
| 711 const Code& orig_stub = Code::Handle( | 712 const Code& orig_stub = Code::Handle( |
| 712 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); | 713 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); |
| 713 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); | 714 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); |
| 714 if (!error.IsNull()) { | 715 if (!error.IsNull()) { |
| 715 Exceptions::PropagateError(error); | 716 Exceptions::PropagateError(error); |
| 716 UNREACHABLE(); | 717 UNREACHABLE(); |
| 717 } | 718 } |
| 718 arguments.SetReturn(orig_stub); | 719 arguments.SetReturn(orig_stub); |
| 720 #else |
| 721 UNREACHABLE(); |
| 722 #endif // !PRODUCT |
| 719 } | 723 } |
| 720 | 724 |
| 721 | 725 |
| 722 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { | 726 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { |
| 727 #ifndef PRODUCT |
| 723 const Error& error = | 728 const Error& error = |
| 724 Error::Handle(isolate->debugger()->DebuggerStepCallback()); | 729 Error::Handle(isolate->debugger()->DebuggerStepCallback()); |
| 725 if (!error.IsNull()) { | 730 if (!error.IsNull()) { |
| 726 Exceptions::PropagateError(error); | 731 Exceptions::PropagateError(error); |
| 727 UNREACHABLE(); | 732 UNREACHABLE(); |
| 728 } | 733 } |
| 734 #else |
| 735 UNREACHABLE(); |
| 736 #endif // !PRODUCT |
| 729 } | 737 } |
| 730 | 738 |
| 731 | 739 |
| 732 // An instance call of the form o.f(...) could not be resolved. Check if | 740 // An instance call of the form o.f(...) could not be resolved. Check if |
| 733 // there is a getter with the same name. If so, invoke it. If the value is | 741 // there is a getter with the same name. If so, invoke it. If the value is |
| 734 // a closure, invoke it with the given arguments. If the value is a | 742 // a closure, invoke it with the given arguments. If the value is a |
| 735 // non-closure, attempt to invoke "call" on it. | 743 // non-closure, attempt to invoke "call" on it. |
| 736 static bool ResolveCallThroughGetter(const Instance& receiver, | 744 static bool ResolveCallThroughGetter(const Instance& receiver, |
| 737 const Class& receiver_class, | 745 const Class& receiver_class, |
| 738 const String& target_name, | 746 const String& target_name, |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 DartEntry::InvokeNoSuchMethod(receiver, | 1243 DartEntry::InvokeNoSuchMethod(receiver, |
| 1236 original_function_name, | 1244 original_function_name, |
| 1237 orig_arguments, | 1245 orig_arguments, |
| 1238 orig_arguments_desc)); | 1246 orig_arguments_desc)); |
| 1239 CheckResultError(result); | 1247 CheckResultError(result); |
| 1240 arguments.SetReturn(result); | 1248 arguments.SetReturn(result); |
| 1241 } | 1249 } |
| 1242 | 1250 |
| 1243 | 1251 |
| 1244 static bool CanOptimizeFunction(const Function& function, Thread* thread) { | 1252 static bool CanOptimizeFunction(const Function& function, Thread* thread) { |
| 1253 #ifndef PRODUCT |
| 1245 Isolate* isolate = thread->isolate(); | 1254 Isolate* isolate = thread->isolate(); |
| 1246 if (isolate->debugger()->IsStepping() || | 1255 if (isolate->debugger()->IsStepping() || |
| 1247 isolate->debugger()->HasBreakpoint(function, thread->zone())) { | 1256 isolate->debugger()->HasBreakpoint(function, thread->zone())) { |
| 1248 // We cannot set breakpoints and single step in optimized code, | 1257 // We cannot set breakpoints and single step in optimized code, |
| 1249 // so do not optimize the function. | 1258 // so do not optimize the function. |
| 1250 function.set_usage_counter(0); | 1259 function.set_usage_counter(0); |
| 1251 return false; | 1260 return false; |
| 1252 } | 1261 } |
| 1262 #endif |
| 1253 if (function.deoptimization_counter() >= | 1263 if (function.deoptimization_counter() >= |
| 1254 FLAG_max_deoptimization_counter_threshold) { | 1264 FLAG_max_deoptimization_counter_threshold) { |
| 1255 if (FLAG_trace_failed_optimization_attempts || | 1265 if (FLAG_trace_failed_optimization_attempts || |
| 1256 FLAG_stop_on_excessive_deoptimization) { | 1266 FLAG_stop_on_excessive_deoptimization) { |
| 1257 THR_Print("Too many deoptimizations: %s\n", | 1267 THR_Print("Too many deoptimizations: %s\n", |
| 1258 function.ToFullyQualifiedCString()); | 1268 function.ToFullyQualifiedCString()); |
| 1259 if (FLAG_stop_on_excessive_deoptimization) { | 1269 if (FLAG_stop_on_excessive_deoptimization) { |
| 1260 FATAL("Stop on excessive deoptimization"); | 1270 FATAL("Stop on excessive deoptimization"); |
| 1261 } | 1271 } |
| 1262 } | 1272 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 strstr(function_name, FLAG_stacktrace_filter) != NULL) { | 1374 strstr(function_name, FLAG_stacktrace_filter) != NULL) { |
| 1365 OS::PrintErr("*** Computing stacktrace (%s)\n", | 1375 OS::PrintErr("*** Computing stacktrace (%s)\n", |
| 1366 function.ToFullyQualifiedCString()); | 1376 function.ToFullyQualifiedCString()); |
| 1367 do_stacktrace = true; | 1377 do_stacktrace = true; |
| 1368 } | 1378 } |
| 1369 } | 1379 } |
| 1370 if (do_deopt) { | 1380 if (do_deopt) { |
| 1371 // TODO(turnidge): Consider using DeoptimizeAt instead. | 1381 // TODO(turnidge): Consider using DeoptimizeAt instead. |
| 1372 DeoptimizeFunctionsOnStack(); | 1382 DeoptimizeFunctionsOnStack(); |
| 1373 } | 1383 } |
| 1374 if (do_stacktrace) { | 1384 if (FLAG_support_debugger && do_stacktrace) { |
| 1375 String& var_name = String::Handle(); | 1385 String& var_name = String::Handle(); |
| 1376 Instance& var_value = Instance::Handle(); | 1386 Instance& var_value = Instance::Handle(); |
| 1377 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1387 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
| 1378 intptr_t num_frames = stack->Length(); | 1388 intptr_t num_frames = stack->Length(); |
| 1379 for (intptr_t i = 0; i < num_frames; i++) { | 1389 for (intptr_t i = 0; i < num_frames; i++) { |
| 1380 ActivationFrame* frame = stack->FrameAt(i); | 1390 ActivationFrame* frame = stack->FrameAt(i); |
| 1381 // Variable locations and number are unknown when precompiling. | 1391 // Variable locations and number are unknown when precompiling. |
| 1382 const int num_vars = | 1392 const int num_vars = |
| 1383 FLAG_precompilation ? 0 : frame->NumLocalVariables(); | 1393 FLAG_precompilation ? 0 : frame->NumLocalVariables(); |
| 1384 TokenPosition unused = TokenPosition::kNoSource; | 1394 TokenPosition unused = TokenPosition::kNoSource; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1898 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
| 1889 const TypedData& new_data = | 1899 const TypedData& new_data = |
| 1890 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1900 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
| 1891 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1901 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
| 1892 typed_data_cell.SetAt(0, new_data); | 1902 typed_data_cell.SetAt(0, new_data); |
| 1893 arguments.SetReturn(new_data); | 1903 arguments.SetReturn(new_data); |
| 1894 } | 1904 } |
| 1895 | 1905 |
| 1896 | 1906 |
| 1897 } // namespace dart | 1907 } // namespace dart |
| OLD | NEW |