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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/typing-asm.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/ast-expression-visitor.h" 8 #include "src/ast-expression-visitor.h"
9 #include "src/parser.h" 9 #include "src/parser.h"
10 #include "src/rewriter.h" 10 #include "src/rewriter.h"
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 } 712 }
713 CHECK_EXPR(Literal, Bounds(cache.kInt32)); 713 CHECK_EXPR(Literal, Bounds(cache.kInt32));
714 } 714 }
715 } 715 }
716 CHECK_SKIP(); 716 CHECK_SKIP();
717 } 717 }
718 CHECK_FUNC_TYPES_END 718 CHECK_FUNC_TYPES_END
719 } 719 }
720 720
721 721
722 TEST(UnsignedFromFloat64) {
723 CHECK_FUNC_ERROR(
724 "function bar() { var x = 1.0; return (x>>>0)|0; }\n"
725 "function foo() { bar(); }",
726 "asm: line 39: ill typed bitwise operation\n");
727 }
728
729
730 TEST(TypeMismatchAddInt32Float64) {
731 CHECK_FUNC_ERROR(
732 "function bar() { var x = 1.0; var y = 0; return (x + y)|0; }\n"
733 "function foo() { bar(); }",
734 "asm: line 39: ill-typed arithmetic operation\n");
735 }
736
737
738 TEST(TypeMismatchSubInt32Float64) {
739 CHECK_FUNC_ERROR(
740 "function bar() { var x = 1.0; var y = 0; return (x - y)|0; }\n"
741 "function foo() { bar(); }",
742 "asm: line 39: ill-typed arithmetic operation\n");
743 }
744
745
746 TEST(TypeMismatchDivInt32Float64) {
747 CHECK_FUNC_ERROR(
748 "function bar() { var x = 1.0; var y = 0; return (x / y)|0; }\n"
749 "function foo() { bar(); }",
750 "asm: line 39: ill-typed arithmetic operation\n");
751 }
752
753
754 TEST(TypeMismatchModInt32Float64) {
755 CHECK_FUNC_ERROR(
756 "function bar() { var x = 1.0; var y = 0; return (x % y)|0; }\n"
757 "function foo() { bar(); }",
758 "asm: line 39: ill-typed arithmetic operation\n");
759 }
760
761
762 TEST(ModFloat32) {
763 CHECK_FUNC_ERROR(
764 "function bar() { var x = fround(1.0); return (x % x)|0; }\n"
765 "function foo() { bar(); }",
766 "asm: line 39: ill-typed arithmetic operation\n");
767 }
768
769
770 TEST(TernaryMismatchInt32Float64) {
771 CHECK_FUNC_ERROR(
772 "function bar() { var x = 1; var y = 0.0; return (1 ? x : y)|0; }\n"
773 "function foo() { bar(); }",
774 "asm: line 39: ill-typed conditional\n");
775 }
776
777
722 TEST(FroundFloat32) { 778 TEST(FroundFloat32) {
723 CHECK_FUNC_TYPES_BEGIN( 779 CHECK_FUNC_TYPES_BEGIN(
724 "function bar() { var x = 1; return fround(x); }\n" 780 "function bar() { var x = 1; return fround(x); }\n"
725 "function foo() { bar(); }") { 781 "function foo() { bar(); }") {
726 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) { 782 CHECK_EXPR(FunctionLiteral, FUNC_F_TYPE) {
727 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { 783 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
728 CHECK_VAR(x, Bounds(cache.kInt32)); 784 CHECK_VAR(x, Bounds(cache.kInt32));
729 CHECK_EXPR(Literal, Bounds(cache.kInt32)); 785 CHECK_EXPR(Literal, Bounds(cache.kInt32));
730 } 786 }
731 CHECK_EXPR(Call, Bounds(cache.kFloat32)) { 787 CHECK_EXPR(Call, Bounds(cache.kFloat32)) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 861
806 862
807 TEST(CompareMismatchInt32Float32) { 863 TEST(CompareMismatchInt32Float32) {
808 CHECK_FUNC_ERROR( 864 CHECK_FUNC_ERROR(
809 "function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n" 865 "function bar() { var x = 1; var y = 2; return (x < fround(y))|0; }\n"
810 "function foo() { bar(); }", 866 "function foo() { bar(); }",
811 "asm: line 39: ill-typed comparison operation\n"); 867 "asm: line 39: ill-typed comparison operation\n");
812 } 868 }
813 869
814 870
871 TEST(Float64ToInt32) {
872 CHECK_FUNC_TYPES_BEGIN(
873 "function bar() { var x = 1; var y = 0.0; x = ~~y; }\n"
874 "function foo() { bar(); }") {
875 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
876 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
877 CHECK_VAR(x, Bounds(cache.kInt32));
878 CHECK_EXPR(Literal, Bounds(cache.kInt32));
879 }
880 CHECK_EXPR(Assignment, Bounds(cache.kFloat64)) {
881 CHECK_VAR(y, Bounds(cache.kFloat64));
882 CHECK_EXPR(Literal, Bounds(cache.kFloat64));
883 }
884 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
885 CHECK_VAR(x, Bounds(cache.kInt32));
886 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) {
887 CHECK_EXPR(BinaryOperation, Bounds(cache.kInt32)) {
888 CHECK_VAR(y, Bounds(cache.kFloat64));
889 CHECK_EXPR(Literal, Bounds(cache.kInt32));
890 }
891 CHECK_EXPR(Literal, Bounds(cache.kInt32));
892 }
893 }
894 }
895 CHECK_SKIP();
896 }
897 CHECK_FUNC_TYPES_END
898 }
899
900
815 TEST(Load1) { 901 TEST(Load1) {
816 CHECK_FUNC_TYPES_BEGIN( 902 CHECK_FUNC_TYPES_BEGIN(
817 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n" 903 "function bar() { var x = 1; var y = i8[x>>0]|0; }\n"
818 "function foo() { bar(); }") { 904 "function foo() { bar(); }") {
819 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) { 905 CHECK_EXPR(FunctionLiteral, FUNC_V_TYPE) {
820 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { 906 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
821 CHECK_VAR(x, Bounds(cache.kInt32)); 907 CHECK_VAR(x, Bounds(cache.kInt32));
822 CHECK_EXPR(Literal, Bounds(cache.kInt32)); 908 CHECK_EXPR(Literal, Bounds(cache.kInt32));
823 } 909 }
824 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) { 910 CHECK_EXPR(Assignment, Bounds(cache.kInt32)) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 "return {foo: foo, bar: 1};" 1138 "return {foo: foo, bar: 1};"
1053 "}\n"; 1139 "}\n";
1054 1140
1055 v8::V8::Initialize(); 1141 v8::V8::Initialize();
1056 HandleAndZoneScope handles; 1142 HandleAndZoneScope handles;
1057 Zone* zone = handles.main_zone(); 1143 Zone* zone = handles.main_zone();
1058 ZoneVector<ExpressionTypeEntry> types(zone); 1144 ZoneVector<ExpressionTypeEntry> types(zone);
1059 CHECK_EQ("asm: line 40: non-function in function table\n", 1145 CHECK_EQ("asm: line 40: non-function in function table\n",
1060 Validate(zone, test_function, &types)); 1146 Validate(zone, test_function, &types));
1061 } 1147 }
OLDNEW
« 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