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 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 ::v8::internal::TypeInfo left_type = | 2046 ::v8::internal::TypeInfo left_type = |
2047 ::v8::internal::TypeInfo::TypeFromValue(left); | 2047 ::v8::internal::TypeInfo::TypeFromValue(left); |
2048 ::v8::internal::TypeInfo right_type = | 2048 ::v8::internal::TypeInfo right_type = |
2049 ::v8::internal::TypeInfo::TypeFromValue(right); | 2049 ::v8::internal::TypeInfo::TypeFromValue(right); |
2050 | 2050 |
2051 if (left_type.IsSmi() && right_type.IsSmi()) { | 2051 if (left_type.IsSmi() && right_type.IsSmi()) { |
2052 return SMI; | 2052 return SMI; |
2053 } | 2053 } |
2054 | 2054 |
2055 if (left_type.IsInteger32() && right_type.IsInteger32()) { | 2055 if (left_type.IsInteger32() && right_type.IsInteger32()) { |
| 2056 ASSERT(kSmiValueSize != 32); // 32-bit Smis cause no distinct INT32 type. |
2056 return INT32; | 2057 return INT32; |
2057 } | 2058 } |
2058 | 2059 |
2059 if (left_type.IsNumber() && right_type.IsNumber()) { | 2060 if (left_type.IsNumber() && right_type.IsNumber()) { |
2060 return HEAP_NUMBER; | 2061 return HEAP_NUMBER; |
2061 } | 2062 } |
2062 | 2063 |
2063 if (left_type.IsString() || right_type.IsString()) { | 2064 if (left_type.IsString() || right_type.IsString()) { |
2064 // Patching for fast string ADD makes sense even if only one of the | 2065 // Patching for fast string ADD makes sense even if only one of the |
2065 // arguments is a string. | 2066 // arguments is a string. |
(...skipping 23 matching lines...) Expand all Loading... |
2089 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); | 2090 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); |
2090 | 2091 |
2091 TRBinaryOpIC::TypeInfo type = TRBinaryOpIC::GetTypeInfo(left, right); | 2092 TRBinaryOpIC::TypeInfo type = TRBinaryOpIC::GetTypeInfo(left, right); |
2092 type = TRBinaryOpIC::JoinTypes(type, previous_type); | 2093 type = TRBinaryOpIC::JoinTypes(type, previous_type); |
2093 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED; | 2094 TRBinaryOpIC::TypeInfo result_type = TRBinaryOpIC::UNINITIALIZED; |
2094 if (type == TRBinaryOpIC::STRING && op != Token::ADD) { | 2095 if (type == TRBinaryOpIC::STRING && op != Token::ADD) { |
2095 type = TRBinaryOpIC::GENERIC; | 2096 type = TRBinaryOpIC::GENERIC; |
2096 } | 2097 } |
2097 if (type == TRBinaryOpIC::SMI && | 2098 if (type == TRBinaryOpIC::SMI && |
2098 previous_type == TRBinaryOpIC::SMI) { | 2099 previous_type == TRBinaryOpIC::SMI) { |
2099 if (op == Token::DIV || op == Token::MUL) { | 2100 if (op == Token::DIV || op == Token::MUL || kSmiValueSize == 32) { |
2100 // Arithmetic on two Smi inputs has yielded a heap number. | 2101 // Arithmetic on two Smi inputs has yielded a heap number. |
2101 // That is the only way to get here from the Smi stub. | 2102 // That is the only way to get here from the Smi stub. |
| 2103 // With 32-bit Smis, all overflows give heap numbers, but with |
| 2104 // 31-bit Smis, most operations overflow to int32 results. |
2102 result_type = TRBinaryOpIC::HEAP_NUMBER; | 2105 result_type = TRBinaryOpIC::HEAP_NUMBER; |
2103 } else { | 2106 } else { |
2104 // Other operations on SMIs that overflow yield int32s. | 2107 // Other operations on SMIs that overflow yield int32s. |
2105 result_type = TRBinaryOpIC::INT32; | 2108 result_type = TRBinaryOpIC::INT32; |
2106 } | 2109 } |
2107 } | 2110 } |
2108 if (type == TRBinaryOpIC::INT32 && | 2111 if (type == TRBinaryOpIC::INT32 && |
2109 previous_type == TRBinaryOpIC::INT32) { | 2112 previous_type == TRBinaryOpIC::INT32) { |
2110 // We must be here because an operation on two INT32 types overflowed. | 2113 // We must be here because an operation on two INT32 types overflowed. |
2111 result_type = TRBinaryOpIC::HEAP_NUMBER; | 2114 result_type = TRBinaryOpIC::HEAP_NUMBER; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 #undef ADDR | 2248 #undef ADDR |
2246 }; | 2249 }; |
2247 | 2250 |
2248 | 2251 |
2249 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2252 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2250 return IC_utilities[id]; | 2253 return IC_utilities[id]; |
2251 } | 2254 } |
2252 | 2255 |
2253 | 2256 |
2254 } } // namespace v8::internal | 2257 } } // namespace v8::internal |
OLD | NEW |