[wasm] Move i64<->BigInt CallDescriptors to WasmEngine
This stores the CallDescriptors used for i64 <-> BigInt conversion builtins as process-globals on the WasmEngine, instead of creating them as temporaries whenever they're needed. The primary purpose of this change is to simplify the interface to the Int64Lowering by eliminating its "special case" parameter, in preparation for moving that lowering to a different point in the compilation pipeline. A minor secondary benefit is that this will save a little bit of (repeated) Zone memory usage. Bonus change: drop the Int64Lowering from 64-bit builds, where it isn't used, but was compiled in up to now. This saves ~17 KiB on Android-arm64 builds. Change-Id: Ib35d2e0f772110652eb05abd4c42d848108164b9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4110898 Auto-Submit: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Maya Lekova <mslekova@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Cr-Commit-Position: refs/heads/main@{#84884}
This commit is contained in:
parent
e073775f8e
commit
2427a3bad1
@ -2955,6 +2955,8 @@ filegroup(
|
||||
":is_v8_enable_webassembly": [
|
||||
"src/compiler/int64-lowering.cc",
|
||||
"src/compiler/int64-lowering.h",
|
||||
"src/compiler/wasm-call-descriptors.cc",
|
||||
"src/compiler/wasm-call-descriptors.h",
|
||||
"src/compiler/wasm-compiler-definitions.h",
|
||||
"src/compiler/wasm-compiler.cc",
|
||||
"src/compiler/wasm-compiler.h",
|
||||
|
2
BUILD.gn
2
BUILD.gn
@ -3669,6 +3669,7 @@ v8_header_set("v8_internal_headers") {
|
||||
"src/asmjs/asm-scanner.h",
|
||||
"src/asmjs/asm-types.h",
|
||||
"src/compiler/int64-lowering.h",
|
||||
"src/compiler/wasm-call-descriptors.h",
|
||||
"src/compiler/wasm-compiler-definitions.h",
|
||||
"src/compiler/wasm-compiler.h",
|
||||
"src/compiler/wasm-escape-analysis.h",
|
||||
@ -4244,6 +4245,7 @@ v8_compiler_sources = [
|
||||
if (v8_enable_webassembly) {
|
||||
v8_compiler_sources += [
|
||||
"src/compiler/int64-lowering.cc",
|
||||
"src/compiler/wasm-call-descriptors.cc",
|
||||
"src/compiler/wasm-compiler.cc",
|
||||
"src/compiler/wasm-escape-analysis.cc",
|
||||
"src/compiler/wasm-gc-lowering.cc",
|
||||
|
@ -13,29 +13,31 @@
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/wasm-call-descriptors.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
// TODO(wasm): Remove this include.
|
||||
#include "src/wasm/wasm-linkage.h"
|
||||
#include "src/wasm/wasm-subtyping.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
Int64Lowering::Int64Lowering(
|
||||
Graph* graph, MachineOperatorBuilder* machine,
|
||||
CommonOperatorBuilder* common, SimplifiedOperatorBuilder* simplified,
|
||||
Zone* zone, const wasm::WasmModule* module,
|
||||
Signature<MachineRepresentation>* signature,
|
||||
std::unique_ptr<Int64LoweringSpecialCase> special_case)
|
||||
Int64Lowering::Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
|
||||
CommonOperatorBuilder* common,
|
||||
SimplifiedOperatorBuilder* simplified, Zone* zone,
|
||||
const wasm::WasmModule* module,
|
||||
Signature<MachineRepresentation>* signature)
|
||||
: graph_(graph),
|
||||
machine_(machine),
|
||||
common_(common),
|
||||
simplified_(simplified),
|
||||
zone_(zone),
|
||||
signature_(signature),
|
||||
special_case_(std::move(special_case)),
|
||||
state_(graph->NodeCount(), State::kUnvisited),
|
||||
stack_(zone),
|
||||
replacements_(nullptr),
|
||||
@ -49,9 +51,6 @@ Int64Lowering::Int64Lowering(
|
||||
}
|
||||
|
||||
void Int64Lowering::LowerGraph() {
|
||||
if (!machine()->Is32()) {
|
||||
return;
|
||||
}
|
||||
stack_.push_back({graph()->end(), 0});
|
||||
state_[graph()->end()->id()] = State::kOnStack;
|
||||
|
||||
@ -1089,12 +1088,10 @@ bool Int64Lowering::DefaultLowering(Node* node, bool low_word_only) {
|
||||
|
||||
const CallDescriptor* Int64Lowering::LowerCallDescriptor(
|
||||
const CallDescriptor* call_descriptor) {
|
||||
if (special_case_) {
|
||||
auto replacement = special_case_->replacements.find(call_descriptor);
|
||||
if (replacement != special_case_->replacements.end()) {
|
||||
return replacement->second;
|
||||
}
|
||||
}
|
||||
CallDescriptor* maybe_special_replacement =
|
||||
wasm::GetWasmEngine()->call_descriptors()->GetLoweredCallDescriptor(
|
||||
call_descriptor);
|
||||
if (maybe_special_replacement) return maybe_special_replacement;
|
||||
return GetI32WasmCallDescriptor(zone(), call_descriptor);
|
||||
}
|
||||
|
||||
@ -1176,3 +1173,5 @@ void Int64Lowering::LowerMemoryBaseAndIndex(Node* node) {
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
|
@ -21,21 +21,26 @@ class Signature;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
// Struct for CallDescriptors that need special lowering.
|
||||
struct V8_EXPORT_PRIVATE Int64LoweringSpecialCase {
|
||||
// Map from CallDescriptors that should be replaced, to the replacement
|
||||
// CallDescriptors.
|
||||
std::unordered_map<const CallDescriptor*, const CallDescriptor*> replacements;
|
||||
#if !V8_TARGET_ARCH_32_BIT
|
||||
class Int64Lowering {
|
||||
public:
|
||||
Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
|
||||
CommonOperatorBuilder* common,
|
||||
SimplifiedOperatorBuilder* simplified_, Zone* zone,
|
||||
const wasm::WasmModule* module,
|
||||
Signature<MachineRepresentation>* signature) {}
|
||||
|
||||
void LowerGraph() {}
|
||||
};
|
||||
#else
|
||||
|
||||
class V8_EXPORT_PRIVATE Int64Lowering {
|
||||
public:
|
||||
Int64Lowering(
|
||||
Graph* graph, MachineOperatorBuilder* machine,
|
||||
CommonOperatorBuilder* common, SimplifiedOperatorBuilder* simplified_,
|
||||
Zone* zone, const wasm::WasmModule* module,
|
||||
Signature<MachineRepresentation>* signature,
|
||||
std::unique_ptr<Int64LoweringSpecialCase> special_case = nullptr);
|
||||
Int64Lowering(Graph* graph, MachineOperatorBuilder* machine,
|
||||
CommonOperatorBuilder* common,
|
||||
SimplifiedOperatorBuilder* simplified_, Zone* zone,
|
||||
const wasm::WasmModule* module,
|
||||
Signature<MachineRepresentation>* signature);
|
||||
|
||||
void LowerGraph();
|
||||
|
||||
@ -95,7 +100,6 @@ class V8_EXPORT_PRIVATE Int64Lowering {
|
||||
SimplifiedOperatorBuilder* simplified_;
|
||||
Zone* zone_;
|
||||
Signature<MachineRepresentation>* signature_;
|
||||
std::unique_ptr<Int64LoweringSpecialCase> special_case_;
|
||||
std::vector<State> state_;
|
||||
ZoneDeque<NodeState> stack_;
|
||||
Replacement* replacements_;
|
||||
@ -105,6 +109,8 @@ class V8_EXPORT_PRIVATE Int64Lowering {
|
||||
Type float64_type_;
|
||||
};
|
||||
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -415,8 +415,7 @@ Reduction JSInliner::ReduceJSWasmCall(Node* node) {
|
||||
BuildInlinedJSToWasmWrapper(
|
||||
graph()->zone(), jsgraph(), wasm_call_params.signature(),
|
||||
wasm_call_params.module(), isolate(), source_positions_,
|
||||
StubCallMode::kCallBuiltinPointer, wasm::WasmFeatures::FromFlags(),
|
||||
continuation_frame_state);
|
||||
wasm::WasmFeatures::FromFlags(), continuation_frame_state);
|
||||
|
||||
// Extract the inlinee start/end nodes.
|
||||
start_node = graph()->start();
|
||||
|
57
src/compiler/wasm-call-descriptors.cc
Normal file
57
src/compiler/wasm-call-descriptors.cc
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright 2022 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/compiler/wasm-call-descriptors.h"
|
||||
|
||||
#include "src/common/globals.h"
|
||||
#include "src/compiler/wasm-graph-assembler.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
namespace v8::internal::compiler {
|
||||
|
||||
WasmCallDescriptors::WasmCallDescriptors(AccountingAllocator* allocator)
|
||||
: zone_(new Zone(allocator, "wasm_call_descriptors")) {
|
||||
for (int i = 0; i < kNumCallModes; i++) {
|
||||
i64_to_bigint_descriptors_[i] = compiler::GetBuiltinCallDescriptor(
|
||||
Builtin::kI64ToBigInt, zone_.get(), static_cast<StubCallMode>(i));
|
||||
bigint_to_i64_descriptors_[i] = compiler::GetBuiltinCallDescriptor(
|
||||
Builtin::kBigIntToI64, zone_.get(), static_cast<StubCallMode>(i));
|
||||
bigint_to_i64_descriptor_with_framestate_ =
|
||||
compiler::GetBuiltinCallDescriptor(Builtin::kBigIntToI64, zone_.get(),
|
||||
StubCallMode::kCallBuiltinPointer,
|
||||
true);
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
i32pair_to_bigint_descriptors_[i] = compiler::GetBuiltinCallDescriptor(
|
||||
Builtin::kI32PairToBigInt, zone_.get(), static_cast<StubCallMode>(i));
|
||||
bigint_to_i32pair_descriptors_[i] = compiler::GetBuiltinCallDescriptor(
|
||||
Builtin::kBigIntToI32Pair, zone_.get(), static_cast<StubCallMode>(i));
|
||||
bigint_to_i32pair_descriptor_with_framestate_ =
|
||||
compiler::GetBuiltinCallDescriptor(
|
||||
Builtin::kBigIntToI32Pair, zone_.get(),
|
||||
StubCallMode::kCallBuiltinPointer, true);
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
}
|
||||
}
|
||||
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
compiler::CallDescriptor* WasmCallDescriptors::GetLoweredCallDescriptor(
|
||||
const compiler::CallDescriptor* original) {
|
||||
// As long as we only have six candidates, linear search is fine.
|
||||
// If we ever support more cases, we could use a hash map or something.
|
||||
for (int i = 0; i < kNumCallModes; i++) {
|
||||
if (original == i64_to_bigint_descriptors_[i]) {
|
||||
return i32pair_to_bigint_descriptors_[i];
|
||||
}
|
||||
if (original == bigint_to_i64_descriptors_[i]) {
|
||||
return bigint_to_i32pair_descriptors_[i];
|
||||
}
|
||||
}
|
||||
if (original == bigint_to_i64_descriptor_with_framestate_) {
|
||||
return bigint_to_i32pair_descriptor_with_framestate_;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
|
||||
} // namespace v8::internal::compiler
|
67
src/compiler/wasm-call-descriptors.h
Normal file
67
src/compiler/wasm-call-descriptors.h
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright 2022 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#if !V8_ENABLE_WEBASSEMBLY
|
||||
#error This header should only be included if WebAssembly is enabled.
|
||||
#endif // !V8_ENABLE_WEBASSEMBLY
|
||||
|
||||
#ifndef V8_COMPILER_WASM_CALL_DESCRIPTORS_H_
|
||||
#define V8_COMPILER_WASM_CALL_DESCRIPTORS_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/common/globals.h"
|
||||
|
||||
namespace v8::internal {
|
||||
|
||||
class AccountingAllocator;
|
||||
class Zone;
|
||||
|
||||
namespace compiler {
|
||||
class CallDescriptor;
|
||||
|
||||
class WasmCallDescriptors {
|
||||
public:
|
||||
explicit WasmCallDescriptors(AccountingAllocator* allocator);
|
||||
|
||||
compiler::CallDescriptor* GetI64ToBigIntDescriptor(StubCallMode mode) {
|
||||
return i64_to_bigint_descriptors_[static_cast<size_t>(mode)];
|
||||
}
|
||||
compiler::CallDescriptor* GetBigIntToI64Descriptor(StubCallMode mode,
|
||||
bool needs_frame_state) {
|
||||
if (needs_frame_state) {
|
||||
DCHECK_EQ(mode, StubCallMode::kCallBuiltinPointer);
|
||||
return bigint_to_i64_descriptor_with_framestate_;
|
||||
}
|
||||
return bigint_to_i64_descriptors_[static_cast<size_t>(mode)];
|
||||
}
|
||||
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
V8_EXPORT_PRIVATE compiler::CallDescriptor* GetLoweredCallDescriptor(
|
||||
const compiler::CallDescriptor* original);
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
|
||||
private:
|
||||
static_assert(static_cast<int>(StubCallMode::kCallCodeObject) == 0);
|
||||
static_assert(static_cast<int>(StubCallMode::kCallWasmRuntimeStub) == 1);
|
||||
static_assert(static_cast<int>(StubCallMode::kCallBuiltinPointer) == 2);
|
||||
static constexpr int kNumCallModes = 3;
|
||||
|
||||
std::unique_ptr<Zone> zone_;
|
||||
|
||||
compiler::CallDescriptor* i64_to_bigint_descriptors_[kNumCallModes];
|
||||
compiler::CallDescriptor* bigint_to_i64_descriptors_[kNumCallModes];
|
||||
compiler::CallDescriptor* bigint_to_i64_descriptor_with_framestate_;
|
||||
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
compiler::CallDescriptor* i32pair_to_bigint_descriptors_[kNumCallModes];
|
||||
compiler::CallDescriptor* bigint_to_i32pair_descriptors_[kNumCallModes];
|
||||
compiler::CallDescriptor* bigint_to_i32pair_descriptor_with_framestate_;
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
};
|
||||
|
||||
} // namespace compiler
|
||||
} // namespace v8::internal
|
||||
|
||||
#endif // V8_COMPILER_WASM_CALL_DESCRIPTORS_H_
|
@ -31,6 +31,7 @@
|
||||
#include "src/compiler/node-origin-table.h"
|
||||
#include "src/compiler/node-properties.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/wasm-call-descriptors.h"
|
||||
#include "src/compiler/wasm-compiler-definitions.h"
|
||||
#include "src/compiler/wasm-graph-assembler.h"
|
||||
#include "src/execution/simulator-base.h"
|
||||
@ -3975,20 +3976,11 @@ Signature<MachineRepresentation>* CreateMachineSignature(
|
||||
|
||||
} // namespace
|
||||
|
||||
void WasmGraphBuilder::AddInt64LoweringReplacement(
|
||||
CallDescriptor* original, CallDescriptor* replacement) {
|
||||
if (!lowering_special_case_) {
|
||||
lowering_special_case_ = std::make_unique<Int64LoweringSpecialCase>();
|
||||
}
|
||||
lowering_special_case_->replacements.insert({original, replacement});
|
||||
}
|
||||
|
||||
void WasmGraphBuilder::LowerInt64(Signature<MachineRepresentation>* sig) {
|
||||
if (mcgraph()->machine()->Is64()) return;
|
||||
Int64Lowering r(mcgraph()->graph(), mcgraph()->machine(), mcgraph()->common(),
|
||||
gasm_->simplified(), mcgraph()->zone(),
|
||||
env_ != nullptr ? env_->module : nullptr, sig,
|
||||
std::move(lowering_special_case_));
|
||||
env_ != nullptr ? env_->module : nullptr, sig);
|
||||
r.LowerGraph();
|
||||
}
|
||||
|
||||
@ -3996,23 +3988,6 @@ void WasmGraphBuilder::LowerInt64(CallOrigin origin) {
|
||||
LowerInt64(CreateMachineSignature(mcgraph()->zone(), sig_, origin));
|
||||
}
|
||||
|
||||
CallDescriptor* WasmGraphBuilder::GetI64ToBigIntCallDescriptor(
|
||||
StubCallMode stub_mode) {
|
||||
CallDescriptor** i64_to_bigint_descriptor =
|
||||
stub_mode == StubCallMode::kCallCodeObject
|
||||
? &i64_to_bigint_stub_descriptor_
|
||||
: &i64_to_bigint_builtin_descriptor_;
|
||||
if (*i64_to_bigint_descriptor) return *i64_to_bigint_descriptor;
|
||||
|
||||
*i64_to_bigint_descriptor =
|
||||
GetBuiltinCallDescriptor(Builtin::kI64ToBigInt, zone_, stub_mode);
|
||||
|
||||
AddInt64LoweringReplacement(
|
||||
*i64_to_bigint_descriptor,
|
||||
GetBuiltinCallDescriptor(Builtin::kI32PairToBigInt, zone_, stub_mode));
|
||||
return *i64_to_bigint_descriptor;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::BuildChangeInt64ToBigInt(Node* input,
|
||||
StubCallMode stub_mode) {
|
||||
Node* target;
|
||||
@ -4032,7 +4007,10 @@ Node* WasmGraphBuilder::BuildChangeInt64ToBigInt(Node* input,
|
||||
wasm::WasmCode::kI32PairToBigInt, RelocInfo::WASM_STUB_CALL)
|
||||
: gasm_->GetBuiltinPointerTarget(Builtin::kI32PairToBigInt);
|
||||
}
|
||||
return gasm_->Call(GetI64ToBigIntCallDescriptor(stub_mode), target, input);
|
||||
CallDescriptor* descriptor =
|
||||
wasm::GetWasmEngine()->call_descriptors()->GetI64ToBigIntDescriptor(
|
||||
stub_mode);
|
||||
return gasm_->Call(descriptor, target, input);
|
||||
}
|
||||
|
||||
void WasmGraphBuilder::SetSourcePosition(Node* node,
|
||||
@ -6375,15 +6353,8 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
enabled_features_(features) {}
|
||||
|
||||
CallDescriptor* GetBigIntToI64CallDescriptor(bool needs_frame_state) {
|
||||
if (bigint_to_i64_descriptor_) return bigint_to_i64_descriptor_;
|
||||
|
||||
bigint_to_i64_descriptor_ = GetBuiltinCallDescriptor(
|
||||
Builtin::kBigIntToI64, zone_, stub_mode_, needs_frame_state);
|
||||
|
||||
AddInt64LoweringReplacement(
|
||||
bigint_to_i64_descriptor_,
|
||||
GetBuiltinCallDescriptor(Builtin::kBigIntToI32Pair, zone_, stub_mode_));
|
||||
return bigint_to_i64_descriptor_;
|
||||
return wasm::GetWasmEngine()->call_descriptors()->GetBigIntToI64Descriptor(
|
||||
stub_mode_, needs_frame_state);
|
||||
}
|
||||
|
||||
Node* GetTargetForBuiltinCall(wasm::WasmCode::RuntimeStubId wasm_stub,
|
||||
@ -7744,9 +7715,6 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
Return(mcgraph()->IntPtrConstant(0));
|
||||
|
||||
if (mcgraph()->machine()->Is32() && ContainsInt64(sig_)) {
|
||||
// No special lowering should be requested in the C entry.
|
||||
DCHECK_NULL(lowering_special_case_);
|
||||
|
||||
MachineRepresentation sig_reps[] = {
|
||||
MachineType::PointerRepresentation(), // return value
|
||||
MachineType::PointerRepresentation(), // target
|
||||
@ -7771,19 +7739,21 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
SetOncePointer<const Operator> float64_to_number_operator_;
|
||||
SetOncePointer<const Operator> tagged_to_float64_operator_;
|
||||
wasm::WasmFeatures enabled_features_;
|
||||
CallDescriptor* bigint_to_i64_descriptor_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void BuildInlinedJSToWasmWrapper(
|
||||
Zone* zone, MachineGraph* mcgraph, const wasm::FunctionSig* signature,
|
||||
const wasm::WasmModule* module, Isolate* isolate,
|
||||
compiler::SourcePositionTable* spt, StubCallMode stub_mode,
|
||||
wasm::WasmFeatures features, Node* frame_state) {
|
||||
void BuildInlinedJSToWasmWrapper(Zone* zone, MachineGraph* mcgraph,
|
||||
const wasm::FunctionSig* signature,
|
||||
const wasm::WasmModule* module,
|
||||
Isolate* isolate,
|
||||
compiler::SourcePositionTable* spt,
|
||||
wasm::WasmFeatures features,
|
||||
Node* frame_state) {
|
||||
WasmWrapperGraphBuilder builder(zone, mcgraph, signature, module,
|
||||
WasmGraphBuilder::kNoSpecialParameterMode,
|
||||
isolate, spt, stub_mode, features);
|
||||
isolate, spt,
|
||||
StubCallMode::kCallBuiltinPointer, features);
|
||||
builder.BuildJSToWasmWrapper(module, false, false, frame_state);
|
||||
}
|
||||
|
||||
|
@ -837,13 +837,8 @@ class WasmGraphBuilder {
|
||||
Node** parameters, int parameter_count);
|
||||
TrapId GetTrapIdForTrap(wasm::TrapReason reason);
|
||||
|
||||
void AddInt64LoweringReplacement(CallDescriptor* original,
|
||||
CallDescriptor* replacement);
|
||||
|
||||
Node* BuildChangeInt64ToBigInt(Node* input, StubCallMode stub_mode);
|
||||
|
||||
CallDescriptor* GetI64ToBigIntCallDescriptor(StubCallMode stub_mode);
|
||||
|
||||
Node* StoreArgsInStackSlot(
|
||||
std::initializer_list<std::pair<MachineRepresentation, Node*>> args);
|
||||
|
||||
@ -870,10 +865,6 @@ class WasmGraphBuilder {
|
||||
Parameter0Mode parameter_mode_;
|
||||
Isolate* const isolate_;
|
||||
SetOncePointer<Node> instance_node_;
|
||||
|
||||
std::unique_ptr<Int64LoweringSpecialCase> lowering_special_case_;
|
||||
CallDescriptor* i64_to_bigint_builtin_descriptor_ = nullptr;
|
||||
CallDescriptor* i64_to_bigint_stub_descriptor_ = nullptr;
|
||||
};
|
||||
|
||||
enum WasmCallKind { kWasmFunction, kWasmImportWrapper, kWasmCapiFunction };
|
||||
@ -881,8 +872,8 @@ enum WasmCallKind { kWasmFunction, kWasmImportWrapper, kWasmCapiFunction };
|
||||
V8_EXPORT_PRIVATE void BuildInlinedJSToWasmWrapper(
|
||||
Zone* zone, MachineGraph* mcgraph, const wasm::FunctionSig* signature,
|
||||
const wasm::WasmModule* module, Isolate* isolate,
|
||||
compiler::SourcePositionTable* spt, StubCallMode stub_mode,
|
||||
wasm::WasmFeatures features, Node* frame_state);
|
||||
compiler::SourcePositionTable* spt, wasm::WasmFeatures features,
|
||||
Node* frame_state);
|
||||
|
||||
V8_EXPORT_PRIVATE CallDescriptor* GetWasmCallDescriptor(
|
||||
Zone* zone, const wasm::FunctionSig* signature,
|
||||
|
@ -13,4 +13,8 @@ specific_include_rules = {
|
||||
"c-api\.h": [
|
||||
"+third_party/wasm-api/wasm.hh",
|
||||
],
|
||||
"wasm-engine\.h": [
|
||||
# The WasmEngine may cache common call descriptors.
|
||||
"+src/compiler/wasm-call-descriptors.h",
|
||||
]
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ struct WasmEngine::NativeModuleInfo {
|
||||
int8_t num_code_gcs_triggered = 0;
|
||||
};
|
||||
|
||||
WasmEngine::WasmEngine() = default;
|
||||
WasmEngine::WasmEngine() : call_descriptors_(&allocator_) {}
|
||||
|
||||
WasmEngine::~WasmEngine() {
|
||||
#ifdef V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "src/base/platform/condition-variable.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/compiler/wasm-call-descriptors.h"
|
||||
#include "src/tasks/cancelable-task.h"
|
||||
#include "src/tasks/operations-barrier.h"
|
||||
#include "src/wasm/canonical-types.h"
|
||||
@ -362,6 +363,10 @@ class V8_EXPORT_PRIVATE WasmEngine {
|
||||
|
||||
TypeCanonicalizer* type_canonicalizer() { return &type_canonicalizer_; }
|
||||
|
||||
compiler::WasmCallDescriptors* call_descriptors() {
|
||||
return &call_descriptors_;
|
||||
}
|
||||
|
||||
// Returns either the compressed tagged pointer representing a null value or
|
||||
// 0 if pointer compression is not available.
|
||||
Tagged_t compressed_null_value_or_zero() const {
|
||||
@ -408,6 +413,8 @@ class V8_EXPORT_PRIVATE WasmEngine {
|
||||
|
||||
TypeCanonicalizer type_canonicalizer_;
|
||||
|
||||
compiler::WasmCallDescriptors call_descriptors_;
|
||||
|
||||
// This mutex protects all information which is mutated concurrently or
|
||||
// fields that are initialized lazily on the first access.
|
||||
base::Mutex mutex_;
|
||||
|
@ -15,11 +15,14 @@
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
||||
#include "src/wasm/value-type.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "test/unittests/compiler/graph-unittest.h"
|
||||
#include "test/unittests/compiler/node-test-utils.h"
|
||||
#include "testing/gmock-support.h"
|
||||
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
|
||||
using testing::AllOf;
|
||||
using testing::Capture;
|
||||
using testing::CaptureEq;
|
||||
@ -54,9 +57,7 @@ class Int64LoweringTest : public GraphTest {
|
||||
lowering.LowerGraph();
|
||||
}
|
||||
|
||||
void LowerGraphWithSpecialCase(
|
||||
Node* node, std::unique_ptr<Int64LoweringSpecialCase> special_case,
|
||||
MachineRepresentation rep) {
|
||||
void LowerGraphWithSpecialCase(Node* node, MachineRepresentation rep) {
|
||||
Node* zero = graph()->NewNode(common()->Int32Constant(0));
|
||||
Node* ret = graph()->NewNode(common()->Return(), zero, node,
|
||||
graph()->start(), graph()->start());
|
||||
@ -69,8 +70,7 @@ class Int64LoweringTest : public GraphTest {
|
||||
sig_builder.AddReturn(rep);
|
||||
|
||||
Int64Lowering lowering(graph(), machine(), common(), simplified(), zone(),
|
||||
nullptr, sig_builder.Build(),
|
||||
std::move(special_case));
|
||||
nullptr, sig_builder.Build());
|
||||
lowering.LowerGraph();
|
||||
}
|
||||
|
||||
@ -430,8 +430,6 @@ TEST_F(Int64LoweringTest, ParameterWithJSClosureParam) {
|
||||
// two assumptions:
|
||||
// - Pointers are 32 bit and therefore pointers do not get lowered.
|
||||
// - 64-bit rol/ror/clz/ctz instructions have a control input.
|
||||
// TODO(wasm): We can find an alternative to re-activate these tests.
|
||||
#if V8_TARGET_ARCH_32_BIT
|
||||
TEST_F(Int64LoweringTest, CallI64Return) {
|
||||
int32_t function = 0x9999;
|
||||
Node* context_address = Int32Constant(0);
|
||||
@ -660,7 +658,6 @@ TEST_F(Int64LoweringTest, I64Ror_43) {
|
||||
IsInt32Constant(21))),
|
||||
start(), start()));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(Int64LoweringTest, Int64Sub) {
|
||||
LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)),
|
||||
@ -1035,37 +1032,20 @@ TEST_F(Int64LoweringTest, WasmBigIntSpecialCaseBigIntToI64) {
|
||||
Node* target = Int32Constant(1);
|
||||
Node* context = Int32Constant(2);
|
||||
Node* bigint = Int32Constant(4);
|
||||
WasmCallDescriptors* descriptors = wasm::GetWasmEngine()->call_descriptors();
|
||||
|
||||
CallDescriptor* bigint_to_i64_call_descriptor =
|
||||
Linkage::GetStubCallDescriptor(
|
||||
zone(), // zone
|
||||
BigIntToI64Descriptor(), // descriptor
|
||||
BigIntToI64Descriptor::GetStackParameterCount(), // stack parameter
|
||||
// count
|
||||
CallDescriptor::kNoFlags, // flags
|
||||
Operator::kNoProperties, // properties
|
||||
StubCallMode::kCallCodeObject); // stub call mode
|
||||
descriptors->GetBigIntToI64Descriptor(StubCallMode::kCallBuiltinPointer,
|
||||
false);
|
||||
|
||||
CallDescriptor* bigint_to_i32_pair_call_descriptor =
|
||||
Linkage::GetStubCallDescriptor(
|
||||
zone(), // zone
|
||||
BigIntToI32PairDescriptor(), // descriptor
|
||||
BigIntToI32PairDescriptor::
|
||||
GetStackParameterCount(), // stack parameter count
|
||||
CallDescriptor::kNoFlags, // flags
|
||||
Operator::kNoProperties, // properties
|
||||
StubCallMode::kCallCodeObject); // stub call mode
|
||||
|
||||
auto lowering_special_case = std::make_unique<Int64LoweringSpecialCase>();
|
||||
lowering_special_case->replacements.insert(
|
||||
{bigint_to_i64_call_descriptor, bigint_to_i32_pair_call_descriptor});
|
||||
descriptors->GetLoweredCallDescriptor(bigint_to_i64_call_descriptor);
|
||||
|
||||
Node* call_node =
|
||||
graph()->NewNode(common()->Call(bigint_to_i64_call_descriptor), target,
|
||||
bigint, context, start(), start());
|
||||
|
||||
LowerGraphWithSpecialCase(call_node, std::move(lowering_special_case),
|
||||
MachineRepresentation::kWord64);
|
||||
LowerGraphWithSpecialCase(call_node, MachineRepresentation::kWord64);
|
||||
|
||||
Capture<Node*> call;
|
||||
Matcher<Node*> call_matcher =
|
||||
@ -1081,36 +1061,18 @@ TEST_F(Int64LoweringTest, WasmBigIntSpecialCaseBigIntToI64) {
|
||||
TEST_F(Int64LoweringTest, WasmBigIntSpecialCaseI64ToBigInt) {
|
||||
Node* target = Int32Constant(1);
|
||||
Node* i64 = Int64Constant(value(0));
|
||||
WasmCallDescriptors* descriptors = wasm::GetWasmEngine()->call_descriptors();
|
||||
|
||||
CallDescriptor* i64_to_bigint_call_descriptor =
|
||||
Linkage::GetStubCallDescriptor(
|
||||
zone(), // zone
|
||||
I64ToBigIntDescriptor(), // descriptor
|
||||
I64ToBigIntDescriptor::GetStackParameterCount(), // stack parameter
|
||||
// count
|
||||
CallDescriptor::kNoFlags, // flags
|
||||
Operator::kNoProperties, // properties
|
||||
StubCallMode::kCallCodeObject); // stub call mode
|
||||
descriptors->GetI64ToBigIntDescriptor(StubCallMode::kCallBuiltinPointer);
|
||||
|
||||
CallDescriptor* i32_pair_to_bigint_call_descriptor =
|
||||
Linkage::GetStubCallDescriptor(
|
||||
zone(), // zone
|
||||
I32PairToBigIntDescriptor(), // descriptor
|
||||
I32PairToBigIntDescriptor::
|
||||
GetStackParameterCount(), // stack parameter count
|
||||
CallDescriptor::kNoFlags, // flags
|
||||
Operator::kNoProperties, // properties
|
||||
StubCallMode::kCallCodeObject); // stub call mode
|
||||
|
||||
auto lowering_special_case = std::make_unique<Int64LoweringSpecialCase>();
|
||||
lowering_special_case->replacements.insert(
|
||||
{i64_to_bigint_call_descriptor, i32_pair_to_bigint_call_descriptor});
|
||||
descriptors->GetLoweredCallDescriptor(i64_to_bigint_call_descriptor);
|
||||
|
||||
Node* call = graph()->NewNode(common()->Call(i64_to_bigint_call_descriptor),
|
||||
target, i64, start(), start());
|
||||
|
||||
LowerGraphWithSpecialCase(call, std::move(lowering_special_case),
|
||||
MachineRepresentation::kTaggedPointer);
|
||||
LowerGraphWithSpecialCase(call, MachineRepresentation::kTaggedPointer);
|
||||
|
||||
EXPECT_THAT(
|
||||
graph()->end()->InputAt(1),
|
||||
@ -1123,3 +1085,5 @@ TEST_F(Int64LoweringTest, WasmBigIntSpecialCaseI64ToBigInt) {
|
||||
} // namespace compiler
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_TARGET_ARCH_32_BIT
|
||||
|
Loading…
Reference in New Issue
Block a user