| 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 939 |
| 940 #ifndef BASELINE_GC |
| 940 // Compacting phase of a full compacting collection: the map word of live | 941 // 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 // 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 // forwarding address (represented as an offset from the first live object |
| 943 // in the same page as the (old) object address). | 944 // in the same page as the (old) object address). |
| 944 | 945 |
| 945 // Create a map word from a map address and a forwarding address offset. | 946 // Create a map word from a map address and a forwarding address offset. |
| 946 static inline MapWord EncodeAddress(Address map_address, int offset); | 947 static inline MapWord EncodeAddress(Address map_address, int offset); |
| 947 | 948 |
| 948 // Return the map address encoded in this map word. | 949 // Return the map address encoded in this map word. |
| 949 inline Address DecodeMapAddress(MapSpace* map_space); | 950 inline Address DecodeMapAddress(MapSpace* map_space); |
| 950 | 951 |
| 951 // Return the forwarding offset encoded in this map word. | 952 // Return the forwarding offset encoded in this map word. |
| 952 inline int DecodeOffset(); | 953 inline int DecodeOffset(); |
| 953 | 954 |
| 954 | 955 |
| 955 // During serialization: the map word is used to hold an encoded | 956 // During serialization: the map word is used to hold an encoded |
| 956 // address, and possibly a mark bit (set and cleared with SetMark | 957 // address, and possibly a mark bit (set and cleared with SetMark |
| 957 // and ClearMark). | 958 // and ClearMark). |
| 958 | 959 |
| 959 // Create a map word from an encoded address. | 960 // Create a map word from an encoded address. |
| 960 static inline MapWord FromEncodedAddress(Address address); | 961 static inline MapWord FromEncodedAddress(Address address); |
| 961 | 962 |
| 962 inline Address ToEncodedAddress(); | 963 inline Address ToEncodedAddress(); |
| 964 #endif |
| 963 | 965 |
| 964 // Bits used by the marking phase of the garbage collector. | 966 // Bits used by the marking phase of the garbage collector. |
| 965 // | 967 // |
| 966 // The first word of a heap object is normally a map pointer. The last two | 968 // 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 | 969 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to |
| 968 // mark an object as live and/or overflowed: | 970 // mark an object as live and/or overflowed: |
| 969 // last bit = 0, marked as alive | 971 // last bit = 0, marked as alive |
| 970 // second bit = 1, overflowed | 972 // second bit = 1, overflowed |
| 971 // An object is only marked as overflowed when it is marked as live while | 973 // An object is only marked as overflowed when it is marked as live while |
| 972 // the marking stack is overflowed. | 974 // the marking stack is overflowed. |
| 973 static const int kMarkingBit = 0; // marking bit | 975 static const int kMarkingBit = 0; // marking bit |
| 974 static const int kMarkingMask = (1 << kMarkingBit); // marking mask | 976 static const int kMarkingMask = (1 << kMarkingBit); // marking mask |
| 975 static const int kOverflowBit = 1; // overflow bit | 977 static const int kOverflowBit = 1; // overflow bit |
| 976 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask | 978 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask |
| 977 | 979 |
| 980 #ifndef BASELINE_GC |
| 978 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are | 981 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are |
| 979 // used. | 982 // used. |
| 980 // +-----------------+------------------+-----------------+ | 983 // +-----------------+------------------+-----------------+ |
| 981 // |forwarding offset|page offset of map|page index of map| | 984 // |forwarding offset|page offset of map|page index of map| |
| 982 // +-----------------+------------------+-----------------+ | 985 // +-----------------+------------------+-----------------+ |
| 983 // ^ ^ ^ | 986 // ^ ^ ^ |
| 984 // | | | | 987 // | | | |
| 985 // | | kMapPageIndexBits | 988 // | | kMapPageIndexBits |
| 986 // | kMapPageOffsetBits | 989 // | kMapPageOffsetBits |
| 987 // kForwardingOffsetBits | 990 // kForwardingOffsetBits |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1001 static const int kForwardingOffsetShift = | 1004 static const int kForwardingOffsetShift = |
| 1002 kMapPageOffsetShift + kMapPageOffsetBits; | 1005 kMapPageOffsetShift + kMapPageOffsetBits; |
| 1003 | 1006 |
| 1004 // Bit masks covering the different parts the encoding. | 1007 // Bit masks covering the different parts the encoding. |
| 1005 static const uintptr_t kMapPageIndexMask = | 1008 static const uintptr_t kMapPageIndexMask = |
| 1006 (1 << kMapPageOffsetShift) - 1; | 1009 (1 << kMapPageOffsetShift) - 1; |
| 1007 static const uintptr_t kMapPageOffsetMask = | 1010 static const uintptr_t kMapPageOffsetMask = |
| 1008 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | 1011 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; |
| 1009 static const uintptr_t kForwardingOffsetMask = | 1012 static const uintptr_t kForwardingOffsetMask = |
| 1010 ~(kMapPageIndexMask | kMapPageOffsetMask); | 1013 ~(kMapPageIndexMask | kMapPageOffsetMask); |
| 1014 #endif |
| 1011 | 1015 |
| 1012 private: | 1016 private: |
| 1013 // HeapObject calls the private constructor and directly reads the value. | 1017 // HeapObject calls the private constructor and directly reads the value. |
| 1014 friend class HeapObject; | 1018 friend class HeapObject; |
| 1015 | 1019 |
| 1016 explicit MapWord(uintptr_t value) : value_(value) {} | 1020 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1017 | 1021 |
| 1018 uintptr_t value_; | 1022 uintptr_t value_; |
| 1019 }; | 1023 }; |
| 1020 | 1024 |
| (...skipping 5080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6101 } else { | 6105 } else { |
| 6102 value &= ~(1 << bit_position); | 6106 value &= ~(1 << bit_position); |
| 6103 } | 6107 } |
| 6104 return value; | 6108 return value; |
| 6105 } | 6109 } |
| 6106 }; | 6110 }; |
| 6107 | 6111 |
| 6108 } } // namespace v8::internal | 6112 } } // namespace v8::internal |
| 6109 | 6113 |
| 6110 #endif // V8_OBJECTS_H_ | 6114 #endif // V8_OBJECTS_H_ |
| OLD | NEW |