Commit e2f94946 authored by titzer's avatar titzer Committed by Commit bot

[wasm] Remove the module environment and signature as arguments to OpcodeArity.

R=rossberg@chromium.org,ahaas@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1937083002
Cr-Commit-Position: refs/heads/master@{#35941}
parent 21f2c3ea
......@@ -287,21 +287,19 @@ class WasmDecoder : public Decoder {
case kExprCallFunction: {
CallFunctionOperand operand(this, pc);
return static_cast<int>(
module_->GetFunctionSignature(operand.index)->parameter_count());
return operand.arity;
}
case kExprCallIndirect: {
CallIndirectOperand operand(this, pc);
return 1 + static_cast<int>(
module_->GetSignature(operand.index)->parameter_count());
return 1 + operand.arity;
}
case kExprCallImport: {
CallImportOperand operand(this, pc);
return static_cast<int>(
module_->GetImportSignature(operand.index)->parameter_count());
return operand.arity;
}
case kExprReturn: {
return static_cast<int>(sig_->return_count());
ReturnArityOperand operand(this, pc);
return operand.arity;
}
#define DECLARE_OPCODE_CASE(name, opcode, sig) \
......@@ -1521,9 +1519,8 @@ int OpcodeLength(const byte* pc, const byte* end) {
return decoder.OpcodeLength(pc);
}
int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc,
const byte* end) {
WasmDecoder decoder(module, sig, pc, end);
int OpcodeArity(const byte* pc, const byte* end) {
WasmDecoder decoder(nullptr, nullptr, pc, end);
return decoder.OpcodeArity(pc);
}
......
......@@ -262,8 +262,8 @@ BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
int OpcodeLength(const byte* pc, const byte* end);
// Computes the arity (number of sub-nodes) of the opcode at the given address.
int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc,
const byte* end);
int OpcodeArity(const byte* pc, const byte* end);
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -2049,18 +2049,15 @@ TEST_F(WasmOpcodeLengthTest, SimpleExpressions) {
class WasmOpcodeArityTest : public TestWithZone {
public:
WasmOpcodeArityTest() : TestWithZone() {}
TestModuleEnv module;
TestSignatures sigs;
};
#define EXPECT_ARITY(expected, ...) \
{ \
static const byte code[] = {__VA_ARGS__}; \
EXPECT_EQ(expected, OpcodeArity(&module, sig, code, code + sizeof(code))); \
EXPECT_EQ(expected, OpcodeArity(code, code + sizeof(code))); \
}
TEST_F(WasmOpcodeArityTest, Control) {
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(0, kExprNop);
EXPECT_ARITY(0, kExprBlock, 0);
......@@ -2086,16 +2083,13 @@ TEST_F(WasmOpcodeArityTest, Control) {
EXPECT_ARITY(2, kExprBrTable, ARITY_1);
{
sig = sigs.v_v();
EXPECT_ARITY(0, kExprReturn, ARITY_0);
sig = sigs.i_i();
EXPECT_ARITY(1, kExprReturn, ARITY_1);
}
}
TEST_F(WasmOpcodeArityTest, Misc) {
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(0, kExprI8Const);
EXPECT_ARITY(0, kExprI32Const);
EXPECT_ARITY(0, kExprF32Const);
......@@ -2109,18 +2103,7 @@ TEST_F(WasmOpcodeArityTest, Misc) {
TEST_F(WasmOpcodeArityTest, Calls) {
module.AddFunction(sigs.i_ii());
module.AddFunction(sigs.i_i());
module.AddSignature(sigs.f_ff());
module.AddSignature(sigs.i_d());
module.AddImport(sigs.f_ff());
module.AddImport(sigs.i_d());
{
FunctionSig* sig = sigs.i_ii();
EXPECT_ARITY(2, kExprCallFunction, 2, 0);
EXPECT_ARITY(2, kExprCallImport, 2, 0);
EXPECT_ARITY(3, kExprCallIndirect, 2, 0);
......@@ -2135,8 +2118,6 @@ TEST_F(WasmOpcodeArityTest, Calls) {
}
{
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(1, kExprCallFunction, ARITY_1, 1);
EXPECT_ARITY(1, kExprCallImport, ARITY_1, 1);
EXPECT_ARITY(2, kExprCallIndirect, ARITY_1, 1);
......@@ -2153,7 +2134,6 @@ TEST_F(WasmOpcodeArityTest, Calls) {
TEST_F(WasmOpcodeArityTest, LoadsAndStores) {
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(1, kExprI32LoadMem8S);
EXPECT_ARITY(1, kExprI32LoadMem8U);
EXPECT_ARITY(1, kExprI32LoadMem16S);
......@@ -2183,14 +2163,12 @@ TEST_F(WasmOpcodeArityTest, LoadsAndStores) {
TEST_F(WasmOpcodeArityTest, MiscMemExpressions) {
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(0, kExprMemorySize);
EXPECT_ARITY(1, kExprGrowMemory);
}
TEST_F(WasmOpcodeArityTest, SimpleExpressions) {
FunctionSig* sig = sigs.v_v();
EXPECT_ARITY(2, kExprI32Add);
EXPECT_ARITY(2, kExprI32Sub);
EXPECT_ARITY(2, kExprI32Mul);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment