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

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

Issue 2454503005: [wasm] Support for restricted table imports. (Closed)
Patch Set: Fix GC stress issue; tables weren't being reset correctly Created 4 years, 1 month 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/mjsunit/wasm/wasm-module-builder.js ('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/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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 ONE_EMPTY_FUNCTION, 503 ONE_EMPTY_FUNCTION,
504 // table declaration --------------------------------------------------- 504 // table declaration ---------------------------------------------------
505 SECTION(Table, 4), ENTRY_COUNT(1), kWasmAnyFunctionTypeForm, 0, 1}; 505 SECTION(Table, 4), ENTRY_COUNT(1), kWasmAnyFunctionTypeForm, 0, 1};
506 506
507 ModuleResult result = DecodeModule(data, data + sizeof(data)); 507 ModuleResult result = DecodeModule(data, data + sizeof(data));
508 EXPECT_OK(result); 508 EXPECT_OK(result);
509 if (result.ok()) { 509 if (result.ok()) {
510 EXPECT_EQ(1, result.val->signatures.size()); 510 EXPECT_EQ(1, result.val->signatures.size());
511 EXPECT_EQ(1, result.val->functions.size()); 511 EXPECT_EQ(1, result.val->functions.size());
512 EXPECT_EQ(1, result.val->function_tables.size()); 512 EXPECT_EQ(1, result.val->function_tables.size());
513 EXPECT_EQ(1, result.val->function_tables[0].values.size()); 513 EXPECT_EQ(1, result.val->function_tables[0].min_size);
514 EXPECT_EQ(-1, result.val->function_tables[0].values[0]);
515 } 514 }
516 if (result.val) delete result.val; 515 if (result.val) delete result.val;
517 } 516 }
518 517
519 TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) { 518 TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) {
520 static const byte data[] = { 519 static const byte data[] = {
521 // sig#0 --------------------------------------------------------------- 520 // sig#0 ---------------------------------------------------------------
522 SIGNATURES_SECTION_VOID_VOID, 521 SIGNATURES_SECTION_VOID_VOID,
523 // funcs --------------------------------------------------------------- 522 // funcs ---------------------------------------------------------------
524 ONE_EMPTY_FUNCTION, 523 ONE_EMPTY_FUNCTION,
525 // table declaration --------------------------------------------------- 524 // table declaration ---------------------------------------------------
526 SECTION(Table, 4), ENTRY_COUNT(1), kWasmAnyFunctionTypeForm, 0, 1, 525 SECTION(Table, 4), ENTRY_COUNT(1), kWasmAnyFunctionTypeForm, 0, 1,
527 // elements ------------------------------------------------------------ 526 // elements ------------------------------------------------------------
528 SECTION(Element, 7), 527 SECTION(Element, 7),
529 1, // entry count 528 1, // entry count
530 TABLE_INDEX(0), WASM_INIT_EXPR_I32V_1(0), 529 TABLE_INDEX(0), WASM_INIT_EXPR_I32V_1(0),
531 1, // elements count 530 1, // elements count
532 FUNC_INDEX(0)}; 531 FUNC_INDEX(0)};
533 532
534 ModuleResult result = DecodeModule(data, data + sizeof(data)); 533 ModuleResult result = DecodeModule(data, data + sizeof(data));
535 EXPECT_OK(result); 534 EXPECT_OK(result);
536 if (result.ok()) { 535 if (result.ok()) {
537 EXPECT_EQ(1, result.val->signatures.size()); 536 EXPECT_EQ(1, result.val->signatures.size());
538 EXPECT_EQ(1, result.val->functions.size()); 537 EXPECT_EQ(1, result.val->functions.size());
539 EXPECT_EQ(1, result.val->function_tables.size()); 538 EXPECT_EQ(1, result.val->function_tables.size());
540 EXPECT_EQ(1, result.val->function_tables[0].values.size()); 539 EXPECT_EQ(1, result.val->function_tables[0].min_size);
541 EXPECT_EQ(0, result.val->function_tables[0].values[0]);
542 } 540 }
543 if (result.val) delete result.val; 541 if (result.val) delete result.val;
544 } 542 }
545 543
546 TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) { 544 TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) {
547 static const byte data[] = { 545 static const byte data[] = {
548 // sig#0 ------------------------------------------------------- 546 // sig#0 -------------------------------------------------------
549 SECTION(Type, 1 + SIZEOF_SIG_ENTRY_v_v + SIZEOF_SIG_ENTRY_v_x), 547 SECTION(Type, 1 + SIZEOF_SIG_ENTRY_v_v + SIZEOF_SIG_ENTRY_v_x),
550 2, // -- 548 2, // --
551 SIG_ENTRY_v_v, // void -> void 549 SIG_ENTRY_v_v, // void -> void
(...skipping 16 matching lines...) Expand all
568 FUNC_INDEX(2), // -- 566 FUNC_INDEX(2), // --
569 FUNC_INDEX(3), // -- 567 FUNC_INDEX(3), // --
570 FOUR_EMPTY_BODIES}; 568 FOUR_EMPTY_BODIES};
571 569
572 ModuleResult result = DecodeModule(data, data + sizeof(data)); 570 ModuleResult result = DecodeModule(data, data + sizeof(data));
573 EXPECT_OK(result); 571 EXPECT_OK(result);
574 if (result.ok()) { 572 if (result.ok()) {
575 EXPECT_EQ(2, result.val->signatures.size()); 573 EXPECT_EQ(2, result.val->signatures.size());
576 EXPECT_EQ(4, result.val->functions.size()); 574 EXPECT_EQ(4, result.val->functions.size());
577 EXPECT_EQ(1, result.val->function_tables.size()); 575 EXPECT_EQ(1, result.val->function_tables.size());
578 EXPECT_EQ(8, result.val->function_tables[0].values.size()); 576 EXPECT_EQ(8, result.val->function_tables[0].min_size);
579 for (int i = 0; i < 8; i++) {
580 EXPECT_EQ(i & 3, result.val->function_tables[0].values[i]);
581 }
582 } 577 }
583 if (result.val) delete result.val; 578 if (result.val) delete result.val;
584 } 579 }
585 580
586 TEST_F(WasmModuleVerifyTest, IndirectFunctionNoFunctions) { 581 TEST_F(WasmModuleVerifyTest, IndirectFunctionNoFunctions) {
587 static const byte data[] = { 582 static const byte data[] = {
588 // sig#0 ------------------------------------------------------- 583 // sig#0 -------------------------------------------------------
589 SIGNATURES_SECTION_VOID_VOID, 584 SIGNATURES_SECTION_VOID_VOID,
590 // indirect table ---------------------------------------------- 585 // indirect table ----------------------------------------------
591 SECTION(Table, 4), ENTRY_COUNT(1), 1, 0, 0, 586 SECTION(Table, 4), ENTRY_COUNT(1), 1, 0, 0,
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 SECTION(Unknown, 4), 1, 'X', 17, 18, // -- 1287 SECTION(Unknown, 4), 1, 'X', 17, 18, // --
1293 SECTION(Unknown, 9), 3, 'f', 'o', 'o', 5, 6, 7, 8, 9, // -- 1288 SECTION(Unknown, 9), 3, 'f', 'o', 'o', 5, 6, 7, 8, 9, // --
1294 SECTION(Unknown, 8), 5, 'o', 't', 'h', 'e', 'r', 7, 8, // -- 1289 SECTION(Unknown, 8), 5, 'o', 't', 'h', 'e', 'r', 7, 8, // --
1295 }; 1290 };
1296 EXPECT_VERIFIES(data); 1291 EXPECT_VERIFIES(data);
1297 } 1292 }
1298 1293
1299 } // namespace wasm 1294 } // namespace wasm
1300 } // namespace internal 1295 } // namespace internal
1301 } // namespace v8 1296 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/wasm-module-builder.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698