Commit eb582256 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Set progress bar flag for FixedArray upon allocation

R=hpayer@chromium.org
TEST=test-heap/Regress598319

Review-Url: https://codereview.chromium.org/2381493004
Cr-Commit-Position: refs/heads/master@{#39912}
parent 38c57c5d
...@@ -25,6 +25,16 @@ ...@@ -25,6 +25,16 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
AllocationSpace AllocationResult::RetrySpace() {
DCHECK(IsRetry());
return static_cast<AllocationSpace>(Smi::cast(object_)->value());
}
HeapObject* AllocationResult::ToObjectChecked() {
CHECK(!IsRetry());
return HeapObject::cast(object_);
}
void PromotionQueue::insert(HeapObject* target, int32_t size, void PromotionQueue::insert(HeapObject* target, int32_t size,
bool was_marked_black) { bool was_marked_black) {
if (emergency_stack_ != NULL) { if (emergency_stack_ != NULL) {
......
...@@ -3937,7 +3937,14 @@ AllocationResult Heap::AllocateRawFixedArray(int length, ...@@ -3937,7 +3937,14 @@ AllocationResult Heap::AllocateRawFixedArray(int length,
int size = FixedArray::SizeFor(length); int size = FixedArray::SizeFor(length);
AllocationSpace space = SelectSpace(pretenure); AllocationSpace space = SelectSpace(pretenure);
return AllocateRaw(size, space); AllocationResult result = AllocateRaw(size, space);
if (!result.IsRetry() && size > kMaxRegularHeapObjectSize &&
FLAG_use_marking_progress_bar) {
MemoryChunk* chunk =
MemoryChunk::FromAddress(result.ToObjectChecked()->address());
chunk->SetFlag(MemoryChunk::HAS_PROGRESS_BAR);
}
return result;
} }
......
...@@ -437,6 +437,10 @@ class PromotionQueue { ...@@ -437,6 +437,10 @@ class PromotionQueue {
class AllocationResult { class AllocationResult {
public: public:
static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
return AllocationResult(space);
}
// Implicit constructor from Object*. // Implicit constructor from Object*.
AllocationResult(Object* object) // NOLINT AllocationResult(Object* object) // NOLINT
: object_(object) { : object_(object) {
...@@ -447,11 +451,9 @@ class AllocationResult { ...@@ -447,11 +451,9 @@ class AllocationResult {
AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {} AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {}
static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
return AllocationResult(space);
}
inline bool IsRetry() { return object_->IsSmi(); } inline bool IsRetry() { return object_->IsSmi(); }
inline HeapObject* ToObjectChecked();
inline AllocationSpace RetrySpace();
template <typename T> template <typename T>
bool To(T** obj) { bool To(T** obj) {
...@@ -460,13 +462,6 @@ class AllocationResult { ...@@ -460,13 +462,6 @@ class AllocationResult {
return true; return true;
} }
Object* ToObjectChecked() {
CHECK(!IsRetry());
return object_;
}
inline AllocationSpace RetrySpace();
private: private:
explicit AllocationResult(AllocationSpace space) explicit AllocationResult(AllocationSpace space)
: object_(Smi::FromInt(static_cast<int>(space))) {} : object_(Smi::FromInt(static_cast<int>(space))) {}
......
...@@ -186,13 +186,9 @@ class IncrementalMarkingMarkingVisitor ...@@ -186,13 +186,9 @@ class IncrementalMarkingMarkingVisitor
static void VisitFixedArrayIncremental(Map* map, HeapObject* object) { static void VisitFixedArrayIncremental(Map* map, HeapObject* object) {
MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); MemoryChunk* chunk = MemoryChunk::FromAddress(object->address());
// TODO(mstarzinger): Move setting of the flag to the allocation site of
// the array. The visitor should just check the flag.
if (FLAG_use_marking_progress_bar &&
chunk->owner()->identity() == LO_SPACE) {
chunk->SetFlag(MemoryChunk::HAS_PROGRESS_BAR);
}
if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) {
DCHECK(!FLAG_use_marking_progress_bar ||
chunk->owner()->identity() == LO_SPACE);
Heap* heap = map->GetHeap(); Heap* heap = map->GetHeap();
// When using a progress bar for large fixed arrays, scan only a chunk of // When using a progress bar for large fixed arrays, scan only a chunk of
// the array and try to push it onto the marking deque again until it is // the array and try to push it onto the marking deque again until it is
......
...@@ -165,14 +165,6 @@ bool NewSpace::FromSpaceContainsSlow(Address a) { ...@@ -165,14 +165,6 @@ bool NewSpace::FromSpaceContainsSlow(Address a) {
bool NewSpace::ToSpaceContains(Object* o) { return to_space_.Contains(o); } bool NewSpace::ToSpaceContains(Object* o) { return to_space_.Contains(o); }
bool NewSpace::FromSpaceContains(Object* o) { return from_space_.Contains(o); } bool NewSpace::FromSpaceContains(Object* o) { return from_space_.Contains(o); }
// --------------------------------------------------------------------------
// AllocationResult
AllocationSpace AllocationResult::RetrySpace() {
DCHECK(IsRetry());
return static_cast<AllocationSpace>(Smi::cast(object_)->value());
}
Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable,
SemiSpace* owner) { SemiSpace* owner) {
DCHECK_EQ(executable, Executability::NOT_EXECUTABLE); DCHECK_EQ(executable, Executability::NOT_EXECUTABLE);
......
...@@ -498,7 +498,6 @@ class MemoryChunk { ...@@ -498,7 +498,6 @@ class MemoryChunk {
void ResetProgressBar() { void ResetProgressBar() {
if (IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) { if (IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) {
set_progress_bar(0); set_progress_bar(0);
ClearFlag(MemoryChunk::HAS_PROGRESS_BAR);
} }
} }
......
...@@ -414,7 +414,7 @@ Address Deserializer::Allocate(int space_index, int size) { ...@@ -414,7 +414,7 @@ Address Deserializer::Allocate(int space_index, int size) {
LargeObjectSpace* lo_space = isolate_->heap()->lo_space(); LargeObjectSpace* lo_space = isolate_->heap()->lo_space();
Executability exec = static_cast<Executability>(source_.Get()); Executability exec = static_cast<Executability>(source_.Get());
AllocationResult result = lo_space->AllocateRaw(size, exec); AllocationResult result = lo_space->AllocateRaw(size, exec);
HeapObject* obj = HeapObject::cast(result.ToObjectChecked()); HeapObject* obj = result.ToObjectChecked();
deserialized_large_objects_.Add(obj); deserialized_large_objects_.Add(obj);
return obj->address(); return obj->address();
} else if (space_index == MAP_SPACE) { } else if (space_index == MAP_SPACE) {
......
...@@ -2230,9 +2230,8 @@ TEST(TestAlignedOverAllocation) { ...@@ -2230,9 +2230,8 @@ TEST(TestAlignedOverAllocation) {
AllocationResult dummy = AllocationResult dummy =
heap->old_space()->AllocateRawUnaligned(kPointerSize); heap->old_space()->AllocateRawUnaligned(kPointerSize);
CHECK(!dummy.IsRetry()); CHECK(!dummy.IsRetry());
heap->CreateFillerObjectAt( heap->CreateFillerObjectAt(dummy.ToObjectChecked()->address(), kPointerSize,
HeapObject::cast(dummy.ToObjectChecked())->address(), kPointerSize, ClearRecordedSlots::kNo);
ClearRecordedSlots::kNo);
// Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones. // Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones.
const intptr_t double_misalignment = kDoubleSize - kPointerSize; const intptr_t double_misalignment = kDoubleSize - kPointerSize;
......
...@@ -19,8 +19,7 @@ namespace internal { ...@@ -19,8 +19,7 @@ namespace internal {
static Address AllocateLabBackingStore(Heap* heap, intptr_t size_in_bytes) { static Address AllocateLabBackingStore(Heap* heap, intptr_t size_in_bytes) {
AllocationResult result = heap->old_space()->AllocateRaw( AllocationResult result = heap->old_space()->AllocateRaw(
static_cast<int>(size_in_bytes), kDoubleAligned); static_cast<int>(size_in_bytes), kDoubleAligned);
Object* obj = result.ToObjectChecked(); Address adr = result.ToObjectChecked()->address();
Address adr = HeapObject::cast(obj)->address();
return adr; return adr;
} }
......
...@@ -368,9 +368,9 @@ TEST(NewSpace) { ...@@ -368,9 +368,9 @@ TEST(NewSpace) {
CHECK(new_space.HasBeenSetUp()); CHECK(new_space.HasBeenSetUp());
while (new_space.Available() >= kMaxRegularHeapObjectSize) { while (new_space.Available() >= kMaxRegularHeapObjectSize) {
Object* obj = new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize) CHECK(new_space.Contains(
.ToObjectChecked(); new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize)
CHECK(new_space.Contains(HeapObject::cast(obj))); .ToObjectChecked()));
} }
new_space.TearDown(); new_space.TearDown();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment