Enable the embedder to specify what kind of context was disposed

This API is used by Blink to inform V8 about HTML frames being disposed.
Using the optional parameter, Blink can tell V8 whether the disposed
frame was a main frame. In that case, we might want to reset GC
parameters

BUG=none
R=hpayer@chromium.org
LOG=y

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

Cr-Commit-Position: refs/heads/master@{#25926}
This commit is contained in:
jochen 2014-12-22 06:27:19 -08:00 committed by Commit bot
parent 88feffc2ab
commit 18b1e6d353
6 changed files with 11 additions and 7 deletions

View File

@ -5180,8 +5180,11 @@ class V8_EXPORT Isolate {
* these notifications to guide the GC heuristic. Returns the number
* of context disposals - including this one - since the last time
* V8 had a chance to clean up.
*
* The optional parameter |dependant_context| specifies whether the disposed
* context was depending on state from other contexts or not.
*/
int ContextDisposedNotification();
int ContextDisposedNotification(bool dependant_context = true);
/**
* Allows the host application to provide the address of a function that is

View File

@ -6742,9 +6742,9 @@ void Isolate::LowMemoryNotification() {
}
int Isolate::ContextDisposedNotification() {
int Isolate::ContextDisposedNotification(bool dependant_context) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
return isolate->heap()->NotifyContextDisposed();
return isolate->heap()->NotifyContextDisposed(dependant_context);
}

View File

@ -863,7 +863,8 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
}
int Heap::NotifyContextDisposed() {
int Heap::NotifyContextDisposed(bool dependant_context) {
// TODO(hpayer): Reset heap shrinking if dependant_context is false.
if (isolate()->concurrent_recompilation_enabled()) {
// Flush the queued recompilation tasks.
isolate()->optimizing_compiler_thread()->Flush();

View File

@ -767,7 +767,7 @@ class Heap {
bool IsHeapIterable();
// Notify the heap that a context has been disposed.
int NotifyContextDisposed();
int NotifyContextDisposed(bool dependant_context);
inline void increment_scan_on_scavenge_pages() {
scan_on_scavenge_pages_++;

View File

@ -170,7 +170,7 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) {
RUNTIME_FUNCTION(Runtime_NotifyContextDisposed) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
isolate->heap()->NotifyContextDisposed();
isolate->heap()->NotifyContextDisposed(true);
return isolate->heap()->undefined_value();
}

View File

@ -1579,7 +1579,7 @@ TEST(TestInternalWeakLists) {
}
// Force compilation cache cleanup.
CcTest::heap()->NotifyContextDisposed();
CcTest::heap()->NotifyContextDisposed(true);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
// Dispose the native contexts one by one.