Commit 06212c9a authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm] Introduce dependency of JS/Wasm frame in wasm-compiler

In wasm-compiler, nodes that reference the Isolate and Instance should
depend on whether the current frame JS or Wasm. This was implemented
with mutable fields caching nodes in WasmGraphBuilder and its
subclasses, but was not done consistently.
This CL removes all mutability and replaces it with an additional field
isolate_ in WasmGraphBuilder, which is only set in the constructor of
the child class WasmWrapperGraphBuilder.

Additional changes:
- Remove three almost-unused utilities from WasmGraphAssembler.
- Reduce duplicate BuildImportCall with int index argument to the one
  with Node* index argument (the additional operations should be
  optimized away).

Bug: v8:11510
Change-Id: I2bb44a617210916edf671c238402727e04bdc38f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739976Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73444}
parent 839f5a64
......@@ -420,7 +420,7 @@ Reduction JSInliner::ReduceJSWasmCall(Node* node) {
BuildInlinedJSToWasmWrapper(
graph()->zone(), jsgraph(), wasm_call_params.signature(),
wasm_call_params.module(), source_positions_,
wasm_call_params.module(), isolate(), source_positions_,
StubCallMode::kCallBuiltinPointer, wasm::WasmFeatures::FromFlags(),
&js_wasm_call_data, continuation_frame_state);
......
This diff is collapsed.
......@@ -221,7 +221,8 @@ class WasmGraphBuilder {
V8_EXPORT_PRIVATE WasmGraphBuilder(
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt = nullptr);
compiler::SourcePositionTable* spt = nullptr)
: WasmGraphBuilder(env, zone, mcgraph, sig, spt, nullptr) {}
V8_EXPORT_PRIVATE ~WasmGraphBuilder();
......@@ -368,10 +369,6 @@ class WasmGraphBuilder {
wasm::WasmCodePosition position, wasm::ValueType type);
static void PrintDebugName(Node* node);
void set_instance_node(Node* instance_node) {
this->instance_node_ = instance_node;
}
Node* effect();
Node* control();
Node* SetEffect(Node* node);
......@@ -514,8 +511,15 @@ class WasmGraphBuilder {
void RemoveBytecodePositionDecorator();
protected:
V8_EXPORT_PRIVATE WasmGraphBuilder(wasm::CompilationEnv* env, Zone* zone,
MachineGraph* mcgraph,
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt,
Isolate* isolate);
Node* NoContextConstant();
Node* BuildLoadInstance();
Node* BuildLoadIsolateRoot();
// MemBuffer is only called with valid offsets (after bounds checking), so the
......@@ -731,11 +735,10 @@ class WasmGraphBuilder {
WasmInstanceCacheNodes* instance_cache_ = nullptr;
SetOncePointer<Node> instance_node_;
SetOncePointer<Node> stack_check_code_node_;
SetOncePointer<Node> isolate_root_node_;
SetOncePointer<const Operator> stack_check_call_operator_;
bool use_js_isolate_and_params() const { return isolate_ != nullptr; }
bool has_simd_ = false;
bool needs_stack_check_ = false;
const bool untrusted_code_mitigations_ = true;
......@@ -745,6 +748,7 @@ class WasmGraphBuilder {
compiler::WasmDecorator* decorator_ = nullptr;
compiler::SourcePositionTable* const source_position_table_ = nullptr;
Isolate* const isolate_;
std::unique_ptr<Int64LoweringSpecialCase> lowering_special_case_;
CallDescriptor* i32_atomic_wait_descriptor_ = nullptr;
......@@ -755,9 +759,10 @@ enum WasmCallKind { kWasmFunction, kWasmImportWrapper, kWasmCapiFunction };
V8_EXPORT_PRIVATE void BuildInlinedJSToWasmWrapper(
Zone* zone, MachineGraph* mcgraph, const wasm::FunctionSig* signature,
const wasm::WasmModule* module, compiler::SourcePositionTable* spt,
StubCallMode stub_mode, wasm::WasmFeatures features,
const JSWasmCallData* js_wasm_call_data, Node* frame_state);
const wasm::WasmModule* module, Isolate* isolate,
compiler::SourcePositionTable* spt, StubCallMode stub_mode,
wasm::WasmFeatures features, const JSWasmCallData* js_wasm_call_data,
Node* frame_state);
V8_EXPORT_PRIVATE CallDescriptor* GetWasmCallDescriptor(
Zone* zone, const wasm::FunctionSig* signature,
......
......@@ -123,8 +123,6 @@ class WasmGraphBuildingInterface {
decoder->zone(), SsaEnv::kReached, start, start, num_locals);
SetEnv(ssa_env);
// Initialize the instance parameter (index 0).
builder_->set_instance_node(builder_->Param(kWasmInstanceParameterIndex));
// Initialize local variables. Parameters are shifted by 1 because of the
// the instance parameter.
uint32_t index = 0;
......
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