Index: test/cctest/test-asm-validator.cc |
diff --git a/test/cctest/test-asm-validator.cc b/test/cctest/test-asm-validator.cc |
index 545957ad955e6230564e55ec5458f4b365f24044..d2a70d438ab578e270390f47b79f14e1e0c9ffdf 100644 |
--- a/test/cctest/test-asm-validator.cc |
+++ b/test/cctest/test-asm-validator.cc |
@@ -183,7 +183,7 @@ TEST(ValidateMinimum) { |
CHECK_EXPR(Literal, Bounds(cache.kAsmFixnum)); |
} |
} |
- // p = (p + 8)|0) {\n" |
+ // p = (p + 8)|0) { |
CHECK_EXPR(Assignment, Bounds(cache.kAsmInt)) { |
CHECK_VAR(p, Bounds(cache.kAsmInt)); |
CHECK_EXPR(BinaryOperation, Bounds(cache.kAsmSigned)) { |
@@ -354,59 +354,54 @@ TEST(MissingReturnExports) { |
Validate(zone, test_function, &types)); |
} |
- |
-#define HARNESS_STDLIB() \ |
- "var Infinity = stdlib.Infinity;\n" \ |
- "var NaN = stdlib.NaN;\n" \ |
- "var acos = stdlib.Math.acos;\n" \ |
- "var asin = stdlib.Math.asin;\n" \ |
- "var atan = stdlib.Math.atan;\n" \ |
- "var cos = stdlib.Math.cos;\n" \ |
- "var sin = stdlib.Math.sin;\n" \ |
- "var tan = stdlib.Math.tan;\n" \ |
- "var exp = stdlib.Math.exp;\n" \ |
- "var log = stdlib.Math.log;\n" \ |
- "var ceil = stdlib.Math.ceil;\n" \ |
- "var floor = stdlib.Math.floor;\n" \ |
- "var sqrt = stdlib.Math.sqrt;\n" \ |
- "var min = stdlib.Math.min;\n" \ |
- "var max = stdlib.Math.max;\n" \ |
- "var atan2 = stdlib.Math.atan2;\n" \ |
- "var pow = stdlib.Math.pow;\n" \ |
- "var abs = stdlib.Math.abs;\n" \ |
- "var imul = stdlib.Math.imul;\n" \ |
- "var fround = stdlib.Math.fround;\n" \ |
- "var E = stdlib.Math.E;\n" \ |
- "var LN10 = stdlib.Math.LN10;\n" \ |
- "var LN2 = stdlib.Math.LN2;\n" \ |
- "var LOG2E = stdlib.Math.LOG2E;\n" \ |
- "var LOG10E = stdlib.Math.LOG10E;\n" \ |
- "var PI = stdlib.Math.PI;\n" \ |
- "var SQRT1_2 = stdlib.Math.SQRT1_2;\n" \ |
- "var SQRT2 = stdlib.Math.SQRT2;\n" |
- |
- |
-#define HARNESS_HEAP() \ |
- "var u8 = new stdlib.Uint8Array(buffer);\n" \ |
- "var i8 = new stdlib.Int8Array(buffer);\n" \ |
- "var u16 = new stdlib.Uint16Array(buffer);\n" \ |
- "var i16 = new stdlib.Int16Array(buffer);\n" \ |
- "var u32 = new stdlib.Uint32Array(buffer);\n" \ |
- "var i32 = new stdlib.Int32Array(buffer);\n" \ |
- "var f32 = new stdlib.Float32Array(buffer);\n" \ |
- "var f64 = new stdlib.Float64Array(buffer);\n" |
- |
- |
-#define HARNESS_PREAMBLE() \ |
- const char test_function[] = \ |
- "function Module(stdlib, foreign, buffer) {\n" \ |
- "\"use asm\";\n" HARNESS_STDLIB() HARNESS_HEAP() |
- |
+#define HARNESS_STDLIB() \ |
+ "var Infinity = stdlib.Infinity; " \ |
+ "var NaN = stdlib.NaN; " \ |
+ "var acos = stdlib.Math.acos; " \ |
+ "var asin = stdlib.Math.asin; " \ |
+ "var atan = stdlib.Math.atan; " \ |
+ "var cos = stdlib.Math.cos; " \ |
+ "var sin = stdlib.Math.sin; " \ |
+ "var tan = stdlib.Math.tan; " \ |
+ "var exp = stdlib.Math.exp; " \ |
+ "var log = stdlib.Math.log; " \ |
+ "var ceil = stdlib.Math.ceil; " \ |
+ "var floor = stdlib.Math.floor; " \ |
+ "var sqrt = stdlib.Math.sqrt; " \ |
+ "var min = stdlib.Math.min; " \ |
+ "var max = stdlib.Math.max; " \ |
+ "var atan2 = stdlib.Math.atan2; " \ |
+ "var pow = stdlib.Math.pow; " \ |
+ "var abs = stdlib.Math.abs; " \ |
+ "var imul = stdlib.Math.imul; " \ |
+ "var fround = stdlib.Math.fround; " \ |
+ "var E = stdlib.Math.E; " \ |
+ "var LN10 = stdlib.Math.LN10; " \ |
+ "var LN2 = stdlib.Math.LN2; " \ |
+ "var LOG2E = stdlib.Math.LOG2E; " \ |
+ "var LOG10E = stdlib.Math.LOG10E; " \ |
+ "var PI = stdlib.Math.PI; " \ |
+ "var SQRT1_2 = stdlib.Math.SQRT1_2; " \ |
+ "var SQRT2 = stdlib.Math.SQRT2; " |
+ |
+#define HARNESS_HEAP() \ |
+ "var u8 = new stdlib.Uint8Array(buffer); " \ |
+ "var i8 = new stdlib.Int8Array(buffer); " \ |
+ "var u16 = new stdlib.Uint16Array(buffer); " \ |
+ "var i16 = new stdlib.Int16Array(buffer); " \ |
+ "var u32 = new stdlib.Uint32Array(buffer); " \ |
+ "var i32 = new stdlib.Int32Array(buffer); " \ |
+ "var f32 = new stdlib.Float32Array(buffer); " \ |
+ "var f64 = new stdlib.Float64Array(buffer); " |
+ |
+#define HARNESS_PREAMBLE() \ |
+ const char test_function[] = \ |
+ "function Module(stdlib, foreign, buffer) { " \ |
+ "\"use asm\"; " HARNESS_STDLIB() HARNESS_HEAP() |
#define HARNESS_POSTAMBLE() \ |
- "return { foo: foo };\n" \ |
- "}\n"; |
- |
+ "return { foo: foo }; " \ |
+ "} "; |
#define CHECK_VAR_MATH_SHORTCUT(name, type) \ |
CHECK_EXPR(Assignment, type) { \ |
@@ -1088,7 +1083,7 @@ TEST(UnsignedFromFloat64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; return (x>>>0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: left bitwise operand expected to be an integer\n"); |
+ "asm: line 1: left bitwise operand expected to be an integer\n"); |
} |
@@ -1096,7 +1091,7 @@ TEST(AndFloat64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; return (x&0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: left bitwise operand expected to be an integer\n"); |
+ "asm: line 1: left bitwise operand expected to be an integer\n"); |
} |
@@ -1104,7 +1099,7 @@ TEST(TypeMismatchAddInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; var y = 0; return (x + y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: ill-typed arithmetic operation\n"); |
+ "asm: line 1: ill-typed arithmetic operation\n"); |
} |
@@ -1112,7 +1107,7 @@ TEST(TypeMismatchSubInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; var y = 0; return (x - y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: ill-typed arithmetic operation\n"); |
+ "asm: line 1: ill-typed arithmetic operation\n"); |
} |
@@ -1120,7 +1115,7 @@ TEST(TypeMismatchDivInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; var y = 0; return (x / y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: ill-typed arithmetic operation\n"); |
+ "asm: line 1: ill-typed arithmetic operation\n"); |
} |
@@ -1128,7 +1123,7 @@ TEST(TypeMismatchModInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1.0; var y = 0; return (x % y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: ill-typed arithmetic operation\n"); |
+ "asm: line 1: ill-typed arithmetic operation\n"); |
} |
@@ -1136,7 +1131,7 @@ TEST(ModFloat32) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = fround(1.0); return (x % x)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: ill-typed arithmetic operation\n"); |
+ "asm: line 1: ill-typed arithmetic operation\n"); |
} |
@@ -1144,7 +1139,7 @@ TEST(TernaryMismatchInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: then and else expressions in ? must have the same type\n"); |
+ "asm: line 1: then and else expressions in ? must have the same type\n"); |
} |
@@ -1152,7 +1147,7 @@ TEST(TernaryMismatchIntish) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 0; return (1 ? x + x : y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: invalid type in ? then expression\n"); |
+ "asm: line 1: invalid type in ? then expression\n"); |
} |
@@ -1160,7 +1155,7 @@ TEST(TernaryMismatchInt32Float32) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2; return (x?fround(y):x)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: then and else expressions in ? must have the same type\n"); |
+ "asm: line 1: then and else expressions in ? must have the same type\n"); |
} |
@@ -1168,14 +1163,14 @@ TEST(TernaryBadCondition) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2.0; return (y?x:1)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: condition must be of type int\n"); |
+ "asm: line 1: condition must be of type int\n"); |
} |
TEST(BadIntishMultiply) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; return ((x + x) * 4) | 0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: intish not allowed in multiply\n"); |
+ "asm: line 1: intish not allowed in multiply\n"); |
} |
TEST(FroundFloat32) { |
@@ -1235,7 +1230,7 @@ TEST(Multiplication2) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2; return (x*y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: multiply must be by an integer literal\n"); |
+ "asm: line 1: multiply must be by an integer literal\n"); |
} |
@@ -1243,7 +1238,7 @@ TEST(Division4) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2; return (x/y/x/y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: too many consecutive multiplicative ops\n"); |
+ "asm: line 1: too many consecutive multiplicative ops\n"); |
} |
@@ -1251,7 +1246,7 @@ TEST(CompareToStringLeft) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; return ('hi' > x)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: bad type on left side of comparison\n"); |
+ "asm: line 1: bad type on left side of comparison\n"); |
} |
@@ -1259,7 +1254,7 @@ TEST(CompareToStringRight) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; return (x < 'hi')|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: bad type on right side of comparison\n"); |
+ "asm: line 1: bad type on right side of comparison\n"); |
} |
@@ -1267,7 +1262,7 @@ TEST(CompareMismatchInt32Float64) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2.0; return (x < y)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: left and right side of comparison must match\n"); |
+ "asm: line 1: left and right side of comparison must match\n"); |
} |
@@ -1275,7 +1270,7 @@ TEST(CompareMismatchInt32Uint32) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2; return ((x|0) < (y>>>0))|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: left and right side of comparison must match\n"); |
+ "asm: line 1: left and right side of comparison must match\n"); |
} |
@@ -1283,7 +1278,7 @@ TEST(CompareMismatchInt32Float32) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: left and right side of comparison must match\n"); |
+ "asm: line 1: left and right side of comparison must match\n"); |
} |
@@ -1624,7 +1619,7 @@ TEST(BadFunctionTable) { |
"function bar(x, y) { x = x | 0; y = y | 0;\n" |
" return table1[x & 1](y)|0; }\n" |
"function foo() { bar(1, 2); }", |
- "asm: line 40: array component expected to be a function\n"); |
+ "asm: line 2: array component expected to be a function\n"); |
} |
@@ -1632,7 +1627,7 @@ TEST(MissingParameterTypes) { |
CHECK_FUNC_ERROR( |
"function bar(x) { var y = 1; }\n" |
"function foo() { bar(2); }", |
- "asm: line 39: missing parameter type annotations\n"); |
+ "asm: line 1: missing parameter type annotations\n"); |
} |
@@ -1640,7 +1635,7 @@ TEST(InvalidTypeAnnotationBinaryOpDiv) { |
CHECK_FUNC_ERROR( |
"function bar(x) { x = x / 4; }\n" |
"function foo() { bar(2); }", |
- "asm: line 39: invalid type annotation on binary op\n"); |
+ "asm: line 1: invalid type annotation on binary op\n"); |
} |
@@ -1648,7 +1643,7 @@ TEST(InvalidTypeAnnotationBinaryOpMul) { |
CHECK_FUNC_ERROR( |
"function bar(x) { x = x * 4.0; }\n" |
"function foo() { bar(2); }", |
- "asm: line 39: invalid type annotation on binary op\n"); |
+ "asm: line 1: invalid type annotation on binary op\n"); |
} |
@@ -1656,7 +1651,7 @@ TEST(InvalidArgumentCount) { |
CHECK_FUNC_ERROR( |
"function bar(x) { return fround(4, 5); }\n" |
"function foo() { bar(); }", |
- "asm: line 39: invalid argument count calling function\n"); |
+ "asm: line 1: invalid argument count calling function\n"); |
} |
@@ -1664,7 +1659,7 @@ TEST(InvalidTypeAnnotationArity) { |
CHECK_FUNC_ERROR( |
"function bar(x) { x = max(x); }\n" |
"function foo() { bar(3); }", |
- "asm: line 39: only fround allowed on expression annotations\n"); |
+ "asm: line 1: only fround allowed on expression annotations\n"); |
} |
@@ -1672,7 +1667,7 @@ TEST(InvalidTypeAnnotationOnlyFround) { |
CHECK_FUNC_ERROR( |
"function bar(x) { x = sin(x); }\n" |
"function foo() { bar(3); }", |
- "asm: line 39: only fround allowed on expression annotations\n"); |
+ "asm: line 1: only fround allowed on expression annotations\n"); |
} |
@@ -1680,7 +1675,7 @@ TEST(InvalidTypeAnnotation) { |
CHECK_FUNC_ERROR( |
"function bar(x) { x = (x+x)(x); }\n" |
"function foo() { bar(3); }", |
- "asm: line 39: invalid type annotation\n"); |
+ "asm: line 1: invalid type annotation\n"); |
} |
@@ -1688,7 +1683,7 @@ TEST(WithStatement) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 0; with (x) { x = x + 1; } }\n" |
"function foo() { bar(); }", |
- "asm: line 39: bad with statement\n"); |
+ "asm: line 1: bad with statement\n"); |
} |
@@ -1696,7 +1691,7 @@ TEST(NestedFunction) { |
CHECK_FUNC_ERROR( |
"function bar() { function x() { return 1; } }\n" |
"function foo() { bar(); }", |
- "asm: line 39: function declared inside another\n"); |
+ "asm: line 1: function declared inside another\n"); |
} |
@@ -1704,7 +1699,7 @@ TEST(UnboundVariable) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = y; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: unbound variable\n"); |
+ "asm: line 1: unbound variable\n"); |
} |
@@ -1712,7 +1707,7 @@ TEST(EqStrict) { |
CHECK_FUNC_ERROR( |
"function bar() { return (0 === 0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal comparison operator\n"); |
+ "asm: line 1: illegal comparison operator\n"); |
} |
@@ -1720,14 +1715,14 @@ TEST(NeStrict) { |
CHECK_FUNC_ERROR( |
"function bar() { return (0 !== 0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal comparison operator\n"); |
+ "asm: line 1: illegal comparison operator\n"); |
} |
TEST(InstanceOf) { |
const char* errorMsg = FLAG_harmony_instanceof |
? "asm: line 0: do-expression encountered\n" |
- : "asm: line 39: illegal comparison operator\n"; |
+ : "asm: line 1: illegal comparison operator\n"; |
CHECK_FUNC_ERROR( |
"function bar() { return (0 instanceof 0)|0; }\n" |
@@ -1740,7 +1735,7 @@ TEST(InOperator) { |
CHECK_FUNC_ERROR( |
"function bar() { return (0 in 0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal comparison operator\n"); |
+ "asm: line 1: illegal comparison operator\n"); |
} |
@@ -1748,7 +1743,7 @@ TEST(LogicalAndOperator) { |
CHECK_FUNC_ERROR( |
"function bar() { return (0 && 0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal logical operator\n"); |
+ "asm: line 1: illegal logical operator\n"); |
} |
@@ -1756,7 +1751,7 @@ TEST(LogicalOrOperator) { |
CHECK_FUNC_ERROR( |
"function bar() { return (0 || 0)|0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal logical operator\n"); |
+ "asm: line 1: illegal logical operator\n"); |
} |
@@ -1764,7 +1759,7 @@ TEST(BadLiteral) { |
CHECK_FUNC_ERROR( |
"function bar() { return true | 0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal literal\n"); |
+ "asm: line 1: illegal literal\n"); |
} |
@@ -1772,7 +1767,7 @@ TEST(MismatchedReturnTypeLiteral) { |
CHECK_FUNC_ERROR( |
"function bar() { if(1) { return 1; } return 1.0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: return type does not match function signature\n"); |
+ "asm: line 1: return type does not match function signature\n"); |
} |
@@ -1781,7 +1776,7 @@ TEST(MismatchedReturnTypeExpression) { |
"function bar() {\n" |
" var x = 1; var y = 1.0; if(1) { return x; } return +y; }\n" |
"function foo() { bar(); }", |
- "asm: line 40: return type does not match function signature\n"); |
+ "asm: line 2: return type does not match function signature\n"); |
} |
@@ -1789,7 +1784,7 @@ TEST(AssignToFloatishToF64) { |
CHECK_FUNC_ERROR( |
"function bar() { var v = fround(1.0); f64[0] = v + fround(1.0); }\n" |
"function foo() { bar(); }", |
- "asm: line 39: floatish assignment to double array\n"); |
+ "asm: line 1: floatish assignment to double array\n"); |
} |
@@ -1858,7 +1853,7 @@ TEST(BadExports) { |
HandleAndZoneScope handles; |
Zone* zone = handles.main_zone(); |
ZoneVector<ExpressionTypeEntry> types(zone); |
- CHECK_EQ("asm: line 40: non-function in function table\n", |
+ CHECK_EQ("asm: line 2: non-function in function table\n", |
Validate(zone, test_function, &types)); |
} |
@@ -1867,14 +1862,14 @@ TEST(NestedHeapAssignment) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 0; i16[x = 1] = 2; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: expected >> in heap access\n"); |
+ "asm: line 1: expected >> in heap access\n"); |
} |
TEST(BadOperatorHeapAssignment) { |
CHECK_FUNC_ERROR( |
"function bar() { var x = 0; i16[x & 1] = 2; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: expected >> in heap access\n"); |
+ "asm: line 1: expected >> in heap access\n"); |
} |
@@ -1882,7 +1877,7 @@ TEST(BadArrayAssignment) { |
CHECK_FUNC_ERROR( |
"function bar() { i8[0] = 0.0; }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal type in assignment\n"); |
+ "asm: line 1: illegal type in assignment\n"); |
} |
@@ -1891,7 +1886,7 @@ TEST(BadStandardFunctionCallOutside) { |
"var s0 = sin(0);\n" |
"function bar() { }\n" |
"function foo() { bar(); }", |
- "asm: line 39: illegal variable reference in module body\n"); |
+ "asm: line 1: illegal variable reference in module body\n"); |
} |
@@ -1900,7 +1895,7 @@ TEST(BadFunctionCallOutside) { |
"function bar() { return 0.0; }\n" |
"var s0 = bar(0);\n" |
"function foo() { bar(); }", |
- "asm: line 40: illegal variable reference in module body\n"); |
+ "asm: line 2: illegal variable reference in module body\n"); |
} |
@@ -2159,7 +2154,7 @@ TEST(BadSwitchRange) { |
CHECK_FUNC_ERROR( |
"function bar() { switch (1) { case -1: case 0x7fffffff: } }\n" |
"function foo() { bar(); }", |
- "asm: line 39: case range too large\n"); |
+ "asm: line 1: case range too large\n"); |
} |
@@ -2167,7 +2162,7 @@ TEST(DuplicateSwitchCase) { |
CHECK_FUNC_ERROR( |
"function bar() { switch (1) { case 0: case 0: } }\n" |
"function foo() { bar(); }", |
- "asm: line 39: duplicate case value\n"); |
+ "asm: line 1: duplicate case value\n"); |
} |
@@ -2175,7 +2170,7 @@ TEST(BadSwitchOrder) { |
CHECK_FUNC_ERROR( |
"function bar() { switch (1) { default: case 0: } }\n" |
"function foo() { bar(); }", |
- "asm: line 39: default case out of order\n"); |
+ "asm: line 1: default case out of order\n"); |
} |
TEST(BadForeignCall) { |