OLD | NEW |
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" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 const Object& stacktrace_object) { | 212 const Object& stacktrace_object) { |
213 // The no_gc StackResource is unwound through the tear down of | 213 // The no_gc StackResource is unwound through the tear down of |
214 // stack resources below. | 214 // stack resources below. |
215 NoSafepointScope no_safepoint; | 215 NoSafepointScope no_safepoint; |
216 RawObject* raw_exception = exception_object.raw(); | 216 RawObject* raw_exception = exception_object.raw(); |
217 RawObject* raw_stacktrace = stacktrace_object.raw(); | 217 RawObject* raw_stacktrace = stacktrace_object.raw(); |
218 | 218 |
219 #if !defined(TARGET_ARCH_DBC) | 219 #if !defined(TARGET_ARCH_DBC) |
220 MallocGrowableArray<PendingLazyDeopt>* pending_deopts = | 220 MallocGrowableArray<PendingLazyDeopt>* pending_deopts = |
221 thread->isolate()->pending_deopts(); | 221 thread->isolate()->pending_deopts(); |
222 for (intptr_t i = pending_deopts->length() - 1; i >= 0; i--) { | 222 if (pending_deopts->length() > 0) { |
223 if ((*pending_deopts)[i].fp() == frame_pointer) { | 223 // Check if the target frame is scheduled for lazy deopt. |
224 // Frame is scheduled for lazy deopt. | 224 for (intptr_t i = 0; i < pending_deopts->length(); i++) { |
| 225 if ((*pending_deopts)[i].fp() == frame_pointer) { |
| 226 // Deopt should now resume in the catch handler instead of after the |
| 227 // call. |
| 228 (*pending_deopts)[i].set_pc(program_counter); |
225 | 229 |
226 // Deopt should now resume in the catch handler instead of after the call. | 230 // Jump to the deopt stub instead of the catch handler. |
227 (*pending_deopts)[i].set_pc(program_counter); | 231 program_counter = |
| 232 StubCode::DeoptimizeLazyFromThrow_entry()->EntryPoint(); |
| 233 if (FLAG_trace_deoptimization) { |
| 234 THR_Print("Throwing to frame scheduled for lazy deopt fp=%" Pp "\n", |
| 235 frame_pointer); |
| 236 } |
| 237 break; |
| 238 } |
| 239 } |
228 | 240 |
229 // Jump to the deopt stub instead of the catch handler. | 241 // We may be jumping over frames scheduled for lazy deopt. Remove these |
230 program_counter = | 242 // frames from the pending deopt table, but only after unmarking them so |
231 StubCode::DeoptimizeLazyFromThrow_entry()->EntryPoint(); | 243 // any stack walk that happens before the stack is unwound will still work. |
232 if (FLAG_trace_deoptimization) { | 244 { |
233 THR_Print("Throwing to frame scheduled for lazy deopt fp=%" Pp "\n", | 245 DartFrameIterator frames(thread); |
234 frame_pointer); | 246 StackFrame* frame = frames.NextFrame(); |
| 247 while ((frame != NULL) && (frame->fp() < frame_pointer)) { |
| 248 if (frame->IsMarkedForLazyDeopt()) { |
| 249 frame->UnmarkForLazyDeopt(); |
| 250 } |
| 251 frame = frames.NextFrame(); |
235 } | 252 } |
236 break; | |
237 } | 253 } |
| 254 |
| 255 #if defined(DEBUG) |
| 256 ValidateFrames(); |
| 257 #endif |
| 258 |
| 259 for (intptr_t i = 0; i < pending_deopts->length(); i++) { |
| 260 if ((*pending_deopts)[i].fp() < frame_pointer) { |
| 261 if (FLAG_trace_deoptimization) { |
| 262 THR_Print("Lazy deopt skipped due to throw for " |
| 263 "fp=%" Pp ", pc=%" Pp "\n", |
| 264 (*pending_deopts)[i].fp(), (*pending_deopts)[i].pc()); |
| 265 } |
| 266 pending_deopts->RemoveAt(i); |
| 267 } |
| 268 } |
| 269 |
| 270 #if defined(DEBUG) |
| 271 ValidateFrames(); |
| 272 #endif |
238 } | 273 } |
239 #endif // !DBC | 274 #endif // !DBC |
240 | 275 |
241 | 276 |
242 #if defined(USING_SIMULATOR) | 277 #if defined(USING_SIMULATOR) |
243 // Unwinding of the C++ frames and destroying of their stack resources is done | 278 // Unwinding of the C++ frames and destroying of their stack resources is done |
244 // by the simulator, because the target stack_pointer is a simulated stack | 279 // by the simulator, because the target stack_pointer is a simulated stack |
245 // pointer and not the C++ stack pointer. | 280 // pointer and not the C++ stack pointer. |
246 | 281 |
247 // Continue simulating at the given pc in the given frame after setting up the | 282 // Continue simulating at the given pc in the given frame after setting up the |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 } | 798 } |
764 | 799 |
765 return DartLibraryCalls::InstanceCreate(library, | 800 return DartLibraryCalls::InstanceCreate(library, |
766 *class_name, | 801 *class_name, |
767 *constructor_name, | 802 *constructor_name, |
768 arguments); | 803 arguments); |
769 } | 804 } |
770 | 805 |
771 | 806 |
772 } // namespace dart | 807 } // namespace dart |
OLD | NEW |