Commit 8b14d187 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove TurbofanWasmCompilationUnit::ok_ field

This field is redundant in that {ok_ == true} equals
{wasm_code_ != nullptr}. Thus remove it, and simplify some logic.

R=ahaas@chromium.org
CC=gdeepti@chromium.org

Bug: v8:8238
Change-Id: I3e3cfcc3a06c945d836c1a8a388bec54e1af12ea
Reviewed-on: https://chromium-review.googlesource.com/c/1290791Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56803}
parent 845ac4b6
......@@ -5209,8 +5209,6 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation(
double decode_ms = 0;
size_t node_count = 0;
// Scope for the {graph_zone}.
{
Zone graph_zone(wasm_unit_->wasm_engine_->allocator(), ZONE_NAME);
MachineGraph* mcgraph = new (&graph_zone)
MachineGraph(new (&graph_zone) Graph(&graph_zone),
......@@ -5241,10 +5239,7 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation(
SourcePositionTable* source_positions =
BuildGraphForWasmFunction(detected, &decode_ms, mcgraph, node_origins);
if (graph_construction_result_.failed()) {
ok_ = false;
return;
}
if (graph_construction_result_.failed()) return;
if (node_origins) {
node_origins->AddDecorator();
......@@ -5264,14 +5259,13 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation(
GetI32WasmCallDescriptor(&compilation_zone, call_descriptor);
}
std::unique_ptr<OptimizedCompilationJob> job(
Pipeline::NewWasmCompilationJob(
std::unique_ptr<OptimizedCompilationJob> job(Pipeline::NewWasmCompilationJob(
&info, wasm_unit_->wasm_engine_, mcgraph, call_descriptor,
source_positions, node_origins, wasm_unit_->func_body_,
const_cast<wasm::WasmModule*>(wasm_unit_->env_->module),
wasm_unit_->native_module_, wasm_unit_->func_index_,
wasm_unit_->env_->module->origin));
ok_ = job->ExecuteJob() == CompilationJob::SUCCEEDED;
bool succeeded = job->ExecuteJob() == CompilationJob::SUCCEEDED;
// TODO(bradnelson): Improve histogram handling of size_t.
wasm_unit_->counters_->wasm_compile_function_peak_memory_bytes()->AddSample(
static_cast<int>(mcgraph->graph()->zone()->allocation_size()));
......@@ -5285,20 +5279,22 @@ void TurbofanWasmCompilationUnit::ExecuteCompilation(
wasm_unit_->func_body_.start),
decode_ms, node_count, pipeline_ms);
}
if (ok_) wasm_code_ = info.wasm_code();
if (succeeded) {
wasm_code_ = info.wasm_code();
wasm_unit_->native_module()->PublishCode(wasm_code_);
}
if (ok_) wasm_unit_->native_module()->PublishCode(wasm_code_);
}
wasm::WasmCode* TurbofanWasmCompilationUnit::FinishCompilation(
wasm::ErrorThrower* thrower) {
if (!ok_) {
DCHECK_IMPLIES(graph_construction_result_.failed(), wasm_code_ == nullptr);
if (wasm_code_ != nullptr) return wasm_code_;
if (graph_construction_result_.failed()) {
// Add the function as another context for the exception. This is
// user-visible, so use official format.
EmbeddedVector<char, 128> message;
wasm::ModuleWireBytes wire_bytes(
wasm_unit_->native_module()->wire_bytes());
wasm::ModuleWireBytes wire_bytes(wasm_unit_->native_module()->wire_bytes());
wasm::WireBytesRef name_ref =
wasm_unit_->native_module()->module()->LookupFunctionName(
wire_bytes, wasm_unit_->func_index_);
......@@ -5307,16 +5303,13 @@ wasm::WasmCode* TurbofanWasmCompilationUnit::FinishCompilation(
SNPrintF(message, "Compiling wasm function \"%.*s\" failed",
name.length(), name.start());
} else {
SNPrintF(message,
"Compiling wasm function \"wasm-function[%d]\" failed",
SNPrintF(message, "Compiling wasm function \"wasm-function[%d]\" failed",
wasm_unit_->func_index_);
}
thrower->CompileFailed(message.start(), graph_construction_result_);
}
return nullptr;
}
return wasm_code_;
}
namespace {
......
......@@ -61,7 +61,6 @@ class TurbofanWasmCompilationUnit {
private:
wasm::WasmCompilationUnit* const wasm_unit_;
bool ok_ = true;
wasm::WasmCode* wasm_code_ = nullptr;
wasm::Result<wasm::DecodeStruct*> graph_construction_result_;
......
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