Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: src/objects-inl.h

Issue 1459083003: Fix object initialization when slack tracking for it's map is still enabled. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@toon
Patch Set: mips64 port Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 2289 //
2290 // The layout of JSObject created from initial map:
2291 //
2292 // ----------------------
2293 // map \ \
2294 // properties | | - JSObject header.
2295 // elements | /
2296 // |
2297 // header field 1 | - Extended header (see for example JSDate).
2298 // ... |
2299 // header field K /
2300 // ----------------------
2301 // internal field 1 \
2302 // ... | - internal fields
2303 // internal field M /
2304 // ----------------------
2305 // in-object property \ \
2306 // field 1 | |
2307 // ... | - pre-allocated |
2308 // in-object property | |
2309 // field P / | - in-object properties
2310 // in-object property \ |
2311 // field P + 1 | |
2312 // ... | - unused property fields |
2313 // in-object property | |
2314 // field P + U / /
2315 // ----------------------
2316 //
2317 // where
2318 // K - number of extra header fields
2319 // M - number of internal fields
2320 // P - number of pre-allocated fields
2321 // U - number of unused fields
2322 //
2323 // The following values are stored in the Map:
2324 // |inobject_properties|, |instance_size|, U := |unused_property_fields| and
2325 // |extended_header_size| (computable via |instance_type|).
2326 //
2327 // The other values are calculated as follows:
2328 // P := |inobject_properties| - |unused_property_fields|
2329 // M := (|instance_size| - |extended_header_size|) / kPointerSize -
2330 // |inobject_properties|
2331 // K := (|extended_header_size| - JSObject::kHeaderSize) / kPointerSize
2332 //
2333 // When in-object slack tracking is enabled for the map, the unused fields
2334 // are initialized with one-word fillers.
2335 //
2290 void JSObject::InitializeBody(Map* map, 2336 void JSObject::InitializeBody(Map* map,
2291 Object* pre_allocated_value, 2337 Object* pre_allocated_value,
2292 Object* filler_value) { 2338 Object* filler_value) {
2293 DCHECK(!filler_value->IsHeapObject() || 2339 DCHECK(!filler_value->IsHeapObject() ||
2294 !GetHeap()->InNewSpace(filler_value)); 2340 !GetHeap()->InNewSpace(filler_value));
2295 DCHECK(!pre_allocated_value->IsHeapObject() || 2341 DCHECK(!pre_allocated_value->IsHeapObject() ||
2296 !GetHeap()->InNewSpace(pre_allocated_value)); 2342 !GetHeap()->InNewSpace(pre_allocated_value));
2297 int size = map->instance_size(); 2343 int size = map->instance_size();
2298 int offset = kHeaderSize; 2344 int offset = kHeaderSize;
2299 if (filler_value != pre_allocated_value) { 2345 if (filler_value != pre_allocated_value) {
2300 int pre_allocated = 2346 int end_of_pre_allocated_offset =
2301 map->GetInObjectProperties() - map->unused_property_fields(); 2347 size - (map->unused_property_fields() << kPointerSizeLog2);
Toon Verwaest 2015/11/20 10:55:55 What about just * kPointerSize? :)
Igor Sheludko 2015/11/20 11:26:14 Done.
2302 DCHECK(pre_allocated * kPointerSize + kHeaderSize <= size); 2348 DCHECK_LE(kHeaderSize, end_of_pre_allocated_offset);
2303 for (int i = 0; i < pre_allocated; i++) { 2349 while (offset < end_of_pre_allocated_offset) {
2304 WRITE_FIELD(this, offset, pre_allocated_value); 2350 WRITE_FIELD(this, offset, pre_allocated_value);
2305 offset += kPointerSize; 2351 offset += kPointerSize;
2306 } 2352 }
2307 } 2353 }
2308 while (offset < size) { 2354 while (offset < size) {
2309 WRITE_FIELD(this, offset, filler_value); 2355 WRITE_FIELD(this, offset, filler_value);
2310 offset += kPointerSize; 2356 offset += kPointerSize;
2311 } 2357 }
2312 } 2358 }
2313 2359
(...skipping 5568 matching lines...) Expand 10 before | Expand all | Expand 10 after
7882 #undef WRITE_INT64_FIELD 7928 #undef WRITE_INT64_FIELD
7883 #undef READ_BYTE_FIELD 7929 #undef READ_BYTE_FIELD
7884 #undef WRITE_BYTE_FIELD 7930 #undef WRITE_BYTE_FIELD
7885 #undef NOBARRIER_READ_BYTE_FIELD 7931 #undef NOBARRIER_READ_BYTE_FIELD
7886 #undef NOBARRIER_WRITE_BYTE_FIELD 7932 #undef NOBARRIER_WRITE_BYTE_FIELD
7887 7933
7888 } // namespace internal 7934 } // namespace internal
7889 } // namespace v8 7935 } // namespace v8
7890 7936
7891 #endif // V8_OBJECTS_INL_H_ 7937 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698