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

Unified Diff: runtime/vm/exceptions.cc

Issue 342473006: Don't add the catch frame at a rethrow to the stacktrace. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | 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 cbf89df3a4c4b2dd329df6d6e52c660dfc2a02b1..6d27fe1f33a2840424d29f33ecc9c764aa292ac4 100644
--- a/runtime/vm/exceptions.cc
+++ b/runtime/vm/exceptions.cc
@@ -375,7 +375,8 @@ RawStacktrace* Exceptions::CurrentStacktrace() {
static void ThrowExceptionHelper(Isolate* isolate,
const Instance& incoming_exception,
- const Instance& existing_stacktrace) {
+ const Instance& existing_stacktrace,
+ const bool is_rethrow) {
bool use_preallocated_stacktrace = false;
Instance& exception = Instance::Handle(isolate, incoming_exception.raw());
if (exception.IsNull()) {
@@ -437,9 +438,13 @@ static void ThrowExceptionHelper(Isolate* isolate,
if (existing_stacktrace.IsNull()) {
stacktrace = Stacktrace::New(code_array, pc_offset_array);
} else {
+ ASSERT(is_rethrow);
stacktrace ^= existing_stacktrace.raw();
if (pc_offset_array.Length() != 0) {
- stacktrace.Append(code_array, pc_offset_array);
+ // Skip the first frame during a rethrow. This is the catch clause with
+ // the rethrow statement, which is not part of the original trace a
+ // rethrow is supposed to preserve.
+ stacktrace.Append(code_array, pc_offset_array, 1);
}
// Since we are re throwing and appending to the existing stack trace
// we clear out the catch trace collected in the existing stack trace
@@ -574,7 +579,7 @@ void Exceptions::CreateAndThrowTypeError(intptr_t location,
void Exceptions::Throw(Isolate* isolate, const Instance& exception) {
isolate->debugger()->SignalExceptionThrown(exception);
// Null object is a valid exception object.
- ThrowExceptionHelper(isolate, exception, Instance::Handle(isolate));
+ ThrowExceptionHelper(isolate, exception, Instance::Handle(isolate), false);
}
@@ -582,7 +587,7 @@ void Exceptions::ReThrow(Isolate* isolate,
const Instance& exception,
const Instance& stacktrace) {
// Null object is a valid exception object.
- ThrowExceptionHelper(isolate, exception, stacktrace);
+ ThrowExceptionHelper(isolate, exception, stacktrace, true);
}
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698