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 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 3358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3369 if (start_offset == map->instance_size()) return; | 3369 if (start_offset == map->instance_size()) return; |
3370 DCHECK_LT(start_offset, map->instance_size()); | 3370 DCHECK_LT(start_offset, map->instance_size()); |
3371 | 3371 |
3372 Object* filler; | 3372 Object* filler; |
3373 // We cannot always fill with one_pointer_filler_map because objects | 3373 // We cannot always fill with one_pointer_filler_map because objects |
3374 // created from API functions expect their internal fields to be initialized | 3374 // created from API functions expect their internal fields to be initialized |
3375 // with undefined_value. | 3375 // with undefined_value. |
3376 // Pre-allocated fields need to be initialized with undefined_value as well | 3376 // Pre-allocated fields need to be initialized with undefined_value as well |
3377 // so that object accesses before the constructor completes (e.g. in the | 3377 // so that object accesses before the constructor completes (e.g. in the |
3378 // debugger) will not cause a crash. | 3378 // debugger) will not cause a crash. |
3379 Object* constructor = map->GetConstructor(); | 3379 |
3380 if (constructor->IsJSFunction() && | 3380 // In case of Array subclassing the |map| could already be transitioned |
3381 JSFunction::cast(constructor)->IsInobjectSlackTrackingInProgress()) { | 3381 // to different elements kind from the initial map on which we track slack. |
| 3382 Map* initial_map = map->FindRootMap(); |
| 3383 if (initial_map->IsInobjectSlackTrackingInProgress()) { |
3382 // We might want to shrink the object later. | 3384 // We might want to shrink the object later. |
3383 DCHECK_EQ(0, obj->GetInternalFieldCount()); | |
3384 filler = Heap::one_pointer_filler_map(); | 3385 filler = Heap::one_pointer_filler_map(); |
3385 } else { | 3386 } else { |
3386 filler = Heap::undefined_value(); | 3387 filler = Heap::undefined_value(); |
3387 } | 3388 } |
3388 obj->InitializeBody(map, start_offset, Heap::undefined_value(), filler); | 3389 obj->InitializeBody(map, start_offset, Heap::undefined_value(), filler); |
| 3390 initial_map->InobjectSlackTrackingStep(); |
3389 } | 3391 } |
3390 | 3392 |
3391 | 3393 |
3392 AllocationResult Heap::AllocateJSObjectFromMap( | 3394 AllocationResult Heap::AllocateJSObjectFromMap( |
3393 Map* map, PretenureFlag pretenure, AllocationSite* allocation_site) { | 3395 Map* map, PretenureFlag pretenure, AllocationSite* allocation_site) { |
3394 // JSFunctions should be allocated using AllocateFunction to be | 3396 // JSFunctions should be allocated using AllocateFunction to be |
3395 // properly initialized. | 3397 // properly initialized. |
3396 DCHECK(map->instance_type() != JS_FUNCTION_TYPE); | 3398 DCHECK(map->instance_type() != JS_FUNCTION_TYPE); |
3397 | 3399 |
3398 // Both types of global objects should be allocated using | 3400 // Both types of global objects should be allocated using |
(...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6099 } | 6101 } |
6100 | 6102 |
6101 | 6103 |
6102 // static | 6104 // static |
6103 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6105 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6104 return StaticVisitorBase::GetVisitorId(map); | 6106 return StaticVisitorBase::GetVisitorId(map); |
6105 } | 6107 } |
6106 | 6108 |
6107 } // namespace internal | 6109 } // namespace internal |
6108 } // namespace v8 | 6110 } // namespace v8 |
OLD | NEW |