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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 278 |
279 #if defined(USING_SIMULATOR) | 279 #if defined(USING_SIMULATOR) |
280 // Unwinding of the C++ frames and destroying of their stack resources is done | 280 // Unwinding of the C++ frames and destroying of their stack resources is done |
281 // by the simulator, because the target stack_pointer is a simulated stack | 281 // by the simulator, because the target stack_pointer is a simulated stack |
282 // pointer and not the C++ stack pointer. | 282 // pointer and not the C++ stack pointer. |
283 | 283 |
284 // Continue simulating at the given pc in the given frame after setting up the | 284 // Continue simulating at the given pc in the given frame after setting up the |
285 // exception object in the kExceptionObjectReg register and the stacktrace | 285 // exception object in the kExceptionObjectReg register and the stacktrace |
286 // object (may be raw null) in the kStackTraceObjectReg register. | 286 // object (may be raw null) in the kStackTraceObjectReg register. |
287 isolate->set_vm_tag(VMTag::kScriptTagId); | 287 isolate->set_vm_tag(VMTag::kScriptTagId); |
| 288 isolate->set_top_context(Context::null()); |
288 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, | 289 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, |
289 raw_exception, raw_stacktrace); | 290 raw_exception, raw_stacktrace); |
290 #else | 291 #else |
291 // Prepare for unwinding frames by destroying all the stack resources | 292 // Prepare for unwinding frames by destroying all the stack resources |
292 // in the previous frames. | 293 // in the previous frames. |
293 | 294 |
294 while (isolate->top_resource() != NULL && | 295 while (isolate->top_resource() != NULL && |
295 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | 296 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { |
296 isolate->top_resource()->~StackResource(); | 297 isolate->top_resource()->~StackResource(); |
297 } | 298 } |
298 | 299 |
299 // Call a stub to set up the exception object in kExceptionObjectReg, | 300 // Call a stub to set up the exception object in kExceptionObjectReg, |
300 // to set up the stacktrace object in kStackTraceObjectReg, and to | 301 // to set up the stacktrace object in kStackTraceObjectReg, and to |
301 // continue execution at the given pc in the given frame. | 302 // continue execution at the given pc in the given frame. |
302 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); | 303 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); |
303 ExcpHandler func = reinterpret_cast<ExcpHandler>( | 304 ExcpHandler func = reinterpret_cast<ExcpHandler>( |
304 StubCode::JumpToExceptionHandlerEntryPoint()); | 305 StubCode::JumpToExceptionHandlerEntryPoint()); |
305 | 306 |
306 // 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. |
307 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; | 308 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; |
308 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), | 309 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), |
309 stack_pointer - current_sp); | 310 stack_pointer - current_sp); |
310 isolate->set_vm_tag(VMTag::kScriptTagId); | 311 isolate->set_vm_tag(VMTag::kScriptTagId); |
| 312 isolate->set_top_context(Context::null()); |
311 func(program_counter, stack_pointer, frame_pointer, | 313 func(program_counter, stack_pointer, frame_pointer, |
312 raw_exception, raw_stacktrace); | 314 raw_exception, raw_stacktrace); |
313 #endif | 315 #endif |
314 UNREACHABLE(); | 316 UNREACHABLE(); |
315 } | 317 } |
316 | 318 |
317 | 319 |
318 static RawField* LookupStacktraceField(const Instance& instance) { | 320 static RawField* LookupStacktraceField(const Instance& instance) { |
319 if (instance.GetClassId() < kNumPredefinedCids) { | 321 if (instance.GetClassId() < kNumPredefinedCids) { |
320 // 'class Error' is not a predefined class. | 322 // 'class Error' is not a predefined class. |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 break; | 720 break; |
719 } | 721 } |
720 | 722 |
721 return DartLibraryCalls::InstanceCreate(library, | 723 return DartLibraryCalls::InstanceCreate(library, |
722 *class_name, | 724 *class_name, |
723 *constructor_name, | 725 *constructor_name, |
724 arguments); | 726 arguments); |
725 } | 727 } |
726 | 728 |
727 } // namespace dart | 729 } // namespace dart |
OLD | NEW |