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