Chromium Code Reviews| Index: src/objects-inl.h |
| diff --git a/src/objects-inl.h b/src/objects-inl.h |
| index 8c6e9253e11a12c21c86487fce8496e42239dc19..32736f3414c1ce78df8457104bd23e3220179317 100644 |
| --- a/src/objects-inl.h |
| +++ b/src/objects-inl.h |
| @@ -1030,10 +1030,7 @@ int Smi::value() { |
| Smi* Smi::FromInt(int value) { |
| ASSERT(Smi::IsValid(value)); |
| - int smi_shift_bits = kSmiTagSize + kSmiShiftSize; |
| - intptr_t tagged_value = |
| - (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; |
| - return reinterpret_cast<Smi*>(tagged_value); |
| + return reinterpret_cast<Smi*>(Internals::IntToSmi(value)); |
| } |
| @@ -1114,24 +1111,7 @@ bool Smi::IsValid(intptr_t value) { |
| #ifdef DEBUG |
| bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
|
Sven Panne
2013/05/21 14:14:56
Not from your CL, but anyway: Can we inline this a
dcarney
2013/05/21 15:14:44
okay
|
| #endif |
| - |
| -#ifdef V8_TARGET_ARCH_X64 |
| - // To be representable as a long smi, the value must be a 32-bit integer. |
| - bool result = (value == static_cast<int32_t>(value)); |
| -#else |
| - // To be representable as an tagged small integer, the two |
| - // most-significant bits of 'value' must be either 00 or 11 due to |
| - // sign-extension. To check this we add 01 to the two |
| - // most-significant bits, and check if the most-significant bit is 0 |
| - // |
| - // CAUTION: The original code below: |
| - // bool result = ((value + 0x40000000) & 0x80000000) == 0; |
| - // may lead to incorrect results according to the C language spec, and |
| - // in fact doesn't work correctly with gcc4.1.1 in some cases: The |
| - // compiler may produce undefined results in case of signed integer |
| - // overflow. The computation must be done w/ unsigned ints. |
| - bool result = (static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U); |
| -#endif |
| + bool result = Internals::IsValidSmi(value); |
| ASSERT(result == in_range); |
| return result; |
| } |