Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: runtime/vm/exceptions.cc

Issue 2380403003: Lazy deopt without code patching. (Closed)
Patch Set: remove tracing register assignment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/exceptions.h" 5 #include "vm/exceptions.h"
6 6
7 #include "platform/address_sanitizer.h" 7 #include "platform/address_sanitizer.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
11 #include "vm/debugger.h" 11 #include "vm/debugger.h"
12 #include "vm/flags.h" 12 #include "vm/flags.h"
13 #include "vm/log.h" 13 #include "vm/log.h"
14 #include "vm/longjump.h" 14 #include "vm/longjump.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_store.h" 16 #include "vm/object_store.h"
17 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
18 #include "vm/stub_code.h" 18 #include "vm/stub_code.h"
19 #include "vm/symbols.h" 19 #include "vm/symbols.h"
20 #include "vm/tags.h" 20 #include "vm/tags.h"
21 21
22 namespace dart { 22 namespace dart {
23 23
24 DECLARE_FLAG(bool, trace_deoptimization);
24 DEFINE_FLAG(bool, print_stacktrace_at_throw, false, 25 DEFINE_FLAG(bool, print_stacktrace_at_throw, false,
25 "Prints a stack trace everytime a throw occurs."); 26 "Prints a stack trace everytime a throw occurs.");
26 27
27 28
28 class StacktraceBuilder : public ValueObject { 29 class StacktraceBuilder : public ValueObject {
29 public: 30 public:
30 StacktraceBuilder() { } 31 StacktraceBuilder() { }
31 virtual ~StacktraceBuilder() { } 32 virtual ~StacktraceBuilder() { }
32 33
33 virtual void AddFrame(const Code& code, const Smi& offset) = 0; 34 virtual void AddFrame(const Code& code, const Smi& offset) = 0;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 122
122 static void BuildStackTrace(StacktraceBuilder* builder) { 123 static void BuildStackTrace(StacktraceBuilder* builder) {
123 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 124 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
124 StackFrame* frame = frames.NextFrame(); 125 StackFrame* frame = frames.NextFrame();
125 ASSERT(frame != NULL); // We expect to find a dart invocation frame. 126 ASSERT(frame != NULL); // We expect to find a dart invocation frame.
126 Code& code = Code::Handle(); 127 Code& code = Code::Handle();
127 Smi& offset = Smi::Handle(); 128 Smi& offset = Smi::Handle();
128 while (frame != NULL) { 129 while (frame != NULL) {
129 if (frame->IsDartFrame()) { 130 if (frame->IsDartFrame()) {
130 code = frame->LookupDartCode(); 131 code = frame->LookupDartCode();
132 ASSERT(code.ContainsInstructionAt(frame->pc()));
131 offset = Smi::New(frame->pc() - code.PayloadStart()); 133 offset = Smi::New(frame->pc() - code.PayloadStart());
132 builder->AddFrame(code, offset); 134 builder->AddFrame(code, offset);
133 } 135 }
134 frame = frames.NextFrame(); 136 frame = frames.NextFrame();
135 } 137 }
136 } 138 }
137 139
138 140
139 // Iterate through the stack frames and try to find a frame with an 141 // Iterate through the stack frames and try to find a frame with an
140 // exception handler. Once found, set the pc, sp and fp so that execution 142 // exception handler. Once found, set the pc, sp and fp so that execution
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 uword stack_pointer, 209 uword stack_pointer,
208 uword frame_pointer, 210 uword frame_pointer,
209 const Object& exception_object, 211 const Object& exception_object,
210 const Object& stacktrace_object) { 212 const Object& stacktrace_object) {
211 // The no_gc StackResource is unwound through the tear down of 213 // The no_gc StackResource is unwound through the tear down of
212 // stack resources below. 214 // stack resources below.
213 NoSafepointScope no_safepoint; 215 NoSafepointScope no_safepoint;
214 RawObject* raw_exception = exception_object.raw(); 216 RawObject* raw_exception = exception_object.raw();
215 RawObject* raw_stacktrace = stacktrace_object.raw(); 217 RawObject* raw_stacktrace = stacktrace_object.raw();
216 218
219 #if !defined(TARGET_ARCH_DBC)
220 MallocGrowableArray<PendingLazyDeopt>* pending_deopts =
221 thread->isolate()->pending_deopts();
222 for (intptr_t i = pending_deopts->length() - 1; i >= 0; i--) {
223 if ((*pending_deopts)[i].fp() == frame_pointer) {
224 // Frame is scheduled for lazy deopt.
225 program_counter =
226 StubCode::DeoptimizeLazyFromThrow_entry()->EntryPoint();
227 if (FLAG_trace_deoptimization) {
228 THR_Print("Throwing to frame scheduled for lazy deopt fp=%" Pp "\n",
229 frame_pointer);
230 }
231 break;
232 }
233 }
234 for (intptr_t i = pending_deopts->length() - 1; i >= 0; i--) {
235 // Leave the mapping at fp itself for use in DeoptimizeCopyFrame.
236 if ((*pending_deopts)[i].fp() < frame_pointer) {
237 pending_deopts->RemoveAt(i);
238 }
239 }
240 #endif // !DBC
241
242
217 #if defined(USING_SIMULATOR) 243 #if defined(USING_SIMULATOR)
218 // Unwinding of the C++ frames and destroying of their stack resources is done 244 // Unwinding of the C++ frames and destroying of their stack resources is done
219 // by the simulator, because the target stack_pointer is a simulated stack 245 // by the simulator, because the target stack_pointer is a simulated stack
220 // pointer and not the C++ stack pointer. 246 // pointer and not the C++ stack pointer.
221 247
222 // Continue simulating at the given pc in the given frame after setting up the 248 // Continue simulating at the given pc in the given frame after setting up the
223 // exception object in the kExceptionObjectReg register and the stacktrace 249 // exception object in the kExceptionObjectReg register and the stacktrace
224 // object (may be raw null) in the kStackTraceObjectReg register. 250 // object (may be raw null) in the kStackTraceObjectReg register.
225 251
226 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, 252 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer,
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 764 }
739 765
740 return DartLibraryCalls::InstanceCreate(library, 766 return DartLibraryCalls::InstanceCreate(library,
741 *class_name, 767 *class_name,
742 *constructor_name, 768 *constructor_name,
743 arguments); 769 arguments);
744 } 770 }
745 771
746 772
747 } // namespace dart 773 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698