OLD | NEW |
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 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 { | 1332 { |
1333 HandleScope scope(isolate); | 1333 HandleScope scope(isolate); |
1334 PerIsolateData data(isolate); | 1334 PerIsolateData data(isolate); |
1335 Local<Context> context = Shell::CreateEvaluationContext(isolate); | 1335 Local<Context> context = Shell::CreateEvaluationContext(isolate); |
1336 { | 1336 { |
1337 Context::Scope cscope(context); | 1337 Context::Scope cscope(context); |
1338 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1338 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1339 Execute(isolate); | 1339 Execute(isolate); |
1340 } | 1340 } |
1341 } | 1341 } |
1342 if (Shell::options.send_idle_notification) { | 1342 Shell::CollectGarbage(isolate); |
1343 const double kLongIdlePauseInSeconds = 1.0; | |
1344 isolate->ContextDisposedNotification(); | |
1345 isolate->IdleNotificationDeadline( | |
1346 g_platform->MonotonicallyIncreasingTime() + | |
1347 kLongIdlePauseInSeconds); | |
1348 } | |
1349 if (Shell::options.invoke_weak_callbacks) { | |
1350 // By sending a low memory notifications, we will try hard to collect | |
1351 // all garbage and will therefore also invoke all weak callbacks of | |
1352 // actually unreachable persistent handles. | |
1353 isolate->LowMemoryNotification(); | |
1354 } | |
1355 } | 1343 } |
1356 done_semaphore_.Signal(); | 1344 done_semaphore_.Signal(); |
1357 } while (!Shell::options.last_run); | 1345 } while (!Shell::options.last_run); |
1358 | 1346 |
1359 isolate->Dispose(); | 1347 isolate->Dispose(); |
1360 } | 1348 } |
1361 | 1349 |
1362 | 1350 |
1363 void SourceGroup::StartExecuteInThread() { | 1351 void SourceGroup::StartExecuteInThread() { |
1364 if (thread_ == NULL) { | 1352 if (thread_ == NULL) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 options.stress_deopt = false; | 1394 options.stress_deopt = false; |
1407 } else if (strcmp(argv[i], "--logfile-per-isolate") == 0) { | 1395 } else if (strcmp(argv[i], "--logfile-per-isolate") == 0) { |
1408 logfile_per_isolate = true; | 1396 logfile_per_isolate = true; |
1409 argv[i] = NULL; | 1397 argv[i] = NULL; |
1410 } else if (strcmp(argv[i], "--shell") == 0) { | 1398 } else if (strcmp(argv[i], "--shell") == 0) { |
1411 options.interactive_shell = true; | 1399 options.interactive_shell = true; |
1412 argv[i] = NULL; | 1400 argv[i] = NULL; |
1413 } else if (strcmp(argv[i], "--test") == 0) { | 1401 } else if (strcmp(argv[i], "--test") == 0) { |
1414 options.test_shell = true; | 1402 options.test_shell = true; |
1415 argv[i] = NULL; | 1403 argv[i] = NULL; |
| 1404 } else if (strcmp(argv[i], "--notest") == 0 || |
| 1405 strcmp(argv[i], "--no-test") == 0) { |
| 1406 options.test_shell = false; |
| 1407 argv[i] = NULL; |
1416 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { | 1408 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { |
1417 options.send_idle_notification = true; | 1409 options.send_idle_notification = true; |
1418 argv[i] = NULL; | 1410 argv[i] = NULL; |
1419 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) { | 1411 } else if (strcmp(argv[i], "--invoke-weak-callbacks") == 0) { |
1420 options.invoke_weak_callbacks = true; | 1412 options.invoke_weak_callbacks = true; |
1421 // TODO(jochen) See issue 3351 | 1413 // TODO(jochen) See issue 3351 |
1422 options.send_idle_notification = true; | 1414 options.send_idle_notification = true; |
1423 argv[i] = NULL; | 1415 argv[i] = NULL; |
1424 } else if (strcmp(argv[i], "--omit-quit") == 0) { | 1416 } else if (strcmp(argv[i], "--omit-quit") == 0) { |
1425 options.omit_quit = true; | 1417 options.omit_quit = true; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 InstallUtilityScript(isolate); | 1527 InstallUtilityScript(isolate); |
1536 } | 1528 } |
1537 #endif // !V8_SHARED | 1529 #endif // !V8_SHARED |
1538 } | 1530 } |
1539 { | 1531 { |
1540 Context::Scope cscope(context); | 1532 Context::Scope cscope(context); |
1541 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1533 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1542 options.isolate_sources[0].Execute(isolate); | 1534 options.isolate_sources[0].Execute(isolate); |
1543 } | 1535 } |
1544 } | 1536 } |
| 1537 CollectGarbage(isolate); |
| 1538 #ifndef V8_SHARED |
| 1539 for (int i = 1; i < options.num_isolates; ++i) { |
| 1540 options.isolate_sources[i].WaitForThread(); |
| 1541 } |
| 1542 #endif // !V8_SHARED |
| 1543 return 0; |
| 1544 } |
| 1545 |
| 1546 |
| 1547 void Shell::CollectGarbage(Isolate* isolate) { |
1545 if (options.send_idle_notification) { | 1548 if (options.send_idle_notification) { |
1546 const double kLongIdlePauseInSeconds = 1.0; | 1549 const double kLongIdlePauseInSeconds = 1.0; |
1547 isolate->ContextDisposedNotification(); | 1550 isolate->ContextDisposedNotification(); |
1548 isolate->IdleNotificationDeadline( | 1551 isolate->IdleNotificationDeadline( |
1549 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); | 1552 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); |
1550 } | 1553 } |
1551 if (options.invoke_weak_callbacks) { | 1554 if (options.invoke_weak_callbacks) { |
1552 // By sending a low memory notifications, we will try hard to collect all | 1555 // By sending a low memory notifications, we will try hard to collect all |
1553 // garbage and will therefore also invoke all weak callbacks of actually | 1556 // garbage and will therefore also invoke all weak callbacks of actually |
1554 // unreachable persistent handles. | 1557 // unreachable persistent handles. |
1555 isolate->LowMemoryNotification(); | 1558 isolate->LowMemoryNotification(); |
1556 } | 1559 } |
1557 | |
1558 #ifndef V8_SHARED | |
1559 for (int i = 1; i < options.num_isolates; ++i) { | |
1560 options.isolate_sources[i].WaitForThread(); | |
1561 } | |
1562 #endif // !V8_SHARED | |
1563 return 0; | |
1564 } | 1560 } |
1565 | 1561 |
1566 | 1562 |
1567 #ifndef V8_SHARED | 1563 #ifndef V8_SHARED |
1568 static void DumpHeapConstants(i::Isolate* isolate) { | 1564 static void DumpHeapConstants(i::Isolate* isolate) { |
1569 i::Heap* heap = isolate->heap(); | 1565 i::Heap* heap = isolate->heap(); |
1570 | 1566 |
1571 // Dump the INSTANCE_TYPES table to the console. | 1567 // Dump the INSTANCE_TYPES table to the console. |
1572 printf("# List of known V8 instance types.\n"); | 1568 printf("# List of known V8 instance types.\n"); |
1573 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); | 1569 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 // Run interactive shell if explicitly requested or if no script has been | 1718 // Run interactive shell if explicitly requested or if no script has been |
1723 // executed, but never on --test | 1719 // executed, but never on --test |
1724 if (options.use_interactive_shell()) { | 1720 if (options.use_interactive_shell()) { |
1725 #ifndef V8_SHARED | 1721 #ifndef V8_SHARED |
1726 if (!i::FLAG_debugger) { | 1722 if (!i::FLAG_debugger) { |
1727 InstallUtilityScript(isolate); | 1723 InstallUtilityScript(isolate); |
1728 } | 1724 } |
1729 #endif // !V8_SHARED | 1725 #endif // !V8_SHARED |
1730 RunShell(isolate); | 1726 RunShell(isolate); |
1731 } | 1727 } |
| 1728 |
| 1729 // Shut down contexts and collect garbage. |
| 1730 evaluation_context_.Reset(); |
| 1731 #ifndef V8_SHARED |
| 1732 utility_context_.Reset(); |
| 1733 #endif // !V8_SHARED |
| 1734 CollectGarbage(isolate); |
1732 } | 1735 } |
1733 OnExit(isolate); | 1736 OnExit(isolate); |
1734 #ifndef V8_SHARED | 1737 #ifndef V8_SHARED |
1735 // Dump basic block profiling data. | 1738 // Dump basic block profiling data. |
1736 if (i::BasicBlockProfiler* profiler = | 1739 if (i::BasicBlockProfiler* profiler = |
1737 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { | 1740 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { |
1738 i::OFStream os(stdout); | 1741 i::OFStream os(stdout); |
1739 os << *profiler; | 1742 os << *profiler; |
1740 } | 1743 } |
1741 #endif // !V8_SHARED | 1744 #endif // !V8_SHARED |
1742 isolate->Dispose(); | 1745 isolate->Dispose(); |
1743 V8::Dispose(); | 1746 V8::Dispose(); |
1744 V8::ShutdownPlatform(); | 1747 V8::ShutdownPlatform(); |
1745 delete g_platform; | 1748 delete g_platform; |
1746 | 1749 |
1747 return result; | 1750 return result; |
1748 } | 1751 } |
1749 | 1752 |
1750 } // namespace v8 | 1753 } // namespace v8 |
1751 | 1754 |
1752 | 1755 |
1753 #ifndef GOOGLE3 | 1756 #ifndef GOOGLE3 |
1754 int main(int argc, char* argv[]) { | 1757 int main(int argc, char* argv[]) { |
1755 return v8::Shell::Main(argc, argv); | 1758 return v8::Shell::Main(argc, argv); |
1756 } | 1759 } |
1757 #endif | 1760 #endif |
OLD | NEW |