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 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 Object* value, | 2279 Object* value, |
2280 WriteBarrierMode mode) { | 2280 WriteBarrierMode mode) { |
2281 // Adjust for the number of properties stored in the object. | 2281 // Adjust for the number of properties stored in the object. |
2282 int offset = GetInObjectPropertyOffset(index); | 2282 int offset = GetInObjectPropertyOffset(index); |
2283 WRITE_FIELD(this, offset, value); | 2283 WRITE_FIELD(this, offset, value); |
2284 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 2284 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
2285 return value; | 2285 return value; |
2286 } | 2286 } |
2287 | 2287 |
2288 | 2288 |
2289 | |
2290 void JSObject::InitializeBody(Map* map, | 2289 void JSObject::InitializeBody(Map* map, |
2291 Object* pre_allocated_value, | 2290 Object* pre_allocated_value, |
2292 Object* filler_value) { | 2291 Object* filler_value) { |
2293 DCHECK(!filler_value->IsHeapObject() || | 2292 DCHECK(!filler_value->IsHeapObject() || |
2294 !GetHeap()->InNewSpace(filler_value)); | 2293 !GetHeap()->InNewSpace(filler_value)); |
2295 DCHECK(!pre_allocated_value->IsHeapObject() || | 2294 DCHECK(!pre_allocated_value->IsHeapObject() || |
2296 !GetHeap()->InNewSpace(pre_allocated_value)); | 2295 !GetHeap()->InNewSpace(pre_allocated_value)); |
2297 int size = map->instance_size(); | 2296 int size = map->instance_size(); |
2298 int offset = kHeaderSize; | 2297 int offset = kHeaderSize; |
2299 if (filler_value != pre_allocated_value) { | 2298 if (filler_value != pre_allocated_value) { |
2300 int pre_allocated = | 2299 int end_of_pre_allocated_offset = |
2301 map->GetInObjectProperties() - map->unused_property_fields(); | 2300 size - (map->unused_property_fields() * kPointerSize); |
2302 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); | 2301 DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset); |
2303 for (int i = 0; i < pre_allocated; i++) { | 2302 while (offset < end_of_pre_allocated_offset) { |
2304 WRITE_FIELD(this, offset, pre_allocated_value); | 2303 WRITE_FIELD(this, offset, pre_allocated_value); |
2305 offset += kPointerSize; | 2304 offset += kPointerSize; |
2306 } | 2305 } |
2307 } | 2306 } |
2308 while (offset < size) { | 2307 while (offset < size) { |
2309 WRITE_FIELD(this, offset, filler_value); | 2308 WRITE_FIELD(this, offset, filler_value); |
2310 offset += kPointerSize; | 2309 offset += kPointerSize; |
2311 } | 2310 } |
2312 } | 2311 } |
2313 | 2312 |
(...skipping 5568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7882 #undef WRITE_INT64_FIELD | 7881 #undef WRITE_INT64_FIELD |
7883 #undef READ_BYTE_FIELD | 7882 #undef READ_BYTE_FIELD |
7884 #undef WRITE_BYTE_FIELD | 7883 #undef WRITE_BYTE_FIELD |
7885 #undef NOBARRIER_READ_BYTE_FIELD | 7884 #undef NOBARRIER_READ_BYTE_FIELD |
7886 #undef NOBARRIER_WRITE_BYTE_FIELD | 7885 #undef NOBARRIER_WRITE_BYTE_FIELD |
7887 | 7886 |
7888 } // namespace internal | 7887 } // namespace internal |
7889 } // namespace v8 | 7888 } // namespace v8 |
7890 | 7889 |
7891 #endif // V8_OBJECTS_INL_H_ | 7890 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |