chromium/v8/test/unittests/wasm/module-decoder-unittest.cc

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/wasm/module-decoder.h"

#include "src/wasm/branch-hint-map.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-features.h"
#include "src/wasm/wasm-limits.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/common/wasm/flag-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"

HasSubstr;

namespace v8 {
namespace internal {
namespace wasm {
namespace module_decoder_unittest {

#define WASM_INIT_EXPR_I32V_1
#define WASM_INIT_EXPR_I32V_2
#define WASM_INIT_EXPR_I32V_3
#define WASM_INIT_EXPR_I32V_4
#define WASM_INIT_EXPR_I32V_5
#define WASM_INIT_EXPR_F32
#define WASM_INIT_EXPR_I64
#define WASM_INIT_EXPR_F64
#define WASM_INIT_EXPR_EXTERN_REF_NULL
#define WASM_INIT_EXPR_FUNC_REF_NULL
#define WASM_INIT_EXPR_REF_FUNC
#define WASM_INIT_EXPR_GLOBAL
#define WASM_INIT_EXPR_STRUCT_NEW(index, ...)
#define WASM_INIT_EXPR_ARRAY_NEW_FIXED(index, length, ...)

#define REF_NULL_ELEMENT
#define REF_FUNC_ELEMENT

#define EMPTY_BODY
#define NOP_BODY

#define SIG_ENTRY_i_i

#define UNKNOWN_SECTION
#define TYPE_SECTION
#define FUNCTION_SECTION

#define FOO_STRING
#define NO_LOCAL_NAMES

#define EMPTY_TYPE_SECTION
#define EMPTY_FUNCTION_SECTION
#define EMPTY_FUNCTION_BODIES_SECTION
#define SECTION_NAMES
#define EMPTY_NAMES_SECTION
#define SECTION_SRC_MAP
#define SECTION_COMPILATION_HINTS

#define SECTION_BRANCH_HINTS(...)

#define X1
#define X2
#define X3
#define X4

#define ONE_EMPTY_FUNCTION

#define TWO_EMPTY_FUNCTIONS

#define THREE_EMPTY_FUNCTIONS

#define FOUR_EMPTY_FUNCTIONS

#define ONE_EMPTY_BODY
#define TWO_EMPTY_BODIES
#define THREE_EMPTY_BODIES
#define FOUR_EMPTY_BODIES

#define TYPE_SECTION_ONE_SIG_VOID_VOID

#define LINEAR_MEMORY_INDEX_0

#define EXCEPTION_ENTRY

#define FIELD_COUNT
#define STRUCT_FIELD
#define WASM_REF
#define WASM_OPT_REF
#define WASM_STRUCT_DEF
#define WASM_ARRAY_DEF
#define WASM_FUNCTION_DEF

#define EXPECT_VERIFIES

#define EXPECT_FAILURE_LEN

#define EXPECT_FAILURE

#define EXPECT_FAILURE_WITH_MSG(data, msg)

#define EXPECT_OFF_END_FAILURE

#define EXPECT_OK

#define EXPECT_NOT_OK

static size_t SizeOfVarInt(size_t value) {}

struct ValueTypePair {} kValueTypes[] =;

class WasmModuleVerifyTest : public TestWithIsolateAndZone {};

TEST_F(WasmModuleVerifyTest, WrongMagic) {}

TEST_F(WasmModuleVerifyTest, WrongVersion) {}

TEST_F(WasmModuleVerifyTest, WrongSection) {}

TEST_F(WasmModuleVerifyTest, DecodeEmpty) {}

TEST_F(WasmModuleVerifyTest, OneGlobal) {}

TEST_F(WasmModuleVerifyTest, S128Global) {}

TEST_F(WasmModuleVerifyTest, ExternRefGlobal) {}

TEST_F(WasmModuleVerifyTest, FuncRefGlobal) {}

TEST_F(WasmModuleVerifyTest, InvalidFuncRefGlobal) {}

TEST_F(WasmModuleVerifyTest, ExternRefGlobalWithGlobalInit) {}

TEST_F(WasmModuleVerifyTest, NullGlobalWithGlobalInit) {}

TEST_F(WasmModuleVerifyTest, GlobalInvalidType) {}

TEST_F(WasmModuleVerifyTest, GlobalInvalidType2) {}

TEST_F(WasmModuleVerifyTest, GlobalInitializer) {}

TEST_F(WasmModuleVerifyTest, ZeroGlobals) {}

TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {}

static void AppendUint32v(std::vector<uint8_t>* buffer, uint32_t val) {}

TEST_F(WasmModuleVerifyTest, NGlobals) {}

TEST_F(WasmModuleVerifyTest, TwoGlobals) {}

TEST_F(WasmModuleVerifyTest, RefNullGlobal) {}

TEST_F(WasmModuleVerifyTest, RefNullGlobalInvalid1) {}

TEST_F(WasmModuleVerifyTest, RefNullGlobalInvalid2) {}

TEST_F(WasmModuleVerifyTest, StructNewInitExpr) {}

TEST_F(WasmModuleVerifyTest, ArrayNewFixedInitExpr) {}

TEST_F(WasmModuleVerifyTest, EmptyStruct) {}

TEST_F(WasmModuleVerifyTest, InvalidStructTypeDef) {}

TEST_F(WasmModuleVerifyTest, InvalidArrayTypeDef) {}

TEST_F(WasmModuleVerifyTest, TypeCanonicalization) {}

// Tests that all types in a rec. group are checked for supertype validity.
TEST_F(WasmModuleVerifyTest, InvalidSupertypeInRecGroup) {}

// Tests supertype declaration with 0 supertypes.
TEST_F(WasmModuleVerifyTest, SuperTypeDeclarationWith0Supertypes) {}

TEST_F(WasmModuleVerifyTest, NoSupertypeSupertype) {}

TEST_F(WasmModuleVerifyTest, NonSpecifiedFinalType) {}

TEST_F(WasmModuleVerifyTest, SpecifiedFinalType) {}

TEST_F(WasmModuleVerifyTest, ZeroExceptions) {}

TEST_F(WasmModuleVerifyTest, OneI32Exception) {}

TEST_F(WasmModuleVerifyTest, TwoExceptions) {}

TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_index) {}

TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_return) {}

TEST_F(WasmModuleVerifyTest, Exception_invalid_attribute) {}

TEST_F(WasmModuleVerifyTest, TagSectionCorrectPlacement) {}

TEST_F(WasmModuleVerifyTest, TagSectionAfterGlobal) {}

TEST_F(WasmModuleVerifyTest, TagSectionBeforeMemory) {}

TEST_F(WasmModuleVerifyTest, TagSectionAfterTableBeforeMemory) {}

TEST_F(WasmModuleVerifyTest, TagImport) {}

TEST_F(WasmModuleVerifyTest, ExceptionExport) {}

TEST_F(WasmModuleVerifyTest, OneSignature) {}

TEST_F(WasmModuleVerifyTest, MultipleSignatures) {}

TEST_F(WasmModuleVerifyTest, CanonicalTypeIds) {}

TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableImportedGlobal) {}

TEST_F(WasmModuleVerifyTest, DataSegmentWithMutableImportedGlobal) {}
TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableGlobal) {}

TEST_F(WasmModuleVerifyTest, OneDataSegment) {}

TEST_F(WasmModuleVerifyTest, TwoDataSegments) {}

TEST_F(WasmModuleVerifyTest, DataWithoutMemory) {}

TEST_F(WasmModuleVerifyTest, MaxMaximumMemorySize) {}

TEST_F(WasmModuleVerifyTest, InvalidMemoryLimits) {}

TEST_F(WasmModuleVerifyTest, DataSegment_wrong_init_type) {}

TEST_F(WasmModuleVerifyTest, DataSegmentEndOverflow) {}

TEST_F(WasmModuleVerifyTest, OneIndirectFunction) {}

TEST_F(WasmModuleVerifyTest, ElementSectionWithInternalTable) {}

TEST_F(WasmModuleVerifyTest, ElementSectionWithImportedTable) {}

TEST_F(WasmModuleVerifyTest, ElementSectionWithoutTable) {}

TEST_F(WasmModuleVerifyTest, Regression_735887) {}

TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) {}

TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) {}

TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTables) {}

TEST_F(WasmModuleVerifyTest, ElementSectionMixedTables) {}

TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTablesArbitraryOrder) {}

TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) {}

TEST_F(WasmModuleVerifyTest, ElementSectionInitExternRefTableWithFuncRef) {}

TEST_F(WasmModuleVerifyTest, ElementSectionIndexElementsTableWithNarrowType) {}

TEST_F(WasmModuleVerifyTest, ElementSectionInitFuncRefTableWithFuncRefNull) {}

TEST_F(WasmModuleVerifyTest, ElementSectionInitFuncRefTableWithExternRefNull) {}

TEST_F(WasmModuleVerifyTest, ElementSectionDontInitExternRefImportedTable) {}

TEST_F(WasmModuleVerifyTest, ElementSectionGlobalGetOutOfBounds) {}

TEST_F(WasmModuleVerifyTest, ExtendedConstantsI32) {}

TEST_F(WasmModuleVerifyTest, ExtendedConstantsI64) {}

TEST_F(WasmModuleVerifyTest, ExtendedConstantsTypeError) {}

TEST_F(WasmModuleVerifyTest, IndirectFunctionNoFunctions) {}

TEST_F(WasmModuleVerifyTest, IndirectFunctionInvalidIndex) {}

TEST_F(WasmModuleVerifyTest, MultipleTables) {}

TEST_F(WasmModuleVerifyTest, TypedFunctionTable) {}

TEST_F(WasmModuleVerifyTest, NullableTableIllegalInitializer) {}

TEST_F(WasmModuleVerifyTest, IllegalTableTypes) {}

TEST_F(WasmModuleVerifyTest, TableWithInitializer) {}

TEST_F(WasmModuleVerifyTest, NonNullableTable) {}

TEST_F(WasmModuleVerifyTest, NonNullableTableNoInitializer) {}

TEST_F(WasmModuleVerifyTest, TieringCompilationHints) {}

TEST_F(WasmModuleVerifyTest, BranchHinting) {}

class WasmSignatureDecodeTest : public TestWithZone {};

TEST_F(WasmSignatureDecodeTest, Ok_v_v) {}

TEST_F(WasmSignatureDecodeTest, Ok_t_v) {}

TEST_F(WasmSignatureDecodeTest, Ok_v_t) {}

TEST_F(WasmSignatureDecodeTest, Ok_t_t) {}

TEST_F(WasmSignatureDecodeTest, Ok_i_tt) {}

TEST_F(WasmSignatureDecodeTest, Ok_tt_tt) {}

TEST_F(WasmSignatureDecodeTest, Simd) {}

TEST_F(WasmSignatureDecodeTest, TooManyParams) {}

TEST_F(WasmSignatureDecodeTest, TooManyReturns) {}

TEST_F(WasmSignatureDecodeTest, Fail_off_end) {}

TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) {}

TEST_F(WasmSignatureDecodeTest, Fail_invalid_ret_type1) {}

TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type1) {}

TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type2) {}

class WasmFunctionVerifyTest : public TestWithIsolateAndZone {};

TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {}

TEST_F(WasmModuleVerifyTest, SectionWithoutNameLength) {}

TEST_F(WasmModuleVerifyTest, EmptyCustomSectionIsInvalid) {}

TEST_F(WasmModuleVerifyTest, TheLoneliestOfValidModulesTheTrulyEmptyOne) {}

TEST_F(WasmModuleVerifyTest, OnlyUnknownSectionEmpty) {}

TEST_F(WasmModuleVerifyTest, OnlyUnknownSectionNonEmpty) {}

TEST_F(WasmModuleVerifyTest, SignatureFollowedByEmptyUnknownSection) {}

TEST_F(WasmModuleVerifyTest, SignatureFollowedByUnknownSection) {}

TEST_F(WasmModuleVerifyTest, UnknownSectionOverflow) {}

TEST_F(WasmModuleVerifyTest, UnknownSectionUnderflow) {}

TEST_F(WasmModuleVerifyTest, UnknownSectionSkipped) {}

TEST_F(WasmModuleVerifyTest, ImportTable_empty) {}

TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) {}

TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {}

TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) {}

TEST_F(WasmModuleVerifyTest, ImportTable_nosigs2) {}

TEST_F(WasmModuleVerifyTest, ImportTable_invalid_sig) {}

TEST_F(WasmModuleVerifyTest, ImportTable_one_sig) {}

TEST_F(WasmModuleVerifyTest, ImportTable_invalid_module) {}

TEST_F(WasmModuleVerifyTest, ImportTable_off_end) {}

TEST_F(WasmModuleVerifyTest, ExportTable_empty1) {}

TEST_F(WasmModuleVerifyTest, ExportTable_empty2) {}

TEST_F(WasmModuleVerifyTest, ExportTable_NoFunctions2) {}

TEST_F(WasmModuleVerifyTest, ExportTableOne) {}

TEST_F(WasmModuleVerifyTest, ExportNameWithInvalidStringLength) {}

TEST_F(WasmModuleVerifyTest, ExportTableTwo) {}

TEST_F(WasmModuleVerifyTest, ExportTableThree) {}

TEST_F(WasmModuleVerifyTest, ExportTableThreeOne) {}

TEST_F(WasmModuleVerifyTest, ExportTableOne_off_end) {}

TEST_F(WasmModuleVerifyTest, Regression_648070) {}

TEST_F(WasmModuleVerifyTest, Regression_738097) {}

TEST_F(WasmModuleVerifyTest, FunctionBodySizeLimit) {}

TEST_F(WasmModuleVerifyTest, IllegalTypeCode) {}

TEST_F(WasmModuleVerifyTest, FunctionBodies_empty) {}

TEST_F(WasmModuleVerifyTest, FunctionBodies_one_empty) {}

TEST_F(WasmModuleVerifyTest, FunctionBodies_one_nop) {}

TEST_F(WasmModuleVerifyTest, FunctionBodies_count_mismatch1) {}

TEST_F(WasmModuleVerifyTest, FunctionBodies_count_mismatch2) {}

TEST_F(WasmModuleVerifyTest, Names_empty) {}

TEST_F(WasmModuleVerifyTest, Names_one_empty) {}

TEST_F(WasmModuleVerifyTest, Names_two_empty) {}

TEST_F(WasmModuleVerifyTest, Regression684855) {}

TEST_F(WasmModuleVerifyTest, FunctionSectionWithoutCodeSection) {}

TEST_F(WasmModuleVerifyTest, CodeSectionWithoutFunctionSection) {}

TEST_F(WasmModuleVerifyTest, EmptyFunctionSectionWithoutCodeSection) {}

TEST_F(WasmModuleVerifyTest, DoubleNonEmptyFunctionSection) {}

TEST_F(WasmModuleVerifyTest, EmptyCodeSectionWithoutFunctionSection) {}

// TODO(manoskouk): Reintroduce tests deleted in
// https://chromium-review.googlesource.com/c/v8/v8/+/2972910 in some other
// form.

TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) {}

TEST_F(WasmModuleVerifyTest, Section_Name_No_UTF8) {}

class WasmModuleCustomSectionTest : public TestWithIsolateAndZone {};

TEST_F(WasmModuleCustomSectionTest, ThreeUnknownSections) {}

TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) {}

TEST_F(WasmModuleVerifyTest, SourceMappingURLSection) {}

TEST_F(WasmModuleVerifyTest, BadSourceMappingURLSection) {}

TEST_F(WasmModuleVerifyTest, MultipleSourceMappingURLSections) {}

TEST_F(WasmModuleVerifyTest, MultipleNameSections) {}

TEST_F(WasmModuleVerifyTest, BadNameSection) {}

TEST_F(WasmModuleVerifyTest, PassiveDataSegment) {}

TEST_F(WasmModuleVerifyTest, ActiveElementSegmentWithElements) {}

TEST_F(WasmModuleVerifyTest, Table64ActiveElementSegmentWithElements) {}

TEST_F(WasmModuleVerifyTest, PassiveElementSegment) {}

TEST_F(WasmModuleVerifyTest, PassiveElementSegmentExternRef) {}

TEST_F(WasmModuleVerifyTest, PassiveElementSegmentWithIndices) {}

TEST_F(WasmModuleVerifyTest, DeclarativeElementSegmentFuncRef) {}

TEST_F(WasmModuleVerifyTest, DeclarativeElementSegmentWithInvalidIndex) {}

TEST_F(WasmModuleVerifyTest, DataCountSectionCorrectPlacement) {}

TEST_F(WasmModuleVerifyTest, DataCountSectionAfterCode) {}

