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