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: --validate-asm --allow-natives-syntax | 5 // Flags: --validate-asm --allow-natives-syntax |
6 | 6 |
7 function IsAlwaysOpt(module) { | 7 function IsAlwaysOpt(module) { |
8 return %GetOptimizationStatus(module) === 3; | 8 return %GetOptimizationStatus(module) === 3; |
9 } | 9 } |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 var Module2 = MkModule(); | 167 var Module2 = MkModule(); |
168 var heap = new ArrayBuffer(1024 * 1024); | 168 var heap = new ArrayBuffer(1024 * 1024); |
169 var m1 = Module1({}, {}, heap); | 169 var m1 = Module1({}, {}, heap); |
170 assertTrue(%IsAsmWasmCode(Module1) || IsAlwaysOpt(Module1)); | 170 assertTrue(%IsAsmWasmCode(Module1) || IsAlwaysOpt(Module1)); |
171 var m2 = Module2(1, 2, 3); | 171 var m2 = Module2(1, 2, 3); |
172 assertFalse(%IsAsmWasmCode(Module2)); | 172 assertFalse(%IsAsmWasmCode(Module2)); |
173 assertEquals(123, m1.foo()); | 173 assertEquals(123, m1.foo()); |
174 assertEquals(123, m2.foo()); | 174 assertEquals(123, m2.foo()); |
175 })(); | 175 })(); |
176 | 176 |
| 177 (function TestSuccessThenFailureThenRetry() { |
| 178 function MkModule() { |
| 179 function Module(stdlib, ffi, heap) { |
| 180 "use asm"; |
| 181 function foo() { return 123; } |
| 182 return { foo: foo }; |
| 183 } |
| 184 return Module; |
| 185 } |
| 186 var Module1 = MkModule(); |
| 187 var Module2 = MkModule(); |
| 188 var heap = new ArrayBuffer(1024 * 1024); |
| 189 var m1a = Module1({}, {}, heap); |
| 190 assertTrue(%IsAsmWasmCode(Module1) || IsAlwaysOpt(Module1)); |
| 191 var m2 = Module2(1, 2, 3); |
| 192 assertFalse(%IsAsmWasmCode(Module2)); |
| 193 var m1b = Module1({}, {}, heap); |
| 194 assertFalse(%IsAsmWasmCode(Module1)); |
| 195 assertEquals(123, m1a.foo()); |
| 196 assertEquals(123, m1b.foo()); |
| 197 assertEquals(123, m2.foo()); |
| 198 })(); |
| 199 |
177 (function TestBoundFunction() { | 200 (function TestBoundFunction() { |
178 function Module(stdlib, ffi, heap) { | 201 function Module(stdlib, ffi, heap) { |
179 "use asm"; | 202 "use asm"; |
180 function foo() { return 123; } | 203 function foo() { return 123; } |
181 return { foo: foo }; | 204 return { foo: foo }; |
182 } | 205 } |
183 var heap = new ArrayBuffer(1024 * 1024); | 206 var heap = new ArrayBuffer(1024 * 1024); |
184 var ModuleBound = Module.bind(this, {}, {}, heap); | 207 var ModuleBound = Module.bind(this, {}, {}, heap); |
185 var m = ModuleBound(); | 208 var m = ModuleBound(); |
186 assertTrue(%IsAsmWasmCode(Module) || IsAlwaysOpt(Module)); | 209 assertTrue(%IsAsmWasmCode(Module) || IsAlwaysOpt(Module)); |
187 assertEquals(123, m.foo()); | 210 assertEquals(123, m.foo()); |
188 })(); | 211 })(); |
OLD | NEW |