Reviewers: ,

Message:
This change removes the need for this hack in Node:

https://github.com/joyent/node/blob/master/src/node_script.cc#L414

As a result of this, a few Node bugs in the vm module should be fixed:

https://github.com/joyent/node/issues/1310
https://github.com/joyent/node/issues/3452

https://github.com/joyent/node/pull/3570 (would be closed)

I tried to do this without needing the restoring_message_ flag, but simply
checking if pending_message_obj_->IsTheHole() breaks throws in finally clauses
since those *do* want to overwrite the current exception.

Added a test, verified it fixes it, and also verified it fixes the Node issues.

Description:
Fix TryCatch.ReThrow() to not clobber Message.

TryCatch.ReThrow() sets a flag which, in the TryCatch destructor,
throws the caught exception using the public v8::ThrowException().
When the TryCatch catches the exception, the pending Message
object is saved internally, but the MessageLocation information is
not.  When the TryCatch is destructed, the Message object is not
re-set in the engine, so the Isolate::DoThrow() that the ReThrow()
triggers winds up creating a new Message object.  This alters the
reported location of the re-thrown exception to be the location of
the TryCatch.

This patch modifies the TryCatch to store the MessageLocation data
as well as the Message object and adds a new Isolate::RestoreMessage()
call which the destructor uses to re-set the Message object and
MessageLocation data within the Isolate TLS prior to calling the
public v8::ThrowException().  Since Isolate::RestoreMessage() is
always followed by a Isolate::DoThrow(), a restore_message_ flag is
set and Isolate::DoThrow() does not re-create the Message if set.

TEST=cctest/test-api/TryCatchNestedSyntax

Please review this at https://codereview.chromium.org/15669003/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     include/v8.h
  M     src/api.cc
  M     src/isolate.h
  M     src/isolate.cc
  M     test/cctest/test-api.cc


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to