Reviewers: Sven Panne,
Message:
This fixes a problem caused by r12926. It turns out that uncaught exceptions
have to be attached as such to the message object passed to the embedder, as
opposed to turned into a string. Therefore, we turn the uncaught exception
to a
string at the point where it is needed (in FormatMessage).
Description:
Fix handling of uncaught exceptions.
BUG=
Please review this at https://chromiumcodereview.appspot.com/11360193/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/isolate.cc
M src/messages.js
A + test/message/stacktrace.js
A + test/message/stacktrace.out
M test/mjsunit/mjsunit.js
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
eec5a54d737e902caddfcfe5679dcb33656c8dd1..4768d99c402600acb77528cc4487b19084aa25fa
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1228,14 +1228,7 @@ void Isolate::DoThrow(Object* exception,
MessageLocation* location) {
stack_trace_for_uncaught_exceptions_options_);
}
}
- // Stringify custom error objects for the message object.
- if (exception_handle->IsJSObject()
&& !IsErrorObject(exception_handle)) {
- bool failed = false;
- exception_handle = Execution::ToString(exception_handle, &failed);
- if (failed) {
- exception_handle = factory()->LookupAsciiSymbol("exception");
- }
- }
+
Handle<Object> message_obj = MessageHandler::MakeMessageObject(
"uncaught_exception",
location,
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index
30f6682adab6c5c2cd91a96cbed1a07f9aca8604..1e3152373ccc2960c1adef7b42e5289edded378b
100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -276,6 +276,8 @@ function MakeGenericError(constructor, type, args) {
// Helper functions; called from the runtime system.
function FormatMessage(type, args) {
var format = kMessages[type];
+ // If an exception was not caught, we turn it into a string for the
message.
+ if (type == "uncaught_exception") args[0] = ToDetailString(args[0]);
if (!format) return "<unknown message " + type + ">";
return FormatString(format, args);
}
Index: test/message/stacktrace.js
diff --git a/test/mjsunit/regress/regress-2373.js
b/test/message/stacktrace.js
similarity index 95%
copy from test/mjsunit/regress/regress-2373.js
copy to test/message/stacktrace.js
index
16a87ece6f57aee42d77171e8087db412610b0a3..9844dc101f1621b7905c0f0ce18d8e6597708c9a
100644
--- a/test/mjsunit/regress/regress-2373.js
+++ b/test/message/stacktrace.js
@@ -25,5 +25,4 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-var o = JSON.parse('{"a":2600753951}');
-assertEquals(2600753951, o.a);
+(function f() { throw new Error(); })();
Index: test/message/stacktrace.out
diff --git a/tools/testrunner/objects/__init__.py
b/test/message/stacktrace.out
similarity index 91%
copy from tools/testrunner/objects/__init__.py
copy to test/message/stacktrace.out
index
202a262709c95ba356e9e1ef6aa2f5256690a24a..3020e74f776892796415249498fe4a5af405a01e
100644
--- a/tools/testrunner/objects/__init__.py
+++ b/test/message/stacktrace.out
@@ -24,3 +24,11 @@
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*%(basename)s:28: Error
+(function f() { throw new Error(); })();
+ ^
+Error
+ at f (*%(basename)s:28:23)
+ at *%(basename)s:28:38
+
Index: test/mjsunit/mjsunit.js
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index
25d7c004326ce3df03ebe83edb2f0becd5336bba..2c382201c4b19c0381c745f72d497285aea860c7
100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -39,6 +39,7 @@ function MjsUnitAssertionError(message) {
MjsUnitAssertionError.prototype.toString = function () {
+ print("abc");
return this.message;
};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev