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

Side by Side Diff: src/typing-asm.cc

Issue 1423563008: Fixing asm typing issues. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: revised 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.h ('k') | test/cctest/test-asm-validator.cc » ('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/typing-asm.h" 7 #include "src/typing-asm.h"
8 8
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 UNREACHABLE(); 787 UNREACHABLE();
788 } 788 }
789 } 789 }
790 790
791 791
792 void AsmTyper::VisitCountOperation(CountOperation* expr) { 792 void AsmTyper::VisitCountOperation(CountOperation* expr) {
793 FAIL(expr, "increment or decrement operator encountered"); 793 FAIL(expr, "increment or decrement operator encountered");
794 } 794 }
795 795
796 796
797 void AsmTyper::VisitIntegerBinaryOperation(BinaryOperation* expr,
798 Type* expected_type,
799 Type* result_type) {
800 RECURSE(VisitWithExpectation(expr->left(), expected_type,
801 "left bit operand expected to be integer"));
802 int left_intish = intish_;
803 RECURSE(VisitWithExpectation(expr->right(), expected_type,
804 "right bit operand expected to be integer"));
805 int right_intish = intish_;
806 if (left_intish > kMaxUncombinedAdditiveSteps) {
807 FAIL(expr, "too many consecutive additive ops");
808 }
809 if (right_intish > kMaxUncombinedAdditiveSteps) {
810 FAIL(expr, "too many consecutive additive ops");
811 }
812 intish_ = 0;
813 IntersectResult(expr, result_type);
814 }
815
816
797 void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) { 817 void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) {
798 switch (expr->op()) { 818 switch (expr->op()) {
799 case Token::COMMA: { 819 case Token::COMMA: {
800 RECURSE(VisitWithExpectation(expr->left(), Type::Any(), 820 RECURSE(VisitWithExpectation(expr->left(), Type::Any(),
801 "left comma operand expected to be any")); 821 "left comma operand expected to be any"));
802 RECURSE(VisitWithExpectation(expr->right(), Type::Any(), 822 RECURSE(VisitWithExpectation(expr->right(), Type::Any(),
803 "right comma operand expected to be any")); 823 "right comma operand expected to be any"));
804 IntersectResult(expr, computed_type_); 824 IntersectResult(expr, computed_type_);
805 return; 825 return;
806 } 826 }
807 case Token::OR: 827 case Token::OR:
808 case Token::AND: 828 case Token::AND:
809 FAIL(expr, "logical operator encountered"); 829 FAIL(expr, "logical operator encountered");
810 case Token::BIT_OR: 830 case Token::BIT_OR: {
811 case Token::BIT_AND: 831 // BIT_OR allows Any since it is used as a type coercion.
812 case Token::BIT_XOR: 832 VisitIntegerBinaryOperation(expr, Type::Any(), cache_.kInt32);
833 return;
834 }
835 case Token::BIT_XOR: {
836 // BIT_XOR allows Number since it is used as a type coercion (encoding ~).
837 VisitIntegerBinaryOperation(expr, Type::Number(), cache_.kInt32);
838 return;
839 }
840 case Token::SHR: {
841 VisitIntegerBinaryOperation(expr, Type::Number(), cache_.kUint32);
842 return;
843 }
813 case Token::SHL: 844 case Token::SHL:
814 case Token::SHR: 845 case Token::SAR:
815 case Token::SAR: { 846 case Token::BIT_AND: {
816 // BIT_OR allows Any since it is used as a type coercion. 847 VisitIntegerBinaryOperation(expr, cache_.kInt32, cache_.kInt32);
817 // BIT_XOR allows Number since it is used as a type coercion (encoding ~).
818 Type* expectation =
819 expr->op() == Token::BIT_OR
820 ? Type::Any()
821 : expr->op() == Token::BIT_XOR ? Type::Number() : cache_.kInt32;
822 Type* result =
823 expr->op() == Token::SHR ? Type::Unsigned32() : cache_.kInt32;
824 RECURSE(VisitWithExpectation(expr->left(), expectation,
825 "left bit operand expected to be integer"));
826 int left_intish = intish_;
827 RECURSE(VisitWithExpectation(expr->right(), expectation,
828 "right bit operand expected to be integer"));
829 int right_intish = intish_;
830 if (left_intish > kMaxUncombinedAdditiveSteps) {
831 FAIL(expr, "too many consecutive additive ops");
832 }
833 if (right_intish > kMaxUncombinedAdditiveSteps) {
834 FAIL(expr, "too many consecutive additive ops");
835 }
836 intish_ = 0;
837 IntersectResult(expr, result);
838 return; 848 return;
839 } 849 }
840 case Token::ADD: 850 case Token::ADD:
841 case Token::SUB: 851 case Token::SUB:
842 case Token::MUL: 852 case Token::MUL:
843 case Token::DIV: 853 case Token::DIV:
844 case Token::MOD: { 854 case Token::MOD: {
845 RECURSE(VisitWithExpectation( 855 RECURSE(VisitWithExpectation(
846 expr->left(), Type::Number(), 856 expr->left(), Type::Number(),
847 "left arithmetic operand expected to be number")); 857 "left arithmetic operand expected to be number"));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 RECURSE( 902 RECURSE(
893 VisitWithExpectation(expr->left(), Type::Number(), 903 VisitWithExpectation(expr->left(), Type::Number(),
894 "left comparison operand expected to be number")); 904 "left comparison operand expected to be number"));
895 Type* left_type = computed_type_; 905 Type* left_type = computed_type_;
896 RECURSE( 906 RECURSE(
897 VisitWithExpectation(expr->right(), Type::Number(), 907 VisitWithExpectation(expr->right(), Type::Number(),
898 "right comparison operand expected to be number")); 908 "right comparison operand expected to be number"));
899 Type* right_type = computed_type_; 909 Type* right_type = computed_type_;
900 Type* type = Type::Union(left_type, right_type, zone()); 910 Type* type = Type::Union(left_type, right_type, zone());
901 expr->set_combined_type(type); 911 expr->set_combined_type(type);
902 if (type->Is(Type::Integral32()) || type->Is(Type::UntaggedFloat64())) { 912 if (type->Is(cache_.kInt32) || type->Is(cache_.kUint32) ||
913 type->Is(cache_.kFloat32) || type->Is(cache_.kFloat64)) {
903 IntersectResult(expr, cache_.kInt32); 914 IntersectResult(expr, cache_.kInt32);
904 } else { 915 } else {
905 FAIL(expr, "ill-typed comparison operation"); 916 FAIL(expr, "ill-typed comparison operation");
906 } 917 }
907 } 918 }
908 919
909 920
910 void AsmTyper::VisitThisFunction(ThisFunction* expr) { 921 void AsmTyper::VisitThisFunction(ThisFunction* expr) {
911 FAIL(expr, "this function not allowed"); 922 FAIL(expr, "this function not allowed");
912 } 923 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 computed_type_->Print(); 1078 computed_type_->Print();
1068 PrintF("Expected type: "); 1079 PrintF("Expected type: ");
1069 expected_type_->Print(); 1080 expected_type_->Print();
1070 #endif 1081 #endif
1071 FAIL(expr, msg); 1082 FAIL(expr, msg);
1072 } 1083 }
1073 expected_type_ = save; 1084 expected_type_ = save;
1074 } 1085 }
1075 } // namespace internal 1086 } // namespace internal
1076 } // namespace v8 1087 } // namespace v8
OLDNEW
« no previous file with comments | « src/typing-asm.h ('k') | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698