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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 // mark an object as live and/or overflowed: | 885 // mark an object as live and/or overflowed: |
886 // last bit = 0, marked as alive | 886 // last bit = 0, marked as alive |
887 // second bit = 1, overflowed | 887 // second bit = 1, overflowed |
888 // An object is only marked as overflowed when it is marked as live while | 888 // An object is only marked as overflowed when it is marked as live while |
889 // the marking stack is overflowed. | 889 // the marking stack is overflowed. |
890 static const int kMarkingBit = 0; // marking bit | 890 static const int kMarkingBit = 0; // marking bit |
891 static const int kMarkingMask = (1 << kMarkingBit); // marking mask | 891 static const int kMarkingMask = (1 << kMarkingBit); // marking mask |
892 static const int kOverflowBit = 1; // overflow bit | 892 static const int kOverflowBit = 1; // overflow bit |
893 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask | 893 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask |
894 | 894 |
895 // Forwarding pointers and map pointer encoding | 895 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are |
896 // 31 21 20 10 9 0 | 896 // used. |
897 // +-----------------+------------------+-----------------+ | 897 // +-----------------+------------------+-----------------+ |
898 // |forwarding offset|page offset of map|page index of map| | 898 // |forwarding offset|page offset of map|page index of map| |
899 // +-----------------+------------------+-----------------+ | 899 // +-----------------+------------------+-----------------+ |
900 // 11 bits 11 bits 10 bits | 900 // ^ ^ ^ |
901 static const int kMapPageIndexBits = 10; | 901 // | | | |
902 static const int kMapPageOffsetBits = 11; | 902 // | | kMapPageIndexBits |
903 static const int kForwardingOffsetBits = 11; | 903 // | kMapPageOffsetBits |
| 904 // kForwardingOffsetBits |
| 905 static const int kMapPageOffsetBits = kPageSizeBits - kMapAlignmentBits; |
| 906 static const int kForwardingOffsetBits = kPageSizeBits - kObjectAlignmentBits; |
| 907 #ifdef V8_HOST_ARCH_64_BIT |
| 908 static const int kMapPageIndexBits = 16; |
| 909 #else |
| 910 // Use all the 32-bits to encode on a 32-bit platform. |
| 911 static const int kMapPageIndexBits = |
| 912 32 - (kMapPageOffsetBits + kForwardingOffsetBits); |
| 913 #endif |
904 | 914 |
905 static const int kMapPageIndexShift = 0; | 915 static const int kMapPageIndexShift = 0; |
906 static const int kMapPageOffsetShift = | 916 static const int kMapPageOffsetShift = |
907 kMapPageIndexShift + kMapPageIndexBits; | 917 kMapPageIndexShift + kMapPageIndexBits; |
908 static const int kForwardingOffsetShift = | 918 static const int kForwardingOffsetShift = |
909 kMapPageOffsetShift + kMapPageOffsetBits; | 919 kMapPageOffsetShift + kMapPageOffsetBits; |
910 | 920 |
911 // 0x000003FF | 921 // Bit masks covering the different parts the encoding. |
912 static const uint32_t kMapPageIndexMask = | 922 static const uintptr_t kMapPageIndexMask = |
913 (1 << kMapPageOffsetShift) - 1; | 923 (1 << kMapPageOffsetShift) - 1; |
914 | 924 static const uintptr_t kMapPageOffsetMask = |
915 // 0x001FFC00 | |
916 static const uint32_t kMapPageOffsetMask = | |
917 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | 925 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; |
918 | 926 static const uintptr_t kForwardingOffsetMask = |
919 // 0xFFE00000 | |
920 static const uint32_t kForwardingOffsetMask = | |
921 ~(kMapPageIndexMask | kMapPageOffsetMask); | 927 ~(kMapPageIndexMask | kMapPageOffsetMask); |
922 | 928 |
923 private: | 929 private: |
924 // HeapObject calls the private constructor and directly reads the value. | 930 // HeapObject calls the private constructor and directly reads the value. |
925 friend class HeapObject; | 931 friend class HeapObject; |
926 | 932 |
927 explicit MapWord(uintptr_t value) : value_(value) {} | 933 explicit MapWord(uintptr_t value) : value_(value) {} |
928 | 934 |
929 uintptr_t value_; | 935 uintptr_t value_; |
930 }; | 936 }; |
(...skipping 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 | 2837 |
2832 // [constructor]: points back to the function responsible for this map. | 2838 // [constructor]: points back to the function responsible for this map. |
2833 DECL_ACCESSORS(constructor, Object) | 2839 DECL_ACCESSORS(constructor, Object) |
2834 | 2840 |
2835 // [instance descriptors]: describes the object. | 2841 // [instance descriptors]: describes the object. |
2836 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 2842 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
2837 | 2843 |
2838 // [stub cache]: contains stubs compiled for this map. | 2844 // [stub cache]: contains stubs compiled for this map. |
2839 DECL_ACCESSORS(code_cache, FixedArray) | 2845 DECL_ACCESSORS(code_cache, FixedArray) |
2840 | 2846 |
2841 // Returns a copy of the map. | |
2842 Object* CopyDropDescriptors(); | 2847 Object* CopyDropDescriptors(); |
2843 | 2848 |
2844 // Returns a copy of the map, with all transitions dropped from the | 2849 // Returns a copy of the map, with all transitions dropped from the |
2845 // instance descriptors. | 2850 // instance descriptors. |
2846 Object* CopyDropTransitions(); | 2851 Object* CopyDropTransitions(); |
2847 | 2852 |
2848 // Returns the property index for name (only valid for FAST MODE). | 2853 // Returns the property index for name (only valid for FAST MODE). |
2849 int PropertyIndexFor(String* name); | 2854 int PropertyIndexFor(String* name); |
2850 | 2855 |
2851 // Returns the next free property index (only valid for FAST MODE). | 2856 // Returns the next free property index (only valid for FAST MODE). |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 static const int kMaxPreAllocatedPropertyFields = 255; | 2904 static const int kMaxPreAllocatedPropertyFields = 255; |
2900 | 2905 |
2901 // Layout description. | 2906 // Layout description. |
2902 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 2907 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
2903 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 2908 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
2904 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 2909 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
2905 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 2910 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
2906 static const int kInstanceDescriptorsOffset = | 2911 static const int kInstanceDescriptorsOffset = |
2907 kConstructorOffset + kPointerSize; | 2912 kConstructorOffset + kPointerSize; |
2908 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 2913 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
2909 static const int kSize = kCodeCacheOffset + kPointerSize; | 2914 static const int kPadStart = kCodeCacheOffset + kPointerSize; |
| 2915 static const int kSize = MAP_SIZE_ALIGN(kPadStart); |
2910 | 2916 |
2911 // Byte offsets within kInstanceSizesOffset. | 2917 // Byte offsets within kInstanceSizesOffset. |
2912 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 2918 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
2913 static const int kInObjectPropertiesByte = 1; | 2919 static const int kInObjectPropertiesByte = 1; |
2914 static const int kInObjectPropertiesOffset = | 2920 static const int kInObjectPropertiesOffset = |
2915 kInstanceSizesOffset + kInObjectPropertiesByte; | 2921 kInstanceSizesOffset + kInObjectPropertiesByte; |
2916 static const int kPreAllocatedPropertyFieldsByte = 2; | 2922 static const int kPreAllocatedPropertyFieldsByte = 2; |
2917 static const int kPreAllocatedPropertyFieldsOffset = | 2923 static const int kPreAllocatedPropertyFieldsOffset = |
2918 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 2924 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
2919 // The byte at position 3 is not in use at the moment. | 2925 // The byte at position 3 is not in use at the moment. |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4863 } else { | 4869 } else { |
4864 value &= ~(1 << bit_position); | 4870 value &= ~(1 << bit_position); |
4865 } | 4871 } |
4866 return value; | 4872 return value; |
4867 } | 4873 } |
4868 }; | 4874 }; |
4869 | 4875 |
4870 } } // namespace v8::internal | 4876 } } // namespace v8::internal |
4871 | 4877 |
4872 #endif // V8_OBJECTS_H_ | 4878 #endif // V8_OBJECTS_H_ |
OLD | NEW |