Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: test/cctest/heap/utils-inl.h

Issue 1518803005: Reland of "[cctest] Add tests for aborting compaction of pages" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Sweep NEVER_ALLOCATE_ON_PAGE pages. Memory gets dropped in the free list again Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/heap/test-compaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/utils-inl.h
diff --git a/test/cctest/heap/utils-inl.h b/test/cctest/heap/utils-inl.h
index 8c2508fcb608b6ac1de2bb3d0094439f3544c56a..f255bb6c033e430a89ce1484129466859c7234f3 100644
--- a/test/cctest/heap/utils-inl.h
+++ b/test/cctest/heap/utils-inl.h
@@ -16,34 +16,32 @@ namespace v8 {
namespace internal {
static int LenFromSize(int size) {
- return (size - i::FixedArray::kHeaderSize) / i::kPointerSize;
+ return (size - FixedArray::kHeaderSize) / 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();
+static inline std::vector<Handle<FixedArray>> CreatePadding(
+ Heap* heap, int padding_size, PretenureFlag tenure,
+ int object_size = Page::kMaxRegularHeapObjectSize) {
+ std::vector<Handle<FixedArray>> handles;
+ 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);
+ heap->old_space()->EmptyAllocationInfo();
+ int overall_free_memory = static_cast<int>(heap->old_space()->Available());
+ CHECK(padding_size <= overall_free_memory || overall_free_memory == 0);
} else {
heap->new_space()->DisableInlineAllocationSteps();
- int current_free_memory =
+ int overall_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);
+ CHECK(padding_size <= overall_free_memory || overall_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;
+ while (free_memory > 0) {
+ if (free_memory > object_size) {
+ allocate_memory = object_size;
length = LenFromSize(allocate_memory);
} else {
allocate_memory = free_memory;
@@ -55,11 +53,12 @@ static inline void CreatePadding(i::Heap* heap, int padding_size,
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])));
+ handles.push_back(isolate->factory()->NewFixedArray(length, tenure));
+ CHECK((tenure == NOT_TENURED && heap->InNewSpace(*handles.back())) ||
+ (tenure == TENURED && heap->InOldSpace(*handles.back())));
free_memory -= allocate_memory;
}
+ return handles;
}
« no previous file with comments | « test/cctest/heap/test-compaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698