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

Side by Side Diff: test/mjsunit/asm/asm-validation.js

Issue 2555323003: [wasm][asm.js] Confirm literals are Numbers before using AsNumber, refactor. (Closed)
Patch Set: fix Created 4 years 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 | « src/asmjs/asm-typer.cc ('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 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 assertValidAsm(func) { 7 function assertValidAsm(func) {
8 assertTrue(%IsAsmWasmCode(func)); 8 assertTrue(%IsAsmWasmCode(func));
9 } 9 }
10 10
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 function Module() { 288 function Module() {
289 "use asm"; 289 "use asm";
290 const i = 0xffffffff; 290 const i = 0xffffffff;
291 function foo() { return i; } 291 function foo() { return i; }
292 return { foo: foo }; 292 return { foo: foo };
293 } 293 }
294 var m = Module(); 294 var m = Module();
295 assertTrue(%IsNotAsmWasmCode(Module)); 295 assertTrue(%IsNotAsmWasmCode(Module));
296 assertEquals(0xffffffff, m.foo()); 296 assertEquals(0xffffffff, m.foo());
297 })(); 297 })();
298
299 (function TestBadBooleanAnnotation() {
300 function Module() {
301 "use asm";
302 function foo(x) {
303 x = x | true;
304 return x;
305 }
306 return { foo: foo };
307 }
308 var m = Module();
309 assertTrue(%IsNotAsmWasmCode(Module));
310 assertEquals(3, m.foo(3));
311 })();
312
313 (function TestBadCase() {
314 function Module() {
315 "use asm";
316 function foo(x) {
317 x = x | 0;
318 switch (x|0) {
319 case true:
320 return 42;
321 default:
322 return 43;
323 }
324 return 0;
325 }
326 return { foo: foo };
327 }
328 var m = Module();
329 assertTrue(%IsNotAsmWasmCode(Module));
330 assertEquals(43, m.foo(3));
331 })();
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698