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

Side by Side Diff: src/d8.cc

Issue 297213006: Reland 21529 - "Add a flag to d8 to invoke weak callbacks" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.h ('k') | tools/run-tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 Context::Scope cscope(context); 1204 Context::Scope cscope(context);
1205 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); 1205 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
1206 Execute(isolate); 1206 Execute(isolate);
1207 } 1207 }
1208 } 1208 }
1209 if (Shell::options.send_idle_notification) { 1209 if (Shell::options.send_idle_notification) {
1210 const int kLongIdlePauseInMs = 1000; 1210 const int kLongIdlePauseInMs = 1000;
1211 V8::ContextDisposedNotification(); 1211 V8::ContextDisposedNotification();
1212 V8::IdleNotification(kLongIdlePauseInMs); 1212 V8::IdleNotification(kLongIdlePauseInMs);
1213 } 1213 }
1214 if (Shell::options.invoke_weak_callbacks) {
1215 // By sending a low memory notifications, we will try hard to collect
1216 // all garbage and will therefore also invoke all weak callbacks of
1217 // actually unreachable persistent handles.
1218 V8::LowMemoryNotification();
1219 }
1214 } 1220 }
1215 done_semaphore_.Signal(); 1221 done_semaphore_.Signal();
1216 } while (!Shell::options.last_run); 1222 } while (!Shell::options.last_run);
1223
1217 isolate->Dispose(); 1224 isolate->Dispose();
1218 } 1225 }
1219 1226
1220 1227
1221 void SourceGroup::StartExecuteInThread() { 1228 void SourceGroup::StartExecuteInThread() {
1222 if (thread_ == NULL) { 1229 if (thread_ == NULL) {
1223 thread_ = new IsolateThread(this); 1230 thread_ = new IsolateThread(this);
1224 thread_->Start(); 1231 thread_->Start();
1225 } 1232 }
1226 next_semaphore_.Signal(); 1233 next_semaphore_.Signal();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 argv[i] = NULL; 1274 argv[i] = NULL;
1268 } else if (strcmp(argv[i], "--shell") == 0) { 1275 } else if (strcmp(argv[i], "--shell") == 0) {
1269 options.interactive_shell = true; 1276 options.interactive_shell = true;
1270 argv[i] = NULL; 1277 argv[i] = NULL;
1271 } else if (strcmp(argv[i], "--test") == 0) { 1278 } else if (strcmp(argv[i], "--test") == 0) {
1272 options.test_shell = true; 1279 options.test_shell = true;
1273 argv[i] = NULL; 1280 argv[i] = NULL;
1274 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { 1281 } else if (strcmp(argv[i], "--send-idle-notification") == 0) {
1275 options.send_idle_notification = true; 1282 options.send_idle_notification = true;
1276 argv[i] = NULL; 1283 argv[i] = NULL;
1284 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) {
1285 options.invoke_weak_callbacks = true;
1286 // TODO(jochen) See issue 3351
1287 options.send_idle_notification = true;
1288 argv[i] = NULL;
1277 } else if (strcmp(argv[i], "-f") == 0) { 1289 } else if (strcmp(argv[i], "-f") == 0) {
1278 // Ignore any -f flags for compatibility with other stand-alone 1290 // Ignore any -f flags for compatibility with other stand-alone
1279 // JavaScript engines. 1291 // JavaScript engines.
1280 continue; 1292 continue;
1281 } else if (strcmp(argv[i], "--isolate") == 0) { 1293 } else if (strcmp(argv[i], "--isolate") == 0) {
1282 #ifdef V8_SHARED 1294 #ifdef V8_SHARED
1283 printf("D8 with shared library does not support multi-threading\n"); 1295 printf("D8 with shared library does not support multi-threading\n");
1284 return false; 1296 return false;
1285 #endif // V8_SHARED 1297 #endif // V8_SHARED
1286 options.num_isolates++; 1298 options.num_isolates++;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 Context::Scope cscope(context); 1372 Context::Scope cscope(context);
1361 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); 1373 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
1362 options.isolate_sources[0].Execute(isolate); 1374 options.isolate_sources[0].Execute(isolate);
1363 } 1375 }
1364 } 1376 }
1365 if (options.send_idle_notification) { 1377 if (options.send_idle_notification) {
1366 const int kLongIdlePauseInMs = 1000; 1378 const int kLongIdlePauseInMs = 1000;
1367 V8::ContextDisposedNotification(); 1379 V8::ContextDisposedNotification();
1368 V8::IdleNotification(kLongIdlePauseInMs); 1380 V8::IdleNotification(kLongIdlePauseInMs);
1369 } 1381 }
1382 if (options.invoke_weak_callbacks) {
1383 // By sending a low memory notifications, we will try hard to collect all
1384 // garbage and will therefore also invoke all weak callbacks of actually
1385 // unreachable persistent handles.
1386 V8::LowMemoryNotification();
1387 }
1370 1388
1371 #ifndef V8_SHARED 1389 #ifndef V8_SHARED
1372 for (int i = 1; i < options.num_isolates; ++i) { 1390 for (int i = 1; i < options.num_isolates; ++i) {
1373 options.isolate_sources[i].WaitForThread(); 1391 options.isolate_sources[i].WaitForThread();
1374 } 1392 }
1375 #endif // !V8_SHARED 1393 #endif // !V8_SHARED
1376 return 0; 1394 return 0;
1377 } 1395 }
1378 1396
1379 1397
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } 1560 }
1543 1561
1544 } // namespace v8 1562 } // namespace v8
1545 1563
1546 1564
1547 #ifndef GOOGLE3 1565 #ifndef GOOGLE3
1548 int main(int argc, char* argv[]) { 1566 int main(int argc, char* argv[]) {
1549 return v8::Shell::Main(argc, argv); 1567 return v8::Shell::Main(argc, argv);
1550 } 1568 }
1551 #endif 1569 #endif
OLDNEW
« 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