Commit b9970708 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm] Reuse RefNull() node in WasmCompiler

Constant reloading of the null reference impacted some wasm-gc
benchmarks. This CL speeds some benchmarks by >5%.
Note: This solution is not ideal as it technically generates invalid
turbofan graphs. It is temporary until a proper optimization eliminating
excessive loads is implemented.

Change-Id: I7afa6fb8857f5dba3dde715bd30fe868ad06d92c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2704668
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72894}
parent b2f9fcd6
......@@ -538,9 +538,20 @@ Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects_and_control) {
}
Node* WasmGraphBuilder::RefNull() {
return LOAD_FULL_POINTER(
BuildLoadIsolateRoot(),
IsolateData::root_slot_offset(RootIndex::kNullValue));
// Technically speaking, this does not generate a valid graph since the effect
// of the last Load is not consumed.
// TODO(manoskouk): Remove this code once we implement Load elimination
// optimization for wasm.
if (!ref_null_node_.is_set()) {
Node* current_effect = effect();
Node* current_control = control();
SetEffectControl(mcgraph()->graph()->start());
ref_null_node_.set(LOAD_FULL_POINTER(
BuildLoadIsolateRoot(),
IsolateData::root_slot_offset(RootIndex::kNullValue)));
SetEffectControl(current_effect, current_control);
}
return ref_null_node_.get();
}
Node* WasmGraphBuilder::RefFunc(uint32_t function_index) {
......
......@@ -713,6 +713,7 @@ class WasmGraphBuilder {
WasmInstanceCacheNodes* instance_cache_ = nullptr;
SetOncePointer<Node> instance_node_;
SetOncePointer<Node> ref_null_node_;
SetOncePointer<Node> globals_start_;
SetOncePointer<Node> imported_mutable_globals_;
SetOncePointer<Node> stack_check_code_node_;
......
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