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

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

Issue 940863002: - Allow any implementation of StackTrace to participate in async/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | « runtime/vm/exceptions.h ('k') | runtime/vm/object.h » ('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 "platform/address_sanitizer.h" 7 #include "platform/address_sanitizer.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 private: 55 private:
56 const GrowableObjectArray& code_list_; 56 const GrowableObjectArray& code_list_;
57 const GrowableObjectArray& pc_offset_list_; 57 const GrowableObjectArray& pc_offset_list_;
58 58
59 DISALLOW_COPY_AND_ASSIGN(RegularStacktraceBuilder); 59 DISALLOW_COPY_AND_ASSIGN(RegularStacktraceBuilder);
60 }; 60 };
61 61
62 62
63 class PreallocatedStacktraceBuilder : public StacktraceBuilder { 63 class PreallocatedStacktraceBuilder : public StacktraceBuilder {
64 public: 64 public:
65 explicit PreallocatedStacktraceBuilder(const Stacktrace& stacktrace) 65 explicit PreallocatedStacktraceBuilder(const Instance& stacktrace)
66 : stacktrace_(stacktrace), 66 : stacktrace_(Stacktrace::Cast(stacktrace)),
67 cur_index_(0) { 67 cur_index_(0) {
68 ASSERT(stacktrace_.raw() == 68 ASSERT(stacktrace_.raw() ==
69 Isolate::Current()->object_store()->preallocated_stack_trace()); 69 Isolate::Current()->object_store()->preallocated_stack_trace());
70 } 70 }
71 ~PreallocatedStacktraceBuilder() { } 71 ~PreallocatedStacktraceBuilder() { }
72 72
73 virtual void AddFrame(const Code& code, const Smi& offset); 73 virtual void AddFrame(const Code& code, const Smi& offset);
74 74
75 private: 75 private:
76 static const int kNumTopframes = 3; 76 static const int kNumTopframes = 3;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 const Array& full_pc_offset_array = Array::Handle(isolate, 286 const Array& full_pc_offset_array = Array::Handle(isolate,
287 Array::MakeArray(frame_builder.pc_offset_list())); 287 Array::MakeArray(frame_builder.pc_offset_list()));
288 const Stacktrace& full_stacktrace = Stacktrace::Handle( 288 const Stacktrace& full_stacktrace = Stacktrace::Handle(
289 Stacktrace::New(full_code_array, full_pc_offset_array)); 289 Stacktrace::New(full_code_array, full_pc_offset_array));
290 return full_stacktrace.raw(); 290 return full_stacktrace.raw();
291 } 291 }
292 292
293 293
294 static void ThrowExceptionHelper(Isolate* isolate, 294 static void ThrowExceptionHelper(Isolate* isolate,
295 const Instance& incoming_exception, 295 const Instance& incoming_exception,
296 const Stacktrace& existing_stacktrace, 296 const Instance& existing_stacktrace,
297 const bool is_rethrow) { 297 const bool is_rethrow) {
298 bool use_preallocated_stacktrace = false; 298 bool use_preallocated_stacktrace = false;
299 Instance& exception = Instance::Handle(isolate, incoming_exception.raw()); 299 Instance& exception = Instance::Handle(isolate, incoming_exception.raw());
300 if (exception.IsNull()) { 300 if (exception.IsNull()) {
301 exception ^= Exceptions::Create(Exceptions::kNullThrown, 301 exception ^= Exceptions::Create(Exceptions::kNullThrown,
302 Object::empty_array()); 302 Object::empty_array());
303 } else if (exception.raw() == isolate->object_store()->out_of_memory() || 303 } else if (exception.raw() == isolate->object_store()->out_of_memory() ||
304 exception.raw() == isolate->object_store()->stack_overflow()) { 304 exception.raw() == isolate->object_store()->stack_overflow()) {
305 use_preallocated_stacktrace = true; 305 use_preallocated_stacktrace = true;
306 } 306 }
307 uword handler_pc = 0; 307 uword handler_pc = 0;
308 uword handler_sp = 0; 308 uword handler_sp = 0;
309 uword handler_fp = 0; 309 uword handler_fp = 0;
310 Stacktrace& stacktrace = Stacktrace::Handle(isolate); 310 Instance& stacktrace = Instance::Handle(isolate);
311 bool handler_exists = false; 311 bool handler_exists = false;
312 bool handler_needs_stacktrace = false; 312 bool handler_needs_stacktrace = false;
313 if (use_preallocated_stacktrace) { 313 if (use_preallocated_stacktrace) {
314 stacktrace ^= isolate->object_store()->preallocated_stack_trace(); 314 stacktrace ^= isolate->object_store()->preallocated_stack_trace();
315 PreallocatedStacktraceBuilder frame_builder(stacktrace); 315 PreallocatedStacktraceBuilder frame_builder(stacktrace);
316 handler_exists = FindExceptionHandler(isolate, 316 handler_exists = FindExceptionHandler(isolate,
317 &handler_pc, 317 &handler_pc,
318 &handler_sp, 318 &handler_sp,
319 &handler_fp, 319 &handler_fp,
320 &handler_needs_stacktrace); 320 &handler_needs_stacktrace);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 exception.raw() != isolate->object_store()->stack_overflow()) { 485 exception.raw() != isolate->object_store()->stack_overflow()) {
486 isolate->debugger()->SignalExceptionThrown(exception); 486 isolate->debugger()->SignalExceptionThrown(exception);
487 } 487 }
488 // Null object is a valid exception object. 488 // Null object is a valid exception object.
489 ThrowExceptionHelper(isolate, exception, Stacktrace::Handle(isolate), false); 489 ThrowExceptionHelper(isolate, exception, Stacktrace::Handle(isolate), false);
490 } 490 }
491 491
492 492
493 void Exceptions::ReThrow(Isolate* isolate, 493 void Exceptions::ReThrow(Isolate* isolate,
494 const Instance& exception, 494 const Instance& exception,
495 const Stacktrace& stacktrace) { 495 const Instance& stacktrace) {
496 // Null object is a valid exception object. 496 // Null object is a valid exception object.
497 ThrowExceptionHelper(isolate, exception, stacktrace, true); 497 ThrowExceptionHelper(isolate, exception, stacktrace, true);
498 } 498 }
499 499
500 500
501 void Exceptions::PropagateError(const Error& error) { 501 void Exceptions::PropagateError(const Error& error) {
502 Isolate* isolate = Isolate::Current(); 502 Isolate* isolate = Isolate::Current();
503 ASSERT(isolate->top_exit_frame_info() != 0); 503 ASSERT(isolate->top_exit_frame_info() != 0);
504 if (error.IsUnhandledException()) { 504 if (error.IsUnhandledException()) {
505 // If the error object represents an unhandled exception, then 505 // If the error object represents an unhandled exception, then
506 // rethrow the exception in the normal fashion. 506 // rethrow the exception in the normal fashion.
507 const UnhandledException& uhe = UnhandledException::Cast(error); 507 const UnhandledException& uhe = UnhandledException::Cast(error);
508 const Instance& exc = Instance::Handle(isolate, uhe.exception()); 508 const Instance& exc = Instance::Handle(isolate, uhe.exception());
509 const Stacktrace& stk = Stacktrace::Handle(isolate, uhe.stacktrace()); 509 const Instance& stk = Instance::Handle(isolate, uhe.stacktrace());
510 Exceptions::ReThrow(isolate, exc, stk); 510 Exceptions::ReThrow(isolate, exc, stk);
511 } else { 511 } else {
512 // Return to the invocation stub and return this error object. The 512 // Return to the invocation stub and return this error object. The
513 // C++ code which invoked this dart sequence can check and do the 513 // C++ code which invoked this dart sequence can check and do the
514 // appropriate thing. 514 // appropriate thing.
515 uword handler_pc = 0; 515 uword handler_pc = 0;
516 uword handler_sp = 0; 516 uword handler_sp = 0;
517 uword handler_fp = 0; 517 uword handler_fp = 0;
518 FindErrorHandler(&handler_pc, &handler_sp, &handler_fp); 518 FindErrorHandler(&handler_pc, &handler_sp, &handler_fp);
519 JumpToExceptionHandler(isolate, handler_pc, handler_sp, handler_fp, error, 519 JumpToExceptionHandler(isolate, handler_pc, handler_sp, handler_fp, error,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 667
668 // Throw JavascriptCompatibilityError exception. 668 // Throw JavascriptCompatibilityError exception.
669 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { 669 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) {
670 const Array& exc_args = Array::Handle(Array::New(1)); 670 const Array& exc_args = Array::Handle(Array::New(1));
671 const String& msg_str = String::Handle(String::New(msg)); 671 const String& msg_str = String::Handle(String::New(msg));
672 exc_args.SetAt(0, msg_str); 672 exc_args.SetAt(0, msg_str);
673 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); 673 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args);
674 } 674 }
675 675
676 } // namespace dart 676 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698