| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 929 |
| 930 // True if this map word's overflow bit is set. | 930 // True if this map word's overflow bit is set. |
| 931 inline bool IsOverflowed(); | 931 inline bool IsOverflowed(); |
| 932 | 932 |
| 933 // Return this map word but with its overflow bit set. | 933 // Return this map word but with its overflow bit set. |
| 934 inline void SetOverflow(); | 934 inline void SetOverflow(); |
| 935 | 935 |
| 936 // Return this map word but with its overflow bit cleared. | 936 // Return this map word but with its overflow bit cleared. |
| 937 inline void ClearOverflow(); | 937 inline void ClearOverflow(); |
| 938 | 938 |
| 939 | |
| 940 // Compacting phase of a full compacting collection: the map word of live | |
| 941 // objects contains an encoding of the original map address along with the | |
| 942 // forwarding address (represented as an offset from the first live object | |
| 943 // in the same page as the (old) object address). | |
| 944 | |
| 945 // Create a map word from a map address and a forwarding address offset. | |
| 946 static inline MapWord EncodeAddress(Address map_address, int offset); | |
| 947 | |
| 948 // Return the map address encoded in this map word. | |
| 949 inline Address DecodeMapAddress(MapSpace* map_space); | |
| 950 | |
| 951 // Return the forwarding offset encoded in this map word. | |
| 952 inline int DecodeOffset(); | |
| 953 | |
| 954 | |
| 955 // During serialization: the map word is used to hold an encoded | |
| 956 // address, and possibly a mark bit (set and cleared with SetMark | |
| 957 // and ClearMark). | |
| 958 | |
| 959 // Create a map word from an encoded address. | |
| 960 static inline MapWord FromEncodedAddress(Address address); | |
| 961 | |
| 962 inline Address ToEncodedAddress(); | |
| 963 | |
| 964 // Bits used by the marking phase of the garbage collector. | 939 // Bits used by the marking phase of the garbage collector. |
| 965 // | 940 // |
| 966 // The first word of a heap object is normally a map pointer. The last two | 941 // The first word of a heap object is normally a map pointer. The last two |
| 967 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to | 942 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to |
| 968 // mark an object as live and/or overflowed: | 943 // mark an object as live and/or overflowed: |
| 969 // last bit = 0, marked as alive | 944 // last bit = 0, marked as alive |
| 970 // second bit = 1, overflowed | 945 // second bit = 1, overflowed |
| 971 // An object is only marked as overflowed when it is marked as live while | 946 // An object is only marked as overflowed when it is marked as live while |
| 972 // the marking stack is overflowed. | 947 // the marking stack is overflowed. |
| 973 static const int kMarkingBit = 0; // marking bit | 948 static const int kMarkingBit = 0; // marking bit |
| 974 static const int kMarkingMask = (1 << kMarkingBit); // marking mask | 949 static const int kMarkingMask = (1 << kMarkingBit); // marking mask |
| 975 static const int kOverflowBit = 1; // overflow bit | 950 static const int kOverflowBit = 1; // overflow bit |
| 976 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask | 951 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask |
| 977 | 952 |
| 978 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are | |
| 979 // used. | |
| 980 // +-----------------+------------------+-----------------+ | |
| 981 // |forwarding offset|page offset of map|page index of map| | |
| 982 // +-----------------+------------------+-----------------+ | |
| 983 // ^ ^ ^ | |
| 984 // | | | | |
| 985 // | | kMapPageIndexBits | |
| 986 // | kMapPageOffsetBits | |
| 987 // kForwardingOffsetBits | |
| 988 static const int kMapPageOffsetBits = kPageSizeBits - kMapAlignmentBits; | |
| 989 static const int kForwardingOffsetBits = kPageSizeBits - kObjectAlignmentBits; | |
| 990 #ifdef V8_HOST_ARCH_64_BIT | |
| 991 static const int kMapPageIndexBits = 16; | |
| 992 #else | |
| 993 // Use all the 32-bits to encode on a 32-bit platform. | |
| 994 static const int kMapPageIndexBits = | |
| 995 32 - (kMapPageOffsetBits + kForwardingOffsetBits); | |
| 996 #endif | |
| 997 | |
| 998 static const int kMapPageIndexShift = 0; | |
| 999 static const int kMapPageOffsetShift = | |
| 1000 kMapPageIndexShift + kMapPageIndexBits; | |
| 1001 static const int kForwardingOffsetShift = | |
| 1002 kMapPageOffsetShift + kMapPageOffsetBits; | |
| 1003 | |
| 1004 // Bit masks covering the different parts the encoding. | |
| 1005 static const uintptr_t kMapPageIndexMask = | |
| 1006 (1 << kMapPageOffsetShift) - 1; | |
| 1007 static const uintptr_t kMapPageOffsetMask = | |
| 1008 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | |
| 1009 static const uintptr_t kForwardingOffsetMask = | |
| 1010 ~(kMapPageIndexMask | kMapPageOffsetMask); | |
| 1011 | |
| 1012 private: | 953 private: |
| 1013 // HeapObject calls the private constructor and directly reads the value. | 954 // HeapObject calls the private constructor and directly reads the value. |
| 1014 friend class HeapObject; | 955 friend class HeapObject; |
| 1015 | 956 |
| 1016 explicit MapWord(uintptr_t value) : value_(value) {} | 957 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1017 | 958 |
| 1018 uintptr_t value_; | 959 uintptr_t value_; |
| 1019 }; | 960 }; |
| 1020 | 961 |
| 1021 | 962 |
| (...skipping 5079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6101 } else { | 6042 } else { |
| 6102 value &= ~(1 << bit_position); | 6043 value &= ~(1 << bit_position); |
| 6103 } | 6044 } |
| 6104 return value; | 6045 return value; |
| 6105 } | 6046 } |
| 6106 }; | 6047 }; |
| 6107 | 6048 |
| 6108 } } // namespace v8::internal | 6049 } } // namespace v8::internal |
| 6109 | 6050 |
| 6110 #endif // V8_OBJECTS_H_ | 6051 #endif // V8_OBJECTS_H_ |
| OLD | NEW |