OLD | NEW |
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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } \ | 834 } \ |
835 CHECK_FUNC_TYPES_END \ | 835 CHECK_FUNC_TYPES_END \ |
836 } | 836 } |
837 | 837 |
838 | 838 |
839 TEST_INT_BIN_OP(AndOperator, "&") | 839 TEST_INT_BIN_OP(AndOperator, "&") |
840 TEST_INT_BIN_OP(OrOperator, "|") | 840 TEST_INT_BIN_OP(OrOperator, "|") |
841 TEST_INT_BIN_OP(XorOperator, "^") | 841 TEST_INT_BIN_OP(XorOperator, "^") |
842 | 842 |
843 | 843 |
| 844 TEST(SignedCompare) { |
| 845 CHECK_FUNC_TYPES_BEGIN( |
| 846 "function bar() { var x = 1; var y = 1; return ((x|0) < (y|0))|0; }\n" |
| 847 "function foo() { bar(); }") { |
| 848 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 849 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 850 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 851 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 852 } |
| 853 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 854 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 855 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 856 } |
| 857 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 858 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
| 859 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 860 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 861 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 862 } |
| 863 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 864 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 865 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 866 } |
| 867 } |
| 868 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 869 } |
| 870 } |
| 871 CHECK_SKIP(); |
| 872 } |
| 873 CHECK_FUNC_TYPES_END |
| 874 } |
| 875 |
| 876 |
| 877 TEST(SignedCompareConst) { |
| 878 CHECK_FUNC_TYPES_BEGIN( |
| 879 "function bar() { var x = 1; var y = 1; return ((x|0) < (1<<31))|0; }\n" |
| 880 "function foo() { bar(); }") { |
| 881 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 882 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 883 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 884 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 885 } |
| 886 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 887 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 888 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 889 } |
| 890 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 891 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
| 892 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 893 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 894 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 895 } |
| 896 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned)); |
| 897 } |
| 898 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 899 } |
| 900 } |
| 901 CHECK_SKIP(); |
| 902 } |
| 903 CHECK_FUNC_TYPES_END |
| 904 } |
| 905 |
| 906 |
844 TEST(UnsignedCompare) { | 907 TEST(UnsignedCompare) { |
845 CHECK_FUNC_TYPES_BEGIN( | 908 CHECK_FUNC_TYPES_BEGIN( |
846 "function bar() { var x = 1; var y = 1; return ((x>>>0) < (y>>>0))|0; }\n" | 909 "function bar() { var x = 1; var y = 1; return ((x>>>0) < (y>>>0))|0; }\n" |
847 "function foo() { bar(); }") { | 910 "function foo() { bar(); }") { |
848 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 911 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
849 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 912 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
850 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 913 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
851 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 914 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
852 } | 915 } |
853 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 916 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
(...skipping 13 matching lines...) Expand all Loading... |
867 } | 930 } |
868 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 931 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
869 } | 932 } |
870 } | 933 } |
871 CHECK_SKIP(); | 934 CHECK_SKIP(); |
872 } | 935 } |
873 CHECK_FUNC_TYPES_END | 936 CHECK_FUNC_TYPES_END |
874 } | 937 } |
875 | 938 |
876 | 939 |
| 940 TEST(UnsignedCompareConst0) { |
| 941 CHECK_FUNC_TYPES_BEGIN( |
| 942 "function bar() { var x = 1; var y = 1; return ((x>>>0) < (0>>>0))|0; }\n" |
| 943 "function foo() { bar(); }") { |
| 944 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 945 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 946 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 947 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 948 } |
| 949 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 950 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 951 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 952 } |
| 953 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 954 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
| 955 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
| 956 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 957 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 958 } |
| 959 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 960 } |
| 961 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 962 } |
| 963 } |
| 964 CHECK_SKIP(); |
| 965 } |
| 966 CHECK_FUNC_TYPES_END |
| 967 } |
| 968 |
| 969 |
| 970 TEST(UnsignedCompareConst1) { |
| 971 CHECK_FUNC_TYPES_BEGIN( |
| 972 "function bar() { var x = 1; var y = 1; return ((x>>>0) < " |
| 973 "(0xffffffff>>>0))|0; }\n" |
| 974 "function foo() { bar(); }") { |
| 975 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
| 976 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 977 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 978 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 979 } |
| 980 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 981 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
| 982 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 983 } |
| 984 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 985 CHECK_EXPR(CompareOperation, Bounds(cache.kAsmSigned)) { |
| 986 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) { |
| 987 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 988 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 989 } |
| 990 CHECK_EXPR(Literal, Bounds(cache.kAsmUnsigned)); |
| 991 } |
| 992 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 993 } |
| 994 } |
| 995 CHECK_SKIP(); |
| 996 } |
| 997 CHECK_FUNC_TYPES_END |
| 998 } |
| 999 |
| 1000 |
877 TEST(UnsignedDivide) { | 1001 TEST(UnsignedDivide) { |
878 CHECK_FUNC_TYPES_BEGIN( | 1002 CHECK_FUNC_TYPES_BEGIN( |
879 "function bar() { var x = 1; var y = 1; return ((x>>>0) / (y>>>0))|0; }\n" | 1003 "function bar() { var x = 1; var y = 1; return ((x>>>0) / (y>>>0))|0; }\n" |
880 "function foo() { bar(); }") { | 1004 "function foo() { bar(); }") { |
881 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 1005 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
882 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1006 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
883 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 1007 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
884 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1008 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
885 } | 1009 } |
886 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1010 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" | 1263 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" |
1140 "function foo() { bar(); }") { | 1264 "function foo() { bar(); }") { |
1141 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1265 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1142 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1266 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1143 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 1267 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1144 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1268 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1145 } | 1269 } |
1146 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1270 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1147 CHECK_VAR(y, Bounds(cache.kAsmInt)); | 1271 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1148 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1272 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1149 CHECK_EXPR(Property, Bounds(cache.kInt8)) { | 1273 CHECK_EXPR(Property, Bounds(cache.kAsmInt)) { |
1150 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1274 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1151 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1275 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1152 CHECK_VAR(x, Bounds(cache.kAsmSigned)); | 1276 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
1153 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1277 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1154 } | 1278 } |
1155 } | 1279 } |
1156 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1280 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1157 } | 1281 } |
1158 } | 1282 } |
1159 } | 1283 } |
1160 CHECK_SKIP(); | 1284 CHECK_SKIP(); |
1161 } | 1285 } |
1162 CHECK_FUNC_TYPES_END | 1286 CHECK_FUNC_TYPES_END |
1163 } | 1287 } |
1164 | 1288 |
1165 | 1289 |
| 1290 TEST(LoadDouble) { |
| 1291 CHECK_FUNC_TYPES_BEGIN( |
| 1292 "function bar() { var x = 1; var y = 0.0; y = +f64[x>>3]; }\n" |
| 1293 "function foo() { bar(); }") { |
| 1294 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1295 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1296 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1297 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1298 } |
| 1299 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
| 1300 CHECK_VAR(y, Bounds(cache.kAsmDouble)); |
| 1301 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 1302 } |
| 1303 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) { |
| 1304 CHECK_VAR(y, Bounds(cache.kAsmDouble)); |
| 1305 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { |
| 1306 CHECK_EXPR(Property, Bounds(cache.kAsmDouble)) { |
| 1307 CHECK_VAR(f64, Bounds(cache.kFloat64Array)); |
| 1308 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 1309 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
| 1310 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1311 } |
| 1312 } |
| 1313 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 1314 } |
| 1315 } |
| 1316 } |
| 1317 CHECK_SKIP(); |
| 1318 } |
| 1319 CHECK_FUNC_TYPES_END |
| 1320 } |
| 1321 |
| 1322 |
| 1323 TEST(Store1) { |
| 1324 CHECK_FUNC_TYPES_BEGIN( |
| 1325 "function bar() { var x = 1; i8[x>>0] = 0; }\n" |
| 1326 "function foo() { bar(); }") { |
| 1327 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1328 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1329 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1330 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1331 } |
| 1332 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1333 CHECK_EXPR(Property, Bounds::Unbounded()) { |
| 1334 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
| 1335 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 1336 CHECK_VAR(x, Bounds(cache.kAsmSigned)); |
| 1337 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1338 } |
| 1339 } |
| 1340 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1341 } |
| 1342 } |
| 1343 CHECK_SKIP(); |
| 1344 } |
| 1345 CHECK_FUNC_TYPES_END |
| 1346 } |
| 1347 |
| 1348 |
| 1349 TEST(StoreFloat) { |
| 1350 CHECK_FUNC_TYPES_BEGIN( |
| 1351 "function bar() { var x = fround(1.0); " |
| 1352 "f32[0] = fround(x + fround(1.0)); }\n" |
| 1353 "function foo() { bar(); }") { |
| 1354 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1355 CHECK_EXPR(Assignment, Bounds(cache.kAsmFloat)) { |
| 1356 CHECK_VAR(x, Bounds(cache.kAsmFloat)); |
| 1357 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
| 1358 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 1359 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 1360 } |
| 1361 } |
| 1362 CHECK_EXPR(Assignment, Bounds(cache.kAsmFloat)) { |
| 1363 CHECK_EXPR(Property, Bounds::Unbounded()) { |
| 1364 CHECK_VAR(f32, Bounds(cache.kFloat32Array)); |
| 1365 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1366 } |
| 1367 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
| 1368 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 1369 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmFloat)) { |
| 1370 CHECK_VAR(x, Bounds(cache.kAsmFloat)); |
| 1371 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { |
| 1372 CHECK_VAR(fround, FUNC_N2F_TYPE); |
| 1373 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); |
| 1374 } |
| 1375 } |
| 1376 } |
| 1377 } |
| 1378 } |
| 1379 CHECK_SKIP(); |
| 1380 } |
| 1381 CHECK_FUNC_TYPES_END |
| 1382 } |
| 1383 |
| 1384 |
1166 TEST(Load1Constant) { | 1385 TEST(Load1Constant) { |
1167 CHECK_FUNC_TYPES_BEGIN( | 1386 CHECK_FUNC_TYPES_BEGIN( |
1168 "function bar() { var x = 1; var y = i8[5]|0; }\n" | 1387 "function bar() { var x = 1; var y = i8[5]|0; }\n" |
1169 "function foo() { bar(); }") { | 1388 "function foo() { bar(); }") { |
1170 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { | 1389 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
1171 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1390 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1172 CHECK_VAR(x, Bounds(cache.kAsmInt)); | 1391 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
1173 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1392 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1174 } | 1393 } |
1175 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { | 1394 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
1176 CHECK_VAR(y, Bounds(cache.kAsmInt)); | 1395 CHECK_VAR(y, Bounds(cache.kAsmInt)); |
1177 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1396 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1178 CHECK_EXPR(Property, Bounds(cache.kInt8)) { | 1397 CHECK_EXPR(Property, Bounds(cache.kAsmInt)) { |
1179 CHECK_VAR(i8, Bounds(cache.kInt8Array)); | 1398 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
1180 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1399 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1181 } | 1400 } |
1182 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1401 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
1183 } | 1402 } |
1184 } | 1403 } |
1185 } | 1404 } |
1186 CHECK_SKIP(); | 1405 CHECK_SKIP(); |
1187 } | 1406 } |
1188 CHECK_FUNC_TYPES_END | 1407 CHECK_FUNC_TYPES_END |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 | 1648 |
1430 TEST(MismatchedReturnTypeExpression) { | 1649 TEST(MismatchedReturnTypeExpression) { |
1431 CHECK_FUNC_ERROR( | 1650 CHECK_FUNC_ERROR( |
1432 "function bar() {\n" | 1651 "function bar() {\n" |
1433 " var x = 1; var y = 1.0; if(1) { return x; } return +y; }\n" | 1652 " var x = 1; var y = 1.0; if(1) { return x; } return +y; }\n" |
1434 "function foo() { bar(); }", | 1653 "function foo() { bar(); }", |
1435 "asm: line 40: return type does not match function signature\n"); | 1654 "asm: line 40: return type does not match function signature\n"); |
1436 } | 1655 } |
1437 | 1656 |
1438 | 1657 |
| 1658 TEST(AssignToFloatishToF64) { |
| 1659 CHECK_FUNC_ERROR( |
| 1660 "function bar() { var v = fround(1.0); f32[0] = v + fround(1.0); }\n" |
| 1661 "function foo() { bar(); }", |
| 1662 "asm: line 39: intish or floatish assignment\n"); |
| 1663 } |
| 1664 |
| 1665 |
1439 TEST(ForeignFunction) { | 1666 TEST(ForeignFunction) { |
1440 CHECK_FUNC_TYPES_BEGIN( | 1667 CHECK_FUNC_TYPES_BEGIN( |
1441 "var baz = foreign.baz;\n" | 1668 "var baz = foreign.baz;\n" |
1442 "function bar() { return baz(1, 2)|0; }\n" | 1669 "function bar() { return baz(1, 2)|0; }\n" |
1443 "function foo() { bar(); }") { | 1670 "function foo() { bar(); }") { |
1444 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { | 1671 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { |
1445 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { | 1672 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
1446 CHECK_EXPR(Call, Bounds(Type::Number(zone))) { | 1673 CHECK_EXPR(Call, Bounds(Type::Number(zone))) { |
1447 CHECK_VAR(baz, Bounds(Type::Any())); | 1674 CHECK_VAR(baz, Bounds(Type::Any())); |
1448 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); | 1675 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
(...skipping 28 matching lines...) Expand all Loading... |
1477 | 1704 |
1478 v8::V8::Initialize(); | 1705 v8::V8::Initialize(); |
1479 HandleAndZoneScope handles; | 1706 HandleAndZoneScope handles; |
1480 Zone* zone = handles.main_zone(); | 1707 Zone* zone = handles.main_zone(); |
1481 ZoneVector<ExpressionTypeEntry> types(zone); | 1708 ZoneVector<ExpressionTypeEntry> types(zone); |
1482 CHECK_EQ("asm: line 40: non-function in function table\n", | 1709 CHECK_EQ("asm: line 40: non-function in function table\n", |
1483 Validate(zone, test_function, &types)); | 1710 Validate(zone, test_function, &types)); |
1484 } | 1711 } |
1485 | 1712 |
1486 | 1713 |
| 1714 TEST(NestedHeapAssignment) { |
| 1715 CHECK_FUNC_ERROR( |
| 1716 "function bar() { var x = 0; i8[x = 1] = 2; }\n" |
| 1717 "function foo() { bar(); }", |
| 1718 "asm: line 39: expected >> in heap access\n"); |
| 1719 } |
| 1720 |
| 1721 |
| 1722 TEST(BadArrayAssignment) { |
| 1723 CHECK_FUNC_ERROR( |
| 1724 "function bar() { i8[0] = 0.0; }\n" |
| 1725 "function foo() { bar(); }", |
| 1726 "asm: line 39: illegal type in assignment\n"); |
| 1727 } |
| 1728 |
| 1729 |
| 1730 TEST(NestedVariableAssignment) { |
| 1731 CHECK_FUNC_TYPES_BEGIN( |
| 1732 "function bar() { var x = 0; x = x = 4; }\n" |
| 1733 "function foo() { bar(); }") { |
| 1734 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1735 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1736 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1737 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1738 } |
| 1739 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1740 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1741 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1742 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1743 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1744 } |
| 1745 } |
| 1746 } |
| 1747 CHECK_SKIP(); |
| 1748 } |
| 1749 CHECK_FUNC_TYPES_END |
| 1750 } |
| 1751 |
| 1752 |
| 1753 TEST(NestedAssignmentInHeap) { |
| 1754 CHECK_FUNC_TYPES_BEGIN( |
| 1755 "function bar() { var x = 0; i8[(x = 1) >> 0] = 2; }\n" |
| 1756 "function foo() { bar(); }") { |
| 1757 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { |
| 1758 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1759 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1760 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1761 } |
| 1762 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
| 1763 CHECK_EXPR(Property, Bounds::Unbounded()) { |
| 1764 CHECK_VAR(i8, Bounds(cache.kInt8Array)); |
| 1765 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
| 1766 CHECK_EXPR(Assignment, Bounds(cache.kAsmSigned)) { |
| 1767 CHECK_VAR(x, Bounds(cache.kAsmInt)); |
| 1768 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1769 } |
| 1770 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1771 } |
| 1772 } |
| 1773 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
| 1774 } |
| 1775 } |
| 1776 CHECK_SKIP(); |
| 1777 } |
| 1778 CHECK_FUNC_TYPES_END |
| 1779 } |
| 1780 |
| 1781 |
1487 TEST(TypeConsistency) { | 1782 TEST(TypeConsistency) { |
1488 v8::V8::Initialize(); | 1783 v8::V8::Initialize(); |
1489 TypeCache cache; | 1784 TypeCache cache; |
1490 // Check the consistency of each of the main Asm.js types. | 1785 // Check the consistency of each of the main Asm.js types. |
1491 CHECK(cache.kAsmFixnum->Is(cache.kAsmFixnum)); | 1786 CHECK(cache.kAsmFixnum->Is(cache.kAsmFixnum)); |
1492 CHECK(cache.kAsmFixnum->Is(cache.kAsmSigned)); | 1787 CHECK(cache.kAsmFixnum->Is(cache.kAsmSigned)); |
1493 CHECK(cache.kAsmFixnum->Is(cache.kAsmUnsigned)); | 1788 CHECK(cache.kAsmFixnum->Is(cache.kAsmUnsigned)); |
1494 CHECK(cache.kAsmFixnum->Is(cache.kAsmInt)); | 1789 CHECK(cache.kAsmFixnum->Is(cache.kAsmInt)); |
1495 CHECK(!cache.kAsmFixnum->Is(cache.kAsmFloat)); | 1790 CHECK(!cache.kAsmFixnum->Is(cache.kAsmFloat)); |
1496 CHECK(!cache.kAsmFixnum->Is(cache.kAsmDouble)); | 1791 CHECK(!cache.kAsmFixnum->Is(cache.kAsmDouble)); |
(...skipping 26 matching lines...) Expand all Loading... |
1523 CHECK(!cache.kAsmFloat->Is(cache.kAsmFixnum)); | 1818 CHECK(!cache.kAsmFloat->Is(cache.kAsmFixnum)); |
1524 CHECK(!cache.kAsmFloat->Is(cache.kAsmDouble)); | 1819 CHECK(!cache.kAsmFloat->Is(cache.kAsmDouble)); |
1525 | 1820 |
1526 CHECK(cache.kAsmDouble->Is(cache.kAsmDouble)); | 1821 CHECK(cache.kAsmDouble->Is(cache.kAsmDouble)); |
1527 CHECK(!cache.kAsmDouble->Is(cache.kAsmInt)); | 1822 CHECK(!cache.kAsmDouble->Is(cache.kAsmInt)); |
1528 CHECK(!cache.kAsmDouble->Is(cache.kAsmUnsigned)); | 1823 CHECK(!cache.kAsmDouble->Is(cache.kAsmUnsigned)); |
1529 CHECK(!cache.kAsmDouble->Is(cache.kAsmSigned)); | 1824 CHECK(!cache.kAsmDouble->Is(cache.kAsmSigned)); |
1530 CHECK(!cache.kAsmDouble->Is(cache.kAsmFixnum)); | 1825 CHECK(!cache.kAsmDouble->Is(cache.kAsmFixnum)); |
1531 CHECK(!cache.kAsmDouble->Is(cache.kAsmFloat)); | 1826 CHECK(!cache.kAsmDouble->Is(cache.kAsmFloat)); |
1532 } | 1827 } |
OLD | NEW |