Reviewers: jochen,
Message:
This still needs a test. There's a Blink test in
https://codereview.chromium.org/273913002 for which I've verified this is a
fix.
But is there a way to write a multithreaded mjsunit test in V8?
Description:
Bail out of running microtasks if one throws, instead of crashing
This should only happen if the embedder has called V8::TerminateExecution.
BUG=371566
LOG=Y
Please review this at https://codereview.chromium.org/294943009/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+21, -15 lines):
M src/api.cc
M src/isolate.h
M src/isolate.cc
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
304d84ffcf872d6163a19f8a38ce9e7f8df8eaf3..84884be304f2388af10e9cd7778e673940f1356c
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -58,7 +58,7 @@
namespace v8 {
#define ON_BAILOUT(isolate, location, code) \
- if (IsExecutionTerminatingCheck(isolate)) { \
+ if (isolate->IsExecutionTerminating()) { \
code; \
UNREACHABLE(); \
}
@@ -192,16 +192,6 @@ bool V8::IsDead() {
}
-static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
- if (!isolate->IsInitialized()) return false;
- if (isolate->has_scheduled_exception()) {
- return isolate->scheduled_exception() ==
- isolate->heap()->termination_exception();
- }
- return false;
-}
-
-
// --- S t a t i c s ---
@@ -6478,7 +6468,7 @@ void V8::TerminateExecution(Isolate* isolate) {
bool V8::IsExecutionTerminating(Isolate* isolate) {
i::Isolate* i_isolate = isolate != NULL ?
reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current();
- return IsExecutionTerminatingCheck(i_isolate);
+ return i_isolate->IsExecutionTerminating();
}
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
f7605d8d21b346e85a78c557aca0b74d78cb624c..5bd2b69815b71f2e6d961e98d61e749fde2b1c32
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -810,6 +810,15 @@ Object* Isolate::TerminateExecution() {
}
+bool Isolate::IsExecutionTerminating() {
+ if (!IsInitialized()) return false;
+ if (has_scheduled_exception()) {
+ return scheduled_exception() == heap()->termination_exception();
+ }
+ return false;
+}
+
+
void Isolate::CancelTerminateExecution() {
if (try_catch_handler()) {
try_catch_handler()->has_terminated_ = false;
@@ -2281,9 +2290,15 @@ void Isolate::RunMicrotasks() {
for (int i = 0; i < num_tasks; i++) {
HandleScope scope(this);
Handle<JSFunction> microtask(JSFunction::cast(queue->get(i)), this);
- // TODO(adamk): This should ignore/clear exceptions instead of
Checking.
- Execution::Call(this, microtask, factory()->undefined_value(),
- 0, NULL).Check();
+ MaybeHandle<Object> result = Execution::Call(
+ this, microtask, factory()->undefined_value(), 0, NULL);
+ if (result.is_null()) {
+ // Microtasks should not throw unless the embedder has asked us to
+ // TerminateExecution.
+ ASSERT(IsExecutionTerminating());
+ handle_scope_implementer()->DecrementCallDepth();
+ return;
+ }
}
}
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
3a675106439881b854363a2275ecac145383cd77..4ab34db1e03d81cdbe5b9249f30f6c18d8677182
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -756,6 +756,7 @@ class Isolate {
// Out of resource exception helpers.
Object* StackOverflow();
Object* TerminateExecution();
+ bool IsExecutionTerminating();
void CancelTerminateExecution();
void InvokeApiInterruptCallback();
--
--
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.