Commit d6c66dbc authored by ulan's avatar ulan Committed by Commit bot

[heap] New API for increasing the heap limit for debugging.

BUG=chromium:675911

Review-Url: https://codereview.chromium.org/2593043002
Cr-Commit-Position: refs/heads/master@{#41957}
parent 47e1cc46
......@@ -7043,6 +7043,17 @@ class V8_EXPORT Isolate {
*/
void SetRAILMode(RAILMode rail_mode);
/**
* Optional notification to tell V8 the current isolate is used for debugging
* and requires higher heap limit.
*/
void IncreaseHeapLimitForDebugging();
/**
* Restores the original heap limit after IncreaseHeapLimitForDebugging().
*/
void RestoreOriginalHeapLimit();
/**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
......
......@@ -8440,6 +8440,16 @@ void Isolate::SetRAILMode(RAILMode rail_mode) {
return isolate->SetRAILMode(rail_mode);
}
void Isolate::IncreaseHeapLimitForDebugging() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->heap()->IncreaseHeapLimitForDebugging();
}
void Isolate::RestoreOriginalHeapLimit() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->heap()->RestoreOriginalHeapLimit();
}
void Isolate::SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......@@ -8455,7 +8465,6 @@ void Isolate::SetStackLimit(uintptr_t stack_limit) {
isolate->stack_guard()->SetStackLimit(stack_limit);
}
void Isolate::GetCodeRange(void** start, size_t* length_in_bytes) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
if (isolate->heap()->memory_allocator()->code_range()->valid()) {
......
......@@ -81,6 +81,7 @@ Heap::Heap()
max_semi_space_size_(8 * (kPointerSize / 4) * MB),
initial_semispace_size_(MB),
max_old_generation_size_(700ul * (kPointerSize / 4) * MB),
initial_max_old_generation_size_(max_old_generation_size_),
initial_old_generation_size_(max_old_generation_size_ /
kInitalOldGenerationLimitFactor),
old_generation_size_configured_(false),
......@@ -5057,7 +5058,7 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size, size_t max_old_space_size,
// The old generation is paged and needs at least one page for each space.
int paged_space_count = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1;
max_old_generation_size_ =
initial_max_old_generation_size_ = max_old_generation_size_ =
Max(static_cast<size_t>(paged_space_count * Page::kPageSize),
max_old_generation_size_);
......
......@@ -950,6 +950,23 @@ class Heap {
return memory_pressure_level_.Value() != MemoryPressureLevel::kNone;
}
void IncreaseHeapLimitForDebugging() {
const size_t kDebugHeapSizeFactor = 4;
size_t max_limit = std::numeric_limits<size_t>::max() / 4;
max_old_generation_size_ =
Max(max_old_generation_size_,
Min(max_limit,
initial_max_old_generation_size_ * kDebugHeapSizeFactor));
}
void RestoreOriginalHeapLimit() {
// Do not set the limit lower than the live size + some slack.
size_t min_limit = SizeOfObjects() + SizeOfObjects() / 4;
max_old_generation_size_ =
Min(max_old_generation_size_,
Max(initial_max_old_generation_size_, min_limit));
}
// ===========================================================================
// Initialization. ===========================================================
// ===========================================================================
......@@ -2127,6 +2144,7 @@ class Heap {
size_t max_semi_space_size_;
size_t initial_semispace_size_;
size_t max_old_generation_size_;
size_t initial_max_old_generation_size_;
size_t initial_old_generation_size_;
bool old_generation_size_configured_;
size_t max_executable_size_;
......
......@@ -26592,3 +26592,22 @@ TEST(SetPrototypeTemplate) {
ExpectTrue("Image.prototype === HTMLImageElement.prototype");
}
UNINITIALIZED_TEST(IncreaseHeapLimitForDebugging) {
using namespace i;
v8::Isolate::CreateParams create_params;
create_params.constraints.set_max_old_space_size(16);
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
{
size_t limit_before = i_isolate->heap()->MaxOldGenerationSize();
CHECK_EQ(16 * MB, limit_before);
isolate->IncreaseHeapLimitForDebugging();
size_t limit_after = i_isolate->heap()->MaxOldGenerationSize();
CHECK_EQ(4 * 16 * MB, limit_after);
isolate->RestoreOriginalHeapLimit();
CHECK_EQ(limit_before, i_isolate->heap()->MaxOldGenerationSize());
}
isolate->Dispose();
}
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