[wasm][fuzzer] Clear pending exception unconditionally

Pending exceptions were not cleared when the TurboFan result was not
compared to the Interpreter result, which happens when the result may be
affected by potential nondeterminism. With this CL we always clear
pending exceptions.

R=clemensh@chromium.org

Bug: chromium:782267
Change-Id: Ibe9b33c94810cccb6282c6c8dc49748fb79b07e4
Reviewed-on: https://chromium-review.googlesource.com/758272
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49265}
This commit is contained in:
Andreas Haas 2017-11-08 15:23:08 +01:00 committed by Commit Bot
parent 6003457c1d
commit 4a7c98e51c

View File

@ -31,9 +31,7 @@ int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size) {
i::Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
// Clear any pending exceptions from a prior run.
if (i_isolate->has_pending_exception()) {
i_isolate->clear_pending_exception();
}
i_isolate->clear_pending_exception();
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
@ -119,9 +117,7 @@ int WasmExecutionFuzzer::FuzzWasmModule(const uint8_t* data, size_t size,
i::Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
// Clear any pending exceptions from a prior run.
if (i_isolate->has_pending_exception()) {
i_isolate->clear_pending_exception();
}
i_isolate->clear_pending_exception();
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
@ -223,11 +219,13 @@ int WasmExecutionFuzzer::FuzzWasmModule(const uint8_t* data, size_t size,
// if the execution may have produced a NaN at some point.
if (!possible_nondeterminism) {
CHECK_EQ(expect_exception, i_isolate->has_pending_exception());
i_isolate->clear_pending_exception();
if (!expect_exception) CHECK_EQ(result_interpreter, result_turbofan);
}
// Clear any pending exceptions for the next run.
i_isolate->clear_pending_exception();
int32_t result_liftoff;
{
FlagScope<bool> liftoff(&FLAG_liftoff, true);
@ -244,11 +242,12 @@ int WasmExecutionFuzzer::FuzzWasmModule(const uint8_t* data, size_t size,
}
if (!possible_nondeterminism) {
CHECK_EQ(expect_exception, i_isolate->has_pending_exception());
i_isolate->clear_pending_exception();
if (!expect_exception) CHECK_EQ(result_interpreter, result_liftoff);
}
// Cleanup any pending exception.
i_isolate->clear_pending_exception();
return 0;
}