Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: test/unittests/wasm/module-decoder-unittest.cc

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/wasm/loop-assignment-analysis-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 TEST_F(WasmModuleVerifyTest, UnknownSectionNoLen) { 933 TEST_F(WasmModuleVerifyTest, UnknownSectionNoLen) {
936 const byte data[] = { 934 const byte data[] = {
937 kMaxModuleSectionCode, // unknown section without length. 935 kMaxModuleSectionCode, // unknown section without length.
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 for (int length = 13; length < sizeof(data); length++) { 1205 for (int length = 13; length < sizeof(data); length++) {
1208 ModuleResult result = DecodeModule(data, data + length); 1206 ModuleResult result = DecodeModule(data, data + length);
1209 EXPECT_FALSE(result.ok()); 1207 EXPECT_FALSE(result.ok());
1210 if (result.val) delete result.val; 1208 if (result.val) delete result.val;
1211 } 1209 }
1212 } 1210 }
1213 1211
1214 } // namespace wasm 1212 } // namespace wasm
1215 } // namespace internal 1213 } // namespace internal
1216 } // namespace v8 1214 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/wasm/loop-assignment-analysis-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698