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 instantiate(sig, body) { | 10 function instantiate(sig, body) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 var module = builder.instantiate(); | 93 var module = builder.instantiate(); |
94 var memory = module.exports.memory.buffer; | 94 var memory = module.exports.memory.buffer; |
95 var view = new Int8Array(memory); | 95 var view = new Int8Array(memory); |
96 assertEquals(77, view[0]); | 96 assertEquals(77, view[0]); |
97 })(); | 97 })(); |
98 | 98 |
99 (function testStartFFI() { | 99 (function testStartFFI() { |
100 print("testStartFFI"); | 100 print("testStartFFI"); |
101 var ranned = false; | 101 var ranned = false; |
102 var ffi = { foo : function() { | 102 var ffi = {gak: {foo : function() { |
103 print("we ranned at stert!"); | 103 print("we ranned at stert!"); |
104 ranned = true; | 104 ranned = true; |
105 }}; | 105 }}}; |
106 | 106 |
107 var builder = new WasmModuleBuilder(); | 107 var builder = new WasmModuleBuilder(); |
108 var sig_index = builder.addType(kSig_v_v); | 108 var sig_index = builder.addType(kSig_v_v); |
109 | 109 |
110 builder.addImport("foo", sig_index); | 110 builder.addImport("gak", "foo", sig_index); |
111 var func = builder.addFunction("", sig_index) | 111 var func = builder.addFunction("", sig_index) |
112 .addBody([kExprCallFunction, 0]); | 112 .addBody([kExprCallFunction, 0]); |
113 | 113 |
114 builder.addStart(func.index); | 114 builder.addStart(func.index); |
115 | 115 |
116 var module = builder.instantiate(ffi); | 116 var module = builder.instantiate(ffi); |
117 assertTrue(ranned); | 117 assertTrue(ranned); |
118 })(); | 118 })(); |
OLD | NEW |