V8 Project
mark-compact-inl.h
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
5 #ifndef V8_HEAP_MARK_COMPACT_INL_H_
6 #define V8_HEAP_MARK_COMPACT_INL_H_
7 
9 #include "src/isolate.h"
10 
11 
12 namespace v8 {
13 namespace internal {
14 
15 
16 MarkBit Marking::MarkBitFrom(Address addr) {
17  MemoryChunk* p = MemoryChunk::FromAddress(addr);
18  return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr),
19  p->ContainsOnlyData());
20 }
21 
22 
27 }
28 
29 
30 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) {
31  DCHECK(Marking::MarkBitFrom(obj) == mark_bit);
32  if (!mark_bit.Get()) {
33  mark_bit.Set();
35  DCHECK(IsMarked(obj));
36  DCHECK(obj->GetIsolate()->heap()->Contains(obj));
37  marking_deque_.PushBlack(obj);
38  }
39 }
40 
41 
42 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) {
43  DCHECK(!mark_bit.Get());
44  DCHECK(Marking::MarkBitFrom(obj) == mark_bit);
45  mark_bit.Set();
46  MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size());
47 }
48 
49 
51  DCHECK(obj->IsHeapObject());
52  HeapObject* heap_object = HeapObject::cast(obj);
53  return Marking::MarkBitFrom(heap_object).Get();
54 }
55 
56 
57 void MarkCompactCollector::RecordSlot(Object** anchor_slot, Object** slot,
58  Object* object,
60  Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object));
61  if (object_page->IsEvacuationCandidate() &&
62  !ShouldSkipEvacuationSlotRecording(anchor_slot)) {
64  object_page->slots_buffer_address(), slot, mode)) {
65  EvictEvacuationCandidate(object_page);
66  }
67  }
68 }
69 }
70 } // namespace v8::internal
71 
72 #endif // V8_HEAP_MARK_COMPACT_INL_H_
Isolate * GetIsolate() const
Definition: objects-inl.h:1387
bool Contains(Address addr)
Definition: heap.cc:4447
static const int kReduceMemoryFootprintMask
Definition: heap.h:717
static const int kAbortIncrementalMarkingMask
Definition: heap.h:718
SlotsBufferAllocator slots_buffer_allocator_
Definition: mark-compact.h:710
static bool IsMarked(Object *obj)
SlotsBuffer ** slots_buffer_address()
Definition: spaces.h:619
static void IncrementLiveBytesFromGC(Address address, int by)
Definition: spaces.h:517
static MemoryChunk * FromAddress(Address a)
Definition: spaces.h:276
bool IsEvacuationCandidate()
Definition: spaces.h:607
static bool AddTo(SlotsBufferAllocator *allocator, SlotsBuffer **buffer_address, SlotType type, Address addr, AdditionMode mode)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
#define DCHECK(condition)
Definition: logging.h:205
byte * Address
Definition: globals.h:101
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20