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

Unified Diff: src/api.cc

Issue 15669003: Fix TryCatch.ReThrow() to not clobber Message. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 7 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 | « include/v8.h ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 14909)
+++ src/api.cc (working copy)
@@ -2052,7 +2052,10 @@
: isolate_(i::Isolate::Current()),
next_(isolate_->try_catch_handler_address()),
exception_(isolate_->heap()->the_hole_value()),
- message_(i::Smi::FromInt(0)),
+ message_obj_(i::Smi::FromInt(0)),
+ message_script_(i::Smi::FromInt(0)),
+ message_start_pos_(0),
+ message_end_pos_(0),
is_verbose_(false),
can_continue_(true),
capture_message_(true),
@@ -2068,6 +2071,17 @@
v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_));
v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception());
isolate_->UnregisterTryCatchHandler(this);
+ if (HasCaught() && capture_message_) {
+ // If an exception was caught and rethrow_ is indicated, the saved
+ // message, script, and location need to be restored to Isolate TLS
+ // so that DoThrow() does not overwrite the values from the original
+ // exception with new ones computed at the current location.
+ i::Object* message = reinterpret_cast<i::Object*>(message_obj_);
+ i::Script* script = message_script_ ?
+ reinterpret_cast<i::Script*>(message_script_) : NULL;
+ isolate_->RestoreMessage(message, script,
+ message_start_pos_, message_end_pos_);
+ }
v8::ThrowException(exc);
} else {
isolate_->UnregisterTryCatchHandler(this);
@@ -2129,8 +2143,8 @@
v8::Local<v8::Message> v8::TryCatch::Message() const {
ASSERT(isolate_ == i::Isolate::Current());
- if (HasCaught() && message_ != i::Smi::FromInt(0)) {
- i::Object* message = reinterpret_cast<i::Object*>(message_);
+ if (HasCaught() && message_obj_ != i::Smi::FromInt(0)) {
+ i::Object* message = reinterpret_cast<i::Object*>(message_obj_);
return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_));
} else {
return v8::Local<v8::Message>();
@@ -2141,7 +2155,10 @@
void v8::TryCatch::Reset() {
ASSERT(isolate_ == i::Isolate::Current());
exception_ = isolate_->heap()->the_hole_value();
- message_ = i::Smi::FromInt(0);
+ message_obj_ = i::Smi::FromInt(0);
+ message_script_ = i::Smi::FromInt(0);
+ message_start_pos_ = 0;
+ message_end_pos_ = 0;
}
« no previous file with comments | « include/v8.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698