| 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-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // funcs ------------------------------------------------------ | 500 // funcs ------------------------------------------------------ |
| 501 ONE_EMPTY_FUNCTION, | 501 ONE_EMPTY_FUNCTION, |
| 502 // indirect table ---------------------------------------------- | 502 // indirect table ---------------------------------------------- |
| 503 SECTION(FUNCTION_TABLE, 2), 1, U32V_1(0)}; | 503 SECTION(FUNCTION_TABLE, 2), 1, U32V_1(0)}; |
| 504 | 504 |
| 505 ModuleResult result = DecodeModule(data, data + arraysize(data)); | 505 ModuleResult result = DecodeModule(data, data + arraysize(data)); |
| 506 EXPECT_OK(result); | 506 EXPECT_OK(result); |
| 507 if (result.ok()) { | 507 if (result.ok()) { |
| 508 EXPECT_EQ(1, result.val->signatures.size()); | 508 EXPECT_EQ(1, result.val->signatures.size()); |
| 509 EXPECT_EQ(1, result.val->functions.size()); | 509 EXPECT_EQ(1, result.val->functions.size()); |
| 510 EXPECT_EQ(1, result.val->function_table.size()); | 510 EXPECT_EQ(1, result.val->function_tables.size()); |
| 511 EXPECT_EQ(0, result.val->function_table[0]); | 511 EXPECT_EQ(1, result.val->function_tables[0].values.size()); |
| 512 EXPECT_EQ(0, result.val->function_tables[0].values[0]); |
| 512 } | 513 } |
| 513 if (result.val) delete result.val; | 514 if (result.val) delete result.val; |
| 514 } | 515 } |
| 515 | 516 |
| 516 TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) { | 517 TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) { |
| 517 static const byte data[] = { | 518 static const byte data[] = { |
| 518 // sig#0 ------------------------------------------------------- | 519 // sig#0 ------------------------------------------------------- |
| 519 SECTION(SIGNATURES, 1 + SIZEOF_SIG_ENTRY_v_v + SIZEOF_SIG_ENTRY_v_x), | 520 SECTION(SIGNATURES, 1 + SIZEOF_SIG_ENTRY_v_v + SIZEOF_SIG_ENTRY_v_x), |
| 520 2, // -- | 521 2, // -- |
| 521 SIG_ENTRY_v_v, // void -> void | 522 SIG_ENTRY_v_v, // void -> void |
| (...skipping 10 matching lines...) Expand all Loading... |
| 532 U32V_1(1), // -- | 533 U32V_1(1), // -- |
| 533 U32V_1(2), // -- | 534 U32V_1(2), // -- |
| 534 U32V_1(3), // -- | 535 U32V_1(3), // -- |
| 535 FOUR_EMPTY_BODIES}; | 536 FOUR_EMPTY_BODIES}; |
| 536 | 537 |
| 537 ModuleResult result = DecodeModule(data, data + arraysize(data)); | 538 ModuleResult result = DecodeModule(data, data + arraysize(data)); |
| 538 EXPECT_OK(result); | 539 EXPECT_OK(result); |
| 539 if (result.ok()) { | 540 if (result.ok()) { |
| 540 EXPECT_EQ(2, result.val->signatures.size()); | 541 EXPECT_EQ(2, result.val->signatures.size()); |
| 541 EXPECT_EQ(4, result.val->functions.size()); | 542 EXPECT_EQ(4, result.val->functions.size()); |
| 542 EXPECT_EQ(8, result.val->function_table.size()); | 543 EXPECT_EQ(1, result.val->function_tables.size()); |
| 544 EXPECT_EQ(8, result.val->function_tables[0].values.size()); |
| 543 for (int i = 0; i < 8; i++) { | 545 for (int i = 0; i < 8; i++) { |
| 544 EXPECT_EQ(i & 3, result.val->function_table[i]); | 546 EXPECT_EQ(i & 3, result.val->function_tables[0].values[i]); |
| 545 } | 547 } |
| 546 } | 548 } |
| 547 if (result.val) delete result.val; | 549 if (result.val) delete result.val; |
| 548 } | 550 } |
| 549 | 551 |
| 550 TEST_F(WasmModuleVerifyTest, IndirectFunctionNoFunctions) { | 552 TEST_F(WasmModuleVerifyTest, IndirectFunctionNoFunctions) { |
| 551 static const byte data[] = { | 553 static const byte data[] = { |
| 552 // sig#0 ------------------------------------------------------- | 554 // sig#0 ------------------------------------------------------- |
| 553 SIGNATURES_SECTION_VOID_VOID, | 555 SIGNATURES_SECTION_VOID_VOID, |
| 554 // indirect table ---------------------------------------------- | 556 // indirect table ---------------------------------------------- |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 NO_LOCAL_NAMES, // -- | 1204 NO_LOCAL_NAMES, // -- |
| 1203 FOO_STRING, | 1205 FOO_STRING, |
| 1204 NO_LOCAL_NAMES, // -- | 1206 NO_LOCAL_NAMES, // -- |
| 1205 }; | 1207 }; |
| 1206 EXPECT_VERIFIES(data); | 1208 EXPECT_VERIFIES(data); |
| 1207 } | 1209 } |
| 1208 | 1210 |
| 1209 } // namespace wasm | 1211 } // namespace wasm |
| 1210 } // namespace internal | 1212 } // namespace internal |
| 1211 } // namespace v8 | 1213 } // namespace v8 |
| OLD | NEW |