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 const stdlib = { | 7 const stdlib = { |
8 Math: Math, | 8 Math: Math, |
9 Int8Array: Int8Array, | 9 Int8Array: Int8Array, |
10 Int16Array: Int16Array, | 10 Int16Array: Int16Array, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 var js_module = eval("(" + nonasm_source + ")")(stdlib, {}, buffer); | 61 var js_module = eval("(" + nonasm_source + ")")(stdlib, {}, buffer); |
62 print("Testing " + asmfunc.name + " (js)..."); | 62 print("Testing " + asmfunc.name + " (js)..."); |
63 expect(js_module); | 63 expect(js_module); |
64 | 64 |
65 print("Testing " + asmfunc.name + " (asm.js)..."); | 65 print("Testing " + asmfunc.name + " (asm.js)..."); |
66 var asm_module = asmfunc(stdlib, {}, buffer); | 66 var asm_module = asmfunc(stdlib, {}, buffer); |
67 expect(asm_module); | 67 expect(asm_module); |
68 | 68 |
69 print("Testing " + asmfunc.name + " (wasm)..."); | 69 print("Testing " + asmfunc.name + " (wasm)..."); |
70 var wasm_module = Wasm.instantiateModuleFromAsm(asm_source, null, buffer); | 70 var wasm_module = Wasm.instantiateModuleFromAsm( |
| 71 asm_source, stdlib, null, buffer); |
71 expect(wasm_module); | 72 expect(wasm_module); |
72 } | 73 } |
73 | 74 |
74 function LoadAt_i32(stdlib, foreign, buffer) { | 75 function LoadAt_i32(stdlib, foreign, buffer) { |
75 "use asm"; | 76 "use asm"; |
76 var HEAP32 = new stdlib.Int32Array(buffer); | 77 var HEAP32 = new stdlib.Int32Array(buffer); |
77 function load(a) { | 78 function load(a) { |
78 a = a | 0; | 79 a = a | 0; |
79 return HEAP32[a >> 2] | 0; | 80 return HEAP32[a >> 2] | 0; |
80 } | 81 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 231 |
231 RunThreeWayTest(LoadAt_f64, function(module) { | 232 RunThreeWayTest(LoadAt_f64, function(module) { |
232 var load = module.load; | 233 var load = module.load; |
233 for (index of OOB_INDEXES) assertEquals(NaN, load(index)); | 234 for (index of OOB_INDEXES) assertEquals(NaN, load(index)); |
234 checkView(new Float64Array(buffer), load, 3); | 235 checkView(new Float64Array(buffer), load, 3); |
235 }); | 236 }); |
236 | 237 |
237 // TODO(titzer): constant heap indexes | 238 // TODO(titzer): constant heap indexes |
238 // TODO(titzer): heap accesses with offsets and arithmetic | 239 // TODO(titzer): heap accesses with offsets and arithmetic |
239 // TODO(titzer): [i >> K] where K is greater than log(size) | 240 // TODO(titzer): [i >> K] where K is greater than log(size) |
OLD | NEW |