| 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/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
| 10 #include "src/ast/context-slot-cache.h" | 10 #include "src/ast/context-slot-cache.h" |
| (...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3502 // for example, JSArray::JSArrayVerify). | 3502 // for example, JSArray::JSArrayVerify). |
| 3503 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize); | 3503 InitializeJSObjectBody(obj, map, JSObject::kHeaderSize); |
| 3504 } | 3504 } |
| 3505 | 3505 |
| 3506 | 3506 |
| 3507 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) { | 3507 void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) { |
| 3508 if (start_offset == map->instance_size()) return; | 3508 if (start_offset == map->instance_size()) return; |
| 3509 DCHECK_LT(start_offset, map->instance_size()); | 3509 DCHECK_LT(start_offset, map->instance_size()); |
| 3510 | 3510 |
| 3511 // We cannot always fill with one_pointer_filler_map because objects | 3511 // We cannot always fill with one_pointer_filler_map because objects |
| 3512 // created from API functions expect their internal fields to be initialized | 3512 // created from API functions expect their embedder fields to be initialized |
| 3513 // with undefined_value. | 3513 // with undefined_value. |
| 3514 // Pre-allocated fields need to be initialized with undefined_value as well | 3514 // Pre-allocated fields need to be initialized with undefined_value as well |
| 3515 // so that object accesses before the constructor completes (e.g. in the | 3515 // so that object accesses before the constructor completes (e.g. in the |
| 3516 // debugger) will not cause a crash. | 3516 // debugger) will not cause a crash. |
| 3517 | 3517 |
| 3518 // In case of Array subclassing the |map| could already be transitioned | 3518 // In case of Array subclassing the |map| could already be transitioned |
| 3519 // to different elements kind from the initial map on which we track slack. | 3519 // to different elements kind from the initial map on which we track slack. |
| 3520 bool in_progress = map->IsInobjectSlackTrackingInProgress(); | 3520 bool in_progress = map->IsInobjectSlackTrackingInProgress(); |
| 3521 Object* filler; | 3521 Object* filler; |
| 3522 if (in_progress) { | 3522 if (in_progress) { |
| (...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5621 deserialization_complete_ = true; | 5621 deserialization_complete_ = true; |
| 5622 } | 5622 } |
| 5623 | 5623 |
| 5624 void Heap::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) { | 5624 void Heap::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) { |
| 5625 DCHECK_EQ(gc_state_, HeapState::NOT_IN_GC); | 5625 DCHECK_EQ(gc_state_, HeapState::NOT_IN_GC); |
| 5626 local_embedder_heap_tracer()->SetRemoteTracer(tracer); | 5626 local_embedder_heap_tracer()->SetRemoteTracer(tracer); |
| 5627 } | 5627 } |
| 5628 | 5628 |
| 5629 void Heap::TracePossibleWrapper(JSObject* js_object) { | 5629 void Heap::TracePossibleWrapper(JSObject* js_object) { |
| 5630 DCHECK(js_object->WasConstructedFromApiFunction()); | 5630 DCHECK(js_object->WasConstructedFromApiFunction()); |
| 5631 if (js_object->GetInternalFieldCount() >= 2 && | 5631 if (js_object->GetEmbedderFieldCount() >= 2 && |
| 5632 js_object->GetInternalField(0) && | 5632 js_object->GetEmbedderField(0) && |
| 5633 js_object->GetInternalField(0) != undefined_value() && | 5633 js_object->GetEmbedderField(0) != undefined_value() && |
| 5634 js_object->GetInternalField(1) != undefined_value()) { | 5634 js_object->GetEmbedderField(1) != undefined_value()) { |
| 5635 DCHECK(reinterpret_cast<intptr_t>(js_object->GetInternalField(0)) % 2 == 0); | 5635 DCHECK(reinterpret_cast<intptr_t>(js_object->GetEmbedderField(0)) % 2 == 0); |
| 5636 local_embedder_heap_tracer()->AddWrapperToTrace(std::pair<void*, void*>( | 5636 local_embedder_heap_tracer()->AddWrapperToTrace(std::pair<void*, void*>( |
| 5637 reinterpret_cast<void*>(js_object->GetInternalField(0)), | 5637 reinterpret_cast<void*>(js_object->GetEmbedderField(0)), |
| 5638 reinterpret_cast<void*>(js_object->GetInternalField(1)))); | 5638 reinterpret_cast<void*>(js_object->GetEmbedderField(1)))); |
| 5639 } | 5639 } |
| 5640 } | 5640 } |
| 5641 | 5641 |
| 5642 void Heap::RegisterExternallyReferencedObject(Object** object) { | 5642 void Heap::RegisterExternallyReferencedObject(Object** object) { |
| 5643 HeapObject* heap_object = HeapObject::cast(*object); | 5643 HeapObject* heap_object = HeapObject::cast(*object); |
| 5644 DCHECK(Contains(heap_object)); | 5644 DCHECK(Contains(heap_object)); |
| 5645 if (FLAG_incremental_marking_wrappers && incremental_marking()->IsMarking()) { | 5645 if (FLAG_incremental_marking_wrappers && incremental_marking()->IsMarking()) { |
| 5646 IncrementalMarking::MarkGrey(this, heap_object); | 5646 IncrementalMarking::MarkGrey(this, heap_object); |
| 5647 } else { | 5647 } else { |
| 5648 DCHECK(mark_compact_collector()->in_use()); | 5648 DCHECK(mark_compact_collector()->in_use()); |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6371 } | 6371 } |
| 6372 | 6372 |
| 6373 | 6373 |
| 6374 // static | 6374 // static |
| 6375 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6375 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6376 return StaticVisitorBase::GetVisitorId(map); | 6376 return StaticVisitorBase::GetVisitorId(map); |
| 6377 } | 6377 } |
| 6378 | 6378 |
| 6379 } // namespace internal | 6379 } // namespace internal |
| 6380 } // namespace v8 | 6380 } // namespace v8 |
| OLD | NEW |