Commit 18104fac authored by ulan's avatar ulan Committed by Commit bot

[heap] Add API function for checking if the heap limit was increased

for debugging. This function is needed to pass increased heap limit
from the main DevTools isolate to the worker isolates it spawns.

BUG=chromium:675911

Review-Url: https://codereview.chromium.org/2624973003
Cr-Commit-Position: refs/heads/master@{#42228}
parent fdff4b07
......@@ -7074,6 +7074,12 @@ class V8_EXPORT Isolate {
*/
void RestoreOriginalHeapLimit();
/**
* Returns true if the heap limit was increased for debugging and the
* original heap limit was not restored yet.
*/
bool IsHeapLimitIncreasedForDebugging();
/**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
......
......@@ -8496,6 +8496,11 @@ void Isolate::RestoreOriginalHeapLimit() {
isolate->heap()->RestoreOriginalHeapLimit();
}
bool Isolate::IsHeapLimitIncreasedForDebugging() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->heap()->IsHeapLimitIncreasedForDebugging();
}
void Isolate::SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......
......@@ -958,13 +958,16 @@ class Heap {
return memory_pressure_level_.Value() != MemoryPressureLevel::kNone;
}
void IncreaseHeapLimitForDebugging() {
size_t HeapLimitForDebugging() {
const size_t kDebugHeapSizeFactor = 4;
size_t max_limit = std::numeric_limits<size_t>::max() / 4;
return Min(max_limit,
initial_max_old_generation_size_ * kDebugHeapSizeFactor);
}
void IncreaseHeapLimitForDebugging() {
max_old_generation_size_ =
Max(max_old_generation_size_,
Min(max_limit,
initial_max_old_generation_size_ * kDebugHeapSizeFactor));
Max(max_old_generation_size_, HeapLimitForDebugging());
}
void RestoreOriginalHeapLimit() {
......@@ -975,6 +978,10 @@ class Heap {
Max(initial_max_old_generation_size_, min_limit));
}
bool IsHeapLimitIncreasedForDebugging() {
return max_old_generation_size_ == HeapLimitForDebugging();
}
// ===========================================================================
// Initialization. ===========================================================
// ===========================================================================
......
......@@ -26622,10 +26622,13 @@ UNINITIALIZED_TEST(IncreaseHeapLimitForDebugging) {
{
size_t limit_before = i_isolate->heap()->MaxOldGenerationSize();
CHECK_EQ(16 * MB, limit_before);
CHECK(!isolate->IsHeapLimitIncreasedForDebugging());
isolate->IncreaseHeapLimitForDebugging();
CHECK(isolate->IsHeapLimitIncreasedForDebugging());
size_t limit_after = i_isolate->heap()->MaxOldGenerationSize();
CHECK_EQ(4 * 16 * MB, limit_after);
isolate->RestoreOriginalHeapLimit();
CHECK(!isolate->IsHeapLimitIncreasedForDebugging());
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