OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 return Construct(EXCEPTION); | 833 return Construct(EXCEPTION); |
834 } | 834 } |
835 | 835 |
836 | 836 |
837 Failure* Failure::OutOfMemoryException() { | 837 Failure* Failure::OutOfMemoryException() { |
838 return Construct(OUT_OF_MEMORY_EXCEPTION); | 838 return Construct(OUT_OF_MEMORY_EXCEPTION); |
839 } | 839 } |
840 | 840 |
841 | 841 |
842 intptr_t Failure::value() const { | 842 intptr_t Failure::value() const { |
843 return reinterpret_cast<intptr_t>(this) >> kFailureTagSize; | 843 return static_cast<intptr_t>( |
| 844 reinterpret_cast<uintptr_t>(this) >> kFailureTagSize); |
844 } | 845 } |
845 | 846 |
846 | 847 |
847 Failure* Failure::RetryAfterGC(int requested_bytes) { | 848 Failure* Failure::RetryAfterGC(int requested_bytes) { |
848 // Assert that the space encoding fits in the three bytes allotted for it. | 849 // Assert that the space encoding fits in the three bytes allotted for it. |
849 ASSERT((LAST_SPACE & ~kSpaceTagMask) == 0); | 850 ASSERT((LAST_SPACE & ~kSpaceTagMask) == 0); |
850 intptr_t requested = requested_bytes >> kObjectAlignmentBits; | 851 uintptr_t requested = |
851 int tag_bits = kSpaceTagSize + kFailureTypeTagSize; | 852 static_cast<uintptr_t>(requested_bytes >> kObjectAlignmentBits); |
| 853 int tag_bits = kSpaceTagSize + kFailureTypeTagSize + kFailureTagSize; |
852 if (((requested << tag_bits) >> tag_bits) != requested) { | 854 if (((requested << tag_bits) >> tag_bits) != requested) { |
853 // No room for entire requested size in the bits. Round down to | 855 // No room for entire requested size in the bits. Round down to |
854 // maximally representable size. | 856 // maximally representable size. |
855 requested = static_cast<intptr_t>( | 857 requested = static_cast<intptr_t>( |
856 (~static_cast<uintptr_t>(0)) >> (tag_bits + 1)); | 858 (~static_cast<uintptr_t>(0)) >> (tag_bits + 1)); |
857 } | 859 } |
858 int value = static_cast<int>(requested << kSpaceTagSize) | NEW_SPACE; | 860 int value = static_cast<int>(requested << kSpaceTagSize) | NEW_SPACE; |
859 return Construct(RETRY_AFTER_GC, value); | 861 return Construct(RETRY_AFTER_GC, value); |
860 } | 862 } |
861 | 863 |
862 | 864 |
863 Failure* Failure::Construct(Type type, intptr_t value) { | 865 Failure* Failure::Construct(Type type, intptr_t value) { |
864 intptr_t info = (static_cast<intptr_t>(value) << kFailureTypeTagSize) | type; | 866 uintptr_t info = |
| 867 (static_cast<uintptr_t>(value) << kFailureTypeTagSize) | type; |
865 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); | 868 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); |
866 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); | 869 return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag); |
867 } | 870 } |
868 | 871 |
869 | 872 |
870 bool Smi::IsValid(intptr_t value) { | 873 bool Smi::IsValid(intptr_t value) { |
871 #ifdef DEBUG | 874 #ifdef DEBUG |
872 bool in_range = (value >= kMinValue) && (value <= kMaxValue); | 875 bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
873 #endif | 876 #endif |
874 | 877 |
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 #undef WRITE_INT_FIELD | 3050 #undef WRITE_INT_FIELD |
3048 #undef READ_SHORT_FIELD | 3051 #undef READ_SHORT_FIELD |
3049 #undef WRITE_SHORT_FIELD | 3052 #undef WRITE_SHORT_FIELD |
3050 #undef READ_BYTE_FIELD | 3053 #undef READ_BYTE_FIELD |
3051 #undef WRITE_BYTE_FIELD | 3054 #undef WRITE_BYTE_FIELD |
3052 | 3055 |
3053 | 3056 |
3054 } } // namespace v8::internal | 3057 } } // namespace v8::internal |
3055 | 3058 |
3056 #endif // V8_OBJECTS_INL_H_ | 3059 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |