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

Side by Side Diff: test/cctest/test-asm-validator.cc

Issue 1804243003: Fix conversion to float32, typing issue, split apart asm-wasm tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 9 months 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/wasm/asm-wasm-builder.cc ('k') | test/mjsunit/mjsunit.status » ('j') | 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/ast-expression-visitor.h" 8 #include "src/ast/ast-expression-visitor.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/parsing/parser.h" 10 #include "src/parsing/parser.h"
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 TEST(TernaryMismatchIntish) { 1146 TEST(TernaryMismatchIntish) {
1147 CHECK_FUNC_ERROR( 1147 CHECK_FUNC_ERROR(
1148 "function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n" 1148 "function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n"
1149 "function foo() { bar(); }", 1149 "function foo() { bar(); }",
1150 "asm: line 1: invalid type in ? then expression\n"); 1150 "asm: line 1: invalid type in ? then expression\n");
1151 } 1151 }
1152 1152
1153 1153
1154 TEST(TernaryMismatchInt32Float32) { 1154 TEST(TernaryMismatchInt32Float32) {
1155 CHECK_FUNC_ERROR( 1155 CHECK_FUNC_ERROR(
1156 "function bar() { var x = 1; var y = 2; return (x?fround(y):x)|0; }\n" 1156 "function bar() { var x = 1; var y = 2.0; return (x?fround(y):x)|0; }\n"
1157 "function foo() { bar(); }", 1157 "function foo() { bar(); }",
1158 "asm: line 1: then and else expressions in ? must have the same type\n"); 1158 "asm: line 1: then and else expressions in ? must have the same type\n");
1159 } 1159 }
1160 1160
1161 1161
1162 TEST(TernaryBadCondition) { 1162 TEST(TernaryBadCondition) {
1163 CHECK_FUNC_ERROR( 1163 CHECK_FUNC_ERROR(
1164 "function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n" 1164 "function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n"
1165 "function foo() { bar(); }", 1165 "function foo() { bar(); }",
1166 "asm: line 1: condition must be of type int\n"); 1166 "asm: line 1: condition must be of type int\n");
1167 } 1167 }
1168 1168
1169 TEST(BadIntishMultiply) { 1169 TEST(BadIntishMultiply) {
1170 CHECK_FUNC_ERROR( 1170 CHECK_FUNC_ERROR(
1171 "function bar() { var x = 1; return ((x + x) * 4) | 0; }\n" 1171 "function bar() { var x = 1; return ((x + x) * 4) | 0; }\n"
1172 "function foo() { bar(); }", 1172 "function foo() { bar(); }",
1173 "asm: line 1: intish not allowed in multiply\n"); 1173 "asm: line 1: intish not allowed in multiply\n");
1174 } 1174 }
1175 1175
1176 TEST(FroundFloat32) { 1176 TEST(IntToFloat32) {
1177 CHECK_FUNC_ERROR(
1178 "function bar() { var x = 1; return fround(x); }\n"
1179 "function foo() { bar(); }",
1180 "asm: line 1: illegal function argument type\n");
1181 }
1182
1183 TEST(Int32ToFloat32) {
1177 CHECK_FUNC_TYPES_BEGIN( 1184 CHECK_FUNC_TYPES_BEGIN(
1178 "function bar() { var x = 1; return fround(x); }\n" 1185 "function bar() { var x = 1; return fround(x|0); }\n"
1179 "function foo() { bar(); }") { 1186 "function foo() { bar(); }") {
1180 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { 1187 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) {
1181 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { 1188 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
1182 CHECK_VAR(x, Bounds(cache.kAsmInt)); 1189 CHECK_VAR(x, Bounds(cache.kAsmInt));
1183 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); 1190 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1184 } 1191 }
1185 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) { 1192 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) {
1186 CHECK_VAR(fround, FUNC_N2F_TYPE); 1193 CHECK_VAR(fround, FUNC_N2F_TYPE);
1187 CHECK_VAR(x, Bounds(cache.kAsmInt)); 1194 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
1195 CHECK_VAR(x, Bounds(cache.kAsmInt));
1196 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1197 }
1188 } 1198 }
1189 } 1199 }
1190 CHECK_SKIP(); 1200 CHECK_SKIP();
1201 }
1202 CHECK_FUNC_TYPES_END
1203 }
1204
1205 TEST(Uint32ToFloat32) {
1206 CHECK_FUNC_TYPES_BEGIN(
1207 "function bar() { var x = 1; return fround(x>>>0); }\n"
1208 "function foo() { bar(); }") {
1209 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) {
1210 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
1211 CHECK_VAR(x, Bounds(cache.kAsmInt));
1212 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1213 }
1214 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) {
1215 CHECK_VAR(fround, FUNC_N2F_TYPE);
1216 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmUnsigned)) {
1217 CHECK_VAR(x, Bounds(cache.kAsmInt));
1218 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1219 }
1220 }
1221 }
1222 CHECK_SKIP();
1191 } 1223 }
1192 CHECK_FUNC_TYPES_END 1224 CHECK_FUNC_TYPES_END
1193 } 1225 }
1194 1226
1227 TEST(Float64ToFloat32) {
1228 CHECK_FUNC_TYPES_BEGIN(
1229 "function bar() { var x = 1.0; return fround(x); }\n"
1230 "function foo() { bar(); }") {
1231 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) {
1232 CHECK_EXPR(Assignment, Bounds(cache.kAsmDouble)) {
1233 CHECK_VAR(x, Bounds(cache.kAsmDouble));
1234 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble));
1235 }
1236 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) {
1237 CHECK_VAR(fround, FUNC_N2F_TYPE);
1238 CHECK_VAR(x, Bounds(cache.kAsmDouble));
1239 }
1240 }
1241 CHECK_SKIP();
1242 }
1243 CHECK_FUNC_TYPES_END
1244 }
1245
1246 TEST(Int32ToFloat32ToInt32) {
1247 CHECK_FUNC_TYPES_BEGIN(
1248 "function bar() { var x = 1; return ~~fround(x|0) | 0; }\n"
1249 "function foo() { bar(); }") {
1250 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) {
1251 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
1252 CHECK_VAR(x, Bounds(cache.kAsmInt));
1253 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1254 }
1255 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
1256 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
1257 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
1258 CHECK_EXPR(Call, Bounds(cache.kAsmFloat)) {
1259 CHECK_VAR(fround, FUNC_N2F_TYPE);
1260 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) {
1261 CHECK_VAR(x, Bounds(cache.kAsmInt));
1262 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1263 }
1264 }
1265 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
1266 }
1267 CHECK_EXPR(Literal, Bounds(cache.kAsmSigned));
1268 }
1269 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1270 }
1271 }
1272 CHECK_SKIP();
1273 }
1274 CHECK_FUNC_TYPES_END
1275 }
1195 1276
1196 TEST(Addition4) { 1277 TEST(Addition4) {
1197 CHECK_FUNC_TYPES_BEGIN( 1278 CHECK_FUNC_TYPES_BEGIN(
1198 "function bar() { var x = 1; var y = 2; return (x+y+x+y)|0; }\n" 1279 "function bar() { var x = 1; var y = 2; return (x+y+x+y)|0; }\n"
1199 "function foo() { bar(); }") { 1280 "function foo() { bar(); }") {
1200 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) { 1281 CHECK_EXPR(FunctionLiteral, FUNC_I_TYPE) {
1201 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { 1282 CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) {
1202 CHECK_VAR(x, Bounds(cache.kAsmInt)); 1283 CHECK_VAR(x, Bounds(cache.kAsmInt));
1203 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); 1284 CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum));
1204 } 1285 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 TEST(CompareMismatchInt32Uint32) { 1350 TEST(CompareMismatchInt32Uint32) {
1270 CHECK_FUNC_ERROR( 1351 CHECK_FUNC_ERROR(
1271 "function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n" 1352 "function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n"
1272 "function foo() { bar(); }", 1353 "function foo() { bar(); }",
1273 "asm: line 1: left and right side of comparison must match\n"); 1354 "asm: line 1: left and right side of comparison must match\n");
1274 } 1355 }
1275 1356
1276 1357
1277 TEST(CompareMismatchInt32Float32) { 1358 TEST(CompareMismatchInt32Float32) {
1278 CHECK_FUNC_ERROR( 1359 CHECK_FUNC_ERROR(
1279 "function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n" 1360 "function bar() { var x = 1; var y = 2.0; return (x < fround(y))|0; }\n"
1280 "function foo() { bar(); }", 1361 "function foo() { bar(); }",
1281 "asm: line 1: left and right side of comparison must match\n"); 1362 "asm: line 1: left and right side of comparison must match\n");
1282 } 1363 }
1283 1364
1284 1365
1285 TEST(Float64ToInt32) { 1366 TEST(Float64ToInt32) {
1286 CHECK_FUNC_TYPES_BEGIN( 1367 CHECK_FUNC_TYPES_BEGIN(
1287 "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n" 1368 "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n"
1288 "function foo() { bar(); }") { 1369 "function foo() { bar(); }") {
1289 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { 1370 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 } 1828 }
1748 1829
1749 1830
1750 TEST(LogicalOrOperator) { 1831 TEST(LogicalOrOperator) {
1751 CHECK_FUNC_ERROR( 1832 CHECK_FUNC_ERROR(
1752 "function bar() { return (0 || 0)|0; }\n" 1833 "function bar() { return (0 || 0)|0; }\n"
1753 "function foo() { bar(); }", 1834 "function foo() { bar(); }",
1754 "asm: line 1: illegal logical operator\n"); 1835 "asm: line 1: illegal logical operator\n");
1755 } 1836 }
1756 1837
1838 TEST(BitOrDouble) {
1839 CHECK_FUNC_ERROR(
1840 "function bar() { var x = 1.0; return x | 0; }\n"
1841 "function foo() { bar(); }",
1842 "asm: line 1: intish required\n");
1843 }
1757 1844
1758 TEST(BadLiteral) { 1845 TEST(BadLiteral) {
1759 CHECK_FUNC_ERROR( 1846 CHECK_FUNC_ERROR(
1760 "function bar() { return true | 0; }\n" 1847 "function bar() { return true | 0; }\n"
1761 "function foo() { bar(); }", 1848 "function foo() { bar(); }",
1762 "asm: line 1: illegal literal\n"); 1849 "asm: line 1: illegal literal\n");
1763 } 1850 }
1764 1851
1765 1852
1766 TEST(MismatchedReturnTypeLiteral) { 1853 TEST(MismatchedReturnTypeLiteral) {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) { 2491 CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmDouble)) {
2405 CHECK_VAR(x, Bounds(cache.kAsmDouble)); 2492 CHECK_VAR(x, Bounds(cache.kAsmDouble));
2406 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble)); 2493 CHECK_EXPR(Literal, Bounds(cache.kAsmDouble));
2407 } 2494 }
2408 } 2495 }
2409 } 2496 }
2410 CHECK_SKIP(); 2497 CHECK_SKIP();
2411 } 2498 }
2412 CHECK_FUNC_TYPES_END 2499 CHECK_FUNC_TYPES_END
2413 } 2500 }
OLDNEW
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698