| 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 "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // stack resources below. | 272 // stack resources below. |
| 273 NoGCScope no_gc; | 273 NoGCScope no_gc; |
| 274 RawObject* raw_exception = exception_object.raw(); | 274 RawObject* raw_exception = exception_object.raw(); |
| 275 RawObject* raw_stacktrace = stacktrace_object.raw(); | 275 RawObject* raw_stacktrace = stacktrace_object.raw(); |
| 276 | 276 |
| 277 #if defined(USING_SIMULATOR) | 277 #if defined(USING_SIMULATOR) |
| 278 // 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 |
| 279 // 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 |
| 280 // pointer and not the C++ stack pointer. | 280 // pointer and not the C++ stack pointer. |
| 281 | 281 |
| 282 // From the VM we are about to jump back to dart code so start the dart |
| 283 // timer back on. |
| 284 START_TIMER(Isolate::Current(), time_dart_execution); |
| 285 |
| 282 // Continue simulating at the given pc in the given frame after setting up the | 286 // Continue simulating at the given pc in the given frame after setting up the |
| 283 // exception object in the kExceptionObjectReg register and the stacktrace | 287 // exception object in the kExceptionObjectReg register and the stacktrace |
| 284 // object (may be raw null) in the kStackTraceObjectReg register. | 288 // object (may be raw null) in the kStackTraceObjectReg register. |
| 285 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, | 289 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, |
| 286 raw_exception, raw_stacktrace); | 290 raw_exception, raw_stacktrace); |
| 287 #else | 291 #else |
| 288 // Prepare for unwinding frames by destroying all the stack resources | 292 // Prepare for unwinding frames by destroying all the stack resources |
| 289 // in the previous frames. | 293 // in the previous frames. |
| 290 Isolate* isolate = Isolate::Current(); | 294 Isolate* isolate = Isolate::Current(); |
| 291 while (isolate->top_resource() != NULL && | 295 while (isolate->top_resource() != NULL && |
| 292 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | 296 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { |
| 293 isolate->top_resource()->~StackResource(); | 297 isolate->top_resource()->~StackResource(); |
| 294 } | 298 } |
| 295 | 299 |
| 296 // Call a stub to set up the exception object in kExceptionObjectReg, | 300 // Call a stub to set up the exception object in kExceptionObjectReg, |
| 297 // to set up the stacktrace object in kStackTraceObjectReg, and to | 301 // to set up the stacktrace object in kStackTraceObjectReg, and to |
| 298 // continue execution at the given pc in the given frame. | 302 // continue execution at the given pc in the given frame. |
| 299 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); | 303 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); |
| 300 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 304 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
| 301 StubCode::JumpToExceptionHandlerEntryPoint()); | 305 StubCode::JumpToExceptionHandlerEntryPoint()); |
| 302 | 306 |
| 303 // Unpoison the stack before we tear it down in the generated stub code. | 307 // Unpoison the stack before we tear it down in the generated stub code. |
| 304 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; | 308 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; |
| 305 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), | 309 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), |
| 306 stack_pointer - current_sp); | 310 stack_pointer - current_sp); |
| 311 // From the VM we are about to jump back to dart code so start the dart |
| 312 // timer back on. |
| 313 START_TIMER(isolate, time_dart_execution); |
| 307 func(program_counter, stack_pointer, frame_pointer, | 314 func(program_counter, stack_pointer, frame_pointer, |
| 308 raw_exception, raw_stacktrace); | 315 raw_exception, raw_stacktrace); |
| 309 #endif | 316 #endif |
| 310 UNREACHABLE(); | 317 UNREACHABLE(); |
| 311 } | 318 } |
| 312 | 319 |
| 313 | 320 |
| 314 static RawField* LookupStacktraceField(const Instance& instance) { | 321 static RawField* LookupStacktraceField(const Instance& instance) { |
| 315 if (instance.GetClassId() < kNumPredefinedCids) { | 322 if (instance.GetClassId() < kNumPredefinedCids) { |
| 316 // 'class Error' is not a predefined class. | 323 // 'class Error' is not a predefined class. |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 break; | 713 break; |
| 707 } | 714 } |
| 708 | 715 |
| 709 return DartLibraryCalls::InstanceCreate(library, | 716 return DartLibraryCalls::InstanceCreate(library, |
| 710 *class_name, | 717 *class_name, |
| 711 *constructor_name, | 718 *constructor_name, |
| 712 arguments); | 719 arguments); |
| 713 } | 720 } |
| 714 | 721 |
| 715 } // namespace dart | 722 } // namespace dart |
| OLD | NEW |