OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 static const int kMinValue = -(1 << (kSmiNumBits - 1)); | 816 static const int kMinValue = -(1 << (kSmiNumBits - 1)); |
817 static const int kMaxValue = (1 << (kSmiNumBits - 1)) - 1; | 817 static const int kMaxValue = (1 << (kSmiNumBits - 1)) - 1; |
818 | 818 |
819 private: | 819 private: |
820 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); | 820 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); |
821 }; | 821 }; |
822 | 822 |
823 | 823 |
824 // Failure is used for reporting out of memory situations and | 824 // Failure is used for reporting out of memory situations and |
825 // propagating exceptions through the runtime system. Failure objects | 825 // propagating exceptions through the runtime system. Failure objects |
826 // are transient and cannot occur as part of the objects graph. | 826 // are transient and cannot occur as part of the object graph. |
827 // | 827 // |
828 // Failures are a single word, encoded as follows: | 828 // Failures are a single word, encoded as follows: |
829 // +-------------------------+---+--+--+ | 829 // +-------------------------+---+--+--+ |
830 // |rrrrrrrrrrrrrrrrrrrrrrrrr|sss|tt|11| | 830 // |rrrrrrrrrrrrrrrrrrrrrrrrr|sss|tt|11| |
831 // +-------------------------+---+--+--+ | 831 // +-------------------------+---+--+--+ |
| 832 // 3 7 6 4 32 10 |
| 833 // 1 |
832 // | 834 // |
833 // The low two bits, 0-1, are the failure tag, 11. The next two bits, | 835 // The low two bits, 0-1, are the failure tag, 11. The next two bits, |
834 // 2-3, are a failure type tag 'tt' with possible values: | 836 // 2-3, are a failure type tag 'tt' with possible values: |
835 // 00 RETRY_AFTER_GC | 837 // 00 RETRY_AFTER_GC |
836 // 01 EXCEPTION | 838 // 01 EXCEPTION |
837 // 10 INTERNAL_ERROR | 839 // 10 INTERNAL_ERROR |
838 // 11 OUT_OF_MEMORY_EXCEPTION | 840 // 11 OUT_OF_MEMORY_EXCEPTION |
839 // | 841 // |
840 // The next three bits, 4-6, are an allocation space tag 'sss'. The | 842 // The next three bits, 4-6, are an allocation space tag 'sss'. The |
841 // allocation space tag is 000 for all failure types except | 843 // allocation space tag is 000 for all failure types except |
842 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are | 844 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the |
843 // (the encoding is found in globals.h): | 845 // allocation spaces (the encoding is found in globals.h). |
844 // 000 NEW_SPACE | |
845 // 001 OLD_SPACE | |
846 // 010 CODE_SPACE | |
847 // 011 MAP_SPACE | |
848 // 100 LO_SPACE | |
849 // | 846 // |
850 // The remaining bits is the number of words requested by the | 847 // The remaining bits is the size of the allocation request in units |
851 // allocation request that failed, and is zeroed except for | 848 // of the pointer size, and is zeroed except for RETRY_AFTER_GC |
852 // RETRY_AFTER_GC failures. The 25 bits (on a 32 bit platform) gives | 849 // failures. The 25 bits (on a 32 bit platform) gives a representable |
853 // a representable range of 2^27 bytes (128MB). | 850 // range of 2^27 bytes (128MB). |
854 | 851 |
855 // Failure type tag info. | 852 // Failure type tag info. |
856 const int kFailureTypeTagSize = 2; | 853 const int kFailureTypeTagSize = 2; |
857 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; | 854 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; |
858 | 855 |
859 class Failure: public Object { | 856 class Failure: public Object { |
860 public: | 857 public: |
861 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. | 858 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. |
862 enum Type { | 859 enum Type { |
863 RETRY_AFTER_GC = 0, | 860 RETRY_AFTER_GC = 0, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 970 |
974 // During serialization: the map word is used to hold an encoded | 971 // During serialization: the map word is used to hold an encoded |
975 // address, and possibly a mark bit (set and cleared with SetMark | 972 // address, and possibly a mark bit (set and cleared with SetMark |
976 // and ClearMark). | 973 // and ClearMark). |
977 | 974 |
978 // Create a map word from an encoded address. | 975 // Create a map word from an encoded address. |
979 static inline MapWord FromEncodedAddress(Address address); | 976 static inline MapWord FromEncodedAddress(Address address); |
980 | 977 |
981 inline Address ToEncodedAddress(); | 978 inline Address ToEncodedAddress(); |
982 | 979 |
983 private: | |
984 // HeapObject calls the private constructor and directly reads the value. | |
985 friend class HeapObject; | |
986 | |
987 explicit MapWord(uintptr_t value) : value_(value) {} | |
988 | |
989 uintptr_t value_; | |
990 | |
991 // Bits used by the marking phase of the garbage collector. | 980 // Bits used by the marking phase of the garbage collector. |
992 // | 981 // |
993 // The first word of a heap object is normally a map pointer. The last two | 982 // The first word of a heap object is normally a map pointer. The last two |
994 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to | 983 // bits are tagged as '01' (kHeapObjectTag). We reuse the last two bits to |
995 // mark an object as live and/or overflowed: | 984 // mark an object as live and/or overflowed: |
996 // last bit = 0, marked as alive | 985 // last bit = 0, marked as alive |
997 // second bit = 1, overflowed | 986 // second bit = 1, overflowed |
998 // An object is only marked as overflowed when it is marked as live while | 987 // An object is only marked as overflowed when it is marked as live while |
999 // the marking stack is overflowed. | 988 // the marking stack is overflowed. |
1000 static const int kMarkingBit = 0; // marking bit | 989 static const int kMarkingBit = 0; // marking bit |
(...skipping 21 matching lines...) Expand all Loading... |
1022 static const uint32_t kMapPageIndexMask = | 1011 static const uint32_t kMapPageIndexMask = |
1023 (1 << kMapPageOffsetShift) - 1; | 1012 (1 << kMapPageOffsetShift) - 1; |
1024 | 1013 |
1025 // 0x001FFC00 | 1014 // 0x001FFC00 |
1026 static const uint32_t kMapPageOffsetMask = | 1015 static const uint32_t kMapPageOffsetMask = |
1027 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | 1016 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; |
1028 | 1017 |
1029 // 0xFFE00000 | 1018 // 0xFFE00000 |
1030 static const uint32_t kForwardingOffsetMask = | 1019 static const uint32_t kForwardingOffsetMask = |
1031 ~(kMapPageIndexMask | kMapPageOffsetMask); | 1020 ~(kMapPageIndexMask | kMapPageOffsetMask); |
| 1021 |
| 1022 private: |
| 1023 // HeapObject calls the private constructor and directly reads the value. |
| 1024 friend class HeapObject; |
| 1025 |
| 1026 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1027 |
| 1028 uintptr_t value_; |
1032 }; | 1029 }; |
1033 | 1030 |
1034 | 1031 |
1035 // HeapObject is the superclass for all classes describing heap allocated | 1032 // HeapObject is the superclass for all classes describing heap allocated |
1036 // objects. | 1033 // objects. |
1037 class HeapObject: public Object { | 1034 class HeapObject: public Object { |
1038 public: | 1035 public: |
1039 // [map]: Contains a map which contains the object's reflective | 1036 // [map]: Contains a map which contains the object's reflective |
1040 // information. | 1037 // information. |
1041 inline Map* map(); | 1038 inline Map* map(); |
(...skipping 3579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4621 } else { | 4618 } else { |
4622 value &= ~(1 << bit_position); | 4619 value &= ~(1 << bit_position); |
4623 } | 4620 } |
4624 return value; | 4621 return value; |
4625 } | 4622 } |
4626 }; | 4623 }; |
4627 | 4624 |
4628 } } // namespace v8::internal | 4625 } } // namespace v8::internal |
4629 | 4626 |
4630 #endif // V8_OBJECTS_H_ | 4627 #endif // V8_OBJECTS_H_ |
OLD | NEW |