Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: src/d8.cc

Issue 306483006: Add a flag to d8 to invoke weak callbacks (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.h ('k') | tools/run-tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 73bde94aad291cfbe6f20786073841c93d388071..b1d996a3f06360005e655671e6ee178dd9696a72 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1190,6 +1190,21 @@ i::Thread::Options SourceGroup::GetThreadOptions() {
}
+void SuggestivelyAskForAggressiveGC() {
+ if (Shell::options.send_idle_notification) {
+ const int kLongIdlePauseInMs = 1000;
+ V8::ContextDisposedNotification();
+ V8::IdleNotification(kLongIdlePauseInMs);
+ }
+ if (Shell::options.invoke_weak_callbacks) {
+ // By sending a low memory notifications, we will try hard to collect
+ // all garbage and will therefore also invoke all weak callbacks of
+ // actually unreachable persistent handles.
+ V8::LowMemoryNotification();
+ }
+}
+
+
void SourceGroup::ExecuteInThread() {
Isolate* isolate = Isolate::New();
do {
@@ -1206,14 +1221,11 @@ void SourceGroup::ExecuteInThread() {
Execute(isolate);
}
}
- if (Shell::options.send_idle_notification) {
- const int kLongIdlePauseInMs = 1000;
- V8::ContextDisposedNotification();
- V8::IdleNotification(kLongIdlePauseInMs);
- }
+ SuggestivelyAskForAggressiveGC();
}
done_semaphore_.Signal();
} while (!Shell::options.last_run);
+
isolate->Dispose();
}
@@ -1274,6 +1286,11 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--send-idle-notification") == 0) {
options.send_idle_notification = true;
argv[i] = NULL;
+ } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) {
+ options.invoke_weak_callbacks = true;
+ // TODO(jochen) See issue 3351
+ options.send_idle_notification = true;
+ argv[i] = NULL;
} else if (strcmp(argv[i], "-f") == 0) {
// Ignore any -f flags for compatibility with other stand-alone
// JavaScript engines.
@@ -1362,11 +1379,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
options.isolate_sources[0].Execute(isolate);
}
}
- if (options.send_idle_notification) {
- const int kLongIdlePauseInMs = 1000;
- V8::ContextDisposedNotification();
- V8::IdleNotification(kLongIdlePauseInMs);
- }
+ SuggestivelyAskForAggressiveGC();
#ifndef V8_SHARED
for (int i = 1; i < options.num_isolates; ++i) {
« no previous file with comments | « src/d8.h ('k') | tools/run-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698