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

Unified Diff: runtime/vm/exceptions.cc

Issue 2511573003: VM: Remove too strict assertion in rethrow. (Closed)
Patch Set: address comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc
index 4b73efd02026d37a0fefc1ab894238631bf9667d..db0d71024c035b5a7a612f799750706c28f8e0f1 100644
--- a/runtime/vm/exceptions.cc
+++ b/runtime/vm/exceptions.cc
@@ -381,12 +381,11 @@ static void ThrowExceptionHelper(Thread* thread,
Instance& stacktrace = Instance::Handle(zone);
bool handler_exists = false;
bool handler_needs_stacktrace = false;
+ // Find the exception handler and determine if the handler needs a
+ // stacktrace.
+ handler_exists = FindExceptionHandler(thread, &handler_pc, &handler_sp,
+ &handler_fp, &handler_needs_stacktrace);
if (use_preallocated_stacktrace) {
- stacktrace ^= isolate->object_store()->preallocated_stack_trace();
- PreallocatedStacktraceBuilder frame_builder(stacktrace);
- handler_exists =
- FindExceptionHandler(thread, &handler_pc, &handler_sp, &handler_fp,
- &handler_needs_stacktrace);
if (handler_pc == 0) {
// No Dart frame.
ASSERT(incoming_exception.raw() ==
@@ -396,37 +395,33 @@ static void ThrowExceptionHelper(Thread* thread,
thread->long_jump_base()->Jump(1, error);
UNREACHABLE();
}
+ stacktrace ^= isolate->object_store()->preallocated_stack_trace();
+ PreallocatedStacktraceBuilder frame_builder(stacktrace);
if (handler_needs_stacktrace) {
BuildStackTrace(&frame_builder);
}
} else {
- // Get stacktrace field of class Error. This is needed to determine whether
- // we have a subclass of Error which carries around its stack trace.
- const Field& stacktrace_field =
- Field::Handle(zone, LookupStacktraceField(exception));
-
- // Find the exception handler and determine if the handler needs a
- // stacktrace.
- handler_exists =
- FindExceptionHandler(thread, &handler_pc, &handler_sp, &handler_fp,
- &handler_needs_stacktrace);
if (!existing_stacktrace.IsNull()) {
// If we have an existing stack trace then this better be a rethrow. The
// reverse is not necessarily true (e.g. Dart_PropagateError can cause
// a rethrow being called without an existing stacktrace.)
ASSERT(is_rethrow);
- ASSERT(stacktrace_field.IsNull() ||
- (exception.GetField(stacktrace_field) != Object::null()));
stacktrace = existing_stacktrace.raw();
- } else if (!stacktrace_field.IsNull() || handler_needs_stacktrace) {
- // Collect the stacktrace if needed.
- ASSERT(existing_stacktrace.IsNull());
- stacktrace = Exceptions::CurrentStacktrace();
- // If we have an Error object, then set its stackTrace field only if it
- // not yet initialized.
- if (!stacktrace_field.IsNull() &&
- (exception.GetField(stacktrace_field) == Object::null())) {
- exception.SetField(stacktrace_field, stacktrace);
+ } else {
+ // Get stacktrace field of class Error to determine whether we have a
+ // subclass of Error which carries around its stack trace.
+ const Field& stacktrace_field =
+ Field::Handle(zone, LookupStacktraceField(exception));
+ if (!stacktrace_field.IsNull() || handler_needs_stacktrace) {
+ // Collect the stacktrace if needed.
+ ASSERT(existing_stacktrace.IsNull());
+ stacktrace = Exceptions::CurrentStacktrace();
+ // If we have an Error object, then set its stackTrace field only if it
+ // not yet initialized.
+ if (!stacktrace_field.IsNull() &&
+ (exception.GetField(stacktrace_field) == Object::null())) {
+ exception.SetField(stacktrace_field, stacktrace);
+ }
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698