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

Side by Side Diff: test/cctest/heap/utils-inl.h

Issue 1514603008: Revert of [cctest] Add tests for aborting compaction of pages (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « test/cctest/heap/test-compaction.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef HEAP_UTILS_H_ 5 #ifndef HEAP_UTILS_H_
6 #define HEAP_UTILS_H_ 6 #define HEAP_UTILS_H_
7 7
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/heap/heap-inl.h" 9 #include "src/heap/heap-inl.h"
10 #include "src/heap/incremental-marking.h" 10 #include "src/heap/incremental-marking.h"
11 #include "src/heap/mark-compact.h" 11 #include "src/heap/mark-compact.h"
12 #include "src/isolate.h" 12 #include "src/isolate.h"
13 13
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 static int LenFromSize(int size) { 18 static int LenFromSize(int size) {
19 return (size - FixedArray::kHeaderSize) / kPointerSize; 19 return (size - i::FixedArray::kHeaderSize) / i::kPointerSize;
20 } 20 }
21 21
22 22
23 static inline std::vector<Handle<FixedArray>> CreatePadding( 23 static inline void CreatePadding(i::Heap* heap, int padding_size,
24 Heap* heap, int padding_size, PretenureFlag tenure, 24 i::PretenureFlag tenure) {
25 int object_size = Page::kMaxRegularHeapObjectSize) { 25 const int max_number_of_objects = 20;
26 std::vector<Handle<FixedArray>> handles; 26 v8::internal::Handle<v8::internal::FixedArray>
27 Isolate* isolate = heap->isolate(); 27 big_objects[max_number_of_objects];
28 i::Isolate* isolate = heap->isolate();
28 int allocate_memory; 29 int allocate_memory;
29 int length; 30 int length;
30 int free_memory = padding_size; 31 int free_memory = padding_size;
31 if (tenure == i::TENURED) { 32 if (tenure == i::TENURED) {
32 int current_free_memory = 33 int current_free_memory =
33 static_cast<int>(*heap->old_space()->allocation_limit_address() - 34 static_cast<int>(*heap->old_space()->allocation_limit_address() -
34 *heap->old_space()->allocation_top_address()); 35 *heap->old_space()->allocation_top_address());
35 CHECK(padding_size <= current_free_memory || current_free_memory == 0); 36 CHECK(padding_size <= current_free_memory || current_free_memory == 0);
36 } else { 37 } else {
37 heap->new_space()->DisableInlineAllocationSteps(); 38 heap->new_space()->DisableInlineAllocationSteps();
38 int current_free_memory = 39 int current_free_memory =
39 static_cast<int>(*heap->new_space()->allocation_limit_address() - 40 static_cast<int>(*heap->new_space()->allocation_limit_address() -
40 *heap->new_space()->allocation_top_address()); 41 *heap->new_space()->allocation_top_address());
41 CHECK(padding_size <= current_free_memory || current_free_memory == 0); 42 CHECK(padding_size <= current_free_memory || current_free_memory == 0);
42 } 43 }
43 while (free_memory > 0) { 44 for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) {
44 // for (int i = 0; i < max_number_of_objects && free_memory > 0; i++) { 45 if (free_memory > i::Page::kMaxRegularHeapObjectSize) {
45 if (free_memory > object_size) { 46 allocate_memory = i::Page::kMaxRegularHeapObjectSize;
46 allocate_memory = object_size;
47 length = LenFromSize(allocate_memory); 47 length = LenFromSize(allocate_memory);
48 } else { 48 } else {
49 allocate_memory = free_memory; 49 allocate_memory = free_memory;
50 length = LenFromSize(allocate_memory); 50 length = LenFromSize(allocate_memory);
51 if (length <= 0) { 51 if (length <= 0) {
52 // Not enough room to create another fixed array. Let's create a filler. 52 // Not enough room to create another fixed array. Let's create a filler.
53 heap->CreateFillerObjectAt(*heap->old_space()->allocation_top_address(), 53 heap->CreateFillerObjectAt(*heap->old_space()->allocation_top_address(),
54 free_memory); 54 free_memory);
55 break; 55 break;
56 } 56 }
57 } 57 }
58 handles.push_back(isolate->factory()->NewFixedArray(length, tenure)); 58 big_objects[i] = isolate->factory()->NewFixedArray(length, tenure);
59 CHECK((tenure == NOT_TENURED && heap->InNewSpace(*handles.back())) || 59 CHECK((tenure == i::NOT_TENURED && heap->InNewSpace(*big_objects[i])) ||
60 (tenure == TENURED && heap->InOldSpace(*handles.back()))); 60 (tenure == i::TENURED && heap->InOldSpace(*big_objects[i])));
61 free_memory -= allocate_memory; 61 free_memory -= allocate_memory;
62 } 62 }
63 return handles;
64 } 63 }
65 64
66 65
67 // Helper function that simulates a full new-space in the heap. 66 // Helper function that simulates a full new-space in the heap.
68 static inline bool FillUpOnePage(v8::internal::NewSpace* space) { 67 static inline bool FillUpOnePage(v8::internal::NewSpace* space) {
69 space->DisableInlineAllocationSteps(); 68 space->DisableInlineAllocationSteps();
70 int space_remaining = static_cast<int>(*space->allocation_limit_address() - 69 int space_remaining = static_cast<int>(*space->allocation_limit_address() -
71 *space->allocation_top_address()); 70 *space->allocation_top_address());
72 if (space_remaining == 0) return false; 71 if (space_remaining == 0) return false;
73 CreatePadding(space->heap(), space_remaining, i::NOT_TENURED); 72 CreatePadding(space->heap(), space_remaining, i::NOT_TENURED);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 marking->FinalizeIncrementally(); 129 marking->FinalizeIncrementally();
131 } 130 }
132 } 131 }
133 CHECK(marking->IsComplete()); 132 CHECK(marking->IsComplete());
134 } 133 }
135 134
136 } // namespace internal 135 } // namespace internal
137 } // namespace v8 136 } // namespace v8
138 137
139 #endif // HEAP_UTILS_H_ 138 #endif // HEAP_UTILS_H_
OLDNEW
« 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