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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 ASSERT(value >> kSpaceTagSize == requested); | 807 ASSERT(value >> kSpaceTagSize == requested); |
808 ASSERT(Smi::IsValid(value)); | 808 ASSERT(Smi::IsValid(value)); |
809 ASSERT(value == ((value << kFailureTypeTagSize) >> kFailureTypeTagSize)); | 809 ASSERT(value == ((value << kFailureTypeTagSize) >> kFailureTypeTagSize)); |
810 ASSERT(Smi::IsValid(value << kFailureTypeTagSize)); | 810 ASSERT(Smi::IsValid(value << kFailureTypeTagSize)); |
811 return Construct(RETRY_AFTER_GC, value); | 811 return Construct(RETRY_AFTER_GC, value); |
812 } | 812 } |
813 | 813 |
814 | 814 |
815 Failure* Failure::Construct(Type type, int value) { | 815 Failure* Failure::Construct(Type type, int value) { |
816 int info = (value << kFailureTypeTagSize) | type; | 816 int info = (value << kFailureTypeTagSize) | type; |
817 // TODO(X64): Stop using Smi validation for non-smi checks, even if they | 817 ASSERT(((info << kFailureTagSize) >> kFailureTagSize) == info); |
818 // happen to be identical at the moment. | |
819 ASSERT(Smi::IsValid(info)); // Same validation check as in Smi | |
820 return reinterpret_cast<Failure*>( | 818 return reinterpret_cast<Failure*>( |
821 (static_cast<intptr_t>(info) << kFailureTagSize) | kFailureTag); | 819 (static_cast<intptr_t>(info) << kFailureTagSize) | kFailureTag); |
822 } | 820 } |
823 | 821 |
824 | 822 |
825 bool Smi::IsValid(int value) { | 823 bool Smi::IsValid(intptr_t value) { |
826 #ifdef DEBUG | 824 #ifdef DEBUG |
827 bool in_range = (value >= kMinValue) && (value <= kMaxValue); | 825 bool in_range = (value >= kMinValue) && (value <= kMaxValue); |
828 #endif | 826 #endif |
829 // To be representable as an tagged small integer, the two | 827 // To be representable as an tagged small integer, the two |
830 // most-significant bits of 'value' must be either 00 or 11 due to | 828 // most-significant bits of 'value' must be either 00 or 11 due to |
831 // sign-extension. To check this we add 01 to the two | 829 // sign-extension. To check this we add 01 to the two |
832 // most-significant bits, and check if the most-significant bit is 0 | 830 // most-significant bits, and check if the most-significant bit is 0 |
833 // | 831 // |
834 // CAUTION: The original code below: | 832 // CAUTION: The original code below: |
835 // bool result = ((value + 0x40000000) & 0x80000000) == 0; | 833 // bool result = ((value + 0x40000000) & 0x80000000) == 0; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 | 928 |
931 uintptr_t encoding = | 929 uintptr_t encoding = |
932 (compact_offset << kForwardingOffsetShift) | | 930 (compact_offset << kForwardingOffsetShift) | |
933 (map_page_offset << kMapPageOffsetShift) | | 931 (map_page_offset << kMapPageOffsetShift) | |
934 (map_page->mc_page_index << kMapPageIndexShift); | 932 (map_page->mc_page_index << kMapPageIndexShift); |
935 return MapWord(encoding); | 933 return MapWord(encoding); |
936 } | 934 } |
937 | 935 |
938 | 936 |
939 Address MapWord::DecodeMapAddress(MapSpace* map_space) { | 937 Address MapWord::DecodeMapAddress(MapSpace* map_space) { |
940 int map_page_index = (value_ & kMapPageIndexMask) >> kMapPageIndexShift; | 938 int map_page_index = |
| 939 static_cast<int>((value_ & kMapPageIndexMask) >> kMapPageIndexShift); |
941 ASSERT_MAP_PAGE_INDEX(map_page_index); | 940 ASSERT_MAP_PAGE_INDEX(map_page_index); |
942 | 941 |
943 int map_page_offset = | 942 int map_page_offset = static_cast<int>( |
944 ((value_ & kMapPageOffsetMask) >> kMapPageOffsetShift) | 943 ((value_ & kMapPageOffsetMask) >> kMapPageOffsetShift) |
945 << kObjectAlignmentBits; | 944 << kObjectAlignmentBits); |
946 | 945 |
947 return (map_space->PageAddress(map_page_index) + map_page_offset); | 946 return (map_space->PageAddress(map_page_index) + map_page_offset); |
948 } | 947 } |
949 | 948 |
950 | 949 |
951 int MapWord::DecodeOffset() { | 950 int MapWord::DecodeOffset() { |
952 // The offset field is represented in the kForwardingOffsetBits | 951 // The offset field is represented in the kForwardingOffsetBits |
953 // most-significant bits. | 952 // most-significant bits. |
954 int offset = (value_ >> kForwardingOffsetShift) << kObjectAlignmentBits; | 953 int offset = (value_ >> kForwardingOffsetShift) << kObjectAlignmentBits; |
955 ASSERT(0 <= offset && offset < Page::kObjectAreaSize); | 954 ASSERT(0 <= offset && offset < Page::kObjectAreaSize); |
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 #undef WRITE_INT_FIELD | 2880 #undef WRITE_INT_FIELD |
2882 #undef READ_SHORT_FIELD | 2881 #undef READ_SHORT_FIELD |
2883 #undef WRITE_SHORT_FIELD | 2882 #undef WRITE_SHORT_FIELD |
2884 #undef READ_BYTE_FIELD | 2883 #undef READ_BYTE_FIELD |
2885 #undef WRITE_BYTE_FIELD | 2884 #undef WRITE_BYTE_FIELD |
2886 | 2885 |
2887 | 2886 |
2888 } } // namespace v8::internal | 2887 } } // namespace v8::internal |
2889 | 2888 |
2890 #endif // V8_OBJECTS_INL_H_ | 2889 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |