| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 : TypeInfo::Integer32(); | 1173 : TypeInfo::Integer32(); |
| 1174 } | 1174 } |
| 1175 case Token::BIT_XOR: | 1175 case Token::BIT_XOR: |
| 1176 // Result is always a 32 bit integer. Smi property of inputs is preserved. | 1176 // Result is always a 32 bit integer. Smi property of inputs is preserved. |
| 1177 return (operands_type.IsSmi()) | 1177 return (operands_type.IsSmi()) |
| 1178 ? TypeInfo::Smi() | 1178 ? TypeInfo::Smi() |
| 1179 : TypeInfo::Integer32(); | 1179 : TypeInfo::Integer32(); |
| 1180 case Token::SAR: | 1180 case Token::SAR: |
| 1181 if (left.is_smi()) return TypeInfo::Smi(); | 1181 if (left.is_smi()) return TypeInfo::Smi(); |
| 1182 // Result is a smi if we shift by a constant >= 1, otherwise an integer32. | 1182 // Result is a smi if we shift by a constant >= 1, otherwise an integer32. |
| 1183 // Shift amount is masked with 0x1F (ECMA standard 11.7.2). |
| 1183 return (right.is_constant() && right.handle()->IsSmi() | 1184 return (right.is_constant() && right.handle()->IsSmi() |
| 1184 && Smi::cast(*right.handle())->value() >= 1) | 1185 && (Smi::cast(*right.handle())->value() & 0x1F) >= 1) |
| 1185 ? TypeInfo::Smi() | 1186 ? TypeInfo::Smi() |
| 1186 : TypeInfo::Integer32(); | 1187 : TypeInfo::Integer32(); |
| 1187 case Token::SHR: | 1188 case Token::SHR: |
| 1188 // Result is a smi if we shift by a constant >= 2, otherwise an integer32. | 1189 // Result is a smi if we shift by a constant >= 2, an integer32 if |
| 1189 return (right.is_constant() && right.handle()->IsSmi() | 1190 // we shift by 1, and an unsigned 32-bit integer if we shift by 0. |
| 1190 && Smi::cast(*right.handle())->value() >= 2) | 1191 if (right.is_constant() && right.handle()->IsSmi()) { |
| 1191 ? TypeInfo::Smi() | 1192 int shift_amount = Smi::cast(*right.handle())->value() & 0x1F; |
| 1192 : TypeInfo::Integer32(); | 1193 if (shift_amount > 1) { |
| 1194 return TypeInfo::Smi(); |
| 1195 } else if (shift_amount > 0) { |
| 1196 return TypeInfo::Integer32(); |
| 1197 } |
| 1198 } |
| 1199 return TypeInfo::Number(); |
| 1193 case Token::ADD: | 1200 case Token::ADD: |
| 1194 if (operands_type.IsSmi()) { | 1201 if (operands_type.IsSmi()) { |
| 1195 // The Integer32 range is big enough to take the sum of any two Smis. | 1202 // The Integer32 range is big enough to take the sum of any two Smis. |
| 1196 return TypeInfo::Integer32(); | 1203 return TypeInfo::Integer32(); |
| 1197 } else if (operands_type.IsNumber()) { | 1204 } else if (operands_type.IsNumber()) { |
| 1198 return TypeInfo::Number(); | 1205 return TypeInfo::Number(); |
| 1199 } else if (left.type_info().IsString() || right.type_info().IsString()) { | 1206 } else if (left.type_info().IsString() || right.type_info().IsString()) { |
| 1200 return TypeInfo::String(); | 1207 return TypeInfo::String(); |
| 1201 } else { | 1208 } else { |
| 1202 return TypeInfo::Unknown(); | 1209 return TypeInfo::Unknown(); |
| (...skipping 11711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12914 | 12921 |
| 12915 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12922 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 12916 // tagged as a small integer. | 12923 // tagged as a small integer. |
| 12917 __ bind(&runtime); | 12924 __ bind(&runtime); |
| 12918 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12925 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 12919 } | 12926 } |
| 12920 | 12927 |
| 12921 #undef __ | 12928 #undef __ |
| 12922 | 12929 |
| 12923 } } // namespace v8::internal | 12930 } } // namespace v8::internal |
| OLD | NEW |