[heap] Prevent direct access to StoreBuffer.

R=mlippautz@chromium.org

Review URL: https://codereview.chromium.org/1317553002

Cr-Commit-Position: refs/heads/master@{#30355}
This commit is contained in:
mstarzinger 2015-08-25 06:38:45 -07:00 committed by Commit bot
parent 8e0aaffdcb
commit 38b9beb8e9
7 changed files with 34 additions and 39 deletions

View File

@ -1141,7 +1141,7 @@ ExternalReference ExternalReference::new_space_start(Isolate* isolate) {
ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) {
return ExternalReference(isolate->heap()->store_buffer()->TopAddress());
return ExternalReference(isolate->heap()->store_buffer_top_address());
}

View File

@ -994,10 +994,6 @@ class Heap {
roots_[kEmptyScriptRootIndex] = script;
}
void public_set_store_buffer_top(Address* top) {
roots_[kStoreBufferTopRootIndex] = reinterpret_cast<Smi*>(top);
}
void public_set_materialized_objects(FixedArray* objects) {
roots_[kMaterializedObjectsRootIndex] = objects;
}
@ -1005,10 +1001,6 @@ class Heap {
// Generated code can embed this address to get access to the roots.
Object** roots_array_start() { return roots_; }
Address* store_buffer_top_address() {
return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
}
void CheckHandleCount();
// Number of "runtime allocations" done so far.
@ -1029,12 +1021,6 @@ class Heap {
return index < OBJECT_STATS_COUNT ? object_sizes_last_time_[index] : 0;
}
// Write barrier support for address[offset] = o.
INLINE(void RecordWrite(Address address, int offset));
// Write barrier support for address[start : start + len[ = o.
INLINE(void RecordWrites(Address address, int start, int len));
inline HeapState gc_state() { return gc_state_; }
inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
@ -1094,10 +1080,6 @@ class Heap {
void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature);
ExternalStringTable* external_string_table() {
return &external_string_table_;
}
bool concurrent_sweeping_enabled() { return concurrent_sweeping_enabled_; }
inline bool OldGenerationAllocationLimitReached();
@ -1307,7 +1289,9 @@ class Heap {
return &mark_compact_collector_;
}
StoreBuffer* store_buffer() { return &store_buffer_; }
ExternalStringTable* external_string_table() {
return &external_string_table_;
}
// ===========================================================================
// Inline allocation. ========================================================
@ -1364,6 +1348,20 @@ class Heap {
Address end, bool record_slots,
ObjectSlotCallback callback);
// ===========================================================================
// Store buffer API. =========================================================
// ===========================================================================
// Write barrier support for address[offset] = o.
INLINE(void RecordWrite(Address address, int offset));
// Write barrier support for address[start : start + len[ = o.
INLINE(void RecordWrites(Address address, int start, int len));
Address* store_buffer_top_address() {
return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
}
// ===========================================================================
// Incremental marking API. ==================================================
// ===========================================================================
@ -1683,6 +1681,8 @@ class Heap {
ROOT_LIST(ROOT_ACCESSOR)
#undef ROOT_ACCESSOR
StoreBuffer* store_buffer() { return &store_buffer_; }
void set_current_gc_flags(int flags) {
current_gc_flags_ = flags;
DCHECK(!ShouldFinalizeIncrementalMarking() ||
@ -2411,6 +2411,7 @@ class Heap {
friend class MarkCompactMarkingVisitor;
friend class MapCompact;
friend class Page;
friend class StoreBuffer;
// Used in cctest.
friend class HeapTester;

View File

@ -303,17 +303,17 @@ static void VerifyValidSlotsBufferEntries(Heap* heap, PagedSpace* space) {
}
static void VerifyValidStoreAndSlotsBufferEntries(Heap* heap) {
heap->store_buffer()->VerifyValidStoreBufferEntries();
void MarkCompactCollector::VerifyValidStoreAndSlotsBufferEntries() {
heap()->store_buffer()->VerifyValidStoreBufferEntries();
VerifyValidSlotsBufferEntries(heap, heap->old_space());
VerifyValidSlotsBufferEntries(heap, heap->code_space());
VerifyValidSlotsBufferEntries(heap, heap->map_space());
VerifyValidSlotsBufferEntries(heap(), heap()->old_space());
VerifyValidSlotsBufferEntries(heap(), heap()->code_space());
VerifyValidSlotsBufferEntries(heap(), heap()->map_space());
LargeObjectIterator it(heap->lo_space());
LargeObjectIterator it(heap()->lo_space());
for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) {
MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
SlotsBuffer::VerifySlots(heap, chunk->slots_buffer());
SlotsBuffer::VerifySlots(heap(), chunk->slots_buffer());
}
}
#endif
@ -349,7 +349,7 @@ void MarkCompactCollector::CollectGarbage() {
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) {
VerifyValidStoreAndSlotsBufferEntries(heap_);
VerifyValidStoreAndSlotsBufferEntries();
}
#endif

View File

@ -559,6 +559,7 @@ class MarkCompactCollector {
enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL };
#ifdef VERIFY_HEAP
void VerifyValidStoreAndSlotsBufferEntries();
void VerifyMarkbitsAreClean();
static void VerifyMarkbitsAreClean(PagedSpace* space);
static void VerifyMarkbitsAreClean(NewSpace* space);

View File

@ -12,16 +12,11 @@
namespace v8 {
namespace internal {
Address StoreBuffer::TopAddress() {
return reinterpret_cast<Address>(heap_->store_buffer_top_address());
}
void StoreBuffer::Mark(Address addr) {
DCHECK(!heap_->code_space()->Contains(addr));
Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
*top++ = addr;
heap_->public_set_store_buffer_top(top);
heap_->set_store_buffer_top(reinterpret_cast<Smi*>(top));
if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) {
DCHECK(top == limit_);
Compact();

View File

@ -88,7 +88,7 @@ void StoreBuffer::SetUp() {
false)) { // Not executable.
V8::FatalProcessOutOfMemory("StoreBuffer::SetUp");
}
heap_->public_set_store_buffer_top(start_);
heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_));
hash_set_1_ = new uintptr_t[kHashSetLength];
hash_set_2_ = new uintptr_t[kHashSetLength];
@ -105,7 +105,7 @@ void StoreBuffer::TearDown() {
delete[] hash_set_2_;
old_start_ = old_top_ = old_limit_ = old_reserved_limit_ = NULL;
start_ = limit_ = NULL;
heap_->public_set_store_buffer_top(start_);
heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_));
}
@ -536,7 +536,7 @@ void StoreBuffer::Compact() {
// There's no check of the limit in the loop below so we check here for
// the worst case (compaction doesn't eliminate any pointers).
DCHECK(top <= limit_);
heap_->public_set_store_buffer_top(start_);
heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_));
EnsureSpace(top - start_);
DCHECK(may_move_store_buffer_entries_);
// Goes through the addresses in the store buffer attempting to remove

View File

@ -30,8 +30,6 @@ class StoreBuffer {
static void StoreBufferOverflow(Isolate* isolate);
inline Address TopAddress();
void SetUp();
void TearDown();