Commit 8ad016d3 authored by mlippautz's avatar mlippautz Committed by Commit bot

[cctest] Move most heap related tests to test/cctest/heap and clean wrt IWYU

* Move most heap related tests into heap/ subdir
* IWYU for heap utility functions

R=ulan@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#32706}
parent c343f309
......@@ -94,11 +94,16 @@
'gay-fixed.cc',
'gay-precision.cc',
'gay-shortest.cc',
'heap-tester.h',
'heap/heap-tester.h',
'heap/test-alloc.cc',
'heap/test-heap.cc',
'heap/test-incremental-marking.cc',
'heap/test-mark-compact.cc',
'heap/test-spaces.cc',
'heap/utils-inl.h',
'print-extension.cc',
'profiler-extension.cc',
'test-accessors.cc',
'test-alloc.cc',
'test-api.cc',
'test-api.h',
# TODO(epertoso): re-enable the following test after the API change is
......@@ -138,18 +143,15 @@
'test-global-object.cc',
'test-hashing.cc',
'test-hashmap.cc',
'test-heap.cc',
'test-heap-profiler.cc',
'test-hydrogen-types.cc',
'test-identity-map.cc',
'test-incremental-marking.cc',
'test-inobject-slack-tracking.cc',
'test-list.cc',
'test-liveedit.cc',
'test-lockers.cc',
'test-log.cc',
'test-microtask-delivery.cc',
'test-mark-compact.cc',
'test-mementos.cc',
'test-object-observe.cc',
'test-parsing.cc',
......@@ -163,7 +165,6 @@
'test-serialize.cc',
'test-simd.cc',
'test-slots-buffer.cc',
'test-spaces.cc',
'test-strings.cc',
'test-symbols.cc',
'test-strtod.cc',
......
......@@ -557,124 +557,6 @@ static inline void CheckDoubleEquals(double expected, double actual) {
}
static int LenFromSize(int size) {
return (size - i::FixedArray::kHeaderSize) / i::kPointerSize;
}
static inline void CreatePadding(i::Heap* heap, int padding_size,
i::PretenureFlag tenure) {
const int max_number_of_objects = 20;
v8::internal::Handle<v8::internal::FixedArray>
big_objects[max_number_of_objects];
i::Isolate* isolate = heap->isolate();
int allocate_memory;
int length;
int free_memory = padding_size;
if (tenure == i::TENURED) {
int current_free_memory =
static_cast<int>(*heap->old_space()->allocation_limit_address() -
*heap->old_space()->allocation_top_address());
CHECK(padding_size <= current_free_memory || current_free_memory == 0);
} else {
heap->new_space()->DisableInlineAllocationSteps();
int current_free_memory =
static_cast<int>(*heap->new_space()->allocation_limit_address() -
*heap->new_space()->allocation_top_address());
CHECK(padding_size <= current_free_memory || current_free_memory == 0);
}
for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) {
if (free_memory > i::Page::kMaxRegularHeapObjectSize) {
allocate_memory = i::Page::kMaxRegularHeapObjectSize;
length = LenFromSize(allocate_memory);
} else {
allocate_memory = free_memory;
length = LenFromSize(allocate_memory);
if (length <= 0) {
// Not enough room to create another fixed array. Let's create a filler.
heap->CreateFillerObjectAt(*heap->old_space()->allocation_top_address(),
free_memory);
break;
}
}
big_objects[i] = isolate->factory()->NewFixedArray(length, tenure);
CHECK((tenure == i::NOT_TENURED && heap->InNewSpace(*big_objects[i])) ||
(tenure == i::TENURED && heap->InOldSpace(*big_objects[i])));
free_memory -= allocate_memory;
}
}
// Helper function that simulates a full new-space in the heap.
static inline bool FillUpOnePage(v8::internal::NewSpace* space) {
space->DisableInlineAllocationSteps();
int space_remaining = static_cast<int>(*space->allocation_limit_address() -
*space->allocation_top_address());
if (space_remaining == 0) return false;
CreatePadding(space->heap(), space_remaining, i::NOT_TENURED);
return true;
}
// Helper function that simulates a fill new-space in the heap.
static inline void AllocateAllButNBytes(v8::internal::NewSpace* space,
int extra_bytes) {
space->DisableInlineAllocationSteps();
int space_remaining = static_cast<int>(*space->allocation_limit_address() -
*space->allocation_top_address());
CHECK(space_remaining >= extra_bytes);
int new_linear_size = space_remaining - extra_bytes;
if (new_linear_size == 0) return;
CreatePadding(space->heap(), new_linear_size, i::NOT_TENURED);
}
static inline void FillCurrentPage(v8::internal::NewSpace* space) {
AllocateAllButNBytes(space, 0);
}
static inline void SimulateFullSpace(v8::internal::NewSpace* space) {
FillCurrentPage(space);
while (FillUpOnePage(space)) {
}
}
// Helper function that simulates a full old-space in the heap.
static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
space->EmptyAllocationInfo();
space->ResetFreeList();
space->ClearStats();
}
// Helper function that simulates many incremental marking steps until
// marking is completed.
static inline void SimulateIncrementalMarking(i::Heap* heap,
bool force_completion = true) {
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
if (!force_completion) return;
while (!marking->IsComplete()) {
marking->Step(i::MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD);
if (marking->IsReadyToOverApproximateWeakClosure()) {
marking->FinalizeIncrementally();
}
}
CHECK(marking->IsComplete());
}
static void DummyDebugEventListener(
const v8::Debug::EventDetails& event_details) {}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef HEAP_TESTER_H_
#define HEAP_TESTER_H_
#ifndef HEAP_HEAP_TESTER_H_
#define HEAP_HEAP_TESTER_H_
#include "src/handles.h"
#include "src/heap/spaces.h"
......@@ -79,4 +79,4 @@ class HeapTester {
} // namespace internal
} // namespace v8
#endif // HEAP_TESTER_H_
#endif // HEAP_HEAP_TESTER_H_
......@@ -30,8 +30,8 @@
#include "src/accessors.h"
#include "src/api.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
......
......@@ -40,7 +40,8 @@
#include "src/macro-assembler.h"
#include "src/snapshot/snapshot.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
#include "test/cctest/test-feedback-vector.h"
......
......@@ -19,6 +19,8 @@
#include "src/full-codegen/full-codegen.h"
#include "src/global-handles.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/utils-inl.h"
using v8::IdleTask;
using v8::Task;
......
......@@ -42,7 +42,9 @@
#include "src/full-codegen/full-codegen.h"
#include "src/global-handles.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
using v8::Just;
......
......@@ -31,7 +31,8 @@
#include "src/snapshot/snapshot.h"
#include "src/v8.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
namespace v8 {
namespace internal {
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef HEAP_UTILS_H_
#define HEAP_UTILS_H_
#include "src/factory.h"
#include "src/heap/heap-inl.h"
#include "src/heap/incremental-marking.h"
#include "src/heap/mark-compact.h"
#include "src/isolate.h"
namespace v8 {
namespace internal {
static int LenFromSize(int size) {
return (size - i::FixedArray::kHeaderSize) / i::kPointerSize;
}
static inline void CreatePadding(i::Heap* heap, int padding_size,
i::PretenureFlag tenure) {
const int max_number_of_objects = 20;
v8::internal::Handle<v8::internal::FixedArray>
big_objects[max_number_of_objects];
i::Isolate* isolate = heap->isolate();
int allocate_memory;
int length;
int free_memory = padding_size;
if (tenure == i::TENURED) {
int current_free_memory =
static_cast<int>(*heap->old_space()->allocation_limit_address() -
*heap->old_space()->allocation_top_address());
CHECK(padding_size <= current_free_memory || current_free_memory == 0);
} else {
heap->new_space()->DisableInlineAllocationSteps();
int current_free_memory =
static_cast<int>(*heap->new_space()->allocation_limit_address() -
*heap->new_space()->allocation_top_address());
CHECK(padding_size <= current_free_memory || current_free_memory == 0);
}
for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) {
if (free_memory > i::Page::kMaxRegularHeapObjectSize) {
allocate_memory = i::Page::kMaxRegularHeapObjectSize;
length = LenFromSize(allocate_memory);
} else {
allocate_memory = free_memory;
length = LenFromSize(allocate_memory);
if (length <= 0) {
// Not enough room to create another fixed array. Let's create a filler.
heap->CreateFillerObjectAt(*heap->old_space()->allocation_top_address(),
free_memory);
break;
}
}
big_objects[i] = isolate->factory()->NewFixedArray(length, tenure);
CHECK((tenure == i::NOT_TENURED && heap->InNewSpace(*big_objects[i])) ||
(tenure == i::TENURED && heap->InOldSpace(*big_objects[i])));
free_memory -= allocate_memory;
}
}
// Helper function that simulates a full new-space in the heap.
static inline bool FillUpOnePage(v8::internal::NewSpace* space) {
space->DisableInlineAllocationSteps();
int space_remaining = static_cast<int>(*space->allocation_limit_address() -
*space->allocation_top_address());
if (space_remaining == 0) return false;
CreatePadding(space->heap(), space_remaining, i::NOT_TENURED);
return true;
}
// Helper function that simulates a fill new-space in the heap.
static inline void AllocateAllButNBytes(v8::internal::NewSpace* space,
int extra_bytes) {
space->DisableInlineAllocationSteps();
int space_remaining = static_cast<int>(*space->allocation_limit_address() -
*space->allocation_top_address());
CHECK(space_remaining >= extra_bytes);
int new_linear_size = space_remaining - extra_bytes;
if (new_linear_size == 0) return;
CreatePadding(space->heap(), new_linear_size, i::NOT_TENURED);
}
static inline void FillCurrentPage(v8::internal::NewSpace* space) {
AllocateAllButNBytes(space, 0);
}
static inline void SimulateFullSpace(v8::internal::NewSpace* space) {
FillCurrentPage(space);
while (FillUpOnePage(space)) {
}
}
// Helper function that simulates a full old-space in the heap.
static inline void SimulateFullSpace(v8::internal::PagedSpace* space) {
space->EmptyAllocationInfo();
space->ResetFreeList();
space->ClearStats();
}
// Helper function that simulates many incremental marking steps until
// marking is completed.
static inline void SimulateIncrementalMarking(i::Heap* heap,
bool force_completion = true) {
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
if (!force_completion) return;
while (!marking->IsComplete()) {
marking->Step(i::MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD);
if (marking->IsReadyToOverApproximateWeakClosure()) {
marking->FinalizeIncrementally();
}
}
CHECK(marking->IsComplete());
}
} // namespace internal
} // namespace v8
#endif // HEAP_UTILS_H_
......@@ -53,7 +53,8 @@
#include "src/unicode-inl.h"
#include "src/utils.h"
#include "src/vm-state.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
static const bool kLogThreading = false;
......
......@@ -35,6 +35,7 @@
#include "src/global-handles.h"
#include "src/macro-assembler.h"
#include "src/objects.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
......
......@@ -43,6 +43,7 @@
#include "src/snapshot/serialize.h"
#include "src/snapshot/snapshot.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
......
......@@ -4,6 +4,7 @@
#include "src/heap/slots-buffer.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/utils-inl.h"
namespace v8 {
namespace internal {
......
......@@ -15,7 +15,7 @@
#include "src/ic/ic.h"
#include "src/macro-assembler.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap-tester.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::base;
using namespace v8::internal;
......
......@@ -31,6 +31,7 @@
#include "src/global-handles.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
......
......@@ -31,6 +31,7 @@
#include "src/global-handles.h"
#include "test/cctest/cctest.h"
#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
......
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