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