OLD | NEW |
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/typing-asm.h" | 5 #include "src/typing-asm.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 | 1106 |
1107 intish_ = 0; | 1107 intish_ = 0; |
1108 | 1108 |
1109 if (left_type->Is(cache_.kAsmFixnum) && right_type->Is(cache_.kAsmInt)) { | 1109 if (left_type->Is(cache_.kAsmFixnum) && right_type->Is(cache_.kAsmInt)) { |
1110 left_type = right_type; | 1110 left_type = right_type; |
1111 } | 1111 } |
1112 if (right_type->Is(cache_.kAsmFixnum) && left_type->Is(cache_.kAsmInt)) { | 1112 if (right_type->Is(cache_.kAsmFixnum) && left_type->Is(cache_.kAsmInt)) { |
1113 right_type = left_type; | 1113 right_type = left_type; |
1114 } | 1114 } |
1115 if (!conversion) { | 1115 if (!conversion) { |
1116 if (!left_type->Is(cache_.kAsmInt) || !right_type->Is(cache_.kAsmInt)) { | 1116 if (!left_type->Is(cache_.kAsmIntQ) || !right_type->Is(cache_.kAsmIntQ)) { |
1117 FAIL(expr, "ill-typed bitwise operation"); | 1117 FAIL(expr, "ill-typed bitwise operation"); |
1118 } | 1118 } |
1119 } | 1119 } |
1120 IntersectResult(expr, result_type); | 1120 IntersectResult(expr, result_type); |
1121 } | 1121 } |
1122 | 1122 |
1123 | 1123 |
1124 void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) { | 1124 void AsmTyper::VisitBinaryOperation(BinaryOperation* expr) { |
1125 if (!in_function_) { | 1125 if (!in_function_) { |
1126 if (expr->op() != Token::BIT_OR && expr->op() != Token::MUL) { | 1126 if (expr->op() != Token::BIT_OR && expr->op() != Token::MUL) { |
(...skipping 23 matching lines...) Expand all Loading... |
1150 RECURSE(VisitWithExpectation(expr->right(), Type::Any(), | 1150 RECURSE(VisitWithExpectation(expr->right(), Type::Any(), |
1151 "right comma operand expected to be any")); | 1151 "right comma operand expected to be any")); |
1152 IntersectResult(expr, computed_type_); | 1152 IntersectResult(expr, computed_type_); |
1153 return; | 1153 return; |
1154 } | 1154 } |
1155 case Token::OR: | 1155 case Token::OR: |
1156 case Token::AND: | 1156 case Token::AND: |
1157 FAIL(expr, "illegal logical operator"); | 1157 FAIL(expr, "illegal logical operator"); |
1158 case Token::BIT_OR: { | 1158 case Token::BIT_OR: { |
1159 // BIT_OR allows Any since it is used as a type coercion. | 1159 // BIT_OR allows Any since it is used as a type coercion. |
1160 VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmInt, | 1160 VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, |
1161 cache_.kAsmSigned, true); | 1161 cache_.kAsmSigned, true); |
1162 if (expr->left()->IsCall() && expr->op() == Token::BIT_OR) { | 1162 if (expr->left()->IsCall() && expr->op() == Token::BIT_OR) { |
1163 expr->left()->set_bounds(Bounds(cache_.kAsmSigned)); | 1163 expr->left()->set_bounds(Bounds(cache_.kAsmSigned)); |
1164 } | 1164 } |
1165 return; | 1165 return; |
1166 } | 1166 } |
1167 case Token::BIT_XOR: { | 1167 case Token::BIT_XOR: { |
1168 // Handle booleans specially to handle de-sugared ! | 1168 // Handle booleans specially to handle de-sugared ! |
1169 Literal* left = expr->left()->AsLiteral(); | 1169 Literal* left = expr->left()->AsLiteral(); |
1170 if (left && left->value()->IsBoolean()) { | 1170 if (left && left->value()->IsBoolean()) { |
1171 if (left->ToBooleanIsTrue()) { | 1171 if (left->ToBooleanIsTrue()) { |
1172 left->set_bounds(Bounds(cache_.kSingletonOne)); | 1172 left->set_bounds(Bounds(cache_.kSingletonOne)); |
1173 RECURSE(VisitWithExpectation(expr->right(), cache_.kAsmInt, | 1173 RECURSE(VisitWithExpectation(expr->right(), cache_.kAsmIntQ, |
1174 "not operator expects an integer")); | 1174 "not operator expects an integer")); |
1175 IntersectResult(expr, cache_.kAsmSigned); | 1175 IntersectResult(expr, cache_.kAsmSigned); |
1176 return; | 1176 return; |
1177 } else { | 1177 } else { |
1178 FAIL(left, "unexpected false"); | 1178 FAIL(left, "unexpected false"); |
1179 } | 1179 } |
1180 } | 1180 } |
1181 // BIT_XOR allows Number since it is used as a type coercion (via ~~). | 1181 // BIT_XOR allows Any since it is used as a type coercion (via ~~). |
1182 VisitIntegerBitwiseOperator(expr, Type::Number(), cache_.kAsmInt, | 1182 VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, |
1183 cache_.kAsmSigned, true); | 1183 cache_.kAsmSigned, true); |
1184 return; | 1184 return; |
1185 } | 1185 } |
1186 case Token::SHR: { | 1186 case Token::SHR: { |
1187 VisitIntegerBitwiseOperator(expr, cache_.kAsmInt, cache_.kAsmInt, | 1187 VisitIntegerBitwiseOperator(expr, cache_.kAsmIntQ, cache_.kAsmIntQ, |
1188 cache_.kAsmUnsigned, false); | 1188 cache_.kAsmUnsigned, false); |
1189 return; | 1189 return; |
1190 } | 1190 } |
1191 case Token::SHL: | 1191 case Token::SHL: |
1192 case Token::SAR: | 1192 case Token::SAR: |
1193 case Token::BIT_AND: { | 1193 case Token::BIT_AND: { |
1194 VisitIntegerBitwiseOperator(expr, cache_.kAsmInt, cache_.kAsmInt, | 1194 VisitIntegerBitwiseOperator(expr, cache_.kAsmIntQ, cache_.kAsmIntQ, |
1195 cache_.kAsmSigned, false); | 1195 cache_.kAsmSigned, false); |
1196 return; | 1196 return; |
1197 } | 1197 } |
1198 case Token::ADD: | 1198 case Token::ADD: |
1199 case Token::SUB: | 1199 case Token::SUB: |
1200 case Token::MUL: | 1200 case Token::MUL: |
1201 case Token::DIV: | 1201 case Token::DIV: |
1202 case Token::MOD: { | 1202 case Token::MOD: { |
1203 RECURSE(VisitWithExpectation( | 1203 RECURSE(VisitWithExpectation( |
1204 expr->left(), Type::Number(), | 1204 expr->left(), Type::Number(), |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 } | 1560 } |
1561 | 1561 |
1562 | 1562 |
1563 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { | 1563 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { |
1564 RECURSE(Visit(expr->expression())); | 1564 RECURSE(Visit(expr->expression())); |
1565 } | 1565 } |
1566 | 1566 |
1567 | 1567 |
1568 } // namespace internal | 1568 } // namespace internal |
1569 } // namespace v8 | 1569 } // namespace v8 |
OLD | NEW |