2016-05-20 13:30:22 +00:00
|
|
|
// Copyright 2016 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_HEAP_UTILS_H_
|
|
|
|
#define HEAP_HEAP_UTILS_H_
|
|
|
|
|
2019-01-29 19:12:21 +00:00
|
|
|
#include "src/api-inl.h"
|
2016-05-20 13:30:22 +00:00
|
|
|
#include "src/heap/heap.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace heap {
|
|
|
|
|
|
|
|
void SealCurrentObjects(Heap* heap);
|
|
|
|
|
|
|
|
int FixedArrayLenFromSize(int size);
|
|
|
|
|
2016-09-06 11:02:21 +00:00
|
|
|
// Fill a page with fixed arrays leaving remainder behind. The function does
|
|
|
|
// not create additional fillers and assumes that the space has just been
|
|
|
|
// sealed.
|
|
|
|
std::vector<Handle<FixedArray>> FillOldSpacePageWithFixedArrays(Heap* heap,
|
|
|
|
int remainder);
|
|
|
|
|
2016-05-20 13:30:22 +00:00
|
|
|
std::vector<Handle<FixedArray>> CreatePadding(
|
|
|
|
Heap* heap, int padding_size, PretenureFlag tenure,
|
2016-09-06 12:58:59 +00:00
|
|
|
int object_size = kMaxRegularHeapObjectSize);
|
2016-05-20 13:30:22 +00:00
|
|
|
|
|
|
|
void AllocateAllButNBytes(
|
|
|
|
v8::internal::NewSpace* space, int extra_bytes,
|
|
|
|
std::vector<Handle<FixedArray>>* out_handles = nullptr);
|
|
|
|
|
|
|
|
void FillCurrentPage(v8::internal::NewSpace* space,
|
|
|
|
std::vector<Handle<FixedArray>>* out_handles = nullptr);
|
|
|
|
|
|
|
|
// Helper function that simulates a full new-space in the heap.
|
|
|
|
bool FillUpOnePage(v8::internal::NewSpace* space,
|
|
|
|
std::vector<Handle<FixedArray>>* out_handles = nullptr);
|
|
|
|
|
|
|
|
void SimulateFullSpace(v8::internal::NewSpace* space,
|
|
|
|
std::vector<Handle<FixedArray>>* out_handles = nullptr);
|
|
|
|
|
|
|
|
// Helper function that simulates many incremental marking steps until
|
|
|
|
// marking is completed.
|
|
|
|
void SimulateIncrementalMarking(i::Heap* heap, bool force_completion = true);
|
|
|
|
|
|
|
|
// Helper function that simulates a full old-space in the heap.
|
|
|
|
void SimulateFullSpace(v8::internal::PagedSpace* space);
|
|
|
|
|
2016-06-07 17:28:31 +00:00
|
|
|
void AbandonCurrentlyFreeMemory(PagedSpace* space);
|
|
|
|
|
|
|
|
void GcAndSweep(Heap* heap, AllocationSpace space);
|
|
|
|
|
2016-11-03 12:12:38 +00:00
|
|
|
void ForceEvacuationCandidate(Page* page);
|
|
|
|
|
2019-01-29 19:12:21 +00:00
|
|
|
void InvokeScavenge();
|
|
|
|
|
|
|
|
void InvokeMarkSweep();
|
|
|
|
|
|
|
|
template <typename GlobalOrPersistent>
|
|
|
|
bool InNewSpace(v8::Isolate* isolate, const GlobalOrPersistent& global) {
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
auto tmp = global.Get(isolate);
|
|
|
|
return i::Heap::InNewSpace(*v8::Utils::OpenHandle(*tmp));
|
|
|
|
}
|
|
|
|
|
2016-05-20 13:30:22 +00:00
|
|
|
} // namespace heap
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // HEAP_HEAP_UTILS_H_
|