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

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

Issue 2398023002: [wasm] asm.js - Parse and convert asm.js to wasm a function at a time. (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 | « test/cctest/asmjs/test-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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 var stdlib = this; 7 var stdlib = this;
8 8
9 function assertValidAsm(func) { 9 function assertValidAsm(func) {
10 assertTrue(%IsAsmWasmCode(func)); 10 assertTrue(%IsAsmWasmCode(func));
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1075
1076 var foreign = new ffi(); 1076 var foreign = new ffi();
1077 1077
1078 var module_decl = eval('(' + AsmModule.toString() + ')'); 1078 var module_decl = eval('(' + AsmModule.toString() + ')');
1079 var module = module_decl(stdlib, foreign, null); 1079 var module = module_decl(stdlib, foreign, null);
1080 assertValidAsm(module_decl); 1080 assertValidAsm(module_decl);
1081 1081
1082 assertEquals(89, module.caller(83, 83.25)); 1082 assertEquals(89, module.caller(83, 83.25));
1083 } 1083 }
1084 1084
1085 print("TestForeignFunctionMultipleUse...");
1085 TestForeignFunctionMultipleUse(); 1086 TestForeignFunctionMultipleUse();
1086 1087
1087 1088
1088 function TestForeignVariables() { 1089 function TestForeignVariables() {
1089 function AsmModule(stdlib, foreign, buffer) { 1090 function AsmModule(stdlib, foreign, buffer) {
1090 "use asm"; 1091 "use asm";
1091 1092
1092 var i1 = foreign.foo | 0; 1093 var i1 = foreign.foo | 0;
1093 var f1 = +foreign.bar; 1094 var f1 = +foreign.bar;
1094 var i2 = foreign.baz | 0; 1095 var i2 = foreign.baz | 0;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 var o = { 1167 var o = {
1167 valueOf: function() { return 99; } 1168 valueOf: function() { return 99; }
1168 }; 1169 };
1169 TestCase({foo: o, bar: o, baz: o}, 99, 99, 99, 99); 1170 TestCase({foo: o, bar: o, baz: o}, 99, 99, 99, 99);
1170 // Check that function values are converted properly. 1171 // Check that function values are converted properly.
1171 TestCase({foo: TestCase, bar: TestCase, qux: TestCase}, 0, NaN, 0, NaN); 1172 TestCase({foo: TestCase, bar: TestCase, qux: TestCase}, 0, NaN, 0, NaN);
1172 // Check that a missing ffi object is safe. 1173 // Check that a missing ffi object is safe.
1173 TestCase(undefined, 0, NaN, 0, NaN); 1174 TestCase(undefined, 0, NaN, 0, NaN);
1174 } 1175 }
1175 1176
1177 print("TestForeignVariables...");
1176 TestForeignVariables(); 1178 TestForeignVariables();
1177 1179
1178 1180
1179 (function() { 1181 (function() {
1180 function TestByteHeapAccessCompat(stdlib, foreign, buffer) { 1182 function TestByteHeapAccessCompat(stdlib, foreign, buffer) {
1181 "use asm"; 1183 "use asm";
1182 1184
1183 var HEAP8 = new stdlib.Uint8Array(buffer); 1185 var HEAP8 = new stdlib.Uint8Array(buffer);
1184 var HEAP32 = new stdlib.Int32Array(buffer); 1186 var HEAP32 = new stdlib.Int32Array(buffer);
1185 1187
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 (function TestBadAssignDoubleFromIntish() { 1381 (function TestBadAssignDoubleFromIntish() {
1380 function Module(stdlib, foreign, heap) { 1382 function Module(stdlib, foreign, heap) {
1381 "use asm"; 1383 "use asm";
1382 function func() { 1384 function func() {
1383 var a = 1; 1385 var a = 1;
1384 var b = 3.0; 1386 var b = 3.0;
1385 b = a; 1387 b = a;
1386 } 1388 }
1387 return {func: func}; 1389 return {func: func};
1388 } 1390 }
1391 print("TestBadAssignDoubleFromIntish...");
1389 Module(stdlib); 1392 Module(stdlib);
1390 assertTrue(%IsNotAsmWasmCode(Module)); 1393 assertTrue(%IsNotAsmWasmCode(Module));
1391 })(); 1394 })();
1392 1395
1393 1396
1394 (function TestBadAssignIntFromDouble() { 1397 (function TestBadAssignIntFromDouble() {
1395 function Module(stdlib, foreign, heap) { 1398 function Module(stdlib, foreign, heap) {
1396 "use asm"; 1399 "use asm";
1397 function func() { 1400 function func() {
1398 var a = 1; 1401 var a = 1;
1399 var b = 3.0; 1402 var b = 3.0;
1400 a = b; 1403 a = b;
1401 } 1404 }
1402 return {func: func}; 1405 return {func: func};
1403 } 1406 }
1407 print("TestBadAssignIntFromDouble...");
1404 Module(stdlib); 1408 Module(stdlib);
1405 assertTrue(%IsNotAsmWasmCode(Module)); 1409 assertTrue(%IsNotAsmWasmCode(Module));
1406 })(); 1410 })();
1407 1411
1408 1412
1409 (function TestBadMultiplyIntish() { 1413 (function TestBadMultiplyIntish() {
1410 function Module(stdlib, foreign, heap) { 1414 function Module(stdlib, foreign, heap) {
1411 "use asm"; 1415 "use asm";
1412 function func() { 1416 function func() {
1413 var a = 1; 1417 var a = 1;
1414 return ((a + a) * 4) | 0; 1418 return ((a + a) * 4) | 0;
1415 } 1419 }
1416 return {func: func}; 1420 return {func: func};
1417 } 1421 }
1422 print("TestBadMultiplyIntish...");
1418 Module(stdlib); 1423 Module(stdlib);
1419 assertTrue(%IsNotAsmWasmCode(Module)); 1424 assertTrue(%IsNotAsmWasmCode(Module));
1420 })(); 1425 })();
1421 1426
1422 1427
1423 (function TestBadCastFromInt() { 1428 (function TestBadCastFromInt() {
1424 function Module(stdlib, foreign, heap) { 1429 function Module(stdlib, foreign, heap) {
1425 "use asm"; 1430 "use asm";
1426 function func() { 1431 function func() {
1427 var a = 1; 1432 var a = 1;
1428 return +a; 1433 return +a;
1429 } 1434 }
1430 return {func: func}; 1435 return {func: func};
1431 } 1436 }
1437 print("TestBadCastFromInt...");
1432 Module(stdlib); 1438 Module(stdlib);
1433 assertTrue(%IsNotAsmWasmCode(Module)); 1439 assertTrue(%IsNotAsmWasmCode(Module));
1434 })(); 1440 })();
1435 1441
1436 1442
1437 function TestAndNegative() { 1443 function TestAndNegative() {
1438 "use asm"; 1444 "use asm";
1439 function func() { 1445 function func() {
1440 var x = 1; 1446 var x = 1;
1441 var y = 2; 1447 var y = 2;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 var foo = fround(1.25); 1668 var foo = fround(1.25);
1663 function caller() { 1669 function caller() {
1664 foo = fround(foo + fround(1.0)); 1670 foo = fround(foo + fround(1.0));
1665 foo = fround(foo + fround(1.0)); 1671 foo = fround(foo + fround(1.0));
1666 return +foo; 1672 return +foo;
1667 } 1673 }
1668 return {caller: caller}; 1674 return {caller: caller};
1669 } 1675 }
1670 1676
1671 assertWasm(3.25, TestFloatGlobals); 1677 assertWasm(3.25, TestFloatGlobals);
OLDNEW
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698