| 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 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 void JSObject::InitializeBody(Map* map, | 2141 void JSObject::InitializeBody(Map* map, |
| 2142 Object* pre_allocated_value, | 2142 Object* pre_allocated_value, |
| 2143 Object* filler_value) { | 2143 Object* filler_value) { |
| 2144 DCHECK(!filler_value->IsHeapObject() || | 2144 DCHECK(!filler_value->IsHeapObject() || |
| 2145 !GetHeap()->InNewSpace(filler_value)); | 2145 !GetHeap()->InNewSpace(filler_value)); |
| 2146 DCHECK(!pre_allocated_value->IsHeapObject() || | 2146 DCHECK(!pre_allocated_value->IsHeapObject() || |
| 2147 !GetHeap()->InNewSpace(pre_allocated_value)); | 2147 !GetHeap()->InNewSpace(pre_allocated_value)); |
| 2148 int size = map->instance_size(); | 2148 int size = map->instance_size(); |
| 2149 int offset = kHeaderSize; | 2149 int offset = kHeaderSize; |
| 2150 if (filler_value != pre_allocated_value) { | 2150 if (filler_value != pre_allocated_value) { |
| 2151 int pre_allocated = map->pre_allocated_property_fields(); | 2151 int pre_allocated = |
| 2152 map->inobject_properties() - map->unused_property_fields(); |
| 2152 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); | 2153 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); |
| 2153 for (int i = 0; i < pre_allocated; i++) { | 2154 for (int i = 0; i < pre_allocated; i++) { |
| 2154 WRITE_FIELD(this, offset, pre_allocated_value); | 2155 WRITE_FIELD(this, offset, pre_allocated_value); |
| 2155 offset += kPointerSize; | 2156 offset += kPointerSize; |
| 2156 } | 2157 } |
| 2157 } | 2158 } |
| 2158 while (offset < size) { | 2159 while (offset < size) { |
| 2159 WRITE_FIELD(this, offset, filler_value); | 2160 WRITE_FIELD(this, offset, filler_value); |
| 2160 offset += kPointerSize; | 2161 offset += kPointerSize; |
| 2161 } | 2162 } |
| (...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4076 return NOBARRIER_READ_BYTE_FIELD( | 4077 return NOBARRIER_READ_BYTE_FIELD( |
| 4077 this, kInstanceSizeOffset) << kPointerSizeLog2; | 4078 this, kInstanceSizeOffset) << kPointerSizeLog2; |
| 4078 } | 4079 } |
| 4079 | 4080 |
| 4080 | 4081 |
| 4081 int Map::inobject_properties() { | 4082 int Map::inobject_properties() { |
| 4082 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); | 4083 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); |
| 4083 } | 4084 } |
| 4084 | 4085 |
| 4085 | 4086 |
| 4086 int Map::pre_allocated_property_fields() { | |
| 4087 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | |
| 4088 } | |
| 4089 | |
| 4090 | |
| 4091 int Map::GetInObjectPropertyOffset(int index) { | 4087 int Map::GetInObjectPropertyOffset(int index) { |
| 4092 // Adjust for the number of properties stored in the object. | 4088 // Adjust for the number of properties stored in the object. |
| 4093 index -= inobject_properties(); | 4089 index -= inobject_properties(); |
| 4094 DCHECK(index <= 0); | 4090 DCHECK(index <= 0); |
| 4095 return instance_size() + (index * kPointerSize); | 4091 return instance_size() + (index * kPointerSize); |
| 4096 } | 4092 } |
| 4097 | 4093 |
| 4098 | 4094 |
| 4099 Handle<Map> Map::CopyInstallDescriptorsForTesting( | 4095 Handle<Map> Map::CopyInstallDescriptorsForTesting( |
| 4100 Handle<Map> map, int new_descriptor, Handle<DescriptorArray> descriptors, | 4096 Handle<Map> map, int new_descriptor, Handle<DescriptorArray> descriptors, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4154 this, kInstanceSizeOffset, static_cast<byte>(value)); | 4150 this, kInstanceSizeOffset, static_cast<byte>(value)); |
| 4155 } | 4151 } |
| 4156 | 4152 |
| 4157 | 4153 |
| 4158 void Map::set_inobject_properties(int value) { | 4154 void Map::set_inobject_properties(int value) { |
| 4159 DCHECK(0 <= value && value < 256); | 4155 DCHECK(0 <= value && value < 256); |
| 4160 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); | 4156 WRITE_BYTE_FIELD(this, kInObjectPropertiesOffset, static_cast<byte>(value)); |
| 4161 } | 4157 } |
| 4162 | 4158 |
| 4163 | 4159 |
| 4164 void Map::set_pre_allocated_property_fields(int value) { | 4160 void Map::clear_unused() { WRITE_BYTE_FIELD(this, kUnusedOffset, 0); } |
| 4165 DCHECK(0 <= value && value < 256); | |
| 4166 WRITE_BYTE_FIELD(this, | |
| 4167 kPreAllocatedPropertyFieldsOffset, | |
| 4168 static_cast<byte>(value)); | |
| 4169 } | |
| 4170 | 4161 |
| 4171 | 4162 |
| 4172 InstanceType Map::instance_type() { | 4163 InstanceType Map::instance_type() { |
| 4173 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset)); | 4164 return static_cast<InstanceType>(READ_BYTE_FIELD(this, kInstanceTypeOffset)); |
| 4174 } | 4165 } |
| 4175 | 4166 |
| 4176 | 4167 |
| 4177 void Map::set_instance_type(InstanceType value) { | 4168 void Map::set_instance_type(InstanceType value) { |
| 4178 WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value); | 4169 WRITE_BYTE_FIELD(this, kInstanceTypeOffset, value); |
| 4179 } | 4170 } |
| (...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7315 #undef READ_SHORT_FIELD | 7306 #undef READ_SHORT_FIELD |
| 7316 #undef WRITE_SHORT_FIELD | 7307 #undef WRITE_SHORT_FIELD |
| 7317 #undef READ_BYTE_FIELD | 7308 #undef READ_BYTE_FIELD |
| 7318 #undef WRITE_BYTE_FIELD | 7309 #undef WRITE_BYTE_FIELD |
| 7319 #undef NOBARRIER_READ_BYTE_FIELD | 7310 #undef NOBARRIER_READ_BYTE_FIELD |
| 7320 #undef NOBARRIER_WRITE_BYTE_FIELD | 7311 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7321 | 7312 |
| 7322 } } // namespace v8::internal | 7313 } } // namespace v8::internal |
| 7323 | 7314 |
| 7324 #endif // V8_OBJECTS_INL_H_ | 7315 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |