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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 *handler_fp = frame->fp(); | 203 *handler_fp = frame->fp(); |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 static void JumpToExceptionHandler(Thread* thread, | 207 static void JumpToExceptionHandler(Thread* thread, |
208 uword program_counter, | 208 uword program_counter, |
209 uword stack_pointer, | 209 uword stack_pointer, |
210 uword frame_pointer, | 210 uword frame_pointer, |
211 const Object& exception_object, | 211 const Object& exception_object, |
212 const Object& stacktrace_object) { | 212 const Object& stacktrace_object) { |
213 thread->set_active_exception(exception_object); | 213 // The no_gc StackResource is unwound through the tear down of |
214 thread->set_active_stacktrace(stacktrace_object); | 214 // stack resources below. |
215 thread->set_resume_pc(program_counter); | 215 NoSafepointScope no_safepoint; |
216 uword run_exception_pc = StubCode::RunExceptionHandler_entry()->EntryPoint(); | 216 RawObject* raw_exception = exception_object.raw(); |
217 Exceptions::JumpToFrame(thread, run_exception_pc, stack_pointer, | 217 RawObject* raw_stacktrace = stacktrace_object.raw(); |
218 frame_pointer); | |
219 } | |
220 | 218 |
221 | |
222 void Exceptions::JumpToFrame(Thread* thread, | |
223 uword program_counter, | |
224 uword stack_pointer, | |
225 uword frame_pointer) { | |
226 #if !defined(TARGET_ARCH_DBC) | 219 #if !defined(TARGET_ARCH_DBC) |
227 MallocGrowableArray<PendingLazyDeopt>* pending_deopts = | 220 MallocGrowableArray<PendingLazyDeopt>* pending_deopts = |
228 thread->isolate()->pending_deopts(); | 221 thread->isolate()->pending_deopts(); |
229 if (pending_deopts->length() > 0) { | 222 if (pending_deopts->length() > 0) { |
230 // Check if the target frame is scheduled for lazy deopt. | 223 // Check if the target frame is scheduled for lazy deopt. |
231 for (intptr_t i = 0; i < pending_deopts->length(); i++) { | 224 for (intptr_t i = 0; i < pending_deopts->length(); i++) { |
232 if ((*pending_deopts)[i].fp() == frame_pointer) { | 225 if ((*pending_deopts)[i].fp() == frame_pointer) { |
233 // Deopt should now resume in the catch handler instead of after the | 226 // Deopt should now resume in the catch handler instead of after the |
234 // call. | 227 // call. |
235 (*pending_deopts)[i].set_pc(program_counter); | 228 (*pending_deopts)[i].set_pc(program_counter); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 277 |
285 #if defined(USING_SIMULATOR) | 278 #if defined(USING_SIMULATOR) |
286 // Unwinding of the C++ frames and destroying of their stack resources is done | 279 // Unwinding of the C++ frames and destroying of their stack resources is done |
287 // by the simulator, because the target stack_pointer is a simulated stack | 280 // by the simulator, because the target stack_pointer is a simulated stack |
288 // pointer and not the C++ stack pointer. | 281 // pointer and not the C++ stack pointer. |
289 | 282 |
290 // Continue simulating at the given pc in the given frame after setting up the | 283 // Continue simulating at the given pc in the given frame after setting up the |
291 // exception object in the kExceptionObjectReg register and the stacktrace | 284 // exception object in the kExceptionObjectReg register and the stacktrace |
292 // object (may be raw null) in the kStackTraceObjectReg register. | 285 // object (may be raw null) in the kStackTraceObjectReg register. |
293 | 286 |
294 Simulator::Current()->JumpToFrame(program_counter, stack_pointer, | 287 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, |
295 frame_pointer, thread); | 288 raw_exception, raw_stacktrace, thread); |
296 #else | 289 #else |
297 // Prepare for unwinding frames by destroying all the stack resources | 290 // Prepare for unwinding frames by destroying all the stack resources |
298 // in the previous frames. | 291 // in the previous frames. |
299 StackResource::Unwind(thread); | 292 StackResource::Unwind(thread); |
300 | 293 |
301 // Call a stub to set up the exception object in kExceptionObjectReg, | 294 // Call a stub to set up the exception object in kExceptionObjectReg, |
302 // to set up the stacktrace object in kStackTraceObjectReg, and to | 295 // to set up the stacktrace object in kStackTraceObjectReg, and to |
303 // continue execution at the given pc in the given frame. | 296 // continue execution at the given pc in the given frame. |
304 typedef void (*ExcpHandler)(uword, uword, uword, Thread*); | 297 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*, |
| 298 Thread*); |
305 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 299 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
306 StubCode::JumpToFrame_entry()->EntryPoint()); | 300 StubCode::JumpToExceptionHandler_entry()->EntryPoint()); |
307 | 301 |
308 // Unpoison the stack before we tear it down in the generated stub code. | 302 // Unpoison the stack before we tear it down in the generated stub code. |
309 uword current_sp = Thread::GetCurrentStackPointer() - 1024; | 303 uword current_sp = Thread::GetCurrentStackPointer() - 1024; |
310 ASAN_UNPOISON(reinterpret_cast<void*>(current_sp), | 304 ASAN_UNPOISON(reinterpret_cast<void*>(current_sp), |
311 stack_pointer - current_sp); | 305 stack_pointer - current_sp); |
312 | 306 |
313 func(program_counter, stack_pointer, frame_pointer, thread); | 307 func(program_counter, stack_pointer, frame_pointer, raw_exception, |
| 308 raw_stacktrace, thread); |
314 #endif | 309 #endif |
315 UNREACHABLE(); | 310 UNREACHABLE(); |
316 } | 311 } |
317 | 312 |
318 | 313 |
319 static RawField* LookupStacktraceField(const Instance& instance) { | 314 static RawField* LookupStacktraceField(const Instance& instance) { |
320 if (instance.GetClassId() < kNumPredefinedCids) { | 315 if (instance.GetClassId() < kNumPredefinedCids) { |
321 // 'class Error' is not a predefined class. | 316 // 'class Error' is not a predefined class. |
322 return Field::null(); | 317 return Field::null(); |
323 } | 318 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 class_name = &Symbols::_CompileTimeError(); | 788 class_name = &Symbols::_CompileTimeError(); |
794 break; | 789 break; |
795 } | 790 } |
796 | 791 |
797 return DartLibraryCalls::InstanceCreate(library, *class_name, | 792 return DartLibraryCalls::InstanceCreate(library, *class_name, |
798 *constructor_name, arguments); | 793 *constructor_name, arguments); |
799 } | 794 } |
800 | 795 |
801 | 796 |
802 } // namespace dart | 797 } // namespace dart |
OLD | NEW |