Commit 527a9401 authored by ulan's avatar ulan Committed by Commit bot

Introduce new API for detecting when the embedder is in foreground/background.

This will allow us to remove background idle notification calls in Chrome.

BUG=chromium:490559
LOG=NO

Review URL: https://codereview.chromium.org/1406303008

Cr-Commit-Position: refs/heads/master@{#31464}
parent ac3919d9
......@@ -5806,6 +5806,18 @@ class V8_EXPORT Isolate {
*/
int ContextDisposedNotification(bool dependant_context = true);
/**
* Optional notification that the isolate switched to the foreground.
* V8 uses these notifications to guide heuristics.
*/
void IsolateInForegroundNotification();
/**
* Optional notification that the isolate switched to the background.
* V8 uses these notifications to guide heuristics.
*/
void IsolateInBackgroundNotification();
/**
* Allows the host application to provide the address of a function that is
* notified each time code is added, moved or removed.
......
......@@ -7379,6 +7379,18 @@ int Isolate::ContextDisposedNotification(bool dependant_context) {
}
void Isolate::IsolateInForegroundNotification() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->heap()->SetOptimizeForLatency();
}
void Isolate::IsolateInBackgroundNotification() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->heap()->SetOptimizeForMemoryUsage();
}
void Isolate::SetJitCodeEventHandler(JitCodeEventOptions options,
JitCodeEventHandler event_handler) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......
......@@ -1029,6 +1029,8 @@ class Heap {
bool HasHighFragmentation();
bool HasHighFragmentation(intptr_t used, intptr_t committed);
void SetOptimizeForLatency() { optimize_for_memory_usage_ = false; }
void SetOptimizeForMemoryUsage() { optimize_for_memory_usage_ = true; }
bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; }
// ===========================================================================
......
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