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 @@
namespace v8 {
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,
bool was_marked_black) {
if (emergency_stack_ != NULL) {
......
......@@ -3937,7 +3937,14 @@ AllocationResult Heap::AllocateRawFixedArray(int length,
int size = FixedArray::SizeFor(length);
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 {
class AllocationResult {
public:
static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
return AllocationResult(space);
}
// Implicit constructor from Object*.
AllocationResult(Object* object) // NOLINT
: object_(object) {
......@@ -447,11 +451,9 @@ class AllocationResult {
AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {}
static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
return AllocationResult(space);
}
inline bool IsRetry() { return object_->IsSmi(); }
inline HeapObject* ToObjectChecked();
inline AllocationSpace RetrySpace();
template <typename T>
bool To(T** obj) {
......@@ -460,13 +462,6 @@ class AllocationResult {
return true;
}
Object* ToObjectChecked() {
CHECK(!IsRetry());
return object_;
}
inline AllocationSpace RetrySpace();
private:
explicit AllocationResult(AllocationSpace space)
: object_(Smi::FromInt(static_cast<int>(space))) {}
......
......@@ -186,13 +186,9 @@ class IncrementalMarkingMarkingVisitor
static void VisitFixedArrayIncremental(Map* map, HeapObject* object) {
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)) {
DCHECK(!FLAG_use_marking_progress_bar ||
chunk->owner()->identity() == LO_SPACE);
Heap* heap = map->GetHeap();
// 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
......
......@@ -165,14 +165,6 @@ bool NewSpace::FromSpaceContainsSlow(Address a) {
bool NewSpace::ToSpaceContains(Object* o) { return to_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,
SemiSpace* owner) {
DCHECK_EQ(executable, Executability::NOT_EXECUTABLE);
......
......@@ -498,7 +498,6 @@ class MemoryChunk {
void ResetProgressBar() {
if (IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) {
set_progress_bar(0);
ClearFlag(MemoryChunk::HAS_PROGRESS_BAR);
}
}
......
......@@ -414,7 +414,7 @@ Address Deserializer::Allocate(int space_index, int size) {
LargeObjectSpace* lo_space = isolate_->heap()->lo_space();
Executability exec = static_cast<Executability>(source_.Get());
AllocationResult result = lo_space->AllocateRaw(size, exec);
HeapObject* obj = HeapObject::cast(result.ToObjectChecked());
HeapObject* obj = result.ToObjectChecked();
deserialized_large_objects_.Add(obj);
return obj->address();
} else if (space_index == MAP_SPACE) {
......
......@@ -2230,8 +2230,7 @@ TEST(TestAlignedOverAllocation) {
AllocationResult dummy =
heap->old_space()->AllocateRawUnaligned(kPointerSize);
CHECK(!dummy.IsRetry());
heap->CreateFillerObjectAt(
HeapObject::cast(dummy.ToObjectChecked())->address(), kPointerSize,
heap->CreateFillerObjectAt(dummy.ToObjectChecked()->address(), kPointerSize,
ClearRecordedSlots::kNo);
// Double misalignment is 4 on 32-bit platforms, 0 on 64-bit ones.
......
......@@ -19,8 +19,7 @@ namespace internal {
static Address AllocateLabBackingStore(Heap* heap, intptr_t size_in_bytes) {
AllocationResult result = heap->old_space()->AllocateRaw(
static_cast<int>(size_in_bytes), kDoubleAligned);
Object* obj = result.ToObjectChecked();
Address adr = HeapObject::cast(obj)->address();
Address adr = result.ToObjectChecked()->address();
return adr;
}
......
......@@ -368,9 +368,9 @@ TEST(NewSpace) {
CHECK(new_space.HasBeenSetUp());
while (new_space.Available() >= kMaxRegularHeapObjectSize) {
Object* obj = new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize)
.ToObjectChecked();
CHECK(new_space.Contains(HeapObject::cast(obj)));
CHECK(new_space.Contains(
new_space.AllocateRawUnaligned(kMaxRegularHeapObjectSize)
.ToObjectChecked()));
}
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