[wasm][test] Compute more lengths automatically
Compute the length of more fields automatically, in particular names. This is the fifth CL in a series to improve our module decoder tests and make them more readable. R=titzer@chromium.org Bug: v8:8238 Change-Id: I1bd27f45380d82af2d7319f15ac7e37d5b9e4081 Reviewed-on: https://chromium-review.googlesource.com/c/1283077 Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Cr-Commit-Position: refs/heads/master@{#56721}
This commit is contained in:
parent
2d11ddab98
commit
5d0055fa6e
@ -22,7 +22,6 @@
|
|||||||
#define TABLE_INDEX(v) U32V_1(v)
|
#define TABLE_INDEX(v) U32V_1(v)
|
||||||
#define EXCEPTION_INDEX(v) U32V_1(v)
|
#define EXCEPTION_INDEX(v) U32V_1(v)
|
||||||
#define NO_NAME U32V_1(0)
|
#define NO_NAME U32V_1(0)
|
||||||
#define NAME_LENGTH(v) U32V_1(v)
|
|
||||||
#define ENTRY_COUNT(v) U32V_1(v)
|
#define ENTRY_COUNT(v) U32V_1(v)
|
||||||
|
|
||||||
#define ZERO_ALIGNMENT 0
|
#define ZERO_ALIGNMENT 0
|
||||||
|
@ -29,15 +29,12 @@ namespace module_decoder_unittest {
|
|||||||
#define WASM_INIT_EXPR_ANYREF WASM_REF_NULL, kExprEnd
|
#define WASM_INIT_EXPR_ANYREF WASM_REF_NULL, kExprEnd
|
||||||
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GET_GLOBAL(index), kExprEnd
|
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GET_GLOBAL(index), kExprEnd
|
||||||
|
|
||||||
#define SIZEOF_EMPTY_FUNCTION ((size_t)5)
|
|
||||||
#define EMPTY_BODY 0
|
#define EMPTY_BODY 0
|
||||||
#define SIZEOF_EMPTY_BODY ((size_t)1)
|
|
||||||
#define NOP_BODY 2, 0, kExprNop
|
#define NOP_BODY 2, 0, kExprNop
|
||||||
#define SIZEOF_NOP_BODY ((size_t)3)
|
|
||||||
|
|
||||||
#define SIG_ENTRY_i_i SIG_ENTRY_x_x(kLocalI32, kLocalI32)
|
#define SIG_ENTRY_i_i SIG_ENTRY_x_x(kLocalI32, kLocalI32)
|
||||||
|
|
||||||
#define UNKNOWN_SECTION(size) 0, U32V_1(size + 5), 4, 'l', 'u', 'l', 'z'
|
#define UNKNOWN_SECTION(size) 0, U32V_1(size + 5), ADD_COUNT('l', 'u', 'l', 'z')
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
std::integral_constant<size_t, sizeof...(Args)> CountArgsHelper(Args...);
|
std::integral_constant<size_t, sizeof...(Args)> CountArgsHelper(Args...);
|
||||||
@ -57,14 +54,14 @@ struct CheckLEB1 : std::integral_constant<size_t, num> {
|
|||||||
#define FUNCTION_SIGNATURES_SECTION(count, ...) \
|
#define FUNCTION_SIGNATURES_SECTION(count, ...) \
|
||||||
SECTION(Function, U32V_1(count), __VA_ARGS__)
|
SECTION(Function, U32V_1(count), __VA_ARGS__)
|
||||||
|
|
||||||
#define FOO_STRING 3, 'f', 'o', 'o'
|
#define FOO_STRING ADD_COUNT('f', 'o', 'o')
|
||||||
#define NO_LOCAL_NAMES 0
|
#define NO_LOCAL_NAMES 0
|
||||||
|
|
||||||
#define EMPTY_SIGNATURES_SECTION SECTION(Type, ENTRY_COUNT(0))
|
#define EMPTY_SIGNATURES_SECTION SECTION(Type, ENTRY_COUNT(0))
|
||||||
#define EMPTY_FUNCTION_SIGNATURES_SECTION SECTION(Function, ENTRY_COUNT(0))
|
#define EMPTY_FUNCTION_SIGNATURES_SECTION SECTION(Function, ENTRY_COUNT(0))
|
||||||
#define EMPTY_FUNCTION_BODIES_SECTION SECTION(Code, ENTRY_COUNT(0))
|
#define EMPTY_FUNCTION_BODIES_SECTION SECTION(Code, ENTRY_COUNT(0))
|
||||||
#define SECTION_NAMES(...) \
|
#define SECTION_NAMES(...) \
|
||||||
SECTION(Unknown, 4, 'n', 'a', 'm', 'e', ##__VA_ARGS__)
|
SECTION(Unknown, ADD_COUNT('n', 'a', 'm', 'e'), ##__VA_ARGS__)
|
||||||
#define EMPTY_NAMES_SECTION SECTION_NAMES()
|
#define EMPTY_NAMES_SECTION SECTION_NAMES()
|
||||||
|
|
||||||
#define FAIL_IF_NO_EXPERIMENTAL_EH(data) \
|
#define FAIL_IF_NO_EXPERIMENTAL_EH(data) \
|
||||||
@ -91,17 +88,16 @@ struct CheckLEB1 : std::integral_constant<size_t, num> {
|
|||||||
#define FOUR_EMPTY_FUNCTIONS(sig_index) \
|
#define FOUR_EMPTY_FUNCTIONS(sig_index) \
|
||||||
SECTION(Function, ENTRY_COUNT(4), X4(sig_index))
|
SECTION(Function, ENTRY_COUNT(4), X4(sig_index))
|
||||||
|
|
||||||
#define ONE_EMPTY_BODY \
|
#define ONE_EMPTY_BODY SECTION(Code, ENTRY_COUNT(1), X1(ADD_COUNT(EMPTY_BODY)))
|
||||||
SECTION(Code, ENTRY_COUNT(1), X1(SIZEOF_EMPTY_BODY, EMPTY_BODY))
|
|
||||||
|
|
||||||
#define TWO_EMPTY_BODIES \
|
#define TWO_EMPTY_BODIES \
|
||||||
SECTION(Code, ENTRY_COUNT(2), X2(SIZEOF_EMPTY_BODY, EMPTY_BODY))
|
SECTION(Code, ENTRY_COUNT(2), X2(ADD_COUNT(EMPTY_BODY)))
|
||||||
|
|
||||||
#define THREE_EMPTY_BODIES \
|
#define THREE_EMPTY_BODIES \
|
||||||
SECTION(Code, ENTRY_COUNT(3), X3(SIZEOF_EMPTY_BODY, EMPTY_BODY))
|
SECTION(Code, ENTRY_COUNT(3), X3(ADD_COUNT(EMPTY_BODY)))
|
||||||
|
|
||||||
#define FOUR_EMPTY_BODIES \
|
#define FOUR_EMPTY_BODIES \
|
||||||
SECTION(Code, ENTRY_COUNT(4), X4(SIZEOF_EMPTY_BODY, EMPTY_BODY))
|
SECTION(Code, ENTRY_COUNT(4), X4(ADD_COUNT(EMPTY_BODY)))
|
||||||
|
|
||||||
#define SIGNATURES_SECTION_VOID_VOID \
|
#define SIGNATURES_SECTION_VOID_VOID \
|
||||||
SECTION(Type, ENTRY_COUNT(1), SIG_ENTRY_v_v)
|
SECTION(Type, ENTRY_COUNT(1), SIG_ENTRY_v_v)
|
||||||
@ -283,10 +279,8 @@ TEST_F(WasmModuleVerifyTest, AnyRefGlobalWithGlobalInit) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Import, // --
|
SECTION(Import, // --
|
||||||
ENTRY_COUNT(1), // number of imports
|
ENTRY_COUNT(1), // number of imports
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'f', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalAnyRef, // type
|
kLocalAnyRef, // type
|
||||||
0), // mutability
|
0), // mutability
|
||||||
@ -347,39 +341,31 @@ TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {
|
|||||||
WASM_FEATURE_SCOPE(mut_global);
|
WASM_FEATURE_SCOPE(mut_global);
|
||||||
{
|
{
|
||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Global, // --
|
SECTION(Global, // --
|
||||||
ENTRY_COUNT(1), // --
|
ENTRY_COUNT(1), // --
|
||||||
kLocalI32, // local type
|
kLocalI32, // local type
|
||||||
0, // immutable
|
0, // immutable
|
||||||
WASM_INIT_EXPR_I32V_1(13)), // init
|
WASM_INIT_EXPR_I32V_1(13)), // init
|
||||||
SECTION(Export, // --
|
SECTION(Export, // --
|
||||||
ENTRY_COUNT(1), // export count
|
ENTRY_COUNT(1), // export count
|
||||||
4, // name length
|
ADD_COUNT('n', 'a', 'm', 'e'), // name
|
||||||
'n', // --
|
kExternalGlobal, // global
|
||||||
'a', // --
|
0), // global index
|
||||||
'm', // --
|
|
||||||
'e', // --
|
|
||||||
kExternalGlobal, // global
|
|
||||||
0), // global index
|
|
||||||
};
|
};
|
||||||
EXPECT_VERIFIES(data);
|
EXPECT_VERIFIES(data);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Global, // --
|
SECTION(Global, // --
|
||||||
ENTRY_COUNT(1), // --
|
ENTRY_COUNT(1), // --
|
||||||
kLocalI32, // local type
|
kLocalI32, // local type
|
||||||
1, // mutable
|
1, // mutable
|
||||||
WASM_INIT_EXPR_I32V_1(13)), // init
|
WASM_INIT_EXPR_I32V_1(13)), // init
|
||||||
SECTION(Export, // --
|
SECTION(Export, // --
|
||||||
ENTRY_COUNT(1), // export count
|
ENTRY_COUNT(1), // export count
|
||||||
4, // name length
|
ADD_COUNT('n', 'a', 'm', 'e'), // name
|
||||||
'n', // --
|
kExternalGlobal, // global
|
||||||
'a', // --
|
0), // global index
|
||||||
'm', // --
|
|
||||||
'e', // --
|
|
||||||
kExternalGlobal, // global
|
|
||||||
0), // global index
|
|
||||||
};
|
};
|
||||||
EXPECT_VERIFIES(data);
|
EXPECT_VERIFIES(data);
|
||||||
}
|
}
|
||||||
@ -572,15 +558,12 @@ TEST_F(WasmModuleVerifyTest, ExceptionSectionBeforeImport) {
|
|||||||
|
|
||||||
TEST_F(WasmModuleVerifyTest, ExceptionImport) {
|
TEST_F(WasmModuleVerifyTest, ExceptionImport) {
|
||||||
static const byte data[] = {SIGNATURES_SECTION_VOID_VOID,
|
static const byte data[] = {SIGNATURES_SECTION_VOID_VOID,
|
||||||
SECTION(Import, // section header
|
SECTION(Import, // section header
|
||||||
ENTRY_COUNT(1), // number of imports
|
ENTRY_COUNT(1), // number of imports
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('e', 'x'), // exception name
|
||||||
NAME_LENGTH(2), // --
|
kExternalException, // import kind
|
||||||
'e', // exception name
|
SIG_INDEX(0))}; // except[0] (sig#0)
|
||||||
'x', // --
|
|
||||||
kExternalException, // import kind
|
|
||||||
SIG_INDEX(0))}; // except[0] (sig#0)
|
|
||||||
FAIL_IF_NO_EXPERIMENTAL_EH(data);
|
FAIL_IF_NO_EXPERIMENTAL_EH(data);
|
||||||
|
|
||||||
WASM_FEATURE_SCOPE(eh);
|
WASM_FEATURE_SCOPE(eh);
|
||||||
@ -650,17 +633,13 @@ TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableImportedGlobal) {
|
|||||||
const byte data[] = {
|
const byte data[] = {
|
||||||
SECTION(Import, // section header
|
SECTION(Import, // section header
|
||||||
ENTRY_COUNT(2), // number of imports
|
ENTRY_COUNT(2), // number of imports
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'f', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
0, // mutability
|
0, // mutability
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('n'), // module name
|
||||||
'n', // module name
|
ADD_COUNT('g'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'g', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
0), // mutability
|
0), // mutability
|
||||||
@ -682,10 +661,8 @@ TEST_F(WasmModuleVerifyTest, DataSegmentWithMutableImportedGlobal) {
|
|||||||
const byte data[] = {
|
const byte data[] = {
|
||||||
SECTION(Import, // section header
|
SECTION(Import, // section header
|
||||||
ENTRY_COUNT(1), // number of imports
|
ENTRY_COUNT(1), // number of imports
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'f', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
1), // mutability
|
1), // mutability
|
||||||
@ -866,10 +843,8 @@ TEST_F(WasmModuleVerifyTest, ElementSectionWithImportedTable) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
// imports -------------------------------------------------------------
|
// imports -------------------------------------------------------------
|
||||||
SECTION(Import, ENTRY_COUNT(1),
|
SECTION(Import, ENTRY_COUNT(1),
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('t'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
't', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
@ -1014,18 +989,14 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTables) {
|
|||||||
SIGNATURES_SECTION_VOID_VOID,
|
SIGNATURES_SECTION_VOID_VOID,
|
||||||
// imports -------------------------------------------------------------
|
// imports -------------------------------------------------------------
|
||||||
SECTION(Import, ENTRY_COUNT(2),
|
SECTION(Import, ENTRY_COUNT(2),
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('t'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
't', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
5, // initial size
|
5, // initial size
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('s'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
's', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
@ -1105,18 +1076,14 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) {
|
|||||||
SIGNATURES_SECTION_VOID_VOID,
|
SIGNATURES_SECTION_VOID_VOID,
|
||||||
// imports -------------------------------------------------------------
|
// imports -------------------------------------------------------------
|
||||||
SECTION(Import, ENTRY_COUNT(2),
|
SECTION(Import, ENTRY_COUNT(2),
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('t'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
't', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
5, // initial size
|
5, // initial size
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('s'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
's', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
@ -1192,18 +1159,14 @@ TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefImportedTable) {
|
|||||||
SIGNATURES_SECTION_VOID_VOID,
|
SIGNATURES_SECTION_VOID_VOID,
|
||||||
// imports -------------------------------------------------------------
|
// imports -------------------------------------------------------------
|
||||||
SECTION(Import, ENTRY_COUNT(2),
|
SECTION(Import, ENTRY_COUNT(2),
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('t'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
't', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyFunc, // elem_type
|
kLocalAnyFunc, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
5, // initial size
|
5, // initial size
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('s'), // table name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
's', // table name
|
|
||||||
kExternalTable, // import kind
|
kExternalTable, // import kind
|
||||||
kLocalAnyRef, // elem_type
|
kLocalAnyRef, // elem_type
|
||||||
0, // no maximum field
|
0, // no maximum field
|
||||||
@ -1440,8 +1403,9 @@ TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) {
|
|||||||
WASM_FEATURE_SCOPE_VAL(anyref, false);
|
WASM_FEATURE_SCOPE_VAL(anyref, false);
|
||||||
byte ref_types[] = {kLocalAnyFunc, kLocalAnyRef};
|
byte ref_types[] = {kLocalAnyFunc, kLocalAnyRef};
|
||||||
for (byte invalid_type : ref_types) {
|
for (byte invalid_type : ref_types) {
|
||||||
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
|
for (size_t i = 0;; i++) {
|
||||||
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
|
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
|
||||||
|
if (i >= arraysize(data)) break;
|
||||||
data[i] = invalid_type;
|
data[i] = invalid_type;
|
||||||
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
|
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
|
||||||
EXPECT_EQ(nullptr, sig);
|
EXPECT_EQ(nullptr, sig);
|
||||||
@ -1451,8 +1415,9 @@ TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) {
|
|||||||
|
|
||||||
TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) {
|
TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) {
|
||||||
byte kInvalidType = 76;
|
byte kInvalidType = 76;
|
||||||
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
|
for (size_t i = 0;; i++) {
|
||||||
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
|
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
|
||||||
|
if (i >= arraysize(data)) break;
|
||||||
data[i] = kInvalidType;
|
data[i] = kInvalidType;
|
||||||
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
|
FunctionSig* sig = DecodeSig(data, data + sizeof(data));
|
||||||
EXPECT_EQ(nullptr, sig);
|
EXPECT_EQ(nullptr, sig);
|
||||||
@ -1516,8 +1481,7 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {
|
|||||||
WasmFunction* function = result.val.get();
|
WasmFunction* function = result.val.get();
|
||||||
EXPECT_EQ(0u, function->sig->parameter_count());
|
EXPECT_EQ(0u, function->sig->parameter_count());
|
||||||
EXPECT_EQ(0u, function->sig->return_count());
|
EXPECT_EQ(0u, function->sig->return_count());
|
||||||
EXPECT_EQ(static_cast<uint32_t>(SIZEOF_SIG_ENTRY_v_v),
|
EXPECT_EQ(COUNT_ARGS(SIG_ENTRY_v_v), function->code.offset());
|
||||||
function->code.offset());
|
|
||||||
EXPECT_EQ(sizeof(data), function->code.end_offset());
|
EXPECT_EQ(sizeof(data), function->code.end_offset());
|
||||||
// TODO(titzer): verify encoding of local declarations
|
// TODO(titzer): verify encoding of local declarations
|
||||||
}
|
}
|
||||||
@ -1643,10 +1607,8 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Import, // section header
|
SECTION(Import, // section header
|
||||||
ENTRY_COUNT(1), // number of imports
|
ENTRY_COUNT(1), // number of imports
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'f', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
0), // mutability
|
0), // mutability
|
||||||
@ -1657,10 +1619,8 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Import, // section header
|
SECTION(Import, // section header
|
||||||
ENTRY_COUNT(1), // sig table
|
ENTRY_COUNT(1), // sig table
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'f', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
1), // mutability
|
1), // mutability
|
||||||
@ -1674,10 +1634,8 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Import,
|
SECTION(Import,
|
||||||
ENTRY_COUNT(1), // --
|
ENTRY_COUNT(1), // --
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('g'), // global name
|
||||||
NAME_LENGTH(1), // --
|
|
||||||
'g', // global name
|
|
||||||
kExternalGlobal, // import kind
|
kExternalGlobal, // import kind
|
||||||
kLocalI32, // type
|
kLocalI32, // type
|
||||||
2), // invalid mutability
|
2), // invalid mutability
|
||||||
@ -1688,8 +1646,8 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) {
|
|||||||
TEST_F(WasmModuleVerifyTest, ImportTable_nosigs2) {
|
TEST_F(WasmModuleVerifyTest, ImportTable_nosigs2) {
|
||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Import, ENTRY_COUNT(1), // sig table
|
SECTION(Import, ENTRY_COUNT(1), // sig table
|
||||||
NAME_LENGTH(1), 'm', // module name
|
ADD_COUNT('m'), // module name
|
||||||
NAME_LENGTH(1), 'f', // function name
|
ADD_COUNT('f'), // function name
|
||||||
kExternalFunction, // import kind
|
kExternalFunction, // import kind
|
||||||
SIG_INDEX(0)), // sig index
|
SIG_INDEX(0)), // sig index
|
||||||
};
|
};
|
||||||
@ -1700,8 +1658,8 @@ TEST_F(WasmModuleVerifyTest, ImportTable_invalid_sig) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
SECTION(Type, ENTRY_COUNT(0)), // --
|
SECTION(Type, ENTRY_COUNT(0)), // --
|
||||||
SECTION(Import, ENTRY_COUNT(1), // --
|
SECTION(Import, ENTRY_COUNT(1), // --
|
||||||
NAME_LENGTH(1), 'm', // module name
|
ADD_COUNT('m'), // module name
|
||||||
NAME_LENGTH(1), 'f', // function name
|
ADD_COUNT('f'), // function name
|
||||||
kExternalFunction, // import kind
|
kExternalFunction, // import kind
|
||||||
SIG_INDEX(0)), // sig index
|
SIG_INDEX(0)), // sig index
|
||||||
};
|
};
|
||||||
@ -1713,11 +1671,9 @@ TEST_F(WasmModuleVerifyTest, ImportTable_one_sig) {
|
|||||||
// signatures
|
// signatures
|
||||||
SIGNATURES_SECTION_VOID_VOID,
|
SIGNATURES_SECTION_VOID_VOID,
|
||||||
SECTION(Import,
|
SECTION(Import,
|
||||||
ENTRY_COUNT(1), // --
|
ENTRY_COUNT(1), // --
|
||||||
NAME_LENGTH(1),
|
ADD_COUNT('m'), // module name
|
||||||
'm', // module name
|
ADD_COUNT('f'), // function name
|
||||||
NAME_LENGTH(1),
|
|
||||||
'f', // function name
|
|
||||||
kExternalFunction, // import kind
|
kExternalFunction, // import kind
|
||||||
SIG_INDEX(0)), // sig index
|
SIG_INDEX(0)), // sig index
|
||||||
};
|
};
|
||||||
@ -1731,8 +1687,7 @@ TEST_F(WasmModuleVerifyTest, ImportTable_invalid_module) {
|
|||||||
SECTION(Import, // --
|
SECTION(Import, // --
|
||||||
ENTRY_COUNT(1), // --
|
ENTRY_COUNT(1), // --
|
||||||
NO_NAME, // module name
|
NO_NAME, // module name
|
||||||
NAME_LENGTH(1), // --
|
ADD_COUNT('f'), // function name
|
||||||
'f', // function name
|
|
||||||
kExternalFunction, // import kind
|
kExternalFunction, // import kind
|
||||||
SIG_INDEX(0), // sig index
|
SIG_INDEX(0), // sig index
|
||||||
0), // auxiliary data
|
0), // auxiliary data
|
||||||
@ -1744,10 +1699,9 @@ TEST_F(WasmModuleVerifyTest, ImportTable_off_end) {
|
|||||||
static const byte data[] = {
|
static const byte data[] = {
|
||||||
// signatures
|
// signatures
|
||||||
SIGNATURES_SECTION_VOID_VOID,
|
SIGNATURES_SECTION_VOID_VOID,
|
||||||
SECTION(Import, ENTRY_COUNT(1), NAME_LENGTH(1),
|
SECTION(Import, ENTRY_COUNT(1),
|
||||||
'm', // module name
|
ADD_COUNT('m'), // module name
|
||||||
NAME_LENGTH(1),
|
ADD_COUNT('f'), // function name
|
||||||
'f', // function name
|
|
||||||
kExternalFunction), // import kind
|
kExternalFunction), // import kind
|
||||||
SIG_INDEX(0), // sig index (outside import section!)
|
SIG_INDEX(0), // sig index (outside import section!)
|
||||||
};
|
};
|
||||||
@ -1803,7 +1757,7 @@ TEST_F(WasmModuleVerifyTest, ExportNameWithInvalidStringLength) {
|
|||||||
SIGNATURES_SECTION_VOID_VOID, ONE_EMPTY_FUNCTION(SIG_INDEX(0)),
|
SIGNATURES_SECTION_VOID_VOID, ONE_EMPTY_FUNCTION(SIG_INDEX(0)),
|
||||||
SECTION(Export,
|
SECTION(Export,
|
||||||
ENTRY_COUNT(1), // exports
|
ENTRY_COUNT(1), // exports
|
||||||
NAME_LENGTH(84), // invalid string length
|
U32V_1(84), // invalid string length
|
||||||
'e', // --
|
'e', // --
|
||||||
kExternalFunction, // --
|
kExternalFunction, // --
|
||||||
FUNC_INDEX(0), // --
|
FUNC_INDEX(0), // --
|
||||||
@ -1818,13 +1772,13 @@ TEST_F(WasmModuleVerifyTest, ExportTableTwo) {
|
|||||||
// signatures
|
// signatures
|
||||||
SIGNATURES_SECTION_VOID_VOID, ONE_EMPTY_FUNCTION(SIG_INDEX(0)),
|
SIGNATURES_SECTION_VOID_VOID, ONE_EMPTY_FUNCTION(SIG_INDEX(0)),
|
||||||
SECTION(Export,
|
SECTION(Export,
|
||||||
ENTRY_COUNT(2), // exports
|
ENTRY_COUNT(2), // exports
|
||||||
NAME_LENGTH(4), 'n', 'a', 'm', 'e', // --
|
ADD_COUNT('n', 'a', 'm', 'e'), // --
|
||||||
kExternalFunction,
|
kExternalFunction,
|
||||||
FUNC_INDEX(0), // --
|
FUNC_INDEX(0), // --
|
||||||
NAME_LENGTH(3), 'n', 'o', 'm', // --
|
ADD_COUNT('n', 'o', 'm'), // --
|
||||||
kExternalFunction, // --
|
kExternalFunction, // --
|
||||||
FUNC_INDEX(0)), // --
|
FUNC_INDEX(0)), // --
|
||||||
ONE_EMPTY_BODY};
|
ONE_EMPTY_BODY};
|
||||||
|
|
||||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||||
@ -1840,16 +1794,13 @@ TEST_F(WasmModuleVerifyTest, ExportTableThree) {
|
|||||||
SIGNATURES_SECTION_VOID_VOID, THREE_EMPTY_FUNCTIONS(SIG_INDEX(0)),
|
SIGNATURES_SECTION_VOID_VOID, THREE_EMPTY_FUNCTIONS(SIG_INDEX(0)),
|
||||||
SECTION(Export,
|
SECTION(Export,
|
||||||
ENTRY_COUNT(3), // exports
|
ENTRY_COUNT(3), // exports
|
||||||
NAME_LENGTH(1),
|
ADD_COUNT('a'), // --
|
||||||
'a', // --
|
|
||||||
kExternalFunction,
|
kExternalFunction,
|
||||||
FUNC_INDEX(0), // --
|
FUNC_INDEX(0), // --
|
||||||
NAME_LENGTH(1),
|
ADD_COUNT('b'), // --
|
||||||
'b', // --
|
|
||||||
kExternalFunction,
|
kExternalFunction,
|
||||||
FUNC_INDEX(1), // --
|
FUNC_INDEX(1), // --
|
||||||
NAME_LENGTH(1),
|
ADD_COUNT('c'), // --
|
||||||
'c', // --
|
|
||||||
kExternalFunction,
|
kExternalFunction,
|
||||||
FUNC_INDEX(2)), // --
|
FUNC_INDEX(2)), // --
|
||||||
THREE_EMPTY_BODIES};
|
THREE_EMPTY_BODIES};
|
||||||
@ -1866,8 +1817,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableThreeOne) {
|
|||||||
// signatures
|
// signatures
|
||||||
SIGNATURES_SECTION_VOID_VOID, THREE_EMPTY_FUNCTIONS(SIG_INDEX(0)),
|
SIGNATURES_SECTION_VOID_VOID, THREE_EMPTY_FUNCTIONS(SIG_INDEX(0)),
|
||||||
SECTION(Export,
|
SECTION(Export,
|
||||||
ENTRY_COUNT(1), // exports
|
ENTRY_COUNT(1), // exports
|
||||||
NAME_LENGTH(2), 'e', 'x', // --
|
ADD_COUNT('e', 'x'), // --
|
||||||
kExternalFunction,
|
kExternalFunction,
|
||||||
FUNC_INDEX(i)), // --
|
FUNC_INDEX(i)), // --
|
||||||
THREE_EMPTY_BODIES};
|
THREE_EMPTY_BODIES};
|
||||||
@ -2263,11 +2214,8 @@ TEST_F(WasmModuleVerifyTest, MultipleNameSections) {
|
|||||||
#undef WASM_INIT_EXPR_F64
|
#undef WASM_INIT_EXPR_F64
|
||||||
#undef WASM_INIT_EXPR_ANYREF
|
#undef WASM_INIT_EXPR_ANYREF
|
||||||
#undef WASM_INIT_EXPR_GLOBAL
|
#undef WASM_INIT_EXPR_GLOBAL
|
||||||
#undef SIZEOF_EMPTY_FUNCTION
|
|
||||||
#undef EMPTY_BODY
|
#undef EMPTY_BODY
|
||||||
#undef SIZEOF_EMPTY_BODY
|
|
||||||
#undef NOP_BODY
|
#undef NOP_BODY
|
||||||
#undef SIZEOF_NOP_BODY
|
|
||||||
#undef SIG_ENTRY_i_i
|
#undef SIG_ENTRY_i_i
|
||||||
#undef UNKNOWN_SECTION
|
#undef UNKNOWN_SECTION
|
||||||
#undef COUNT_ARGS
|
#undef COUNT_ARGS
|
||||||
|
Loading…
Reference in New Issue
Block a user