Reviewers: Yang,
Message:
PTAL
Description:
Clear pending exceptions occured in a script loaded by load().
BUG=chromium:444805
LOG=Y
Please review this at https://codereview.chromium.org/793333003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+26, -10 lines):
M src/d8.cc
A test/mjsunit/regress/regress-444805.js
A test/mjsunit/regress/regress-444805.js-script
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
132891e2b8a694919c0643118dea5fd8ef82b403..2ef7162878713a6c0385c4c5c0ed6a190facb87b
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -587,24 +587,24 @@ Handle<String> Shell::ReadFromStdin(Isolate* isolate)
{
void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Isolate* isolate = args.GetIsolate();
for (int i = 0; i < args.Length(); i++) {
- HandleScope handle_scope(args.GetIsolate());
+ HandleScope handle_scope(isolate);
String::Utf8Value file(args[i]);
if (*file == NULL) {
- Throw(args.GetIsolate(), "Error loading file");
+ Throw(isolate, "Error loading file");
return;
}
- Handle<String> source = ReadFile(args.GetIsolate(), *file);
+ Handle<String> source = ReadFile(isolate, *file);
if (source.IsEmpty()) {
- Throw(args.GetIsolate(), "Error loading file");
+ Throw(isolate, "Error loading file");
return;
}
- if (!ExecuteString(args.GetIsolate(),
- source,
- String::NewFromUtf8(args.GetIsolate(), *file),
- false,
- true)) {
- Throw(args.GetIsolate(), "Error executing file");
+ if (!ExecuteString(isolate, source, String::NewFromUtf8(isolate,
*file),
+ false, true)) {
+ // Exception is already reported, so clear it before throwing
another one.
+ reinterpret_cast<i::Isolate*>(isolate)->clear_pending_exception();
+ Throw(isolate, "Error executing file");
return;
}
}
Index: test/mjsunit/regress/regress-444805.js
diff --git a/test/mjsunit/regress/regress-444805.js
b/test/mjsunit/regress/regress-444805.js
new file mode 100644
index
0000000000000000000000000000000000000000..0b50dafcb3175960f9f5b5959472748977ebd32c
--- /dev/null
+++ b/test/mjsunit/regress/regress-444805.js
@@ -0,0 +1,5 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+load("test/mjsunit/regress/regress-444805.js-script");
Index: test/mjsunit/regress/regress-444805.js-script
diff --git a/test/mjsunit/regress/regress-444805.js-script
b/test/mjsunit/regress/regress-444805.js-script
new file mode 100644
index
0000000000000000000000000000000000000000..17b233b5613fcf1d71c8f7e77ab42d9f5a0bdcf1
--- /dev/null
+++ b/test/mjsunit/regress/regress-444805.js-script
@@ -0,0 +1,11 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+Error.prepareStackTrace = function(dummyObject, v8StackTrace)
+{
+ throw new Error('boom');
+};
+
+
+throw new Error('just error');
--
--
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/d/optout.