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

Side by Side Diff: test/cctest/heap/heap-utils.cc

Issue 2035413003: Revert of Provide a tagged allocation top pointer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months 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 | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "test/cctest/heap/heap-utils.h" 5 #include "test/cctest/heap/heap-utils.h"
6 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/heap/incremental-marking.h" 9 #include "src/heap/incremental-marking.h"
10 #include "src/heap/mark-compact.h" 10 #include "src/heap/mark-compact.h"
(...skipping 27 matching lines...) Expand all
38 int allocate_memory; 38 int allocate_memory;
39 int length; 39 int length;
40 int free_memory = padding_size; 40 int free_memory = padding_size;
41 if (tenure == i::TENURED) { 41 if (tenure == i::TENURED) {
42 heap->old_space()->EmptyAllocationInfo(); 42 heap->old_space()->EmptyAllocationInfo();
43 int overall_free_memory = static_cast<int>(heap->old_space()->Available()); 43 int overall_free_memory = static_cast<int>(heap->old_space()->Available());
44 CHECK(padding_size <= overall_free_memory || overall_free_memory == 0); 44 CHECK(padding_size <= overall_free_memory || overall_free_memory == 0);
45 } else { 45 } else {
46 heap->new_space()->DisableInlineAllocationSteps(); 46 heap->new_space()->DisableInlineAllocationSteps();
47 int overall_free_memory = 47 int overall_free_memory =
48 static_cast<int>(heap->new_space()->limit() - heap->new_space()->top()); 48 static_cast<int>(*heap->new_space()->allocation_limit_address() -
49 *heap->new_space()->allocation_top_address());
49 CHECK(padding_size <= overall_free_memory || overall_free_memory == 0); 50 CHECK(padding_size <= overall_free_memory || overall_free_memory == 0);
50 } 51 }
51 while (free_memory > 0) { 52 while (free_memory > 0) {
52 if (free_memory > object_size) { 53 if (free_memory > object_size) {
53 allocate_memory = object_size; 54 allocate_memory = object_size;
54 length = FixedArrayLenFromSize(allocate_memory); 55 length = FixedArrayLenFromSize(allocate_memory);
55 } else { 56 } else {
56 allocate_memory = free_memory; 57 allocate_memory = free_memory;
57 length = FixedArrayLenFromSize(allocate_memory); 58 length = FixedArrayLenFromSize(allocate_memory);
58 if (length <= 0) { 59 if (length <= 0) {
59 // Not enough room to create another fixed array. Let's create a filler. 60 // Not enough room to create another fixed array. Let's create a filler.
60 if (free_memory > (2 * kPointerSize)) { 61 if (free_memory > (2 * kPointerSize)) {
61 if (tenure == i::TENURED) { 62 heap->CreateFillerObjectAt(
62 heap->CreateFillerObjectAt(heap->old_space()->top(), free_memory, 63 *heap->old_space()->allocation_top_address(), free_memory,
63 ClearRecordedSlots::kNo); 64 ClearRecordedSlots::kNo);
64 } else {
65 heap->CreateFillerObjectAt(heap->new_space()->top(), free_memory,
66 ClearRecordedSlots::kNo);
67 }
68 } 65 }
69 break; 66 break;
70 } 67 }
71 } 68 }
72 handles.push_back(isolate->factory()->NewFixedArray(length, tenure)); 69 handles.push_back(isolate->factory()->NewFixedArray(length, tenure));
73 CHECK((tenure == NOT_TENURED && heap->InNewSpace(*handles.back())) || 70 CHECK((tenure == NOT_TENURED && heap->InNewSpace(*handles.back())) ||
74 (tenure == TENURED && heap->InOldSpace(*handles.back()))); 71 (tenure == TENURED && heap->InOldSpace(*handles.back())));
75 free_memory -= allocate_memory; 72 free_memory -= allocate_memory;
76 } 73 }
77 return handles; 74 return handles;
78 } 75 }
79 76
80 void AllocateAllButNBytes(v8::internal::NewSpace* space, int extra_bytes, 77 void AllocateAllButNBytes(v8::internal::NewSpace* space, int extra_bytes,
81 std::vector<Handle<FixedArray>>* out_handles) { 78 std::vector<Handle<FixedArray>>* out_handles) {
82 space->DisableInlineAllocationSteps(); 79 space->DisableInlineAllocationSteps();
83 int space_remaining = static_cast<int>(space->limit() - space->top()); 80 int space_remaining = static_cast<int>(*space->allocation_limit_address() -
81 *space->allocation_top_address());
84 CHECK(space_remaining >= extra_bytes); 82 CHECK(space_remaining >= extra_bytes);
85 int new_linear_size = space_remaining - extra_bytes; 83 int new_linear_size = space_remaining - extra_bytes;
86 if (new_linear_size == 0) return; 84 if (new_linear_size == 0) return;
87 std::vector<Handle<FixedArray>> handles = 85 std::vector<Handle<FixedArray>> handles =
88 heap::CreatePadding(space->heap(), new_linear_size, i::NOT_TENURED); 86 heap::CreatePadding(space->heap(), new_linear_size, i::NOT_TENURED);
89 if (out_handles != nullptr) 87 if (out_handles != nullptr)
90 out_handles->insert(out_handles->end(), handles.begin(), handles.end()); 88 out_handles->insert(out_handles->end(), handles.begin(), handles.end());
91 } 89 }
92 90
93 void FillCurrentPage(v8::internal::NewSpace* space, 91 void FillCurrentPage(v8::internal::NewSpace* space,
94 std::vector<Handle<FixedArray>>* out_handles) { 92 std::vector<Handle<FixedArray>>* out_handles) {
95 heap::AllocateAllButNBytes(space, 0, out_handles); 93 heap::AllocateAllButNBytes(space, 0, out_handles);
96 } 94 }
97 95
98 bool FillUpOnePage(v8::internal::NewSpace* space, 96 bool FillUpOnePage(v8::internal::NewSpace* space,
99 std::vector<Handle<FixedArray>>* out_handles) { 97 std::vector<Handle<FixedArray>>* out_handles) {
100 space->DisableInlineAllocationSteps(); 98 space->DisableInlineAllocationSteps();
101 int space_remaining = static_cast<int>(space->limit() - space->top()); 99 int space_remaining = static_cast<int>(*space->allocation_limit_address() -
100 *space->allocation_top_address());
102 if (space_remaining == 0) return false; 101 if (space_remaining == 0) return false;
103 std::vector<Handle<FixedArray>> handles = 102 std::vector<Handle<FixedArray>> handles =
104 heap::CreatePadding(space->heap(), space_remaining, i::NOT_TENURED); 103 heap::CreatePadding(space->heap(), space_remaining, i::NOT_TENURED);
105 if (out_handles != nullptr) 104 if (out_handles != nullptr)
106 out_handles->insert(out_handles->end(), handles.begin(), handles.end()); 105 out_handles->insert(out_handles->end(), handles.begin(), handles.end());
107 return true; 106 return true;
108 } 107 }
109 108
110 void SimulateFullSpace(v8::internal::NewSpace* space, 109 void SimulateFullSpace(v8::internal::NewSpace* space,
111 std::vector<Handle<FixedArray>>* out_handles) { 110 std::vector<Handle<FixedArray>>* out_handles) {
(...skipping 26 matching lines...) Expand all
138 137
139 void SimulateFullSpace(v8::internal::PagedSpace* space) { 138 void SimulateFullSpace(v8::internal::PagedSpace* space) {
140 space->EmptyAllocationInfo(); 139 space->EmptyAllocationInfo();
141 space->ResetFreeList(); 140 space->ResetFreeList();
142 space->ClearStats(); 141 space->ClearStats();
143 } 142 }
144 143
145 } // namespace heap 144 } // namespace heap
146 } // namespace internal 145 } // namespace internal
147 } // namespace v8 146 } // namespace v8
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698