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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 } | 695 } |
696 | 696 |
697 | 697 |
698 // Gets called from debug stub when code reaches a breakpoint | 698 // Gets called from debug stub when code reaches a breakpoint |
699 // set on a runtime stub call. | 699 // set on a runtime stub call. |
700 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { | 700 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { |
701 ASSERT(isolate->debugger() != NULL); | 701 ASSERT(isolate->debugger() != NULL); |
702 DartFrameIterator iterator; | 702 DartFrameIterator iterator; |
703 StackFrame* caller_frame = iterator.NextFrame(); | 703 StackFrame* caller_frame = iterator.NextFrame(); |
704 ASSERT(caller_frame != NULL); | 704 ASSERT(caller_frame != NULL); |
| 705 ASSERT(isolate->debugger() != NULL); |
705 uword orig_stub = | 706 uword orig_stub = |
706 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc()); | 707 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc()); |
707 isolate->debugger()->SignalBpReached(); | 708 isolate->debugger()->SignalBpReached(); |
708 ASSERT((orig_stub & kSmiTagMask) == kSmiTag); | 709 ASSERT((orig_stub & kSmiTagMask) == kSmiTag); |
709 arguments.SetReturn(Smi::Handle(reinterpret_cast<RawSmi*>(orig_stub))); | 710 arguments.SetReturn(Smi::Handle(reinterpret_cast<RawSmi*>(orig_stub))); |
710 } | 711 } |
711 | 712 |
712 | 713 |
713 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { | 714 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { |
714 ASSERT(isolate->debugger() != NULL); | 715 ASSERT(isolate->debugger() != NULL); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 DartEntry::InvokeNoSuchMethod(receiver, | 1043 DartEntry::InvokeNoSuchMethod(receiver, |
1043 original_function_name, | 1044 original_function_name, |
1044 orig_arguments, | 1045 orig_arguments, |
1045 orig_arguments_desc)); | 1046 orig_arguments_desc)); |
1046 CheckResultError(result); | 1047 CheckResultError(result); |
1047 arguments.SetReturn(result); | 1048 arguments.SetReturn(result); |
1048 } | 1049 } |
1049 | 1050 |
1050 | 1051 |
1051 static bool CanOptimizeFunction(const Function& function, Isolate* isolate) { | 1052 static bool CanOptimizeFunction(const Function& function, Isolate* isolate) { |
| 1053 ASSERT(isolate->debugger() != NULL); |
1052 const intptr_t kLowInvocationCount = -100000000; | 1054 const intptr_t kLowInvocationCount = -100000000; |
1053 if (isolate->debugger()->IsStepping() || | 1055 if (isolate->debugger()->IsStepping() || |
1054 isolate->debugger()->HasBreakpoint(function)) { | 1056 isolate->debugger()->HasBreakpoint(function)) { |
1055 // We cannot set breakpoints and single step in optimized code, | 1057 // We cannot set breakpoints and single step in optimized code, |
1056 // so do not optimize the function. | 1058 // so do not optimize the function. |
1057 function.set_usage_counter(0); | 1059 function.set_usage_counter(0); |
1058 return false; | 1060 return false; |
1059 } | 1061 } |
1060 if (function.deoptimization_counter() >= | 1062 if (function.deoptimization_counter() >= |
1061 FLAG_deoptimization_counter_threshold) { | 1063 FLAG_deoptimization_counter_threshold) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 OS::PrintErr("*** Computing stacktrace (%s)\n", | 1171 OS::PrintErr("*** Computing stacktrace (%s)\n", |
1170 function.ToFullyQualifiedCString()); | 1172 function.ToFullyQualifiedCString()); |
1171 do_stacktrace = true; | 1173 do_stacktrace = true; |
1172 } | 1174 } |
1173 } | 1175 } |
1174 if (do_deopt) { | 1176 if (do_deopt) { |
1175 // TODO(turnidge): Consider using DeoptimizeAt instead. | 1177 // TODO(turnidge): Consider using DeoptimizeAt instead. |
1176 DeoptimizeFunctionsOnStack(); | 1178 DeoptimizeFunctionsOnStack(); |
1177 } | 1179 } |
1178 if (do_stacktrace) { | 1180 if (do_stacktrace) { |
| 1181 ASSERT(isolate->debugger() != NULL); |
1179 String& var_name = String::Handle(); | 1182 String& var_name = String::Handle(); |
1180 Instance& var_value = Instance::Handle(); | 1183 Instance& var_value = Instance::Handle(); |
1181 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1184 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
1182 intptr_t num_frames = stack->Length(); | 1185 intptr_t num_frames = stack->Length(); |
1183 for (intptr_t i = 0; i < num_frames; i++) { | 1186 for (intptr_t i = 0; i < num_frames; i++) { |
1184 ActivationFrame* frame = stack->FrameAt(i); | 1187 ActivationFrame* frame = stack->FrameAt(i); |
1185 // Variable locations and number are unknown when 'always_optimize'. | 1188 // Variable locations and number are unknown when 'always_optimize'. |
1186 const int num_vars = | 1189 const int num_vars = |
1187 Compiler::always_optimize() ? 0 : frame->NumLocalVariables(); | 1190 Compiler::always_optimize() ? 0 : frame->NumLocalVariables(); |
1188 intptr_t unused; | 1191 intptr_t unused; |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1687 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
1685 const TypedData& new_data = | 1688 const TypedData& new_data = |
1686 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1689 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
1687 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1690 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
1688 typed_data_cell.SetAt(0, new_data); | 1691 typed_data_cell.SetAt(0, new_data); |
1689 arguments.SetReturn(new_data); | 1692 arguments.SetReturn(new_data); |
1690 } | 1693 } |
1691 | 1694 |
1692 | 1695 |
1693 } // namespace dart | 1696 } // namespace dart |
OLD | NEW |