| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 uword stack_pointer, | 273 uword stack_pointer, |
| 274 uword frame_pointer, | 274 uword frame_pointer, |
| 275 const Object& exception_object, | 275 const Object& exception_object, |
| 276 const Object& stacktrace_object) { | 276 const Object& stacktrace_object) { |
| 277 // The no_gc StackResource is unwound through the tear down of | 277 // The no_gc StackResource is unwound through the tear down of |
| 278 // stack resources below. | 278 // stack resources below. |
| 279 NoGCScope no_gc; | 279 NoGCScope no_gc; |
| 280 RawObject* raw_exception = exception_object.raw(); | 280 RawObject* raw_exception = exception_object.raw(); |
| 281 RawObject* raw_stacktrace = stacktrace_object.raw(); | 281 RawObject* raw_stacktrace = stacktrace_object.raw(); |
| 282 | 282 |
| 283 // The following three operations are part of the 'epilogue' of the | 283 // The following operation is part of the 'epilogue' of the CallToRuntime, |
| 284 // CallToRuntime, CallBootstrapCFunction, and CallNativeCFunction stubs. | 284 // CallBootstrapCFunction, and CallNativeCFunction stubs. In the case of an |
| 285 // In the case of an exception, we skip the epilogues and must set the | 285 // exception, we skip the epilogues and must set the correct state here. |
| 286 // correct state here. | 286 // The other operations performed as part of the 'epilogue' are handled |
| 287 isolate->set_vm_tag(VMTag::kScriptTagId); | 287 // by the simulator's Longjmp or the JumpToExceptionHandler stub. |
| 288 isolate->set_top_exit_frame_info(0); | |
| 289 isolate->set_top_context(Context::null()); | 288 isolate->set_top_context(Context::null()); |
| 290 | 289 |
| 291 #if defined(USING_SIMULATOR) | 290 #if defined(USING_SIMULATOR) |
| 292 // Unwinding of the C++ frames and destroying of their stack resources is done | 291 // Unwinding of the C++ frames and destroying of their stack resources is done |
| 293 // by the simulator, because the target stack_pointer is a simulated stack | 292 // by the simulator, because the target stack_pointer is a simulated stack |
| 294 // pointer and not the C++ stack pointer. | 293 // pointer and not the C++ stack pointer. |
| 295 | 294 |
| 296 // Continue simulating at the given pc in the given frame after setting up the | 295 // Continue simulating at the given pc in the given frame after setting up the |
| 297 // exception object in the kExceptionObjectReg register and the stacktrace | 296 // exception object in the kExceptionObjectReg register and the stacktrace |
| 298 // object (may be raw null) in the kStackTraceObjectReg register. | 297 // object (may be raw null) in the kStackTraceObjectReg register. |
| 299 | 298 |
| 300 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, | 299 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, |
| 301 raw_exception, raw_stacktrace); | 300 raw_exception, raw_stacktrace, isolate); |
| 302 #else | 301 #else |
| 303 // Prepare for unwinding frames by destroying all the stack resources | 302 // Prepare for unwinding frames by destroying all the stack resources |
| 304 // in the previous frames. | 303 // in the previous frames. |
| 305 | 304 |
| 306 while (isolate->top_resource() != NULL && | 305 while (isolate->top_resource() != NULL && |
| 307 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | 306 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { |
| 308 isolate->top_resource()->~StackResource(); | 307 isolate->top_resource()->~StackResource(); |
| 309 } | 308 } |
| 310 | 309 |
| 311 // Call a stub to set up the exception object in kExceptionObjectReg, | 310 // Call a stub to set up the exception object in kExceptionObjectReg, |
| 312 // to set up the stacktrace object in kStackTraceObjectReg, and to | 311 // to set up the stacktrace object in kStackTraceObjectReg, and to |
| 313 // continue execution at the given pc in the given frame. | 312 // continue execution at the given pc in the given frame. |
| 314 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); | 313 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*, |
| 314 Isolate*); |
| 315 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 315 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
| 316 StubCode::JumpToExceptionHandlerEntryPoint()); | 316 StubCode::JumpToExceptionHandlerEntryPoint()); |
| 317 | 317 |
| 318 // Unpoison the stack before we tear it down in the generated stub code. | 318 // Unpoison the stack before we tear it down in the generated stub code. |
| 319 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; | 319 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; |
| 320 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), | 320 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), |
| 321 stack_pointer - current_sp); | 321 stack_pointer - current_sp); |
| 322 | 322 |
| 323 func(program_counter, stack_pointer, frame_pointer, | 323 func(program_counter, stack_pointer, frame_pointer, |
| 324 raw_exception, raw_stacktrace); | 324 raw_exception, raw_stacktrace, isolate); |
| 325 #endif | 325 #endif |
| 326 UNREACHABLE(); | 326 UNREACHABLE(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 | 329 |
| 330 static RawField* LookupStacktraceField(const Instance& instance) { | 330 static RawField* LookupStacktraceField(const Instance& instance) { |
| 331 if (instance.GetClassId() < kNumPredefinedCids) { | 331 if (instance.GetClassId() < kNumPredefinedCids) { |
| 332 // 'class Error' is not a predefined class. | 332 // 'class Error' is not a predefined class. |
| 333 return Field::null(); | 333 return Field::null(); |
| 334 } | 334 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 758 |
| 759 // Throw JavascriptCompatibilityError exception. | 759 // Throw JavascriptCompatibilityError exception. |
| 760 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { | 760 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { |
| 761 const Array& exc_args = Array::Handle(Array::New(1)); | 761 const Array& exc_args = Array::Handle(Array::New(1)); |
| 762 const String& msg_str = String::Handle(String::New(msg)); | 762 const String& msg_str = String::Handle(String::New(msg)); |
| 763 exc_args.SetAt(0, msg_str); | 763 exc_args.SetAt(0, msg_str); |
| 764 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); | 764 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); |
| 765 } | 765 } |
| 766 | 766 |
| 767 } // namespace dart | 767 } // namespace dart |
| OLD | NEW |