Chromium Code Reviews

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: fix Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | 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 797 matching lines...)
808 case Token::AND: 808 case Token::AND:
809 FAIL(expr, "logical operator encountered"); 809 FAIL(expr, "logical operator encountered");
810 case Token::BIT_OR: 810 case Token::BIT_OR:
811 case Token::BIT_AND: 811 case Token::BIT_AND:
812 case Token::BIT_XOR: 812 case Token::BIT_XOR:
813 case Token::SHL: 813 case Token::SHL:
814 case Token::SHR: 814 case Token::SHR:
815 case Token::SAR: { 815 case Token::SAR: {
816 // BIT_OR allows Any since it is used as a type coercion. 816 // BIT_OR allows Any since it is used as a type coercion.
817 // BIT_XOR allows Number since it is used as a type coercion (encoding ~). 817 // BIT_XOR allows Number since it is used as a type coercion (encoding ~).
818 Type* expectation = 818 // SHR allows Number since it is used as a type coercion to uint32.
819 expr->op() == Token::BIT_OR 819 Type* expectation;
titzer 2015/11/02 22:57:15 Is it time for a helper function where each case p
bradn 2015/11/03 00:10:24 Done.
820 ? Type::Any() 820 if (expr->op() == Token::BIT_OR) {
821 : expr->op() == Token::BIT_XOR ? Type::Number() : cache_.kInt32; 821 expectation = Type::Any();
822 Type* result = 822 } else if (expr->op() == Token::BIT_XOR ||
823 expr->op() == Token::SHR ? Type::Unsigned32() : cache_.kInt32; 823 expr->op() == Token::SHR) {
824 expectation = Type::Number();
825 } else {
826 expectation = cache_.kInt32;
827 }
824 RECURSE(VisitWithExpectation(expr->left(), expectation, 828 RECURSE(VisitWithExpectation(expr->left(), expectation,
825 "left bit operand expected to be integer")); 829 "left bit operand expected to be integer"));
826 int left_intish = intish_; 830 int left_intish = intish_;
827 RECURSE(VisitWithExpectation(expr->right(), expectation, 831 RECURSE(VisitWithExpectation(expr->right(), expectation,
828 "right bit operand expected to be integer")); 832 "right bit operand expected to be integer"));
829 int right_intish = intish_; 833 int right_intish = intish_;
830 if (left_intish > kMaxUncombinedAdditiveSteps) { 834 if (left_intish > kMaxUncombinedAdditiveSteps) {
831 FAIL(expr, "too many consecutive additive ops"); 835 FAIL(expr, "too many consecutive additive ops");
832 } 836 }
833 if (right_intish > kMaxUncombinedAdditiveSteps) { 837 if (right_intish > kMaxUncombinedAdditiveSteps) {
834 FAIL(expr, "too many consecutive additive ops"); 838 FAIL(expr, "too many consecutive additive ops");
835 } 839 }
836 intish_ = 0; 840 intish_ = 0;
841 Type* result =
842 expr->op() == Token::SHR ? cache_.kUint32 : cache_.kInt32;
837 IntersectResult(expr, result); 843 IntersectResult(expr, result);
838 return; 844 return;
839 } 845 }
840 case Token::ADD: 846 case Token::ADD:
841 case Token::SUB: 847 case Token::SUB:
842 case Token::MUL: 848 case Token::MUL:
843 case Token::DIV: 849 case Token::DIV:
844 case Token::MOD: { 850 case Token::MOD: {
845 RECURSE(VisitWithExpectation( 851 RECURSE(VisitWithExpectation(
846 expr->left(), Type::Number(), 852 expr->left(), Type::Number(),
(...skipping 45 matching lines...)
892 RECURSE( 898 RECURSE(
893 VisitWithExpectation(expr->left(), Type::Number(), 899 VisitWithExpectation(expr->left(), Type::Number(),
894 "left comparison operand expected to be number")); 900 "left comparison operand expected to be number"));
895 Type* left_type = computed_type_; 901 Type* left_type = computed_type_;
896 RECURSE( 902 RECURSE(
897 VisitWithExpectation(expr->right(), Type::Number(), 903 VisitWithExpectation(expr->right(), Type::Number(),
898 "right comparison operand expected to be number")); 904 "right comparison operand expected to be number"));
899 Type* right_type = computed_type_; 905 Type* right_type = computed_type_;
900 Type* type = Type::Union(left_type, right_type, zone()); 906 Type* type = Type::Union(left_type, right_type, zone());
901 expr->set_combined_type(type); 907 expr->set_combined_type(type);
902 if (type->Is(Type::Integral32()) || type->Is(Type::UntaggedFloat64())) { 908 if (type->Is(cache_.kInt32) ||
909 type->Is(cache_.kUint32) ||
910 type->Is(cache_.kFloat32) ||
911 type->Is(cache_.kFloat64)) {
903 IntersectResult(expr, cache_.kInt32); 912 IntersectResult(expr, cache_.kInt32);
904 } else { 913 } else {
905 FAIL(expr, "ill-typed comparison operation"); 914 FAIL(expr, "ill-typed comparison operation");
906 } 915 }
907 } 916 }
908 917
909 918
910 void AsmTyper::VisitThisFunction(ThisFunction* expr) { 919 void AsmTyper::VisitThisFunction(ThisFunction* expr) {
911 FAIL(expr, "this function not allowed"); 920 FAIL(expr, "this function not allowed");
912 } 921 }
(...skipping 154 matching lines...)
1067 computed_type_->Print(); 1076 computed_type_->Print();
1068 PrintF("Expected type: "); 1077 PrintF("Expected type: ");
1069 expected_type_->Print(); 1078 expected_type_->Print();
1070 #endif 1079 #endif
1071 FAIL(expr, msg); 1080 FAIL(expr, msg);
1072 } 1081 }
1073 expected_type_ = save; 1082 expected_type_ = save;
1074 } 1083 }
1075 } // namespace internal 1084 } // namespace internal
1076 } // namespace v8 1085 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine