| 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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 value_ &= ~kOverflowMask; | 945 value_ &= ~kOverflowMask; |
| 946 } | 946 } |
| 947 | 947 |
| 948 | 948 |
| 949 MapWord MapWord::EncodeAddress(Address map_address, int offset) { | 949 MapWord MapWord::EncodeAddress(Address map_address, int offset) { |
| 950 // Offset is the distance in live bytes from the first live object in the | 950 // Offset is the distance in live bytes from the first live object in the |
| 951 // same page. The offset between two objects in the same page should not | 951 // same page. The offset between two objects in the same page should not |
| 952 // exceed the object area size of a page. | 952 // exceed the object area size of a page. |
| 953 ASSERT(0 <= offset && offset < Page::kObjectAreaSize); | 953 ASSERT(0 <= offset && offset < Page::kObjectAreaSize); |
| 954 | 954 |
| 955 int compact_offset = offset >> kObjectAlignmentBits; | 955 uintptr_t compact_offset = offset >> kObjectAlignmentBits; |
| 956 ASSERT(compact_offset < (1 << kForwardingOffsetBits)); | 956 ASSERT(compact_offset < (1 << kForwardingOffsetBits)); |
| 957 | 957 |
| 958 Page* map_page = Page::FromAddress(map_address); | 958 Page* map_page = Page::FromAddress(map_address); |
| 959 ASSERT_MAP_PAGE_INDEX(map_page->mc_page_index); | 959 ASSERT_MAP_PAGE_INDEX(map_page->mc_page_index); |
| 960 | 960 |
| 961 int map_page_offset = | 961 uintptr_t map_page_offset = |
| 962 map_page->Offset(map_address) >> kObjectAlignmentBits; | 962 map_page->Offset(map_address) >> kMapAlignmentBits; |
| 963 | 963 |
| 964 uintptr_t encoding = | 964 uintptr_t encoding = |
| 965 (compact_offset << kForwardingOffsetShift) | | 965 (compact_offset << kForwardingOffsetShift) | |
| 966 (map_page_offset << kMapPageOffsetShift) | | 966 (map_page_offset << kMapPageOffsetShift) | |
| 967 (map_page->mc_page_index << kMapPageIndexShift); | 967 (map_page->mc_page_index << kMapPageIndexShift); |
| 968 return MapWord(encoding); | 968 return MapWord(encoding); |
| 969 } | 969 } |
| 970 | 970 |
| 971 | 971 |
| 972 Address MapWord::DecodeMapAddress(MapSpace* map_space) { | 972 Address MapWord::DecodeMapAddress(MapSpace* map_space) { |
| 973 int map_page_index = | 973 int map_page_index = |
| 974 static_cast<int>((value_ & kMapPageIndexMask) >> kMapPageIndexShift); | 974 static_cast<int>((value_ & kMapPageIndexMask) >> kMapPageIndexShift); |
| 975 ASSERT_MAP_PAGE_INDEX(map_page_index); | 975 ASSERT_MAP_PAGE_INDEX(map_page_index); |
| 976 | 976 |
| 977 int map_page_offset = static_cast<int>( | 977 int map_page_offset = static_cast<int>( |
| 978 ((value_ & kMapPageOffsetMask) >> kMapPageOffsetShift) | 978 ((value_ & kMapPageOffsetMask) >> kMapPageOffsetShift) << |
| 979 << kObjectAlignmentBits); | 979 kMapAlignmentBits); |
| 980 | 980 |
| 981 return (map_space->PageAddress(map_page_index) + map_page_offset); | 981 return (map_space->PageAddress(map_page_index) + map_page_offset); |
| 982 } | 982 } |
| 983 | 983 |
| 984 | 984 |
| 985 int MapWord::DecodeOffset() { | 985 int MapWord::DecodeOffset() { |
| 986 // The offset field is represented in the kForwardingOffsetBits | 986 // The offset field is represented in the kForwardingOffsetBits |
| 987 // most-significant bits. | 987 // most-significant bits. |
| 988 uintptr_t offset = (value_ >> kForwardingOffsetShift) << kObjectAlignmentBits; | 988 uintptr_t offset = (value_ >> kForwardingOffsetShift) << kObjectAlignmentBits; |
| 989 ASSERT(offset < static_cast<uintptr_t>(Page::kObjectAreaSize)); | 989 ASSERT(offset < static_cast<uintptr_t>(Page::kObjectAreaSize)); |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 #undef WRITE_INT_FIELD | 3030 #undef WRITE_INT_FIELD |
| 3031 #undef READ_SHORT_FIELD | 3031 #undef READ_SHORT_FIELD |
| 3032 #undef WRITE_SHORT_FIELD | 3032 #undef WRITE_SHORT_FIELD |
| 3033 #undef READ_BYTE_FIELD | 3033 #undef READ_BYTE_FIELD |
| 3034 #undef WRITE_BYTE_FIELD | 3034 #undef WRITE_BYTE_FIELD |
| 3035 | 3035 |
| 3036 | 3036 |
| 3037 } } // namespace v8::internal | 3037 } } // namespace v8::internal |
| 3038 | 3038 |
| 3039 #endif // V8_OBJECTS_INL_H_ | 3039 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |