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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 Expression* arg = args->at(i); | 981 Expression* arg = args->at(i); |
982 RECURSE(VisitWithExpectation( | 982 RECURSE(VisitWithExpectation( |
983 arg, fun_type->Parameter(i), | 983 arg, fun_type->Parameter(i), |
984 "call argument expected to match callee parameter")); | 984 "call argument expected to match callee parameter")); |
985 if (standard_member != kNone && standard_member != kMathFround && | 985 if (standard_member != kNone && standard_member != kMathFround && |
986 i == 0) { | 986 i == 0) { |
987 result_type = computed_type_; | 987 result_type = computed_type_; |
988 } | 988 } |
989 } | 989 } |
990 // Handle polymorphic stdlib functions specially. | 990 // Handle polymorphic stdlib functions specially. |
991 if (standard_member == kMathCeil || standard_member == kMathFloor || | 991 if (standard_member == kMathFround) { |
992 standard_member == kMathSqrt) { | 992 if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) && |
titzer
2016/03/21 07:59:44
Cache args->at(0)->bounds().upper?
bradn
2016/03/21 20:31:08
Done.
| |
993 !args->at(0)->bounds().upper->Is(cache_.kAsmDouble) && | |
994 !args->at(0)->bounds().upper->Is(cache_.kAsmSigned) && | |
995 !args->at(0)->bounds().upper->Is(cache_.kAsmUnsigned)) { | |
996 FAIL(expr, "illegal function argument type"); | |
997 } | |
998 } else if (standard_member == kMathCeil || | |
999 standard_member == kMathFloor || | |
1000 standard_member == kMathSqrt) { | |
993 if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) && | 1001 if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) && |
994 !args->at(0)->bounds().upper->Is(cache_.kAsmDouble)) { | 1002 !args->at(0)->bounds().upper->Is(cache_.kAsmDouble)) { |
995 FAIL(expr, "illegal function argument type"); | 1003 FAIL(expr, "illegal function argument type"); |
996 } | 1004 } |
997 } else if (standard_member == kMathAbs || standard_member == kMathMin || | 1005 } else if (standard_member == kMathAbs || standard_member == kMathMin || |
998 standard_member == kMathMax) { | 1006 standard_member == kMathMax) { |
999 if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) && | 1007 if (!args->at(0)->bounds().upper->Is(cache_.kAsmFloat) && |
1000 !args->at(0)->bounds().upper->Is(cache_.kAsmDouble) && | 1008 !args->at(0)->bounds().upper->Is(cache_.kAsmDouble) && |
1001 !args->at(0)->bounds().upper->Is(cache_.kAsmSigned)) { | 1009 !args->at(0)->bounds().upper->Is(cache_.kAsmSigned)) { |
1002 FAIL(expr, "illegal function argument type"); | 1010 FAIL(expr, "illegal function argument type"); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1149 RECURSE(VisitWithExpectation(expr->right(), Type::Any(), | 1157 RECURSE(VisitWithExpectation(expr->right(), Type::Any(), |
1150 "right comma operand expected to be any")); | 1158 "right comma operand expected to be any")); |
1151 IntersectResult(expr, computed_type_); | 1159 IntersectResult(expr, computed_type_); |
1152 return; | 1160 return; |
1153 } | 1161 } |
1154 case Token::OR: | 1162 case Token::OR: |
1155 case Token::AND: | 1163 case Token::AND: |
1156 FAIL(expr, "illegal logical operator"); | 1164 FAIL(expr, "illegal logical operator"); |
1157 case Token::BIT_OR: { | 1165 case Token::BIT_OR: { |
1158 // BIT_OR allows Any since it is used as a type coercion. | 1166 // BIT_OR allows Any since it is used as a type coercion. |
1159 VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, | 1167 RECURSE(VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, |
1160 cache_.kAsmSigned, true); | 1168 cache_.kAsmSigned, true)); |
1161 if (expr->left()->IsCall() && expr->op() == Token::BIT_OR && | 1169 if (expr->left()->IsCall() && expr->op() == Token::BIT_OR && |
1162 Type::Number()->Is(expr->left()->bounds().upper)) { | 1170 Type::Number()->Is(expr->left()->bounds().upper)) { |
1163 // Force the return types of foreign functions. | 1171 // Force the return types of foreign functions. |
1164 expr->left()->set_bounds(Bounds(cache_.kAsmSigned)); | 1172 expr->left()->set_bounds(Bounds(cache_.kAsmSigned)); |
1165 } | 1173 } |
1174 if (in_function_ && !expr->left()->bounds().upper->Is(cache_.kAsmIntQ)) { | |
1175 FAIL(expr->left(), "intish required"); | |
1176 } | |
1166 return; | 1177 return; |
1167 } | 1178 } |
1168 case Token::BIT_XOR: { | 1179 case Token::BIT_XOR: { |
1169 // Handle booleans specially to handle de-sugared ! | 1180 // Handle booleans specially to handle de-sugared ! |
1170 Literal* left = expr->left()->AsLiteral(); | 1181 Literal* left = expr->left()->AsLiteral(); |
1171 if (left && left->value()->IsBoolean()) { | 1182 if (left && left->value()->IsBoolean()) { |
1172 if (left->ToBooleanIsTrue()) { | 1183 if (left->ToBooleanIsTrue()) { |
1173 left->set_bounds(Bounds(cache_.kSingletonOne)); | 1184 left->set_bounds(Bounds(cache_.kSingletonOne)); |
1174 RECURSE(VisitWithExpectation(expr->right(), cache_.kAsmIntQ, | 1185 RECURSE(VisitWithExpectation(expr->right(), cache_.kAsmIntQ, |
1175 "not operator expects an integer")); | 1186 "not operator expects an integer")); |
1176 IntersectResult(expr, cache_.kAsmSigned); | 1187 IntersectResult(expr, cache_.kAsmSigned); |
1177 return; | 1188 return; |
1178 } else { | 1189 } else { |
1179 FAIL(left, "unexpected false"); | 1190 FAIL(left, "unexpected false"); |
1180 } | 1191 } |
1181 } | 1192 } |
1182 // BIT_XOR allows Any since it is used as a type coercion (via ~~). | 1193 // BIT_XOR allows Any since it is used as a type coercion (via ~~). |
1183 VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, | 1194 RECURSE(VisitIntegerBitwiseOperator(expr, Type::Any(), cache_.kAsmIntQ, |
1184 cache_.kAsmSigned, true); | 1195 cache_.kAsmSigned, true)); |
1185 return; | 1196 return; |
1186 } | 1197 } |
1187 case Token::SHR: { | 1198 case Token::SHR: { |
1188 VisitIntegerBitwiseOperator(expr, cache_.kAsmIntQ, cache_.kAsmIntQ, | 1199 RECURSE(VisitIntegerBitwiseOperator( |
1189 cache_.kAsmUnsigned, false); | 1200 expr, cache_.kAsmIntQ, cache_.kAsmIntQ, cache_.kAsmUnsigned, false)); |
1190 return; | 1201 return; |
1191 } | 1202 } |
1192 case Token::SHL: | 1203 case Token::SHL: |
1193 case Token::SAR: | 1204 case Token::SAR: |
1194 case Token::BIT_AND: { | 1205 case Token::BIT_AND: { |
1195 VisitIntegerBitwiseOperator(expr, cache_.kAsmIntQ, cache_.kAsmIntQ, | 1206 RECURSE(VisitIntegerBitwiseOperator( |
1196 cache_.kAsmSigned, false); | 1207 expr, cache_.kAsmIntQ, cache_.kAsmIntQ, cache_.kAsmSigned, false)); |
1197 return; | 1208 return; |
1198 } | 1209 } |
1199 case Token::ADD: | 1210 case Token::ADD: |
1200 case Token::SUB: | 1211 case Token::SUB: |
1201 case Token::MUL: | 1212 case Token::MUL: |
1202 case Token::DIV: | 1213 case Token::DIV: |
1203 case Token::MOD: { | 1214 case Token::MOD: { |
1204 RECURSE(VisitWithExpectation( | 1215 RECURSE(VisitWithExpectation( |
1205 expr->left(), Type::Number(), | 1216 expr->left(), Type::Number(), |
1206 "left arithmetic operand expected to be number")); | 1217 "left arithmetic operand expected to be number")); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1571 } | 1582 } |
1572 | 1583 |
1573 | 1584 |
1574 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { | 1585 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { |
1575 RECURSE(Visit(expr->expression())); | 1586 RECURSE(Visit(expr->expression())); |
1576 } | 1587 } |
1577 | 1588 |
1578 | 1589 |
1579 } // namespace internal | 1590 } // namespace internal |
1580 } // namespace v8 | 1591 } // namespace v8 |
OLD | NEW |