| 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 3428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3439 // verification code has to cope with (temporarily) invalid objects. See | 3439 // verification code has to cope with (temporarily) invalid objects. See |
| 3440 // for example, JSArray::JSArrayVerify). | 3440 // for example, JSArray::JSArrayVerify). |
| 3441 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize); | 3441 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize); |
| 3442 } | 3442 } |
| 3443 | 3443 |
| 3444 | 3444 |
| 3445 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) { | 3445 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) { |
| 3446 if (start_offset == map->instance_size()) return; | 3446 if (start_offset == map->instance_size()) return; |
| 3447 DCHECK_LT(start_offset, map->instance_size()); | 3447 DCHECK_LT(start_offset, map->instance_size()); |
| 3448 | 3448 |
| 3449 Object* filler; | |
| 3450 // We cannot always fill with one_pointer_filler_map because objects | 3449 // We cannot always fill with one_pointer_filler_map because objects |
| 3451 // created from API functions expect their internal fields to be initialized | 3450 // created from API functions expect their internal fields to be initialized |
| 3452 // with undefined_value. | 3451 // with undefined_value. |
| 3453 // Pre-allocated fields need to be initialized with undefined_value as well | 3452 // Pre-allocated fields need to be initialized with undefined_value as well |
| 3454 // so that object accesses before the constructor completes (e.g. in the | 3453 // so that object accesses before the constructor completes (e.g. in the |
| 3455 // debugger) will not cause a crash. | 3454 // debugger) will not cause a crash. |
| 3456 | 3455 |
| 3457 // In case of Array subclassing the |map| could already be transitioned | 3456 // In case of Array subclassing the |map| could already be transitioned |
| 3458 // to different elements kind from the initial map on which we track slack. | 3457 // to different elements kind from the initial map on which we track slack. |
| 3459 Map* initial_map = map->FindRootMap(); | 3458 bool in_progress = map->IsInobjectSlackTrackingInProgress(); |
| 3460 if (initial_map->IsInobjectSlackTrackingInProgress()) { | 3459 Object* filler; |
| 3461 // We might want to shrink the object later. | 3460 if (in_progress) { |
| 3462 filler = Heap::one_pointer_filler_map(); | 3461 filler = one_pointer_filler_map(); |
| 3463 } else { | 3462 } else { |
| 3464 filler = Heap::undefined_value(); | 3463 filler = undefined_value(); |
| 3465 } | 3464 } |
| 3466 obj->InitializeBody(map, start_offset, Heap::undefined_value(), filler); | 3465 obj->InitializeBody(map, start_offset, Heap::undefined_value(), filler); |
| 3467 initial_map->InobjectSlackTrackingStep(); | 3466 if (in_progress) { |
| 3467 map->FindRootMap()->InobjectSlackTrackingStep(); |
| 3468 } |
| 3468 } | 3469 } |
| 3469 | 3470 |
| 3470 | 3471 |
| 3471 AllocationResult Heap::AllocateJSObjectFromMap( | 3472 AllocationResult Heap::AllocateJSObjectFromMap( |
| 3472 Map* map, PretenureFlag pretenure, AllocationSite* allocation_site) { | 3473 Map* map, PretenureFlag pretenure, AllocationSite* allocation_site) { |
| 3473 // JSFunctions should be allocated using AllocateFunction to be | 3474 // JSFunctions should be allocated using AllocateFunction to be |
| 3474 // properly initialized. | 3475 // properly initialized. |
| 3475 DCHECK(map->instance_type() != JS_FUNCTION_TYPE); | 3476 DCHECK(map->instance_type() != JS_FUNCTION_TYPE); |
| 3476 | 3477 |
| 3477 // Both types of global objects should be allocated using | 3478 // Both types of global objects should be allocated using |
| (...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6214 } | 6215 } |
| 6215 | 6216 |
| 6216 | 6217 |
| 6217 // static | 6218 // static |
| 6218 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6219 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6219 return StaticVisitorBase::GetVisitorId(map); | 6220 return StaticVisitorBase::GetVisitorId(map); |
| 6220 } | 6221 } |
| 6221 | 6222 |
| 6222 } // namespace internal | 6223 } // namespace internal |
| 6223 } // namespace v8 | 6224 } // namespace v8 |
| OLD | NEW |