Commit 5824c72d authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Delete all compilation units even after compilation errors

FinishCompilationUnits used the assumption that FinishCompilationUnit
only return null if there is no compilation unit left to be finished.
This assumption was wrong though, because also a compilation error can
cause the result to be null. Therefore I switched to use the function
index as a new indicator.

BUG=chromium:709174

Change-Id: I3e9689fd71b8364422e1c74404921df2799191aa
Reviewed-on: https://chromium-review.googlesource.com/471347
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44468}
parent 44984194
......@@ -396,19 +396,18 @@ class CompilationHelper {
void FinishCompilationUnits(std::vector<Handle<Code>>& results,
ErrorThrower* thrower) {
while (true) {
int func_index = 0;
MaybeHandle<Code> result = FinishCompilationUnit(thrower, &func_index);
if (result.is_null()) break;
results[func_index] = result.ToHandleChecked();
int func_index = -1;
Handle<Code> result = FinishCompilationUnit(thrower, &func_index);
if (func_index < 0) break;
results[func_index] = result;
}
}
MaybeHandle<Code> FinishCompilationUnit(ErrorThrower* thrower,
int* func_index) {
Handle<Code> FinishCompilationUnit(ErrorThrower* thrower, int* func_index) {
compiler::WasmCompilationUnit* unit = nullptr;
{
base::LockGuard<base::Mutex> guard(&result_mutex_);
if (executed_units_.empty()) return {};
if (executed_units_.empty()) return Handle<Code>::null();
unit = executed_units_.front();
executed_units_.pop();
}
......@@ -2892,16 +2891,15 @@ class AsyncCompileJob {
HandleScope scope(isolate_);
if (failed_) return true; // already failed
int func_index = 0;
int func_index = -1;
ErrorThrower thrower(isolate_, nullptr);
MaybeHandle<Code> result =
helper_->FinishCompilationUnit(&thrower, &func_index);
Handle<Code> result = helper_->FinishCompilationUnit(&thrower, &func_index);
if (thrower.error()) {
RejectPromise(isolate_, context_, &thrower, module_promise_);
failed_ = true;
} else {
code_table_->set(func_index + module_->num_imported_functions,
*(result.ToHandleChecked()));
DCHECK(func_index >= 0);
code_table_->set(func_index + module_->num_imported_functions, *(result));
}
if (failed_ || --outstanding_units_ == 0) {
// All compilation units are done. We still need to wait for the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment