Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "test/unittests/test-utils.h" | 5 #include "test/unittests/test-utils.h" |
| 6 | 6 |
| 7 #include "src/handles.h" | 7 #include "src/handles.h" |
| 8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
| 9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
| 10 #include "src/wasm/wasm-limits.h" | 10 #include "src/wasm/wasm-limits.h" |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 EXPECT_EQ(nullptr, sig); | 912 EXPECT_EQ(nullptr, sig); |
| 913 } | 913 } |
| 914 | 914 |
| 915 TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type2) { | 915 TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type2) { |
| 916 static const byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalVoid)}; | 916 static const byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalVoid)}; |
| 917 FunctionSig* sig = | 917 FunctionSig* sig = |
| 918 DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); | 918 DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); |
| 919 EXPECT_EQ(nullptr, sig); | 919 EXPECT_EQ(nullptr, sig); |
| 920 } | 920 } |
| 921 | 921 |
| 922 class WasmFunctionVerifyTest : public TestWithIsolateAndZone {}; | 922 class WasmFunctionVerifyTest : public TestWithIsolateAndZone { |
|
Karl
2017/03/28 01:53:16
Added class fields to implement a dummy instance o
| |
| 923 public: | |
| 924 WasmFunctionVerifyTest() | |
| 925 : instance(&module), env(&module, &instance, bytes) {} | |
| 926 virtual ~WasmFunctionVerifyTest() {} | |
| 927 | |
| 928 ModuleBytesEnv* get_env() { return &env; } | |
| 929 | |
| 930 private: | |
| 931 WasmModule module; | |
| 932 WasmInstance instance; | |
| 933 Vector<const byte> bytes; | |
| 934 ModuleBytesEnv env; | |
| 935 DISALLOW_COPY_AND_ASSIGN(WasmFunctionVerifyTest); | |
| 936 }; | |
| 923 | 937 |
| 924 TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { | 938 TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { |
| 925 static const byte data[] = { | 939 static const byte data[] = { |
| 926 SIG_ENTRY_v_v, // signature entry | 940 SIG_ENTRY_v_v, // signature entry |
| 927 4, // locals | 941 4, // locals |
| 928 3, | 942 3, |
| 929 kLocalI32, // -- | 943 kLocalI32, // -- |
| 930 4, | 944 4, |
| 931 kLocalI64, // -- | 945 kLocalI64, // -- |
| 932 5, | 946 5, |
| 933 kLocalF32, // -- | 947 kLocalF32, // -- |
| 934 6, | 948 6, |
| 935 kLocalF64, // -- | 949 kLocalF64, // -- |
| 936 kExprEnd // body | 950 kExprEnd // body |
| 937 }; | 951 }; |
| 938 | 952 |
| 939 FunctionResult result = | 953 FunctionResult result = DecodeWasmFunction(isolate(), zone(), get_env(), data, |
| 940 DecodeWasmFunction(isolate(), zone(), nullptr, data, data + sizeof(data)); | 954 data + sizeof(data)); |
| 941 EXPECT_OK(result); | 955 EXPECT_OK(result); |
| 942 | 956 |
| 943 if (result.val && result.ok()) { | 957 if (result.val && result.ok()) { |
| 944 WasmFunction* function = result.val; | 958 WasmFunction* function = result.val; |
| 945 EXPECT_EQ(0u, function->sig->parameter_count()); | 959 EXPECT_EQ(0u, function->sig->parameter_count()); |
| 946 EXPECT_EQ(0u, function->sig->return_count()); | 960 EXPECT_EQ(0u, function->sig->return_count()); |
| 947 EXPECT_EQ(0u, function->name_offset); | 961 EXPECT_EQ(0u, function->name_offset); |
| 948 EXPECT_EQ(static_cast<uint32_t>(SIZEOF_SIG_ENTRY_v_v), | 962 EXPECT_EQ(static_cast<uint32_t>(SIZEOF_SIG_ENTRY_v_v), |
| 949 function->code_start_offset); | 963 function->code_start_offset); |
| 950 EXPECT_EQ(sizeof(data), function->code_end_offset); | 964 EXPECT_EQ(sizeof(data), function->code_end_offset); |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1615 {19, 20, 1, 21, 2, 4}, // -- | 1629 {19, 20, 1, 21, 2, 4}, // -- |
| 1616 {29, 30, 5, 35, 2, 8}, // -- | 1630 {29, 30, 5, 35, 2, 8}, // -- |
| 1617 }; | 1631 }; |
| 1618 | 1632 |
| 1619 CheckSections(data, data + sizeof(data), expected, arraysize(expected)); | 1633 CheckSections(data, data + sizeof(data), expected, arraysize(expected)); |
| 1620 } | 1634 } |
| 1621 | 1635 |
| 1622 } // namespace wasm | 1636 } // namespace wasm |
| 1623 } // namespace internal | 1637 } // namespace internal |
| 1624 } // namespace v8 | 1638 } // namespace v8 |
| OLD | NEW |