TEST_F(WasmModuleVerifyTest, DataCountSectionBeforeElement) {}

TEST_F(WasmModuleVerifyTest, DataCountSectionAfterStartBeforeElement) {}

TEST_F(WasmModuleVerifyTest, MultipleDataCountSections) {}

TEST_F(WasmModuleVerifyTest, DataCountSegmentCountMatch) {}

TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_greater) {}

TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_less) {}

TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_omitted) {}

TEST_F(WasmModuleVerifyTest, GcStructIdsPass) {}

TEST_F(WasmModuleVerifyTest, OutOfBoundsTypeInGlobal) {}

TEST_F(WasmModuleVerifyTest, OutOfBoundsTypeInType) {}

TEST_F(WasmModuleVerifyTest, RecursiveTypeOutsideRecursiveGroup) {}

TEST_F(WasmModuleVerifyTest, OutOfBoundsSupertype) {}

TEST_F(WasmModuleVerifyTest, ForwardSupertypeSameType) {}

TEST_F(WasmModuleVerifyTest, ForwardSupertypeSameRecGroup) {}

TEST_F(WasmModuleVerifyTest, IllegalPackedFields) {}

TEST_F(WasmModuleVerifyTest, Memory64DataSegment) {}

TEST_F(WasmModuleVerifyTest, InvalidSharedType) {}

TEST_F(WasmModuleVerifyTest, InvalidSharedGlobal) {}

#undef EXPECT_INIT_EXPR
#undef EXPECT_INIT_EXPR_FAIL
#undef WASM_INIT_EXPR_I32V_1
#undef WASM_INIT_EXPR_I32V_2
#undef WASM_INIT_EXPR_I32V_3
#undef WASM_INIT_EXPR_I32V_4
#undef WASM_INIT_EXPR_I32V_5
#undef WASM_INIT_EXPR_F32
#undef WASM_INIT_EXPR_I64
#undef WASM_INIT_EXPR_F64
#undef WASM_INIT_EXPR_EXTERN_REF_NULL
#undef WASM_INIT_EXPR_FUNC_REF_NULL
#undef WASM_INIT_EXPR_REF_FUNC
#undef WASM_INIT_EXPR_GLOBAL
#undef REF_NULL_ELEMENT
#undef REF_FUNC_ELEMENT
#undef EMPTY_BODY
#undef NOP_BODY
#undef SIG_ENTRY_i_i
#undef UNKNOWN_SECTION
#undef ADD_COUNT
#undef SECTION
#undef TYPE_SECTION
#undef FUNCTION_SECTION
#undef FOO_STRING
#undef NO_LOCAL_NAMES
#undef EMPTY_TYPE_SECTION
#undef EMPTY_FUNCTION_SECTION
#undef EMPTY_FUNCTION_BODIES_SECTION
#undef SECTION_NAMES
#undef EMPTY_NAMES_SECTION
#undef SECTION_SRC_MAP
#undef SECTION_COMPILATION_HINTS
#undef X1
#undef X2
#undef X3
#undef X4
#undef ONE_EMPTY_FUNCTION
#undef TWO_EMPTY_FUNCTIONS
#undef THREE_EMPTY_FUNCTIONS
#undef FOUR_EMPTY_FUNCTIONS
#undef ONE_EMPTY_BODY
#undef TWO_EMPTY_BODIES
#undef THREE_EMPTY_BODIES
#undef FOUR_EMPTY_BODIES
#undef TYPE_SECTION_ONE_SIG_VOID_VOID
#undef LINEAR_MEMORY_INDEX_0

#undef FIELD_COUNT
#undef STRUCT_FIELD
#undef WASM_REF
#undef WASM_OPT_REF
#undef WASM_STRUCT_DEF
#undef WASM_ARRAY_DEF
#undef WASM_FUNCTION_DEF
#undef EXCEPTION_ENTRY
#undef EXPECT_VERIFIES
#undef EXPECT_FAILURE_LEN
#undef EXPECT_FAILURE
#undef EXPECT_OFF_END_FAILURE
#undef EXPECT_OK
#undef EXPECT_NOT_OK

}  // namespace module_decoder_unittest
}  // namespace wasm
}  // namespace internal
}  // namespace v8