OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 5536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5547 // - Size information about the object | 5547 // - Size information about the object |
5548 // - How to iterate over an object (for garbage collection) | 5548 // - How to iterate over an object (for garbage collection) |
5549 class Map: public HeapObject { | 5549 class Map: public HeapObject { |
5550 public: | 5550 public: |
5551 // Instance size. | 5551 // Instance size. |
5552 // Size in bytes or kVariableSizeSentinel if instances do not have | 5552 // Size in bytes or kVariableSizeSentinel if instances do not have |
5553 // a fixed size. | 5553 // a fixed size. |
5554 inline int instance_size(); | 5554 inline int instance_size(); |
5555 inline void set_instance_size(int value); | 5555 inline void set_instance_size(int value); |
5556 | 5556 |
| 5557 // Only to clear an unused byte, remove once byte is used. |
| 5558 inline void clear_unused(); |
| 5559 |
5557 // Count of properties allocated in the object. | 5560 // Count of properties allocated in the object. |
5558 inline int inobject_properties(); | 5561 inline int inobject_properties(); |
5559 inline void set_inobject_properties(int value); | 5562 inline void set_inobject_properties(int value); |
5560 | 5563 |
5561 // Count of property fields pre-allocated in the object when first allocated. | |
5562 inline int pre_allocated_property_fields(); | |
5563 inline void set_pre_allocated_property_fields(int value); | |
5564 | |
5565 // Instance type. | 5564 // Instance type. |
5566 inline InstanceType instance_type(); | 5565 inline InstanceType instance_type(); |
5567 inline void set_instance_type(InstanceType value); | 5566 inline void set_instance_type(InstanceType value); |
5568 | 5567 |
5569 // Tells how many unused property fields are available in the | 5568 // Tells how many unused property fields are available in the |
5570 // instance (only used for JSObject in fast mode). | 5569 // instance (only used for JSObject in fast mode). |
5571 inline int unused_property_fields(); | 5570 inline int unused_property_fields(); |
5572 inline void set_unused_property_fields(int value); | 5571 inline void set_unused_property_fields(int value); |
5573 | 5572 |
5574 // Bit field. | 5573 // Bit field. |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5996 static Handle<Map> Create(Isolate* isolate, int inobject_properties); | 5995 static Handle<Map> Create(Isolate* isolate, int inobject_properties); |
5997 | 5996 |
5998 // Returns the next free property index (only valid for FAST MODE). | 5997 // Returns the next free property index (only valid for FAST MODE). |
5999 int NextFreePropertyIndex(); | 5998 int NextFreePropertyIndex(); |
6000 | 5999 |
6001 // Returns the number of properties described in instance_descriptors | 6000 // Returns the number of properties described in instance_descriptors |
6002 // filtering out properties with the specified attributes. | 6001 // filtering out properties with the specified attributes. |
6003 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, | 6002 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, |
6004 PropertyAttributes filter = NONE); | 6003 PropertyAttributes filter = NONE); |
6005 | 6004 |
6006 // Returns the number of slots allocated for the initial properties | |
6007 // backing storage for instances of this map. | |
6008 int InitialPropertiesLength() { | |
6009 return pre_allocated_property_fields() + unused_property_fields() - | |
6010 inobject_properties(); | |
6011 } | |
6012 | |
6013 DECLARE_CAST(Map) | 6005 DECLARE_CAST(Map) |
6014 | 6006 |
6015 // Code cache operations. | 6007 // Code cache operations. |
6016 | 6008 |
6017 // Clears the code cache. | 6009 // Clears the code cache. |
6018 inline void ClearCodeCache(Heap* heap); | 6010 inline void ClearCodeCache(Heap* heap); |
6019 | 6011 |
6020 // Update code cache. | 6012 // Update code cache. |
6021 static void UpdateCodeCache(Handle<Map> map, | 6013 static void UpdateCodeCache(Handle<Map> map, |
6022 Handle<Name> name, | 6014 Handle<Name> name, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6138 // Layout of pointer fields. Heap iteration code relies on them | 6130 // Layout of pointer fields. Heap iteration code relies on them |
6139 // being continuously allocated. | 6131 // being continuously allocated. |
6140 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 6132 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
6141 static const int kPointerFieldsEndOffset = kSize; | 6133 static const int kPointerFieldsEndOffset = kSize; |
6142 | 6134 |
6143 // Byte offsets within kInstanceSizesOffset. | 6135 // Byte offsets within kInstanceSizesOffset. |
6144 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 6136 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
6145 static const int kInObjectPropertiesByte = 1; | 6137 static const int kInObjectPropertiesByte = 1; |
6146 static const int kInObjectPropertiesOffset = | 6138 static const int kInObjectPropertiesOffset = |
6147 kInstanceSizesOffset + kInObjectPropertiesByte; | 6139 kInstanceSizesOffset + kInObjectPropertiesByte; |
6148 static const int kPreAllocatedPropertyFieldsByte = 2; | 6140 // Note there is one byte available for use here. |
6149 static const int kPreAllocatedPropertyFieldsOffset = | 6141 static const int kUnusedByte = 2; |
6150 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 6142 static const int kUnusedOffset = kInstanceSizesOffset + kUnusedByte; |
6151 static const int kVisitorIdByte = 3; | 6143 static const int kVisitorIdByte = 3; |
6152 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; | 6144 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; |
6153 | 6145 |
6154 // Byte offsets within kInstanceAttributesOffset attributes. | 6146 // Byte offsets within kInstanceAttributesOffset attributes. |
6155 #if V8_TARGET_LITTLE_ENDIAN | 6147 #if V8_TARGET_LITTLE_ENDIAN |
6156 // Order instance type and bit field together such that they can be loaded | 6148 // Order instance type and bit field together such that they can be loaded |
6157 // together as a 16-bit word with instance type in the lower 8 bits regardless | 6149 // together as a 16-bit word with instance type in the lower 8 bits regardless |
6158 // of endianess. Also provide endian-independent offset to that 16-bit word. | 6150 // of endianess. Also provide endian-independent offset to that 16-bit word. |
6159 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 6151 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
6160 static const int kBitFieldOffset = kInstanceAttributesOffset + 1; | 6152 static const int kBitFieldOffset = kInstanceAttributesOffset + 1; |
6161 #else | 6153 #else |
6162 static const int kBitFieldOffset = kInstanceAttributesOffset + 0; | 6154 static const int kBitFieldOffset = kInstanceAttributesOffset + 0; |
6163 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1; | 6155 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 1; |
6164 #endif | 6156 #endif |
6165 static const int kInstanceTypeAndBitFieldOffset = | 6157 static const int kInstanceTypeAndBitFieldOffset = |
6166 kInstanceAttributesOffset + 0; | 6158 kInstanceAttributesOffset + 0; |
6167 static const int kBitField2Offset = kInstanceAttributesOffset + 2; | 6159 static const int kBitField2Offset = kInstanceAttributesOffset + 2; |
| 6160 static const int kUnusedPropertyFieldsByte = 3; |
6168 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3; | 6161 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 3; |
6169 | 6162 |
6170 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset == | 6163 STATIC_ASSERT(kInstanceTypeAndBitFieldOffset == |
6171 Internals::kMapInstanceTypeAndBitFieldOffset); | 6164 Internals::kMapInstanceTypeAndBitFieldOffset); |
6172 | 6165 |
6173 // Bit positions for bit field. | 6166 // Bit positions for bit field. |
6174 static const int kHasNonInstancePrototype = 0; | 6167 static const int kHasNonInstancePrototype = 0; |
6175 static const int kIsHiddenPrototype = 1; | 6168 static const int kIsHiddenPrototype = 1; |
6176 static const int kHasNamedInterceptor = 2; | 6169 static const int kHasNamedInterceptor = 2; |
6177 static const int kHasIndexedInterceptor = 3; | 6170 static const int kHasIndexedInterceptor = 3; |
(...skipping 4653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10831 } else { | 10824 } else { |
10832 value &= ~(1 << bit_position); | 10825 value &= ~(1 << bit_position); |
10833 } | 10826 } |
10834 return value; | 10827 return value; |
10835 } | 10828 } |
10836 }; | 10829 }; |
10837 | 10830 |
10838 } } // namespace v8::internal | 10831 } } // namespace v8::internal |
10839 | 10832 |
10840 #endif // V8_OBJECTS_H_ | 10833 #endif // V8_OBJECTS_H_ |
OLD | NEW |