| 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/wasm/module-decoder.h" | 7 #include "src/wasm/module-decoder.h" |
| 8 #include "src/wasm/wasm-macro-gen.h" | 8 #include "src/wasm/wasm-macro-gen.h" |
| 9 #include "src/wasm/wasm-opcodes.h" | 9 #include "src/wasm/wasm-opcodes.h" |
| 10 | 10 |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 } | 896 } |
| 897 } | 897 } |
| 898 | 898 |
| 899 | 899 |
| 900 class WasmFunctionVerifyTest : public TestWithZone {}; | 900 class WasmFunctionVerifyTest : public TestWithZone {}; |
| 901 | 901 |
| 902 | 902 |
| 903 TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { | 903 TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { |
| 904 static const byte data[] = { | 904 static const byte data[] = { |
| 905 0, kLocalVoid, // signature | 905 0, kLocalVoid, // signature |
| 906 3, 0, // local int32 count | 906 4, // locals |
| 907 4, 0, // local int64 count | 907 3, kLocalI32, // -- |
| 908 5, 0, // local float32 count | 908 4, kLocalI64, // -- |
| 909 6, 0, // local float64 count | 909 5, kLocalF32, // -- |
| 910 6, kLocalF64, // -- |
| 910 kExprNop // body | 911 kExprNop // body |
| 911 }; | 912 }; |
| 912 | 913 |
| 913 FunctionResult result = DecodeWasmFunction(nullptr, zone(), nullptr, data, | 914 FunctionResult result = DecodeWasmFunction(nullptr, zone(), nullptr, data, |
| 914 data + arraysize(data)); | 915 data + arraysize(data)); |
| 915 EXPECT_TRUE(result.ok()); | 916 EXPECT_TRUE(result.ok()); |
| 916 | 917 |
| 917 if (result.val && result.ok()) { | 918 if (result.val && result.ok()) { |
| 918 WasmFunction* function = result.val; | 919 WasmFunction* function = result.val; |
| 919 EXPECT_EQ(0, function->sig->parameter_count()); | 920 EXPECT_EQ(0, function->sig->parameter_count()); |
| 920 EXPECT_EQ(0, function->sig->return_count()); | 921 EXPECT_EQ(0, function->sig->return_count()); |
| 921 EXPECT_EQ(0, function->name_offset); | 922 EXPECT_EQ(0, function->name_offset); |
| 922 EXPECT_EQ(arraysize(data) - 1, function->code_start_offset); | 923 EXPECT_EQ(2, function->code_start_offset); |
| 923 EXPECT_EQ(arraysize(data), function->code_end_offset); | 924 EXPECT_EQ(arraysize(data), function->code_end_offset); |
| 924 EXPECT_EQ(3, function->local_i32_count); | 925 // TODO(titzer): verify encoding of local declarations |
| 925 EXPECT_EQ(4, function->local_i64_count); | |
| 926 EXPECT_EQ(5, function->local_f32_count); | |
| 927 EXPECT_EQ(6, function->local_f64_count); | |
| 928 EXPECT_FALSE(function->external); | 926 EXPECT_FALSE(function->external); |
| 929 EXPECT_FALSE(function->exported); | 927 EXPECT_FALSE(function->exported); |
| 930 } | 928 } |
| 931 | 929 |
| 932 if (result.val) delete result.val; | 930 if (result.val) delete result.val; |
| 933 } | 931 } |
| 934 | 932 |
| 935 | 933 |
| 936 TEST_F(WasmModuleVerifyTest, WLLSectionNoLen) { | 934 TEST_F(WasmModuleVerifyTest, WLLSectionNoLen) { |
| 937 const byte data[] = { | 935 const byte data[] = { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 for (int length = 13; length < sizeof(data); length++) { | 1145 for (int length = 13; length < sizeof(data); length++) { |
| 1148 ModuleResult result = DecodeModule(data, data + length); | 1146 ModuleResult result = DecodeModule(data, data + length); |
| 1149 EXPECT_FALSE(result.ok()); | 1147 EXPECT_FALSE(result.ok()); |
| 1150 if (result.val) delete result.val; | 1148 if (result.val) delete result.val; |
| 1151 } | 1149 } |
| 1152 } | 1150 } |
| 1153 | 1151 |
| 1154 } // namespace wasm | 1152 } // namespace wasm |
| 1155 } // namespace internal | 1153 } // namespace internal |
| 1156 } // namespace v8 | 1154 } // namespace v8 |
| OLD | NEW |