OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 ::v8::internal::TypeInfo left_type = | 2054 ::v8::internal::TypeInfo left_type = |
2055 ::v8::internal::TypeInfo::TypeFromValue(left); | 2055 ::v8::internal::TypeInfo::TypeFromValue(left); |
2056 ::v8::internal::TypeInfo right_type = | 2056 ::v8::internal::TypeInfo right_type = |
2057 ::v8::internal::TypeInfo::TypeFromValue(right); | 2057 ::v8::internal::TypeInfo::TypeFromValue(right); |
2058 | 2058 |
2059 if (left_type.IsSmi() && right_type.IsSmi()) { | 2059 if (left_type.IsSmi() && right_type.IsSmi()) { |
2060 return SMI; | 2060 return SMI; |
2061 } | 2061 } |
2062 | 2062 |
2063 if (left_type.IsInteger32() && right_type.IsInteger32()) { | 2063 if (left_type.IsInteger32() && right_type.IsInteger32()) { |
| 2064 // Platforms with 32-bit Smis have no distinct INT32 type. |
| 2065 if (kSmiValueSize == 32) return SMI; |
2064 return INT32; | 2066 return INT32; |
2065 } | 2067 } |
2066 | 2068 |
2067 if (left_type.IsNumber() && right_type.IsNumber()) { | 2069 if (left_type.IsNumber() && right_type.IsNumber()) { |
2068 return HEAP_NUMBER; | 2070 return HEAP_NUMBER; |
2069 } | 2071 } |
2070 | 2072 |
2071 if (left_type.IsString() || right_type.IsString()) { | 2073 if (left_type.IsString() || right_type.IsString()) { |
2072 // Patching for fast string ADD makes sense even if only one of the | 2074 // Patching for fast string ADD makes sense even if only one of the |
2073 // arguments is a string. | 2075 // arguments is a string. |
(...skipping 23 matching lines...) Expand all Loading... |
2097 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); | 2099 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); |
2098 | 2100 |
2099 TRBinaryOpIC::TypeInfo type = TRBinaryOpIC::GetTypeInfo(left, right); | 2101 TRBinaryOpIC::TypeInfo type = TRBinaryOpIC::GetTypeInfo(left, right); |
2100 type = TRBinaryOpIC::JoinTypes(type, previous_type); | 2102 type = TRBinaryOpIC::JoinTypes(type, previous_type); |
2101 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED; | 2103 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED; |
2102 if (type == TRBinaryOpIC::STRING && op != Token::ADD) { | 2104 if (type == TRBinaryOpIC::STRING && op != Token::ADD) { |
2103 type = TRBinaryOpIC::GENERIC; | 2105 type = TRBinaryOpIC::GENERIC; |
2104 } | 2106 } |
2105 if (type == TRBinaryOpIC::SMI && | 2107 if (type == TRBinaryOpIC::SMI && |
2106 previous_type == TRBinaryOpIC::SMI) { | 2108 previous_type == TRBinaryOpIC::SMI) { |
2107 if (op == Token::DIV || op == Token::MUL) { | 2109 if (op == Token::DIV || op == Token::MUL || kSmiValueSize == 32) { |
2108 // Arithmetic on two Smi inputs has yielded a heap number. | 2110 // Arithmetic on two Smi inputs has yielded a heap number. |
2109 // That is the only way to get here from the Smi stub. | 2111 // That is the only way to get here from the Smi stub. |
| 2112 // With 32-bit Smis, all overflows give heap numbers, but with |
| 2113 // 31-bit Smis, most operations overflow to int32 results. |
2110 result_type = TRBinaryOpIC::HEAP_NUMBER; | 2114 result_type = TRBinaryOpIC::HEAP_NUMBER; |
2111 } else { | 2115 } else { |
2112 // Other operations on SMIs that overflow yield int32s. | 2116 // Other operations on SMIs that overflow yield int32s. |
2113 result_type = TRBinaryOpIC::INT32; | 2117 result_type = TRBinaryOpIC::INT32; |
2114 } | 2118 } |
2115 } | 2119 } |
2116 if (type == TRBinaryOpIC::INT32 && | 2120 if (type == TRBinaryOpIC::INT32 && |
2117 previous_type == TRBinaryOpIC::INT32) { | 2121 previous_type == TRBinaryOpIC::INT32) { |
2118 // We must be here because an operation on two INT32 types overflowed. | 2122 // We must be here because an operation on two INT32 types overflowed. |
2119 result_type = TRBinaryOpIC::HEAP_NUMBER; | 2123 result_type = TRBinaryOpIC::HEAP_NUMBER; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2253 #undef ADDR | 2257 #undef ADDR |
2254 }; | 2258 }; |
2255 | 2259 |
2256 | 2260 |
2257 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2261 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2258 return IC_utilities[id]; | 2262 return IC_utilities[id]; |
2259 } | 2263 } |
2260 | 2264 |
2261 | 2265 |
2262 } } // namespace v8::internal | 2266 } } // namespace v8::internal |
OLD | NEW |