OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 9 |
10 function AddFunctions(builder) { | 10 function AddFunctions(builder) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 // Verify that grow does not alter function behaviors | 437 // Verify that grow does not alter function behaviors |
438 for (var j = 0; j < 10; j++) { | 438 for (var j = 0; j < 10; j++) { |
439 let func = table.get(j); | 439 let func = table.get(j); |
440 assertEquals("function", typeof func); | 440 assertEquals("function", typeof func); |
441 assertEquals(j, func()); | 441 assertEquals(j, func()); |
442 assertEquals(j, instances[j].exports.main(j)); | 442 assertEquals(j, instances[j].exports.main(j)); |
443 } | 443 } |
444 | 444 |
445 let new_builder = new WasmModuleBuilder(); | 445 let new_builder = new WasmModuleBuilder(); |
446 new_builder.addExport("wasm", new_builder.addFunction("", kSig_v_v)); | 446 new_builder.addExport("wasm", new_builder.addFunction("", kSig_v_v).addBody([]
)); |
447 new_builder.addImportedTable("x", "table", 20, 30); | 447 new_builder.addImportedTable("x", "table", 20, 30); |
448 let new_module = new WebAssembly.Module(new_builder.toBuffer()); | 448 let new_module = new WebAssembly.Module(new_builder.toBuffer()); |
449 let instance = new WebAssembly.Instance(new_module, {x: {table: table}}); | 449 let instance = new WebAssembly.Instance(new_module, {x: {table: table}}); |
450 let new_func = instance.exports.wasm; | 450 let new_func = instance.exports.wasm; |
451 | 451 |
452 for (var j = 10; j < 20; j++) { | 452 for (var j = 10; j < 20; j++) { |
453 table.set(j, new_func); | 453 table.set(j, new_func); |
454 let func = table.get(j); | 454 let func = table.get(j); |
455 assertEquals("function", typeof func); | 455 assertEquals("function", typeof func); |
456 assertSame(new_func, table.get(j)); | 456 assertSame(new_func, table.get(j)); |
457 } | 457 } |
458 assertThrows(() => table.grow(11)); | 458 assertThrows(() => table.grow(11)); |
459 })(); | 459 })(); |
OLD | NEW |