[wasm][cleanup] Avoid passing non-const FunctionSig*

Most function signatures are created once and never changed. Hence pass
them as const pointer. This makes it clear in function signatures that
these parameters will not be modified.

This also avoids a few ugly const_casts where we were passing pointers
to constexpr FunctionSigs via non-const pointers.

R=jkummerow@chromium.org

Bug: v8:10155
Change-Id: Ieb658ab5582bff276f76babdaf7ddb8f72bd4790
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2072739
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66478}
This commit is contained in:
Clemens Backes 2020-02-25 21:00:50 +01:00 committed by Commit Bot
parent 169d336ec3
commit 8d1c5f3344
47 changed files with 290 additions and 282 deletions

View File

@ -135,14 +135,14 @@ void MergeControlToEnd(MachineGraph* mcgraph, Node* node) {
}
}
bool ContainsSimd(wasm::FunctionSig* sig) {
bool ContainsSimd(const wasm::FunctionSig* sig) {
for (auto type : sig->all()) {
if (type == wasm::kWasmS128) return true;
}
return false;
}
bool ContainsInt64(wasm::FunctionSig* sig) {
bool ContainsInt64(const wasm::FunctionSig* sig) {
for (auto type : sig->all()) {
if (type == wasm::kWasmI64) return true;
}
@ -158,7 +158,7 @@ class WasmGraphAssembler : public GraphAssembler {
WasmGraphBuilder::WasmGraphBuilder(
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig,
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* source_position_table)
: gasm_(std::make_unique<WasmGraphAssembler>(mcgraph, zone)),
zone_(zone),
@ -2575,7 +2575,7 @@ Node* WasmGraphBuilder::BuildCCall(MachineSignature* sig, Node* function,
return SetEffect(graph()->NewNode(op, arraysize(call_args), call_args));
}
Node* WasmGraphBuilder::BuildCallNode(wasm::FunctionSig* sig,
Node* WasmGraphBuilder::BuildCallNode(const wasm::FunctionSig* sig,
Vector<Node*> args,
wasm::WasmCodePosition position,
Node* instance_node, const Operator* op) {
@ -2610,7 +2610,7 @@ Node* WasmGraphBuilder::BuildCallNode(wasm::FunctionSig* sig,
return call;
}
Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig,
Node* WasmGraphBuilder::BuildWasmCall(const wasm::FunctionSig* sig,
Vector<Node*> args, Vector<Node*> rets,
wasm::WasmCodePosition position,
Node* instance_node,
@ -2637,7 +2637,7 @@ Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig,
return call;
}
Node* WasmGraphBuilder::BuildWasmReturnCall(wasm::FunctionSig* sig,
Node* WasmGraphBuilder::BuildWasmReturnCall(const wasm::FunctionSig* sig,
Vector<Node*> args,
wasm::WasmCodePosition position,
Node* instance_node,
@ -2652,7 +2652,7 @@ Node* WasmGraphBuilder::BuildWasmReturnCall(wasm::FunctionSig* sig,
return call;
}
Node* WasmGraphBuilder::BuildImportCall(wasm::FunctionSig* sig,
Node* WasmGraphBuilder::BuildImportCall(const wasm::FunctionSig* sig,
Vector<Node*> args, Vector<Node*> rets,
wasm::WasmCodePosition position,
int func_index,
@ -2683,7 +2683,7 @@ Node* WasmGraphBuilder::BuildImportCall(wasm::FunctionSig* sig,
}
}
Node* WasmGraphBuilder::BuildImportCall(wasm::FunctionSig* sig,
Node* WasmGraphBuilder::BuildImportCall(const wasm::FunctionSig* sig,
Vector<Node*> args, Vector<Node*> rets,
wasm::WasmCodePosition position,
Node* func_index,
@ -2737,7 +2737,7 @@ Node* WasmGraphBuilder::CallDirect(uint32_t index, Vector<Node*> args,
Vector<Node*> rets,
wasm::WasmCodePosition position) {
DCHECK_NULL(args[0]);
wasm::FunctionSig* sig = env_->module->functions[index].sig;
const wasm::FunctionSig* sig = env_->module->functions[index].sig;
if (env_ && index < env_->module->num_imported_functions) {
// Call to an imported function.
@ -2814,7 +2814,7 @@ Node* WasmGraphBuilder::BuildIndirectCall(uint32_t table_index,
LoadIndirectFunctionTable(table_index, &ift_size, &ift_sig_ids, &ift_targets,
&ift_instances);
wasm::FunctionSig* sig = env_->module->signatures[sig_index];
const wasm::FunctionSig* sig = env_->module->signatures[sig_index];
MachineOperatorBuilder* machine = mcgraph()->machine();
Node* key = args[0];
@ -2893,7 +2893,7 @@ Node* WasmGraphBuilder::BuildIndirectCall(uint32_t table_index,
Node* WasmGraphBuilder::ReturnCall(uint32_t index, Vector<Node*> args,
wasm::WasmCodePosition position) {
DCHECK_NULL(args[0]);
wasm::FunctionSig* sig = env_->module->functions[index].sig;
const wasm::FunctionSig* sig = env_->module->functions[index].sig;
if (env_ && index < env_->module->num_imported_functions) {
// Return Call to an imported function.
@ -4037,7 +4037,8 @@ Graph* WasmGraphBuilder::graph() { return mcgraph()->graph(); }
namespace {
Signature<MachineRepresentation>* CreateMachineSignature(
Zone* zone, wasm::FunctionSig* sig, WasmGraphBuilder::CallOrigin origin) {
Zone* zone, const wasm::FunctionSig* sig,
WasmGraphBuilder::CallOrigin origin) {
Signature<MachineRepresentation>::Builder builder(zone, sig->return_count(),
sig->parameter_count());
for (auto ret : sig->returns()) {
@ -5101,7 +5102,7 @@ CallDescriptor* GetBuiltinCallDescriptor(WasmGraphBuilder* builder,
class WasmWrapperGraphBuilder : public WasmGraphBuilder {
public:
WasmWrapperGraphBuilder(Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig,
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt,
StubCallMode stub_mode, wasm::WasmFeatures features)
: WasmGraphBuilder(nullptr, zone, mcgraph, sig, spt),
@ -5304,7 +5305,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
}
int AddArgumentNodes(Vector<Node*> args, int pos, int param_count,
wasm::FunctionSig* sig) {
const wasm::FunctionSig* sig) {
// Convert wasm numbers to JS values.
for (int i = 0; i < param_count; ++i) {
Node* param =
@ -6297,8 +6298,9 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
} // namespace
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine, wasm::FunctionSig* sig,
bool is_import, const wasm::WasmFeatures& enabled_features) {
Isolate* isolate, wasm::WasmEngine* wasm_engine,
const wasm::FunctionSig* sig, bool is_import,
const wasm::WasmFeatures& enabled_features) {
//----------------------------------------------------------------------------
// Create the Graph.
//----------------------------------------------------------------------------
@ -6338,13 +6340,13 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
}
std::pair<WasmImportCallKind, Handle<JSReceiver>> ResolveWasmImportCall(
Handle<JSReceiver> callable, wasm::FunctionSig* expected_sig,
Handle<JSReceiver> callable, const wasm::FunctionSig* expected_sig,
const wasm::WasmFeatures& enabled_features) {
if (WasmExportedFunction::IsWasmExportedFunction(*callable)) {
auto imported_function = Handle<WasmExportedFunction>::cast(callable);
auto func_index = imported_function->function_index();
auto module = imported_function->instance().module();
wasm::FunctionSig* imported_sig = module->functions[func_index].sig;
const wasm::FunctionSig* imported_sig = module->functions[func_index].sig;
if (*imported_sig != *expected_sig) {
return std::make_pair(WasmImportCallKind::kLinkError, callable);
}
@ -6383,14 +6385,15 @@ std::pair<WasmImportCallKind, Handle<JSReceiver>> ResolveWasmImportCall(
SharedFunctionInfo shared = function->shared();
// Check for math intrinsics.
#define COMPARE_SIG_FOR_BUILTIN(name) \
{ \
wasm::FunctionSig* sig = wasm::WasmOpcodes::Signature(wasm::kExpr##name); \
if (!sig) sig = wasm::WasmOpcodes::AsmjsSignature(wasm::kExpr##name); \
DCHECK_NOT_NULL(sig); \
if (*expected_sig == *sig) { \
return std::make_pair(WasmImportCallKind::k##name, callable); \
} \
#define COMPARE_SIG_FOR_BUILTIN(name) \
{ \
const wasm::FunctionSig* sig = \
wasm::WasmOpcodes::Signature(wasm::kExpr##name); \
if (!sig) sig = wasm::WasmOpcodes::AsmjsSignature(wasm::kExpr##name); \
DCHECK_NOT_NULL(sig); \
if (*expected_sig == *sig) { \
return std::make_pair(WasmImportCallKind::k##name, callable); \
} \
}
#define COMPARE_SIG_FOR_BUILTIN_F64(name) \
case Builtins::kMath##name: \
@ -6487,7 +6490,7 @@ wasm::WasmOpcode GetMathIntrinsicOpcode(WasmImportCallKind kind,
wasm::WasmCompilationResult CompileWasmMathIntrinsic(
wasm::WasmEngine* wasm_engine, WasmImportCallKind kind,
wasm::FunctionSig* sig) {
const wasm::FunctionSig* sig) {
DCHECK_EQ(1, sig->return_count());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"),
@ -6550,7 +6553,8 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic(
wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env,
WasmImportCallKind kind, wasm::FunctionSig* sig, bool source_positions) {
WasmImportCallKind kind, const wasm::FunctionSig* sig,
bool source_positions) {
DCHECK_NE(WasmImportCallKind::kLinkError, kind);
DCHECK_NE(WasmImportCallKind::kWasmToWasm, kind);
@ -6602,7 +6606,7 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine,
wasm::NativeModule* native_module,
wasm::FunctionSig* sig,
const wasm::FunctionSig* sig,
Address address) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "CompileWasmCapiFunction");
@ -6653,7 +6657,7 @@ wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine,
wasm::WasmCompilationResult CompileWasmInterpreterEntry(
wasm::WasmEngine* wasm_engine, const wasm::WasmFeatures& enabled_features,
uint32_t func_index, wasm::FunctionSig* sig) {
uint32_t func_index, const wasm::FunctionSig* sig) {
//----------------------------------------------------------------------------
// Create the Graph
//----------------------------------------------------------------------------
@ -6692,7 +6696,7 @@ wasm::WasmCompilationResult CompileWasmInterpreterEntry(
}
MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
wasm::FunctionSig* sig) {
const wasm::FunctionSig* sig) {
std::unique_ptr<Zone> zone =
std::make_unique<Zone>(isolate->allocator(), ZONE_NAME);
Graph* graph = new (zone.get()) Graph(zone.get());
@ -6737,7 +6741,8 @@ MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
return code;
}
MaybeHandle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) {
MaybeHandle<Code> CompileCWasmEntry(Isolate* isolate,
const wasm::FunctionSig* sig) {
std::unique_ptr<Zone> zone =
std::make_unique<Zone>(isolate->allocator(), ZONE_NAME);
Graph* graph = new (zone.get()) Graph(zone.get());
@ -6967,7 +6972,7 @@ class LinkageLocationAllocator {
// General code uses the above configuration data.
CallDescriptor* GetWasmCallDescriptor(
Zone* zone, wasm::FunctionSig* fsig,
Zone* zone, const wasm::FunctionSig* fsig,
WasmGraphBuilder::UseRetpoline use_retpoline, WasmCallKind call_kind) {
// The extra here is to accomodate the instance object as first parameter
// and, when specified, the additional callable.

View File

@ -106,35 +106,36 @@ constexpr WasmImportCallKind kDefaultImportCallKind =
// some callables (e.g. a {WasmExportedFunction} or {WasmJSFunction}) just wrap
// another target, which is why the ultimate target is returned as well.
V8_EXPORT_PRIVATE std::pair<WasmImportCallKind, Handle<JSReceiver>>
ResolveWasmImportCall(Handle<JSReceiver> callable, wasm::FunctionSig* sig,
ResolveWasmImportCall(Handle<JSReceiver> callable, const wasm::FunctionSig* sig,
const wasm::WasmFeatures& enabled_features);
// Compiles an import call wrapper, which allows WASM to call imports.
V8_EXPORT_PRIVATE wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::WasmEngine*, wasm::CompilationEnv* env, WasmImportCallKind,
wasm::FunctionSig*, bool source_positions);
const wasm::FunctionSig*, bool source_positions);
// Compiles a host call wrapper, which allows WASM to call host functions.
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine*,
wasm::NativeModule*,
wasm::FunctionSig*, Address address);
const wasm::FunctionSig*,
Address address);
// Returns an OptimizedCompilationJob object for a JS to Wasm wrapper.
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, wasm::WasmEngine* wasm_engine, wasm::FunctionSig* sig,
bool is_import, const wasm::WasmFeatures& enabled_features);
Isolate* isolate, wasm::WasmEngine* wasm_engine,
const wasm::FunctionSig* sig, bool is_import,
const wasm::WasmFeatures& enabled_features);
// Compiles a stub that redirects a call to a wasm function to the wasm
// interpreter. It's ABI compatible with the compiled wasm function.
V8_EXPORT_PRIVATE wasm::WasmCompilationResult CompileWasmInterpreterEntry(
wasm::WasmEngine*, const wasm::WasmFeatures& enabled_features,
uint32_t func_index, wasm::FunctionSig*);
uint32_t func_index, const wasm::FunctionSig*);
// Compiles a stub with JS linkage that serves as an adapter for function
// objects constructed via {WebAssembly.Function}. It performs a round-trip
// simulating a JS-to-Wasm-to-JS coercion of parameter and return values.
MaybeHandle<Code> CompileJSToJSWrapper(Isolate* isolate,
wasm::FunctionSig* sig);
MaybeHandle<Code> CompileJSToJSWrapper(Isolate*, const wasm::FunctionSig*);
enum CWasmEntryParameters {
kCodeEntry,
@ -147,7 +148,7 @@ enum CWasmEntryParameters {
// Compiles a stub with C++ linkage, to be called from Execution::CallWasm,
// which knows how to feed it its parameters.
MaybeHandle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig);
MaybeHandle<Code> CompileCWasmEntry(Isolate*, const wasm::FunctionSig*);
// Values from the instance object are cached between WASM-level function calls.
// This struct allows the SSA environment handling this cache to be defined
@ -174,7 +175,8 @@ class WasmGraphBuilder {
V8_EXPORT_PRIVATE WasmGraphBuilder(
wasm::CompilationEnv* env, Zone* zone, MachineGraph* mcgraph,
wasm::FunctionSig* sig, compiler::SourcePositionTable* spt = nullptr);
const wasm::FunctionSig* sig,
compiler::SourcePositionTable* spt = nullptr);
V8_EXPORT_PRIVATE ~WasmGraphBuilder();
@ -340,7 +342,7 @@ class WasmGraphBuilder {
this->instance_cache_ = instance_cache;
}
wasm::FunctionSig* GetFunctionSignature() { return sig_; }
const wasm::FunctionSig* GetFunctionSignature() { return sig_; }
enum CallOrigin { kCalledFromWasm, kCalledFromJS };
@ -435,7 +437,7 @@ class WasmGraphBuilder {
template <typename... Args>
Node* BuildCCall(MachineSignature* sig, Node* function, Args... args);
Node* BuildCallNode(wasm::FunctionSig* sig, Vector<Node*> args,
Node* BuildCallNode(const wasm::FunctionSig* sig, Vector<Node*> args,
wasm::WasmCodePosition position, Node* instance_node,
const Operator* op);
// Helper function for {BuildIndirectCall}.
@ -446,16 +448,16 @@ class WasmGraphBuilder {
Vector<Node*> args, Vector<Node*> rets,
wasm::WasmCodePosition position,
IsReturnCall continuation);
Node* BuildWasmCall(wasm::FunctionSig* sig, Vector<Node*> args,
Node* BuildWasmCall(const wasm::FunctionSig* sig, Vector<Node*> args,
Vector<Node*> rets, wasm::WasmCodePosition position,
Node* instance_node, UseRetpoline use_retpoline);
Node* BuildWasmReturnCall(wasm::FunctionSig* sig, Vector<Node*> args,
Node* BuildWasmReturnCall(const wasm::FunctionSig* sig, Vector<Node*> args,
wasm::WasmCodePosition position,
Node* instance_node, UseRetpoline use_retpoline);
Node* BuildImportCall(wasm::FunctionSig* sig, Vector<Node*> args,
Node* BuildImportCall(const wasm::FunctionSig* sig, Vector<Node*> args,
Vector<Node*> rets, wasm::WasmCodePosition position,
int func_index, IsReturnCall continuation);
Node* BuildImportCall(wasm::FunctionSig* sig, Vector<Node*> args,
Node* BuildImportCall(const wasm::FunctionSig* sig, Vector<Node*> args,
Vector<Node*> rets, wasm::WasmCodePosition position,
Node* func_index, IsReturnCall continuation);
@ -574,7 +576,7 @@ class WasmGraphBuilder {
bool needs_stack_check_ = false;
const bool untrusted_code_mitigations_ = true;
wasm::FunctionSig* const sig_;
const wasm::FunctionSig* const sig_;
compiler::WasmDecorator* decorator_ = nullptr;
@ -586,7 +588,7 @@ class WasmGraphBuilder {
enum WasmCallKind { kWasmFunction, kWasmImportWrapper, kWasmCapiFunction };
V8_EXPORT_PRIVATE CallDescriptor* GetWasmCallDescriptor(
Zone* zone, wasm::FunctionSig* signature,
Zone* zone, const wasm::FunctionSig* signature,
WasmGraphBuilder::UseRetpoline use_retpoline =
WasmGraphBuilder::kNoRetpoline,
WasmCallKind kind = kWasmFunction);

View File

@ -220,7 +220,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
// Reserve buffers for argument and return values.
DCHECK_GE(instance->module()->functions.size(), func_index);
wasm::FunctionSig* sig = instance->module()->functions[func_index].sig;
const wasm::FunctionSig* sig = instance->module()->functions[func_index].sig;
DCHECK_GE(kMaxInt, sig->parameter_count());
int num_params = static_cast<int>(sig->parameter_count());
ScopedVector<wasm::WasmValue> wasm_args(num_params);

View File

@ -1633,7 +1633,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
Ret();
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -1714,7 +1714,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
Call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
DCHECK(target != no_reg);

View File

@ -1126,7 +1126,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
Ret();
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -1173,7 +1173,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
Call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
// For Arm64, we have more cache registers than wasm parameters. That means

View File

@ -2009,7 +2009,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
ret(static_cast<int>(num_stack_slots * kSystemPointerSize));
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -2059,7 +2059,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
wasm_call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
// Since we have more cache registers than parameter registers, the

View File

@ -592,7 +592,7 @@ void LiftoffAssembler::SpillAllRegisters() {
cache_state_.reset_used_registers();
}
void LiftoffAssembler::PrepareCall(FunctionSig* sig,
void LiftoffAssembler::PrepareCall(const FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register* target,
Register* target_instance) {
@ -723,7 +723,7 @@ void LiftoffAssembler::PrepareCall(FunctionSig* sig,
}
}
void LiftoffAssembler::FinishCall(FunctionSig* sig,
void LiftoffAssembler::FinishCall(const FunctionSig* sig,
compiler::CallDescriptor* call_descriptor) {
const size_t return_count = sig->return_count();
if (return_count != 0) {
@ -781,7 +781,7 @@ void LiftoffAssembler::ParallelRegisterMove(
}
}
void LiftoffAssembler::MoveToReturnRegisters(FunctionSig* sig) {
void LiftoffAssembler::MoveToReturnRegisters(const FunctionSig* sig) {
// We do not support multi-value yet.
DCHECK_EQ(1, sig->return_count());
ValueType return_type = sig->GetReturn(0);

View File

@ -376,11 +376,11 @@ class LiftoffAssembler : public TurboAssembler {
// Load parameters into the right registers / stack slots for the call.
// Move {*target} into another register if needed and update {*target} to that
// register, or {no_reg} if target was spilled to the stack.
void PrepareCall(FunctionSig*, compiler::CallDescriptor*,
void PrepareCall(const FunctionSig*, compiler::CallDescriptor*,
Register* target = nullptr,
Register* target_instance = nullptr);
// Process return values of the call.
void FinishCall(FunctionSig*, compiler::CallDescriptor*);
void FinishCall(const FunctionSig*, compiler::CallDescriptor*);
// Move {src} into {dst}. {src} and {dst} must be different.
void Move(LiftoffRegister dst, LiftoffRegister src, ValueType);
@ -398,7 +398,7 @@ class LiftoffAssembler : public TurboAssembler {
};
void ParallelRegisterMove(Vector<ParallelRegisterMoveTuple>);
void MoveToReturnRegisters(FunctionSig*);
void MoveToReturnRegisters(const FunctionSig*);
#ifdef ENABLE_SLOW_DCHECKS
// Validate that the register use counts reflect the state of the cache.
@ -709,13 +709,13 @@ class LiftoffAssembler : public TurboAssembler {
// this is the return value of the C function, stored in {rets[0]}. Further
// outputs (specified in {sig->returns()}) are read from the buffer and stored
// in the remaining {rets} registers.
inline void CallC(FunctionSig* sig, const LiftoffRegister* args,
inline void CallC(const FunctionSig* sig, const LiftoffRegister* args,
const LiftoffRegister* rets, ValueType out_argument_type,
int stack_bytes, ExternalReference ext_ref);
inline void CallNativeWasmCode(Address addr);
// Indirect call: If {target == no_reg}, then pop the target from the stack.
inline void CallIndirect(FunctionSig* sig,
inline void CallIndirect(const FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target);
inline void CallRuntimeStub(WasmCode::RuntimeStubId sid);

View File

@ -797,7 +797,7 @@ class LiftoffCompiler {
enum CCallReturn : bool { kHasReturn = true, kNoReturn = false };
void GenerateCCall(const LiftoffRegister* result_regs, FunctionSig* sig,
void GenerateCCall(const LiftoffRegister* result_regs, const FunctionSig* sig,
ValueType out_argument_type,
const LiftoffRegister* arg_regs,
ExternalReference ext_ref) {

View File

@ -1624,7 +1624,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
TurboAssembler::DropAndRet(static_cast<int>(num_stack_slots));
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -1671,7 +1671,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
Call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
if (target == no_reg) {

View File

@ -1416,7 +1416,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
TurboAssembler::DropAndRet(static_cast<int>(num_stack_slots));
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -1463,7 +1463,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
Call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
if (target == no_reg) {

View File

@ -569,7 +569,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
bailout(kUnsupportedArchitecture, "DropStackSlotsAndRet");
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -581,7 +581,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
bailout(kUnsupportedArchitecture, "CallNativeWasmCode");
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
bailout(kUnsupportedArchitecture, "CallIndirect");

View File

@ -573,7 +573,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
bailout(kUnsupportedArchitecture, "DropStackSlotsAndRet");
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -585,7 +585,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
bailout(kUnsupportedArchitecture, "CallNativeWasmCode");
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
bailout(kUnsupportedArchitecture, "CallIndirect");

View File

@ -1946,7 +1946,7 @@ void LiftoffAssembler::DropStackSlotsAndRet(uint32_t num_stack_slots) {
ret(static_cast<int>(num_stack_slots * kSystemPointerSize));
}
void LiftoffAssembler::CallC(wasm::FunctionSig* sig,
void LiftoffAssembler::CallC(const wasm::FunctionSig* sig,
const LiftoffRegister* args,
const LiftoffRegister* rets,
ValueType out_argument_type, int stack_bytes,
@ -1992,7 +1992,7 @@ void LiftoffAssembler::CallNativeWasmCode(Address addr) {
near_call(addr, RelocInfo::WASM_CALL);
}
void LiftoffAssembler::CallIndirect(wasm::FunctionSig* sig,
void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target) {
if (target == no_reg) {

View File

@ -1322,7 +1322,7 @@ auto Func::param_arity() const -> size_t {
DCHECK(i::WasmExportedFunction::IsWasmExportedFunction(*func));
i::Handle<i::WasmExportedFunction> function =
i::Handle<i::WasmExportedFunction>::cast(func);
i::wasm::FunctionSig* sig =
const i::wasm::FunctionSig* sig =
function->instance().module()->functions[function->function_index()].sig;
return sig->parameter_count();
}
@ -1335,7 +1335,7 @@ auto Func::result_arity() const -> size_t {
DCHECK(i::WasmExportedFunction::IsWasmExportedFunction(*func));
i::Handle<i::WasmExportedFunction> function =
i::Handle<i::WasmExportedFunction>::cast(func);
i::wasm::FunctionSig* sig =
const i::wasm::FunctionSig* sig =
function->instance().module()->functions[function->function_index()].sig;
return sig->return_count();
}
@ -1375,7 +1375,7 @@ i::Address CallTargetFromCache(i::Object cached_call_target) {
void PrepareFunctionData(i::Isolate* isolate,
i::Handle<i::WasmExportedFunctionData> function_data,
i::wasm::FunctionSig* sig) {
const i::wasm::FunctionSig* sig) {
// If the data is already populated, return immediately.
if (!function_data->c_wrapper_code().IsSmi()) return;
// Compile wrapper code.
@ -1393,7 +1393,7 @@ void PrepareFunctionData(i::Isolate* isolate,
function_data->set_wasm_call_target(*call_target);
}
void PushArgs(i::wasm::FunctionSig* sig, const Val args[],
void PushArgs(const i::wasm::FunctionSig* sig, const Val args[],
i::wasm::CWasmArgumentsPacker* packer, StoreImpl* store) {
for (size_t i = 0; i < sig->parameter_count(); i++) {
i::wasm::ValueType type = sig->GetParam(i);
@ -1425,7 +1425,7 @@ void PushArgs(i::wasm::FunctionSig* sig, const Val args[],
}
}
void PopArgs(i::wasm::FunctionSig* sig, Val results[],
void PopArgs(const i::wasm::FunctionSig* sig, Val results[],
i::wasm::CWasmArgumentsPacker* packer, StoreImpl* store) {
packer->Reset();
for (size_t i = 0; i < sig->return_count(); i++) {
@ -1512,7 +1512,8 @@ auto Func::call(const Val args[], Val results[]) const -> own<Trap> {
i::Handle<i::WasmInstanceObject> instance(function_data->instance(), isolate);
int function_index = function_data->function_index();
// Caching {sig} would give a ~10% reduction in overhead.
i::wasm::FunctionSig* sig = instance->module()->functions[function_index].sig;
const i::wasm::FunctionSig* sig =
instance->module()->functions[function_index].sig;
PrepareFunctionData(isolate, function_data, sig);
i::Handle<i::Code> wrapper_code = i::Handle<i::Code>(
i::Code::cast(function_data->c_wrapper_code()), isolate);

View File

@ -277,7 +277,7 @@ struct BlockTypeImmediate {
uint32_t length = 1;
ValueType type = kWasmStmt;
uint32_t sig_index = 0;
FunctionSig* sig = nullptr;
const FunctionSig* sig = nullptr;
inline BlockTypeImmediate(const WasmFeatures& enabled, Decoder* decoder,
const byte* pc) {
@ -377,7 +377,7 @@ template <Decoder::ValidateFlag validate>
struct CallIndirectImmediate {
uint32_t table_index;
uint32_t sig_index;
FunctionSig* sig = nullptr;
const FunctionSig* sig = nullptr;
uint32_t length = 0;
inline CallIndirectImmediate(const WasmFeatures enabled, Decoder* decoder,
const byte* pc) {
@ -397,7 +397,7 @@ struct CallIndirectImmediate {
template <Decoder::ValidateFlag validate>
struct CallFunctionImmediate {
uint32_t index;
FunctionSig* sig = nullptr;
const FunctionSig* sig = nullptr;
uint32_t length;
inline CallFunctionImmediate(Decoder* decoder, const byte* pc) {
index = decoder->read_u32v<validate>(pc + 1, &length, "function index");
@ -782,7 +782,7 @@ template <Decoder::ValidateFlag validate>
class WasmDecoder : public Decoder {
public:
WasmDecoder(const WasmModule* module, const WasmFeatures& enabled,
WasmFeatures* detected, FunctionSig* sig, const byte* start,
WasmFeatures* detected, const FunctionSig* sig, const byte* start,
const byte* end, uint32_t buffer_offset = 0)
: Decoder(start, end, buffer_offset),
module_(module),
@ -793,7 +793,7 @@ class WasmDecoder : public Decoder {
const WasmModule* module_;
const WasmFeatures enabled_;
WasmFeatures* detected_;
FunctionSig* sig_;
const FunctionSig* sig_;
ZoneVector<ValueType>* local_types_;
@ -989,7 +989,7 @@ class WasmDecoder : public Decoder {
return true;
}
inline bool CanReturnCall(FunctionSig* target_sig) {
inline bool CanReturnCall(const FunctionSig* target_sig) {
if (target_sig == nullptr) return false;
size_t num_returns = sig_->return_count();
if (num_returns != target_sig->return_count()) return false;
@ -1437,7 +1437,7 @@ class WasmDecoder : public Decoder {
std::pair<uint32_t, uint32_t> StackEffect(const byte* pc) {
WasmOpcode opcode = static_cast<WasmOpcode>(*pc);
// Handle "simple" opcodes with a fixed signature first.
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (!sig) sig = WasmOpcodes::AsmjsSignature(opcode);
if (sig) return {sig->parameter_count(), sig->return_count()};
@ -2386,7 +2386,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
default: {
// Deal with special asmjs opcodes.
if (this->module_ != nullptr && is_asmjs_module(this->module_)) {
FunctionSig* sig = WasmOpcodes::AsmjsSignature(opcode);
const FunctionSig* sig = WasmOpcodes::AsmjsSignature(opcode);
if (sig) {
BuildSimpleOperator(opcode, sig);
}
@ -2498,7 +2498,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
}
// Pops arguments as required by signature.
V8_INLINE ArgVector PopArgs(FunctionSig* sig) {
V8_INLINE ArgVector PopArgs(const FunctionSig* sig) {
int count = sig ? static_cast<int>(sig->parameter_count()) : 0;
ArgVector args(count);
for (int i = count - 1; i >= 0; --i) {
@ -2507,7 +2507,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
return args;
}
ValueType GetReturnType(FunctionSig* sig) {
ValueType GetReturnType(const FunctionSig* sig) {
DCHECK_GE(1, sig->return_count());
return sig->return_count() == 0 ? kWasmStmt : sig->GetReturn();
}
@ -2779,7 +2779,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
LoadTransformationKind::kExtend);
break;
default: {
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (!VALIDATE(sig != nullptr)) {
this->error("invalid simd opcode");
break;
@ -2796,7 +2796,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
uint32_t DecodeAtomicOpcode(WasmOpcode opcode) {
uint32_t len = 0;
ValueType ret_type;
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (!VALIDATE(sig != nullptr)) {
this->error("invalid atomic opcode");
return 0;
@ -2844,7 +2844,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
unsigned DecodeNumericOpcode(WasmOpcode opcode) {
unsigned len = 0;
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig != nullptr) {
switch (opcode) {
case kExprI32SConvertSatF32:
@ -2986,7 +2986,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
DCHECK_EQ(c->stack_depth + merge->arity, stack_.size());
}
Value* PushReturns(FunctionSig* sig) {
Value* PushReturns(const FunctionSig* sig) {
size_t return_count = sig->return_count();
if (return_count == 0) return nullptr;
size_t old_size = stack_.size();
@ -3207,11 +3207,11 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (WasmOpcodes::IsAnyRefOpcode(opcode)) {
RET_ON_PROTOTYPE_OPCODE(anyref);
}
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
BuildSimpleOperator(opcode, sig);
}
void BuildSimpleOperator(WasmOpcode opcode, FunctionSig* sig) {
void BuildSimpleOperator(WasmOpcode opcode, const FunctionSig* sig) {
switch (sig->parameter_count()) {
case 1: {
auto val = Pop(0, sig->GetParam(0));

View File

@ -59,8 +59,8 @@ unsigned OpcodeLength(const byte* pc, const byte* end) {
}
std::pair<uint32_t, uint32_t> StackEffect(const WasmModule* module,
FunctionSig* sig, const byte* pc,
const byte* end) {
const FunctionSig* sig,
const byte* pc, const byte* end) {
WasmFeatures unused_detected_features = WasmFeatures::None();
WasmDecoder<Decoder::kNoValidate> decoder(
module, WasmFeatures::All(), &unused_detected_features, sig, pc, end);

View File

@ -24,12 +24,12 @@ struct WasmModule; // forward declaration of module interface.
// A wrapper around the signature and bytes of a function.
struct FunctionBody {
FunctionSig* sig; // function signature
uint32_t offset; // offset in the module bytes, for error reporting
const byte* start; // start of the function body
const byte* end; // end of the function body
const FunctionSig* sig; // function signature
uint32_t offset; // offset in the module bytes, for error reporting
const byte* start; // start of the function body
const byte* end; // end of the function body
FunctionBody(FunctionSig* sig, uint32_t offset, const byte* start,
FunctionBody(const FunctionSig* sig, uint32_t offset, const byte* start,
const byte* end)
: sig(sig), offset(offset), start(start), end(end) {}
};
@ -81,8 +81,8 @@ V8_EXPORT_PRIVATE unsigned OpcodeLength(const byte* pc, const byte* end);
// local stack effect (e.g. BrIf pops 1, Br pops 0). Those opcodes can have
// non-local stack effect though, which are not covered here.
std::pair<uint32_t, uint32_t> StackEffect(const WasmModule* module,
FunctionSig* sig, const byte* pc,
const byte* end);
const FunctionSig* sig,
const byte* pc, const byte* end);
// A simple forward iterator for bytecodes.
class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {

View File

@ -145,7 +145,7 @@ WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
WasmCompilationResult WasmCompilationUnit::ExecuteImportWrapperCompilation(
WasmEngine* engine, CompilationEnv* env) {
FunctionSig* sig = env->module->functions[func_index_].sig;
const FunctionSig* sig = env->module->functions[func_index_].sig;
// Assume the wrapper is going to be a JS function with matching arity at
// instantiation time.
auto kind = compiler::kDefaultImportCallKind;
@ -265,8 +265,8 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
}
JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit(
Isolate* isolate, WasmEngine* wasm_engine, FunctionSig* sig, bool is_import,
const WasmFeatures& enabled_features)
Isolate* isolate, WasmEngine* wasm_engine, const FunctionSig* sig,
bool is_import, const WasmFeatures& enabled_features)
: is_import_(is_import),
sig_(sig),
job_(compiler::NewJSToWasmCompilationJob(isolate, wasm_engine, sig,
@ -293,7 +293,7 @@ Handle<Code> JSToWasmWrapperCompilationUnit::Finalize(Isolate* isolate) {
// static
Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
Isolate* isolate, FunctionSig* sig, bool is_import) {
Isolate* isolate, const FunctionSig* sig, bool is_import) {
// Run the compilation unit synchronously.
WasmFeatures enabled_features = WasmFeatures::FromIsolate(isolate);
JSToWasmWrapperCompilationUnit unit(isolate, isolate->wasm_engine(), sig,

View File

@ -113,7 +113,7 @@ STATIC_ASSERT(sizeof(WasmCompilationUnit) <= 2 * kSystemPointerSize);
class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final {
public:
JSToWasmWrapperCompilationUnit(Isolate* isolate, WasmEngine* wasm_engine,
FunctionSig* sig, bool is_import,
const FunctionSig* sig, bool is_import,
const WasmFeatures& enabled_features);
~JSToWasmWrapperCompilationUnit();
@ -121,15 +121,16 @@ class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final {
Handle<Code> Finalize(Isolate* isolate);
bool is_import() const { return is_import_; }
FunctionSig* sig() const { return sig_; }
const FunctionSig* sig() const { return sig_; }
// Run a compilation unit synchronously.
static Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, FunctionSig* sig,
static Handle<Code> CompileJSToWasmWrapper(Isolate* isolate,
const FunctionSig* sig,
bool is_import);
private:
bool is_import_;
FunctionSig* sig_;
const FunctionSig* sig_;
std::unique_ptr<OptimizedCompilationJob> job_;
};

View File

@ -911,7 +911,7 @@ class WasmGraphBuildingInterface {
}
void DoCall(FullDecoder* decoder, uint32_t table_index, TFNode* index_node,
FunctionSig* sig, uint32_t sig_index, const Value args[],
const FunctionSig* sig, uint32_t sig_index, const Value args[],
Value returns[]) {
size_t param_count = sig->parameter_count();
size_t return_count = sig->return_count();
@ -937,8 +937,8 @@ class WasmGraphBuildingInterface {
}
void DoReturnCall(FullDecoder* decoder, uint32_t table_index,
TFNode* index_node, FunctionSig* sig, uint32_t sig_index,
const Value args[]) {
TFNode* index_node, const FunctionSig* sig,
uint32_t sig_index, const Value args[]) {
size_t arg_count = sig->parameter_count();
base::SmallVector<TFNode*, 16> arg_nodes(arg_count + 1);
arg_nodes[0] = index_node;

View File

@ -14,11 +14,10 @@ namespace v8 {
namespace internal {
namespace wasm {
// A helper for encoding local declarations prepended to the body of a
// function.
// A helper for encoding local declarations prepended to the body of a function.
class V8_EXPORT_PRIVATE LocalDeclEncoder {
public:
explicit LocalDeclEncoder(Zone* zone, FunctionSig* s = nullptr)
explicit LocalDeclEncoder(Zone* zone, const FunctionSig* s = nullptr)
: sig(s), local_decls(zone), total(0) {}
// Prepend local declarations by creating a new buffer and copying data
@ -34,11 +33,11 @@ class V8_EXPORT_PRIVATE LocalDeclEncoder {
size_t Size() const;
bool has_sig() const { return sig != nullptr; }
FunctionSig* get_sig() const { return sig; }
void set_sig(FunctionSig* s) { sig = s; }
const FunctionSig* get_sig() const { return sig; }
void set_sig(const FunctionSig* s) { sig = s; }
private:
FunctionSig* sig;
const FunctionSig* sig;
ZoneVector<std::pair<uint32_t, ValueType>> local_decls;
size_t total;
};

View File

@ -1080,7 +1080,8 @@ bool ExecuteCompilationUnits(
DCHECK_LE(0, func_index);
DCHECK_LT(func_index, native_module->num_functions());
if (func_index < num_imported_functions) {
FunctionSig* sig = native_module->module()->functions[func_index].sig;
const FunctionSig* sig =
native_module->module()->functions[func_index].sig;
WasmImportWrapperCache::CacheKey key(compiler::kDefaultImportCallKind,
sig);
// If two imported functions have the same key, only one of them should
@ -1177,7 +1178,7 @@ int AddImportWrapperUnits(NativeModule* native_module,
keys;
int num_imported_functions = native_module->num_imported_functions();
for (int func_index = 0; func_index < num_imported_functions; func_index++) {
FunctionSig* sig = native_module->module()->functions[func_index].sig;
const FunctionSig* sig = native_module->module()->functions[func_index].sig;
if (!IsJSCompatibleSignature(sig, native_module->enabled_features())) {
continue;
}
@ -2968,7 +2969,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
WasmCode* CompileImportWrapper(
WasmEngine* wasm_engine, NativeModule* native_module, Counters* counters,
compiler::WasmImportCallKind kind, FunctionSig* sig,
compiler::WasmImportCallKind kind, const FunctionSig* sig,
WasmImportWrapperCache::ModificationScope* cache_scope) {
// Entry should exist, so that we don't insert a new one and invalidate
// other threads' iterators/references, but it should not have been compiled

View File

@ -57,7 +57,7 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
V8_EXPORT_PRIVATE
WasmCode* CompileImportWrapper(
WasmEngine* wasm_engine, NativeModule* native_module, Counters* counters,
compiler::WasmImportCallKind kind, FunctionSig* sig,
compiler::WasmImportCallKind kind, const FunctionSig* sig,
WasmImportWrapperCache::ModificationScope* cache_scope);
V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript(

View File

@ -552,7 +552,7 @@ class ModuleDecoderImpl : public Decoder {
for (uint32_t i = 0; ok() && i < signatures_count; ++i) {
TRACE("DecodeSignature[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
FunctionSig* s = consume_sig(module_->signature_zone.get());
const FunctionSig* s = consume_sig(module_->signature_zone.get());
module_->signatures.push_back(s);
uint32_t id = s ? module_->signature_map.FindOrInsert(*s) : 0;
module_->signature_ids.push_back(id);
@ -650,7 +650,7 @@ class ModuleDecoderImpl : public Decoder {
break;
}
import->index = static_cast<uint32_t>(module_->exceptions.size());
WasmExceptionSig* exception_sig = nullptr;
const WasmExceptionSig* exception_sig = nullptr;
consume_exception_attribute(); // Attribute ignored for now.
consume_exception_sig_index(module_.get(), &exception_sig);
module_->exceptions.emplace_back(exception_sig);
@ -1128,7 +1128,7 @@ class ModuleDecoderImpl : public Decoder {
for (uint32_t i = 0; ok() && i < exception_count; ++i) {
TRACE("DecodeException[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
WasmExceptionSig* exception_sig = nullptr;
const WasmExceptionSig* exception_sig = nullptr;
consume_exception_attribute(); // Attribute ignored for now.
consume_exception_sig_index(module_.get(), &exception_sig);
module_->exceptions.emplace_back(exception_sig);
@ -1262,9 +1262,9 @@ class ModuleDecoderImpl : public Decoder {
}
// Decodes a single function signature at {start}.
FunctionSig* DecodeFunctionSignature(Zone* zone, const byte* start) {
const FunctionSig* DecodeFunctionSignature(Zone* zone, const byte* start) {
pc_ = start;
FunctionSig* result = consume_sig(zone);
const FunctionSig* result = consume_sig(zone);
return ok() ? result : nullptr;
}
@ -1431,7 +1431,7 @@ class ModuleDecoderImpl : public Decoder {
}
}
uint32_t consume_sig_index(WasmModule* module, FunctionSig** sig) {
uint32_t consume_sig_index(WasmModule* module, const FunctionSig** sig) {
const byte* pos = pc_;
uint32_t sig_index = consume_u32v("signature index");
if (sig_index >= module->signatures.size()) {
@ -1444,7 +1444,8 @@ class ModuleDecoderImpl : public Decoder {
return sig_index;
}
uint32_t consume_exception_sig_index(WasmModule* module, FunctionSig** sig) {
uint32_t consume_exception_sig_index(WasmModule* module,
const FunctionSig** sig) {
const byte* pos = pc_;
uint32_t sig_index = consume_sig_index(module, sig);
if (*sig && (*sig)->return_count() != 0) {
@ -1749,7 +1750,7 @@ class ModuleDecoderImpl : public Decoder {
return kWasmStmt;
}
FunctionSig* consume_sig(Zone* zone) {
const FunctionSig* consume_sig(Zone* zone) {
if (!expect_u8("type form", kWasmFunctionTypeCode)) return nullptr;
// parse parameter types
uint32_t param_count =
@ -2071,9 +2072,9 @@ size_t ModuleDecoder::IdentifyUnknownSection(ModuleDecoder* decoder,
bool ModuleDecoder::ok() { return impl_->ok(); }
FunctionSig* DecodeWasmSignatureForTesting(const WasmFeatures& enabled,
Zone* zone, const byte* start,
const byte* end) {
const FunctionSig* DecodeWasmSignatureForTesting(const WasmFeatures& enabled,
Zone* zone, const byte* start,
const byte* end) {
ModuleDecoderImpl decoder(enabled, start, end, kWasmOrigin);
return decoder.DecodeFunctionSignature(zone, start);
}

View File

@ -133,7 +133,7 @@ V8_EXPORT_PRIVATE ModuleResult DecodeWasmModule(
// Exposed for testing. Decodes a single function signature, allocating it
// in the given zone. Returns {nullptr} upon failure.
V8_EXPORT_PRIVATE FunctionSig* DecodeWasmSignatureForTesting(
V8_EXPORT_PRIVATE const FunctionSig* DecodeWasmSignatureForTesting(
const WasmFeatures& enabled, Zone* zone, const byte* start,
const byte* end);

View File

@ -835,7 +835,7 @@ bool InstanceBuilder::ProcessImportedFunction(
Handle<WasmExternalFunction>::cast(value));
}
auto js_receiver = Handle<JSReceiver>::cast(value);
FunctionSig* expected_sig = module_->functions[func_index].sig;
const FunctionSig* expected_sig = module_->functions[func_index].sig;
auto resolved =
compiler::ResolveWasmImportCall(js_receiver, expected_sig, enabled_);
compiler::WasmImportCallKind kind = resolved.first;
@ -929,10 +929,10 @@ bool InstanceBuilder::InitializeImportedIndirectFunctionTable(
Handle<WasmInstanceObject> target_instance =
maybe_target_instance.ToHandleChecked();
FunctionSig* sig = target_instance->module_object()
.module()
->functions[function_index]
.sig;
const FunctionSig* sig = target_instance->module_object()
.module()
->functions[function_index]
.sig;
// Look up the signature's canonical id. If there is no canonical
// id, then the signature does not appear at all in this module,
@ -1212,7 +1212,7 @@ void InstanceBuilder::CompileImportWrappers(
}
auto js_receiver = Handle<JSReceiver>::cast(value);
uint32_t func_index = module_->import_table[index].index;
FunctionSig* sig = module_->functions[func_index].sig;
const FunctionSig* sig = module_->functions[func_index].sig;
auto resolved = compiler::ResolveWasmImportCall(js_receiver, sig, enabled_);
compiler::WasmImportCallKind kind = resolved.first;
if (kind == compiler::WasmImportCallKind::kWasmToWasm ||

View File

@ -45,7 +45,7 @@ class CWasmArgumentsPacker {
return base::ReadUnalignedValue<T>(address);
}
static int TotalSize(FunctionSig* sig) {
static int TotalSize(const FunctionSig* sig) {
int return_size = 0;
for (ValueType t : sig->returns()) {
return_size += ValueTypes::ElementSizeInBytes(t);

View File

@ -201,7 +201,7 @@ void WasmCode::LogCode(Isolate* isolate) const {
size_t prefix_len = name_buffer.size();
constexpr size_t kMaxSigLength = 128;
name_buffer.resize(prefix_len + kMaxSigLength);
FunctionSig* sig = native_module()->module()->functions[index_].sig;
const FunctionSig* sig = native_module()->module()->functions[index_].sig;
size_t sig_length =
PrintSignature(VectorOf(&name_buffer[prefix_len], kMaxSigLength), sig);
name_buffer.resize(prefix_len + sig_length);

View File

@ -166,7 +166,7 @@ class InterpreterHandle {
Vector<WasmValue> argument_values,
Vector<WasmValue> return_values) {
DCHECK_GE(module()->functions.size(), func_index);
FunctionSig* sig = module()->functions[func_index].sig;
const FunctionSig* sig = module()->functions[func_index].sig;
DCHECK_EQ(sig->parameter_count(), argument_values.size());
DCHECK_EQ(sig->return_count(), return_values.size());
@ -955,7 +955,7 @@ Handle<JSObject> WasmDebugInfo::GetLocalScopeObject(
// static
Handle<Code> WasmDebugInfo::GetCWasmEntry(Handle<WasmDebugInfo> debug_info,
wasm::FunctionSig* sig) {
const wasm::FunctionSig* sig) {
Isolate* isolate = debug_info->GetIsolate();
DCHECK_EQ(debug_info->has_c_wasm_entries(),
debug_info->has_c_wasm_entry_map());

View File

@ -24,7 +24,7 @@ WasmCode*& WasmImportWrapperCache::operator[](
}
WasmCode* WasmImportWrapperCache::Get(compiler::WasmImportCallKind kind,
FunctionSig* sig) const {
const FunctionSig* sig) const {
base::MutexGuard lock(&mutex_);
auto it = entry_map_.find({kind, sig});
DCHECK(it != entry_map_.end());

View File

@ -23,7 +23,7 @@ using FunctionSig = Signature<ValueType>;
// Implements a cache for import wrappers.
class WasmImportWrapperCache {
public:
using CacheKey = std::pair<compiler::WasmImportCallKind, FunctionSig*>;
using CacheKey = std::pair<compiler::WasmImportCallKind, const FunctionSig*>;
class CacheKeyHash {
public:
@ -51,7 +51,7 @@ class WasmImportWrapperCache {
// Thread-safe. Assumes the key exists in the map.
V8_EXPORT_PRIVATE WasmCode* Get(compiler::WasmImportCallKind kind,
FunctionSig* sig) const;
const FunctionSig* sig) const;
~WasmImportWrapperCache();

View File

@ -3853,7 +3853,7 @@ class ThreadImpl {
ExternalCallResult CallExternalWasmFunction(Isolate* isolate,
Handle<Object> object_ref,
const WasmCode* code,
FunctionSig* sig) {
const FunctionSig* sig) {
int num_args = static_cast<int>(sig->parameter_count());
WasmFeatures enabled_features = WasmFeatures::FromIsolate(isolate);
@ -3980,7 +3980,7 @@ class ThreadImpl {
// and compiled we may get an exception.
if (code == nullptr) return TryHandleException(isolate_);
FunctionSig* sig = module()->functions[function_index].sig;
const FunctionSig* sig = module()->functions[function_index].sig;
return CallExternalWasmFunction(isolate_, object_ref, code, sig);
}
@ -4005,7 +4005,7 @@ class ThreadImpl {
return {ExternalCallResult::SIGNATURE_MISMATCH};
}
FunctionSig* signature = module()->signatures[sig_index];
const FunctionSig* signature = module()->signatures[sig_index];
Handle<Object> object_ref = handle(entry.object_ref(), isolate_);
WasmCode* code = GetTargetCode(isolate_, entry.target());

View File

@ -1516,7 +1516,7 @@ void WebAssemblyFunction(const v8::FunctionCallbackInfo<v8::Value>& args) {
return;
}
i::wasm::FunctionSig* sig = builder.Build();
const i::wasm::FunctionSig* sig = builder.Build();
i::Handle<i::JSReceiver> callable =
Utils::OpenHandle(*args[1].As<Function>());
i::Handle<i::JSFunction> result =
@ -1531,7 +1531,7 @@ void WebAssemblyFunctionType(const v8::FunctionCallbackInfo<v8::Value>& args) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Function.type()");
i::wasm::FunctionSig* sig;
const i::wasm::FunctionSig* sig;
i::Zone zone(i_isolate->allocator(), ZONE_NAME);
i::Handle<i::Object> arg0 = Utils::OpenHandle(*args[0]);
if (i::WasmExportedFunction::IsWasmExportedFunction(*arg0)) {

View File

@ -261,7 +261,7 @@ Handle<String> ToValueTypeString(Isolate* isolate, ValueType type) {
} // namespace
Handle<JSObject> GetTypeForFunction(Isolate* isolate, FunctionSig* sig) {
Handle<JSObject> GetTypeForFunction(Isolate* isolate, const FunctionSig* sig) {
Factory* factory = isolate->factory();
// Extract values for the {ValueType[]} arrays.
@ -641,7 +641,7 @@ size_t EstimateStoredSize(const WasmModule* module) {
VectorSize(module->elem_segments);
}
size_t PrintSignature(Vector<char> buffer, wasm::FunctionSig* sig) {
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig* sig) {
if (buffer.empty()) return 0;
size_t old_size = buffer.size();
auto append_char = [&buffer](char c) {

View File

@ -51,10 +51,10 @@ class WireBytesRef {
// Static representation of a wasm function.
struct WasmFunction {
FunctionSig* sig; // signature of the function.
uint32_t func_index; // index into the function table.
uint32_t sig_index; // index into the signature table.
WireBytesRef code; // code of this function.
const FunctionSig* sig; // signature of the function.
uint32_t func_index; // index into the function table.
uint32_t sig_index; // index into the signature table.
WireBytesRef code; // code of this function.
bool imported;
bool exported;
bool declared;
@ -80,7 +80,7 @@ using WasmExceptionSig = FunctionSig;
// Static representation of a wasm exception type.
struct WasmException {
explicit WasmException(const WasmExceptionSig* sig) : sig(sig) {}
FunctionSig* ToFunctionSig() const { return const_cast<FunctionSig*>(sig); }
const FunctionSig* ToFunctionSig() const { return sig; }
const WasmExceptionSig* sig; // type signature of the exception.
};
@ -256,7 +256,7 @@ struct V8_EXPORT_PRIVATE WasmModule {
uint32_t num_exported_functions = 0;
uint32_t num_declared_data_segments = 0; // From the DataCount section.
WireBytesRef name = {0, 0};
std::vector<FunctionSig*> signatures; // by signature index
std::vector<const FunctionSig*> signatures; // by signature index
std::vector<uint32_t> signature_ids; // by signature index
std::vector<WasmFunction> functions;
std::vector<WasmDataSegment> data_segments;
@ -363,7 +363,7 @@ std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name);
V8_EXPORT_PRIVATE bool IsWasmCodegenAllowed(Isolate* isolate,
Handle<Context> context);
Handle<JSObject> GetTypeForFunction(Isolate* isolate, FunctionSig* sig);
Handle<JSObject> GetTypeForFunction(Isolate* isolate, const FunctionSig* sig);
Handle<JSObject> GetTypeForGlobal(Isolate* isolate, bool is_mutable,
ValueType type);
Handle<JSObject> GetTypeForMemory(Isolate* isolate, uint32_t min_size,
@ -430,7 +430,7 @@ class TruncatedUserString {
// Print the signature into the given {buffer}. If {buffer} is non-empty, it
// will be null-terminated, even if the signature is cut off. Returns the number
// of characters written, excluding the terminating null-byte.
size_t PrintSignature(Vector<char> buffer, wasm::FunctionSig*);
size_t PrintSignature(Vector<char> buffer, const wasm::FunctionSig*);
} // namespace wasm
} // namespace internal

View File

@ -516,7 +516,7 @@ void WasmTableObject::Fill(Isolate* isolate, Handle<WasmTableObject> table,
void WasmTableObject::UpdateDispatchTables(
Isolate* isolate, Handle<WasmTableObject> table, int entry_index,
wasm::FunctionSig* sig, Handle<WasmInstanceObject> target_instance,
const wasm::FunctionSig* sig, Handle<WasmInstanceObject> target_instance,
int target_func_index) {
// We simply need to update the IFTs for each instance that imports
// this table.
@ -1441,7 +1441,7 @@ void WasmInstanceObject::ImportWasmJSFunctionIntoTable(
// Note that {SignatureMap::Find} may return {-1} if the signature is
// not found; it will simply never match any check.
Zone zone(isolate->allocator(), ZONE_NAME);
wasm::FunctionSig* sig = js_function->GetSignature(&zone);
const wasm::FunctionSig* sig = js_function->GetSignature(&zone);
auto sig_id = instance->module()->signature_map.Find(*sig);
// Compile a wrapper for the target callable.
@ -1812,7 +1812,7 @@ Address WasmExportedFunction::GetWasmCallTarget() {
return instance().GetCallTarget(function_index());
}
wasm::FunctionSig* WasmExportedFunction::sig() {
const wasm::FunctionSig* WasmExportedFunction::sig() {
return instance().module()->functions[function_index()].sig;
}
@ -1824,7 +1824,7 @@ bool WasmJSFunction::IsWasmJSFunction(Object object) {
}
Handle<WasmJSFunction> WasmJSFunction::New(Isolate* isolate,
wasm::FunctionSig* sig,
const wasm::FunctionSig* sig,
Handle<JSReceiver> callable) {
DCHECK_LE(sig->all().size(), kMaxInt);
int sig_size = static_cast<int>(sig->all().size());
@ -1864,7 +1864,7 @@ JSReceiver WasmJSFunction::GetCallable() const {
return shared().wasm_js_function_data().callable();
}
wasm::FunctionSig* WasmJSFunction::GetSignature(Zone* zone) {
const wasm::FunctionSig* WasmJSFunction::GetSignature(Zone* zone) {
WasmJSFunctionData function_data = shared().wasm_js_function_data();
int sig_size = function_data.serialized_signature().length();
wasm::ValueType* types = zone->NewArray<wasm::ValueType>(sig_size);
@ -1876,7 +1876,7 @@ wasm::FunctionSig* WasmJSFunction::GetSignature(Zone* zone) {
return new (zone) wasm::FunctionSig(return_count, parameter_count, types);
}
bool WasmJSFunction::MatchesSignature(wasm::FunctionSig* sig) {
bool WasmJSFunction::MatchesSignature(const wasm::FunctionSig* sig) {
DCHECK_LE(sig->all().size(), kMaxInt);
int sig_size = static_cast<int>(sig->all().size());
int return_count = static_cast<int>(sig->return_count());

View File

@ -247,7 +247,8 @@ class V8_EXPORT_PRIVATE WasmTableObject : public JSObject {
// TODO(wasm): Unify these three methods into one.
static void UpdateDispatchTables(Isolate* isolate,
Handle<WasmTableObject> table,
int entry_index, wasm::FunctionSig* sig,
int entry_index,
const wasm::FunctionSig* sig,
Handle<WasmInstanceObject> target_instance,
int target_func_index);
static void UpdateDispatchTables(Isolate* isolate,
@ -635,7 +636,7 @@ class WasmExportedFunction : public JSFunction {
Address GetWasmCallTarget();
wasm::FunctionSig* sig();
const wasm::FunctionSig* sig();
DECL_CAST(WasmExportedFunction)
OBJECT_CONSTRUCTORS(WasmExportedFunction, JSFunction);
@ -647,14 +648,15 @@ class WasmJSFunction : public JSFunction {
public:
static bool IsWasmJSFunction(Object object);
static Handle<WasmJSFunction> New(Isolate* isolate, wasm::FunctionSig* sig,
static Handle<WasmJSFunction> New(Isolate* isolate,
const wasm::FunctionSig* sig,
Handle<JSReceiver> callable);
JSReceiver GetCallable() const;
// Deserializes the signature of this function using the provided zone. Note
// that lifetime of the signature is hence directly coupled to the zone.
wasm::FunctionSig* GetSignature(Zone* zone);
bool MatchesSignature(wasm::FunctionSig* sig);
const wasm::FunctionSig* GetSignature(Zone* zone);
bool MatchesSignature(const wasm::FunctionSig* sig);
DECL_CAST(WasmJSFunction)
OBJECT_CONSTRUCTORS(WasmJSFunction, JSFunction);
@ -876,7 +878,7 @@ class WasmDebugInfo : public Struct {
int frame_index);
V8_EXPORT_PRIVATE static Handle<Code> GetCWasmEntry(Handle<WasmDebugInfo>,
wasm::FunctionSig*);
const wasm::FunctionSig*);
OBJECT_CONSTRUCTORS(WasmDebugInfo, Struct);
};

View File

@ -549,29 +549,25 @@ constexpr std::array<WasmOpcodeSig, 256> kNumericExprSigTable =
} // namespace
FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
const FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
switch (opcode >> 8) {
case 0:
return const_cast<FunctionSig*>(kCachedSigs[kShortSigTable[opcode]]);
return kCachedSigs[kShortSigTable[opcode]];
case kSimdPrefix:
return const_cast<FunctionSig*>(
kCachedSigs[kSimdExprSigTable[opcode & 0xFF]]);
return kCachedSigs[kSimdExprSigTable[opcode & 0xFF]];
case kAtomicPrefix:
return const_cast<FunctionSig*>(
kCachedSigs[kAtomicExprSigTable[opcode & 0xFF]]);
return kCachedSigs[kAtomicExprSigTable[opcode & 0xFF]];
case kNumericPrefix:
return const_cast<FunctionSig*>(
kCachedSigs[kNumericExprSigTable[opcode & 0xFF]]);
return kCachedSigs[kNumericExprSigTable[opcode & 0xFF]];
default:
UNREACHABLE(); // invalid prefix.
return nullptr;
}
}
FunctionSig* WasmOpcodes::AsmjsSignature(WasmOpcode opcode) {
const FunctionSig* WasmOpcodes::AsmjsSignature(WasmOpcode opcode) {
DCHECK_GT(kSimpleAsmjsExprSigTable.size(), opcode);
return const_cast<FunctionSig*>(
kCachedSigs[kSimpleAsmjsExprSigTable[opcode]]);
return kCachedSigs[kSimpleAsmjsExprSigTable[opcode]];
}
// Define constexpr arrays.

View File

@ -668,8 +668,8 @@ enum TrapReason {
class V8_EXPORT_PRIVATE WasmOpcodes {
public:
static const char* OpcodeName(WasmOpcode opcode);
static FunctionSig* Signature(WasmOpcode opcode);
static FunctionSig* AsmjsSignature(WasmOpcode opcode);
static const FunctionSig* Signature(WasmOpcode opcode);
static const FunctionSig* AsmjsSignature(WasmOpcode opcode);
static bool IsPrefixOpcode(WasmOpcode opcode);
static bool IsControlOpcode(WasmOpcode opcode);
static bool IsAnyRefOpcode(WasmOpcode opcode);

View File

@ -81,7 +81,7 @@ class CWasmEntryArgTester {
WasmRunner<ReturnType, Args...> runner_;
Isolate* isolate_;
std::function<ReturnType(Args...)> expected_fn_;
FunctionSig* sig_;
const FunctionSig* sig_;
Handle<Code> c_wasm_entry_;
WasmCode* wasm_code_;
};

View File

@ -2009,7 +2009,7 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
compiler::Graph graph(&zone);
compiler::JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr,
&machine);
FunctionSig* sig = WasmOpcodes::Signature(opcode);
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig->parameter_count() == 1) {
byte code[] = {WASM_NO_LOCALS, kExprLocalGet, 0, static_cast<byte>(opcode),

View File

@ -105,7 +105,8 @@ byte* TestingModuleBuilder::AddMemory(uint32_t size, SharedFlag shared) {
return mem_start_;
}
uint32_t TestingModuleBuilder::AddFunction(FunctionSig* sig, const char* name,
uint32_t TestingModuleBuilder::AddFunction(const FunctionSig* sig,
const char* name,
FunctionType type) {
if (test_module_->functions.size() == 0) {
// TODO(titzer): Reserving space here to avoid the underlying WasmFunction
@ -240,7 +241,7 @@ uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) {
return bytes_offset;
}
uint32_t TestingModuleBuilder::AddException(FunctionSig* sig) {
uint32_t TestingModuleBuilder::AddException(const FunctionSig* sig) {
DCHECK_EQ(0, sig->return_count());
uint32_t index = static_cast<uint32_t>(test_module_->exceptions.size());
test_module_->exceptions.push_back(WasmException{sig});
@ -358,7 +359,7 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
}
void TestBuildingGraphWithBuilder(compiler::WasmGraphBuilder* builder,
Zone* zone, FunctionSig* sig,
Zone* zone, const FunctionSig* sig,
const byte* start, const byte* end) {
WasmFeatures unused_detected_features;
FunctionBody body(sig, 0, start, end);
@ -385,7 +386,7 @@ void TestBuildingGraphWithBuilder(compiler::WasmGraphBuilder* builder,
}
void TestBuildingGraph(Zone* zone, compiler::JSGraph* jsgraph,
CompilationEnv* module, FunctionSig* sig,
CompilationEnv* module, const FunctionSig* sig,
compiler::SourcePositionTable* source_position_table,
const byte* start, const byte* end) {
compiler::WasmGraphBuilder builder(module, zone, jsgraph, sig,
@ -558,7 +559,7 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
if (WasmCode::ShouldBeLogged(isolate())) code->LogCode(isolate());
}
WasmFunctionCompiler::WasmFunctionCompiler(Zone* zone, FunctionSig* sig,
WasmFunctionCompiler::WasmFunctionCompiler(Zone* zone, const FunctionSig* sig,
TestingModuleBuilder* builder,
const char* name)
: GraphAndBuilders(zone),
@ -577,8 +578,8 @@ WasmFunctionCompiler::WasmFunctionCompiler(Zone* zone, FunctionSig* sig,
WasmFunctionCompiler::~WasmFunctionCompiler() = default;
FunctionSig* WasmRunnerBase::CreateSig(MachineType return_type,
Vector<MachineType> param_types) {
const FunctionSig* WasmRunnerBase::CreateSig(MachineType return_type,
Vector<MachineType> param_types) {
int return_count = return_type.IsNone() ? 0 : 1;
int param_count = param_types.length();

View File

@ -77,7 +77,7 @@ using compiler::Node;
// For tests that must manually import a JSFunction with source code.
struct ManuallyImportedJSFunction {
FunctionSig* sig;
const FunctionSig* sig;
Handle<JSFunction> js_function;
};
@ -110,7 +110,7 @@ class TestingModuleBuilder {
return reinterpret_cast<T*>(globals_data_ + global->offset);
}
byte AddSignature(FunctionSig* sig) {
byte AddSignature(const FunctionSig* sig) {
DCHECK_EQ(test_module_->signatures.size(),
test_module_->signature_ids.size());
test_module_->signatures.push_back(sig);
@ -181,7 +181,8 @@ class TestingModuleBuilder {
void SetHasSharedMemory() { test_module_->has_shared_memory = true; }
enum FunctionType { kImport, kWasm };
uint32_t AddFunction(FunctionSig* sig, const char* name, FunctionType type);
uint32_t AddFunction(const FunctionSig* sig, const char* name,
FunctionType type);
// Freezes the signature map of the module and allocates the storage for
// export wrappers.
@ -197,7 +198,7 @@ class TestingModuleBuilder {
uint32_t AddBytes(Vector<const byte> bytes);
uint32_t AddException(FunctionSig* sig);
uint32_t AddException(const FunctionSig* sig);
uint32_t AddPassiveDataSegment(Vector<const byte> bytes);
uint32_t AddPassiveElementSegment(const std::vector<uint32_t>& entries);
@ -259,7 +260,7 @@ class TestingModuleBuilder {
};
void TestBuildingGraph(Zone* zone, compiler::JSGraph* jsgraph,
CompilationEnv* module, FunctionSig* sig,
CompilationEnv* module, const FunctionSig* sig,
compiler::SourcePositionTable* source_position_table,
const byte* start, const byte* end);
@ -338,11 +339,11 @@ class WasmFunctionCompiler : public compiler::GraphAndBuilders {
private:
friend class WasmRunnerBase;
WasmFunctionCompiler(Zone* zone, FunctionSig* sig,
WasmFunctionCompiler(Zone* zone, const FunctionSig* sig,
TestingModuleBuilder* builder, const char* name);
compiler::JSGraph jsgraph;
FunctionSig* sig;
const FunctionSig* sig;
// The call descriptor is initialized when the function is compiled.
CallDescriptor* descriptor_;
TestingModuleBuilder* builder_;
@ -384,7 +385,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
// Resets the state for building the next function.
// The main function called will be the last generated function.
// Returns the index of the previously built function.
WasmFunctionCompiler& NewFunction(FunctionSig* sig,
WasmFunctionCompiler& NewFunction(const FunctionSig* sig,
const char* name = nullptr) {
functions_.emplace_back(
new WasmFunctionCompiler(&zone_, sig, &builder_, name));
@ -409,7 +410,7 @@ class WasmRunnerBase : public HandleAndZoneScope {
bool interpret() { return builder_.interpret(); }
template <typename ReturnType, typename... ParamTypes>
FunctionSig* CreateSig() {
const FunctionSig* CreateSig() {
std::array<MachineType, sizeof...(ParamTypes)> param_machine_types{
{MachineTypeForC<ParamTypes>()...}};
Vector<MachineType> param_vec(param_machine_types.data(),
@ -418,8 +419,8 @@ class WasmRunnerBase : public HandleAndZoneScope {
}
private:
FunctionSig* CreateSig(MachineType return_type,
Vector<MachineType> param_types);
const FunctionSig* CreateSig(MachineType return_type,
Vector<MachineType> param_types);
protected:
v8::internal::AccountingAllocator allocator_;

View File

@ -77,7 +77,8 @@ bool InterpretWasmModuleForTesting(Isolate* isolate,
return false;
}
int function_index = function->function_index();
FunctionSig* signature = instance->module()->functions[function_index].sig;
const FunctionSig* signature =
instance->module()->functions[function_index].sig;
size_t param_count = signature->parameter_count();
std::unique_ptr<WasmValue[]> arguments(new WasmValue[param_count]);

View File

@ -109,7 +109,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
// Prepends local variable declarations and renders nice error messages for
// verification failures.
template <typename Code = std::initializer_list<const byte>>
void Validate(bool expected_success, FunctionSig* sig, Code&& raw_code,
void Validate(bool expected_success, const FunctionSig* sig, Code&& raw_code,
AppendEnd append_end = kAppendEnd,
const char* message = nullptr) {
Vector<const byte> code =
@ -136,20 +136,20 @@ class FunctionBodyDecoderTest : public TestWithZone {
}
template <typename Code = std::initializer_list<const byte>>
void ExpectValidates(FunctionSig* sig, Code&& raw_code,
void ExpectValidates(const FunctionSig* sig, Code&& raw_code,
AppendEnd append_end = kAppendEnd,
const char* message = nullptr) {
Validate(true, sig, std::forward<Code>(raw_code), append_end, message);
}
template <typename Code = std::initializer_list<const byte>>
void ExpectFailure(FunctionSig* sig, Code&& raw_code,
void ExpectFailure(const FunctionSig* sig, Code&& raw_code,
AppendEnd append_end = kAppendEnd,
const char* message = nullptr) {
Validate(false, sig, std::forward<Code>(raw_code), append_end, message);
}
void TestBinop(WasmOpcode opcode, FunctionSig* success) {
void TestBinop(WasmOpcode opcode, const FunctionSig* success) {
// op(local[0], local[1])
byte code[] = {WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
ExpectValidates(success, code);
@ -171,7 +171,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
}
}
void TestUnop(WasmOpcode opcode, FunctionSig* success) {
void TestUnop(WasmOpcode opcode, const FunctionSig* success) {
TestUnop(opcode, success->GetReturn(), success->GetParam(0));
}
@ -215,12 +215,12 @@ class TestModuleBuilder {
CHECK_LE(mod.globals.size(), kMaxByteSizedLeb128);
return static_cast<byte>(mod.globals.size() - 1);
}
byte AddSignature(FunctionSig* sig) {
byte AddSignature(const FunctionSig* sig) {
mod.signatures.push_back(sig);
CHECK_LE(mod.signatures.size(), kMaxByteSizedLeb128);
return static_cast<byte>(mod.signatures.size() - 1);
}
byte AddFunction(FunctionSig* sig, bool declared = true) {
byte AddFunction(const FunctionSig* sig, bool declared = true) {
mod.functions.push_back({sig, // sig
0, // func_index
0, // sig_index
@ -231,7 +231,7 @@ class TestModuleBuilder {
CHECK_LE(mod.functions.size(), kMaxByteSizedLeb128);
return static_cast<byte>(mod.functions.size() - 1);
}
byte AddImport(FunctionSig* sig) {
byte AddImport(const FunctionSig* sig) {
byte result = AddFunction(sig);
mod.functions[result].imported = true;
return result;
@ -399,10 +399,8 @@ TEST_F(FunctionBodyDecoderTest, TooManyLocals) {
}
TEST_F(FunctionBodyDecoderTest, GetLocal0_param_n) {
FunctionSig* array[] = {sigs.i_i(), sigs.i_ii(), sigs.i_iii()};
for (size_t i = 0; i < arraysize(array); i++) {
ExpectValidates(array[i], kCodeGetLocal0);
for (const FunctionSig* sig : {sigs.i_i(), sigs.i_ii(), sigs.i_iii()}) {
ExpectValidates(sig, kCodeGetLocal0);
}
}
@ -1362,14 +1360,14 @@ TEST_F(FunctionBodyDecoderTest, MacrosInt64) {
TEST_F(FunctionBodyDecoderTest, AllSimpleExpressions) {
WASM_FEATURE_SCOPE(anyref);
// Test all simple expressions which are described by a signature.
#define DECODE_TEST(name, opcode, sig) \
{ \
FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \
if (sig->parameter_count() == 1) { \
TestUnop(kExpr##name, sig); \
} else { \
TestBinop(kExpr##name, sig); \
} \
#define DECODE_TEST(name, opcode, sig) \
{ \
const FunctionSig* sig = WasmOpcodes::Signature(kExpr##name); \
if (sig->parameter_count() == 1) { \
TestUnop(kExpr##name, sig); \
} else { \
TestBinop(kExpr##name, sig); \
} \
}
FOREACH_SIMPLE_OPCODE(DECODE_TEST);
@ -1508,7 +1506,7 @@ TEST_F(FunctionBodyDecoderTest, AllStoreMemCombinations) {
}
TEST_F(FunctionBodyDecoderTest, SimpleCalls) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1523,7 +1521,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleCalls) {
}
TEST_F(FunctionBodyDecoderTest, CallsWithTooFewArguments) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1537,7 +1535,7 @@ TEST_F(FunctionBodyDecoderTest, CallsWithTooFewArguments) {
}
TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs2) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1549,7 +1547,7 @@ TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs2) {
}
TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1569,7 +1567,7 @@ TEST_F(FunctionBodyDecoderTest, CallsWithMismatchedSigs3) {
TEST_F(FunctionBodyDecoderTest, SimpleReturnCalls) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1586,7 +1584,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleReturnCalls) {
TEST_F(FunctionBodyDecoderTest, ReturnCallsWithTooFewArguments) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1602,7 +1600,7 @@ TEST_F(FunctionBodyDecoderTest, ReturnCallsWithTooFewArguments) {
TEST_F(FunctionBodyDecoderTest, ReturnCallsWithMismatchedSigs) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1621,7 +1619,7 @@ TEST_F(FunctionBodyDecoderTest, ReturnCallsWithMismatchedSigs) {
TEST_F(FunctionBodyDecoderTest, SimpleIndirectReturnCalls) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.AddTable(kWasmFuncRef, 20, true, 30);
module = builder.module();
@ -1640,7 +1638,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectReturnCalls) {
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module();
@ -1662,7 +1660,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) {
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithMismatchedSigs3) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeTable(wasm::kWasmStmt);
module = builder.module();
@ -1693,7 +1691,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithMismatchedSigs3) {
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithoutTableCrash) {
WASM_FEATURE_SCOPE(return_call);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1709,7 +1707,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithoutTableCrash) {
}
TEST_F(FunctionBodyDecoderTest, IncompleteIndirectReturnCall) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeTable(wasm::kWasmStmt);
module = builder.module();
@ -1764,7 +1762,7 @@ TEST_F(FunctionBodyDecoderTest, MultiReturnType) {
}
TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module();
@ -1780,7 +1778,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module();
@ -1797,7 +1795,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeTable(wasm::kWasmStmt);
module = builder.module();
@ -1820,7 +1818,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsWithMismatchedSigs3) {
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsWithoutTableCrash) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1835,7 +1833,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsWithoutTableCrash) {
}
TEST_F(FunctionBodyDecoderTest, IncompleteIndirectCall) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeTable(wasm::kWasmStmt);
module = builder.module();
@ -1845,7 +1843,7 @@ TEST_F(FunctionBodyDecoderTest, IncompleteIndirectCall) {
}
TEST_F(FunctionBodyDecoderTest, IncompleteStore) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeMemory();
builder.InitializeTable(wasm::kWasmStmt);
@ -1857,7 +1855,7 @@ TEST_F(FunctionBodyDecoderTest, IncompleteStore) {
TEST_F(FunctionBodyDecoderTest, IncompleteS8x16Shuffle) {
WASM_FEATURE_SCOPE(simd);
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
builder.InitializeMemory();
builder.InitializeTable(wasm::kWasmStmt);
@ -1869,7 +1867,7 @@ TEST_F(FunctionBodyDecoderTest, IncompleteS8x16Shuffle) {
}
TEST_F(FunctionBodyDecoderTest, SimpleImportCalls) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1884,7 +1882,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleImportCalls) {
}
TEST_F(FunctionBodyDecoderTest, ImportCallsWithMismatchedSigs3) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1904,7 +1902,7 @@ TEST_F(FunctionBodyDecoderTest, ImportCallsWithMismatchedSigs3) {
}
TEST_F(FunctionBodyDecoderTest, Int32Globals) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1916,7 +1914,7 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals) {
}
TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
FunctionSig* sig = sigs.v_v();
const FunctionSig* sig = sigs.v_v();
TestModuleBuilder builder;
module = builder.module();
@ -1928,7 +1926,7 @@ TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
}
TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
FunctionSig* sig = sigs.i_i();
const FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder;
module = builder.module();
@ -1949,7 +1947,7 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
}
TEST_F(FunctionBodyDecoderTest, Int64Globals) {
FunctionSig* sig = sigs.l_l();
const FunctionSig* sig = sigs.l_l();
TestModuleBuilder builder;
module = builder.module();
@ -1966,7 +1964,7 @@ TEST_F(FunctionBodyDecoderTest, Int64Globals) {
}
TEST_F(FunctionBodyDecoderTest, Float32Globals) {
FunctionSig* sig = sigs.f_ff();
const FunctionSig* sig = sigs.f_ff();
TestModuleBuilder builder;
module = builder.module();
@ -1978,7 +1976,7 @@ TEST_F(FunctionBodyDecoderTest, Float32Globals) {
}
TEST_F(FunctionBodyDecoderTest, Float64Globals) {
FunctionSig* sig = sigs.d_dd();
const FunctionSig* sig = sigs.d_dd();
TestModuleBuilder builder;
module = builder.module();
@ -2193,7 +2191,7 @@ TEST_F(FunctionBodyDecoderTest, AsmJsBinOpsCheckOrigin) {
FunctionSig sig_d_id(1, 2, float64int32float64);
struct {
WasmOpcode op;
FunctionSig* sig;
const FunctionSig* sig;
} AsmJsBinOps[] = {
{kExprF64Atan2, sigs.d_dd()},
{kExprF64Pow, sigs.d_dd()},
@ -2237,7 +2235,7 @@ TEST_F(FunctionBodyDecoderTest, AsmJsUnOpsCheckOrigin) {
FunctionSig sig_d_i(1, 1, float64int32);
struct {
WasmOpcode op;
FunctionSig* sig;
const FunctionSig* sig;
} AsmJsUnOps[] = {{kExprF64Acos, sigs.d_d()},
{kExprF64Asin, sigs.d_d()},
{kExprF64Atan, sigs.d_d()},
@ -2379,9 +2377,8 @@ TEST_F(FunctionBodyDecoderTest, BreakNesting_6_levels) {
}
TEST_F(FunctionBodyDecoderTest, Break_TypeCheck) {
FunctionSig* sigarray[] = {sigs.i_i(), sigs.l_l(), sigs.f_ff(), sigs.d_dd()};
for (size_t i = 0; i < arraysize(sigarray); i++) {
FunctionSig* sig = sigarray[i];
for (const FunctionSig* sig :
{sigs.i_i(), sigs.l_l(), sigs.f_ff(), sigs.d_dd()}) {
// unify X and X => OK
byte code[] = {WASM_BLOCK_T(
sig->GetReturn(), WASM_IF(WASM_ZERO, WASM_BRV(0, WASM_GET_LOCAL(0))),

View File

@ -1522,7 +1522,7 @@ class WasmSignatureDecodeTest : public TestWithZone {
public:
WasmFeatures enabled_features_ = WasmFeatures::None();
FunctionSig* DecodeSig(const byte* start, const byte* end) {
const FunctionSig* DecodeSig(const byte* start, const byte* end) {
return DecodeWasmSignatureForTesting(enabled_features_, zone(), start, end);
}
};
@ -1531,7 +1531,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_v) {
static const byte data[] = {SIG_ENTRY_v_v};
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(0u, sig->parameter_count());
@ -1543,7 +1543,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_v) {
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair ret_type = kValueTypes[i];
const byte data[] = {SIG_ENTRY_x(ret_type.code)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(0u, sig->parameter_count());
@ -1557,7 +1557,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_t) {
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueTypePair param_type = kValueTypes[i];
const byte data[] = {SIG_ENTRY_v_x(param_type.code)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(1u, sig->parameter_count());
@ -1573,7 +1573,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_t) {
for (size_t j = 0; j < arraysize(kValueTypes); j++) {
ValueTypePair param_type = kValueTypes[j];
const byte data[] = {SIG_ENTRY_x_x(ret_type.code, param_type.code)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(1u, sig->parameter_count());
@ -1593,7 +1593,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_i_tt) {
ValueTypePair p1_type = kValueTypes[j];
const byte data[] = {
SIG_ENTRY_x_xx(kLocalI32, p0_type.code, p1_type.code)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(2u, sig->parameter_count());
@ -1613,7 +1613,7 @@ TEST_F(WasmSignatureDecodeTest, Ok_tt_tt) {
ValueTypePair p1_type = kValueTypes[j];
const byte data[] = {SIG_ENTRY_xx_xx(p0_type.code, p1_type.code,
p0_type.code, p1_type.code)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_TRUE(sig != nullptr);
EXPECT_EQ(2u, sig->parameter_count());
@ -1630,7 +1630,7 @@ TEST_F(WasmSignatureDecodeTest, TooManyParams) {
static const byte data[] = {kWasmFunctionTypeCode,
WASM_I32V_3(kV8MaxWasmFunctionParams + 1),
kLocalI32, 0};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_FALSE(sig != nullptr);
}
@ -1642,7 +1642,7 @@ TEST_F(WasmSignatureDecodeTest, TooManyReturns) {
enable_mv ? kV8MaxWasmFunctionMultiReturns : kV8MaxWasmFunctionReturns);
byte data[] = {kWasmFunctionTypeCode, 0, WASM_I32V_3(max_return_count + 1),
kLocalI32};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
}
@ -1655,7 +1655,7 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) {
for (int i = 0; i < p + 1; i++) {
// Should fall off the end for all signatures.
FunctionSig* sig = DecodeSig(data, data + i);
const FunctionSig* sig = DecodeSig(data, data + i);
EXPECT_EQ(nullptr, sig);
}
}
@ -1670,7 +1670,7 @@ TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) {
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
if (i >= arraysize(data)) break;
data[i] = invalid_type;
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
}
@ -1682,26 +1682,26 @@ TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) {
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
if (i >= arraysize(data)) break;
data[i] = kInvalidType;
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
}
TEST_F(WasmSignatureDecodeTest, Fail_invalid_ret_type1) {
static const byte data[] = {SIG_ENTRY_x_x(kLocalVoid, kLocalI32)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type1) {
static const byte data[] = {SIG_ENTRY_x_x(kLocalI32, kLocalVoid)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type2) {
static const byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalVoid)};
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
const FunctionSig* sig = DecodeSig(data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}