Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: runtime/vm/exceptions.cc

Issue 341083002: Use Dart stack walker when we have an exit frame. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
284 // CallToRuntime, CallBootstrapCFunction, and CallNativeCFunction stubs.
285 // In the case of an exception, we skip the epilogues and must set the
286 // correct state here.
287 isolate->set_vm_tag(VMTag::kScriptTagId);
288 isolate->set_top_exit_frame_info(0);
289 isolate->set_top_context(Context::null());
290
283 #if defined(USING_SIMULATOR) 291 #if defined(USING_SIMULATOR)
284 // Unwinding of the C++ frames and destroying of their stack resources is done 292 // Unwinding of the C++ frames and destroying of their stack resources is done
285 // by the simulator, because the target stack_pointer is a simulated stack 293 // by the simulator, because the target stack_pointer is a simulated stack
286 // pointer and not the C++ stack pointer. 294 // pointer and not the C++ stack pointer.
287 295
288 // Continue simulating at the given pc in the given frame after setting up the 296 // Continue simulating at the given pc in the given frame after setting up the
289 // exception object in the kExceptionObjectReg register and the stacktrace 297 // exception object in the kExceptionObjectReg register and the stacktrace
290 // object (may be raw null) in the kStackTraceObjectReg register. 298 // object (may be raw null) in the kStackTraceObjectReg register.
291 isolate->set_vm_tag(VMTag::kScriptTagId); 299
292 isolate->set_top_context(Context::null());
293 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer, 300 Simulator::Current()->Longjmp(program_counter, stack_pointer, frame_pointer,
294 raw_exception, raw_stacktrace); 301 raw_exception, raw_stacktrace);
295 #else 302 #else
296 // Prepare for unwinding frames by destroying all the stack resources 303 // Prepare for unwinding frames by destroying all the stack resources
297 // in the previous frames. 304 // in the previous frames.
298 305
299 while (isolate->top_resource() != NULL && 306 while (isolate->top_resource() != NULL &&
300 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { 307 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
301 isolate->top_resource()->~StackResource(); 308 isolate->top_resource()->~StackResource();
302 } 309 }
303 310
304 // Call a stub to set up the exception object in kExceptionObjectReg, 311 // Call a stub to set up the exception object in kExceptionObjectReg,
305 // to set up the stacktrace object in kStackTraceObjectReg, and to 312 // to set up the stacktrace object in kStackTraceObjectReg, and to
306 // continue execution at the given pc in the given frame. 313 // continue execution at the given pc in the given frame.
307 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*); 314 typedef void (*ExcpHandler)(uword, uword, uword, RawObject*, RawObject*);
308 ExcpHandler func = reinterpret_cast<ExcpHandler>( 315 ExcpHandler func = reinterpret_cast<ExcpHandler>(
309 StubCode::JumpToExceptionHandlerEntryPoint()); 316 StubCode::JumpToExceptionHandlerEntryPoint());
310 317
311 // 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.
312 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024; 319 uword current_sp = reinterpret_cast<uword>(&program_counter) - 1024;
313 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp), 320 __asan_unpoison_memory_region(reinterpret_cast<void*>(current_sp),
314 stack_pointer - current_sp); 321 stack_pointer - current_sp);
315 isolate->set_vm_tag(VMTag::kScriptTagId); 322
316 isolate->set_top_context(Context::null());
317 func(program_counter, stack_pointer, frame_pointer, 323 func(program_counter, stack_pointer, frame_pointer,
318 raw_exception, raw_stacktrace); 324 raw_exception, raw_stacktrace);
319 #endif 325 #endif
320 UNREACHABLE(); 326 UNREACHABLE();
321 } 327 }
322 328
323 329
324 static RawField* LookupStacktraceField(const Instance& instance) { 330 static RawField* LookupStacktraceField(const Instance& instance) {
325 if (instance.GetClassId() < kNumPredefinedCids) { 331 if (instance.GetClassId() < kNumPredefinedCids) {
326 // 'class Error' is not a predefined class. 332 // 'class Error' is not a predefined class.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 756
751 // Throw JavascriptCompatibilityError exception. 757 // Throw JavascriptCompatibilityError exception.
752 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { 758 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) {
753 const Array& exc_args = Array::Handle(Array::New(1)); 759 const Array& exc_args = Array::Handle(Array::New(1));
754 const String& msg_str = String::Handle(String::New(msg)); 760 const String& msg_str = String::Handle(String::New(msg));
755 exc_args.SetAt(0, msg_str); 761 exc_args.SetAt(0, msg_str);
756 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); 762 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args);
757 } 763 }
758 764
759 } // namespace dart 765 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698