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

Unified Diff: test/cctest/test-asm-validator.cc

Issue 1405383007: Increase strictness of asm type conversions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/typing-asm.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-asm-validator.cc
diff --git a/test/cctest/test-asm-validator.cc b/test/cctest/test-asm-validator.cc
index c62d0fd998405365ff52e548963b99611f3736bb..5b2a04d47dbf6535f981cb251901d6169c957c65 100644
--- a/test/cctest/test-asm-validator.cc
+++ b/test/cctest/test-asm-validator.cc
@@ -719,6 +719,62 @@ TEST(UnsignedDivide) {
}
+TEST(UnsignedFromFloat64) {
+ CHECK_FUNC_ERROR(
+ "function bar() { var x = 1.0; return (x>>>0)|0; }\n"
+ "function foo() { bar(); }",
+ "asm: line 39: ill typed bitwise operation\n");
+}
+
+
+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");
+}
+
+
+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");
+}
+
+
+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");
+}
+
+
+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");
+}
+
+
+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");
+}
+
+
+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: ill-typed conditional\n");
+}
+
+
TEST(FroundFloat32) {
CHECK_FUNC_TYPES_BEGIN(
"function bar() { var x = 1; return fround(x); }\n"
@@ -812,6 +868,36 @@ TEST(CompareMismatchInt32Float32) {
}
+TEST(Float64ToInt32) {
+ CHECK_FUNC_TYPES_BEGIN(
+ "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n"
+ "function foo() { bar(); }") {
+ CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
+ CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
+ CHECK_VAR(x, Bounds(cache.kInt32));
+ CHECK_EXPR(Literal, Bounds(cache.kInt32));
+ }
+ CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) {
+ CHECK_VAR(y, Bounds(cache.kFloat64));
+ CHECK_EXPR(Literal, Bounds(cache.kFloat64));
+ }
+ CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
+ CHECK_VAR(x, Bounds(cache.kInt32));
+ CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) {
+ CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) {
+ CHECK_VAR(y, Bounds(cache.kFloat64));
+ CHECK_EXPR(Literal, Bounds(cache.kInt32));
+ }
+ CHECK_EXPR(Literal, Bounds(cache.kInt32));
+ }
+ }
+ }
+ CHECK_SKIP();
+ }
+ CHECK_FUNC_TYPES_END
+}
+
+
TEST(Load1) {
CHECK_FUNC_TYPES_BEGIN(
"function bar() { var x = 1; var y = i8[x>>0]|0; }\n"
« no previous file with comments | « src/typing-asm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698