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