[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:
parent
8e0aaffdcb
commit
38b9beb8e9
@ -1141,7 +1141,7 @@ ExternalReference ExternalReference::new_space_start(Isolate* isolate) {
|
|||||||
|
|
||||||
|
|
||||||
ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) {
|
ExternalReference ExternalReference::store_buffer_top(Isolate* isolate) {
|
||||||
return ExternalReference(isolate->heap()->store_buffer()->TopAddress());
|
return ExternalReference(isolate->heap()->store_buffer_top_address());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -994,10 +994,6 @@ class Heap {
|
|||||||
roots_[kEmptyScriptRootIndex] = script;
|
roots_[kEmptyScriptRootIndex] = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
void public_set_store_buffer_top(Address* top) {
|
|
||||||
roots_[kStoreBufferTopRootIndex] = reinterpret_cast<Smi*>(top);
|
|
||||||
}
|
|
||||||
|
|
||||||
void public_set_materialized_objects(FixedArray* objects) {
|
void public_set_materialized_objects(FixedArray* objects) {
|
||||||
roots_[kMaterializedObjectsRootIndex] = objects;
|
roots_[kMaterializedObjectsRootIndex] = objects;
|
||||||
}
|
}
|
||||||
@ -1005,10 +1001,6 @@ class Heap {
|
|||||||
// Generated code can embed this address to get access to the roots.
|
// Generated code can embed this address to get access to the roots.
|
||||||
Object** roots_array_start() { return roots_; }
|
Object** roots_array_start() { return roots_; }
|
||||||
|
|
||||||
Address* store_buffer_top_address() {
|
|
||||||
return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckHandleCount();
|
void CheckHandleCount();
|
||||||
|
|
||||||
// Number of "runtime allocations" done so far.
|
// Number of "runtime allocations" done so far.
|
||||||
@ -1029,12 +1021,6 @@ class Heap {
|
|||||||
return index < OBJECT_STATS_COUNT ? object_sizes_last_time_[index] : 0;
|
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 HeapState gc_state() { return gc_state_; }
|
||||||
|
|
||||||
inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
|
inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }
|
||||||
@ -1094,10 +1080,6 @@ class Heap {
|
|||||||
|
|
||||||
void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature);
|
void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature);
|
||||||
|
|
||||||
ExternalStringTable* external_string_table() {
|
|
||||||
return &external_string_table_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool concurrent_sweeping_enabled() { return concurrent_sweeping_enabled_; }
|
bool concurrent_sweeping_enabled() { return concurrent_sweeping_enabled_; }
|
||||||
|
|
||||||
inline bool OldGenerationAllocationLimitReached();
|
inline bool OldGenerationAllocationLimitReached();
|
||||||
@ -1307,7 +1289,9 @@ class Heap {
|
|||||||
return &mark_compact_collector_;
|
return &mark_compact_collector_;
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreBuffer* store_buffer() { return &store_buffer_; }
|
ExternalStringTable* external_string_table() {
|
||||||
|
return &external_string_table_;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// Inline allocation. ========================================================
|
// Inline allocation. ========================================================
|
||||||
@ -1364,6 +1348,20 @@ class Heap {
|
|||||||
Address end, bool record_slots,
|
Address end, bool record_slots,
|
||||||
ObjectSlotCallback callback);
|
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. ==================================================
|
// Incremental marking API. ==================================================
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@ -1683,6 +1681,8 @@ class Heap {
|
|||||||
ROOT_LIST(ROOT_ACCESSOR)
|
ROOT_LIST(ROOT_ACCESSOR)
|
||||||
#undef ROOT_ACCESSOR
|
#undef ROOT_ACCESSOR
|
||||||
|
|
||||||
|
StoreBuffer* store_buffer() { return &store_buffer_; }
|
||||||
|
|
||||||
void set_current_gc_flags(int flags) {
|
void set_current_gc_flags(int flags) {
|
||||||
current_gc_flags_ = flags;
|
current_gc_flags_ = flags;
|
||||||
DCHECK(!ShouldFinalizeIncrementalMarking() ||
|
DCHECK(!ShouldFinalizeIncrementalMarking() ||
|
||||||
@ -2411,6 +2411,7 @@ class Heap {
|
|||||||
friend class MarkCompactMarkingVisitor;
|
friend class MarkCompactMarkingVisitor;
|
||||||
friend class MapCompact;
|
friend class MapCompact;
|
||||||
friend class Page;
|
friend class Page;
|
||||||
|
friend class StoreBuffer;
|
||||||
|
|
||||||
// Used in cctest.
|
// Used in cctest.
|
||||||
friend class HeapTester;
|
friend class HeapTester;
|
||||||
|
@ -303,17 +303,17 @@ static void VerifyValidSlotsBufferEntries(Heap* heap, PagedSpace* space) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void VerifyValidStoreAndSlotsBufferEntries(Heap* heap) {
|
void MarkCompactCollector::VerifyValidStoreAndSlotsBufferEntries() {
|
||||||
heap->store_buffer()->VerifyValidStoreBufferEntries();
|
heap()->store_buffer()->VerifyValidStoreBufferEntries();
|
||||||
|
|
||||||
VerifyValidSlotsBufferEntries(heap, heap->old_space());
|
VerifyValidSlotsBufferEntries(heap(), heap()->old_space());
|
||||||
VerifyValidSlotsBufferEntries(heap, heap->code_space());
|
VerifyValidSlotsBufferEntries(heap(), heap()->code_space());
|
||||||
VerifyValidSlotsBufferEntries(heap, heap->map_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()) {
|
for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) {
|
||||||
MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
|
MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
|
||||||
SlotsBuffer::VerifySlots(heap, chunk->slots_buffer());
|
SlotsBuffer::VerifySlots(heap(), chunk->slots_buffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -349,7 +349,7 @@ void MarkCompactCollector::CollectGarbage() {
|
|||||||
|
|
||||||
#ifdef VERIFY_HEAP
|
#ifdef VERIFY_HEAP
|
||||||
if (FLAG_verify_heap) {
|
if (FLAG_verify_heap) {
|
||||||
VerifyValidStoreAndSlotsBufferEntries(heap_);
|
VerifyValidStoreAndSlotsBufferEntries();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -559,6 +559,7 @@ class MarkCompactCollector {
|
|||||||
enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL };
|
enum SweepingParallelism { SWEEP_ON_MAIN_THREAD, SWEEP_IN_PARALLEL };
|
||||||
|
|
||||||
#ifdef VERIFY_HEAP
|
#ifdef VERIFY_HEAP
|
||||||
|
void VerifyValidStoreAndSlotsBufferEntries();
|
||||||
void VerifyMarkbitsAreClean();
|
void VerifyMarkbitsAreClean();
|
||||||
static void VerifyMarkbitsAreClean(PagedSpace* space);
|
static void VerifyMarkbitsAreClean(PagedSpace* space);
|
||||||
static void VerifyMarkbitsAreClean(NewSpace* space);
|
static void VerifyMarkbitsAreClean(NewSpace* space);
|
||||||
|
@ -12,16 +12,11 @@
|
|||||||
namespace v8 {
|
namespace v8 {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
Address StoreBuffer::TopAddress() {
|
|
||||||
return reinterpret_cast<Address>(heap_->store_buffer_top_address());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StoreBuffer::Mark(Address addr) {
|
void StoreBuffer::Mark(Address addr) {
|
||||||
DCHECK(!heap_->code_space()->Contains(addr));
|
DCHECK(!heap_->code_space()->Contains(addr));
|
||||||
Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
|
Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
|
||||||
*top++ = addr;
|
*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) {
|
if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) {
|
||||||
DCHECK(top == limit_);
|
DCHECK(top == limit_);
|
||||||
Compact();
|
Compact();
|
||||||
|
@ -88,7 +88,7 @@ void StoreBuffer::SetUp() {
|
|||||||
false)) { // Not executable.
|
false)) { // Not executable.
|
||||||
V8::FatalProcessOutOfMemory("StoreBuffer::SetUp");
|
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_1_ = new uintptr_t[kHashSetLength];
|
||||||
hash_set_2_ = new uintptr_t[kHashSetLength];
|
hash_set_2_ = new uintptr_t[kHashSetLength];
|
||||||
@ -105,7 +105,7 @@ void StoreBuffer::TearDown() {
|
|||||||
delete[] hash_set_2_;
|
delete[] hash_set_2_;
|
||||||
old_start_ = old_top_ = old_limit_ = old_reserved_limit_ = NULL;
|
old_start_ = old_top_ = old_limit_ = old_reserved_limit_ = NULL;
|
||||||
start_ = 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
|
// 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).
|
// the worst case (compaction doesn't eliminate any pointers).
|
||||||
DCHECK(top <= limit_);
|
DCHECK(top <= limit_);
|
||||||
heap_->public_set_store_buffer_top(start_);
|
heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_));
|
||||||
EnsureSpace(top - start_);
|
EnsureSpace(top - start_);
|
||||||
DCHECK(may_move_store_buffer_entries_);
|
DCHECK(may_move_store_buffer_entries_);
|
||||||
// Goes through the addresses in the store buffer attempting to remove
|
// Goes through the addresses in the store buffer attempting to remove
|
||||||
|
@ -30,8 +30,6 @@ class StoreBuffer {
|
|||||||
|
|
||||||
static void StoreBufferOverflow(Isolate* isolate);
|
static void StoreBufferOverflow(Isolate* isolate);
|
||||||
|
|
||||||
inline Address TopAddress();
|
|
||||||
|
|
||||||
void SetUp();
|
void SetUp();
|
||||||
void TearDown();
|
void TearDown();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user