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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 #ifndef DCHECK | 65 #ifndef DCHECK |
66 #define DCHECK(condition) assert(condition) | 66 #define DCHECK(condition) assert(condition) |
67 #endif | 67 #endif |
68 | 68 |
69 #ifndef CHECK | 69 #ifndef CHECK |
70 #define CHECK(condition) assert(condition) | 70 #define CHECK(condition) assert(condition) |
71 #endif | 71 #endif |
72 | 72 |
73 namespace v8 { | 73 namespace v8 { |
74 | 74 |
| 75 namespace { |
| 76 v8::Platform* g_platform = NULL; |
| 77 } // namespace |
| 78 |
75 | 79 |
76 static Handle<Value> Throw(Isolate* isolate, const char* message) { | 80 static Handle<Value> Throw(Isolate* isolate, const char* message) { |
77 return isolate->ThrowException(String::NewFromUtf8(isolate, message)); | 81 return isolate->ThrowException(String::NewFromUtf8(isolate, message)); |
78 } | 82 } |
79 | 83 |
80 | 84 |
81 | 85 |
82 class PerIsolateData { | 86 class PerIsolateData { |
83 public: | 87 public: |
84 explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) { | 88 explicit PerIsolateData(Isolate* isolate) : isolate_(isolate), realms_(NULL) { |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 HandleScope scope(isolate); | 1286 HandleScope scope(isolate); |
1283 PerIsolateData data(isolate); | 1287 PerIsolateData data(isolate); |
1284 Local<Context> context = Shell::CreateEvaluationContext(isolate); | 1288 Local<Context> context = Shell::CreateEvaluationContext(isolate); |
1285 { | 1289 { |
1286 Context::Scope cscope(context); | 1290 Context::Scope cscope(context); |
1287 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1291 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1288 Execute(isolate); | 1292 Execute(isolate); |
1289 } | 1293 } |
1290 } | 1294 } |
1291 if (Shell::options.send_idle_notification) { | 1295 if (Shell::options.send_idle_notification) { |
1292 const int kLongIdlePauseInMs = 1000; | 1296 const double kLongIdlePauseInSeconds = 1.0; |
1293 isolate->ContextDisposedNotification(); | 1297 isolate->ContextDisposedNotification(); |
1294 isolate->IdleNotification(kLongIdlePauseInMs); | 1298 isolate->IdleNotificationDeadline( |
| 1299 g_platform->MonotonicallyIncreasingTime() + |
| 1300 kLongIdlePauseInSeconds); |
1295 } | 1301 } |
1296 if (Shell::options.invoke_weak_callbacks) { | 1302 if (Shell::options.invoke_weak_callbacks) { |
1297 // By sending a low memory notifications, we will try hard to collect | 1303 // By sending a low memory notifications, we will try hard to collect |
1298 // all garbage and will therefore also invoke all weak callbacks of | 1304 // all garbage and will therefore also invoke all weak callbacks of |
1299 // actually unreachable persistent handles. | 1305 // actually unreachable persistent handles. |
1300 isolate->LowMemoryNotification(); | 1306 isolate->LowMemoryNotification(); |
1301 } | 1307 } |
1302 } | 1308 } |
1303 done_semaphore_.Signal(); | 1309 done_semaphore_.Signal(); |
1304 } while (!Shell::options.last_run); | 1310 } while (!Shell::options.last_run); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 } | 1486 } |
1481 #endif // !V8_SHARED | 1487 #endif // !V8_SHARED |
1482 } | 1488 } |
1483 { | 1489 { |
1484 Context::Scope cscope(context); | 1490 Context::Scope cscope(context); |
1485 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); | 1491 PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); |
1486 options.isolate_sources[0].Execute(isolate); | 1492 options.isolate_sources[0].Execute(isolate); |
1487 } | 1493 } |
1488 } | 1494 } |
1489 if (options.send_idle_notification) { | 1495 if (options.send_idle_notification) { |
1490 const int kLongIdlePauseInMs = 1000; | 1496 const double kLongIdlePauseInSeconds = 1.0; |
1491 isolate->ContextDisposedNotification(); | 1497 isolate->ContextDisposedNotification(); |
1492 isolate->IdleNotification(kLongIdlePauseInMs); | 1498 isolate->IdleNotificationDeadline( |
| 1499 g_platform->MonotonicallyIncreasingTime() + kLongIdlePauseInSeconds); |
1493 } | 1500 } |
1494 if (options.invoke_weak_callbacks) { | 1501 if (options.invoke_weak_callbacks) { |
1495 // By sending a low memory notifications, we will try hard to collect all | 1502 // By sending a low memory notifications, we will try hard to collect all |
1496 // garbage and will therefore also invoke all weak callbacks of actually | 1503 // garbage and will therefore also invoke all weak callbacks of actually |
1497 // unreachable persistent handles. | 1504 // unreachable persistent handles. |
1498 isolate->LowMemoryNotification(); | 1505 isolate->LowMemoryNotification(); |
1499 } | 1506 } |
1500 | 1507 |
1501 #ifndef V8_SHARED | 1508 #ifndef V8_SHARED |
1502 for (int i = 1; i < options.num_isolates; ++i) { | 1509 for (int i = 1; i < options.num_isolates; ++i) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 1601 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
1595 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 1602 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
1596 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); | 1603 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); |
1597 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 1604 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
1598 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); | 1605 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); |
1599 _set_error_mode(_OUT_TO_STDERR); | 1606 _set_error_mode(_OUT_TO_STDERR); |
1600 #endif // defined(_MSC_VER) | 1607 #endif // defined(_MSC_VER) |
1601 #endif // defined(_WIN32) || defined(_WIN64) | 1608 #endif // defined(_WIN32) || defined(_WIN64) |
1602 if (!SetOptions(argc, argv)) return 1; | 1609 if (!SetOptions(argc, argv)) return 1; |
1603 v8::V8::InitializeICU(options.icu_data_file); | 1610 v8::V8::InitializeICU(options.icu_data_file); |
1604 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); | 1611 g_platform = v8::platform::CreateDefaultPlatform(); |
1605 v8::V8::InitializePlatform(platform); | 1612 v8::V8::InitializePlatform(g_platform); |
1606 v8::V8::Initialize(); | 1613 v8::V8::Initialize(); |
1607 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 1614 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
1608 v8::StartupDataHandler startup_data(argv[0], options.natives_blob, | 1615 v8::StartupDataHandler startup_data(argv[0], options.natives_blob, |
1609 options.snapshot_blob); | 1616 options.snapshot_blob); |
1610 #endif | 1617 #endif |
1611 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); | 1618 SetFlagsFromString("--trace-hydrogen-file=hydrogen.cfg"); |
1612 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg"); | 1619 SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg"); |
1613 SetFlagsFromString("--redirect-code-traces-to=code.asm"); | 1620 SetFlagsFromString("--redirect-code-traces-to=code.asm"); |
1614 ShellArrayBufferAllocator array_buffer_allocator; | 1621 ShellArrayBufferAllocator array_buffer_allocator; |
1615 MockArrayBufferAllocator mock_arraybuffer_allocator; | 1622 MockArrayBufferAllocator mock_arraybuffer_allocator; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 // Dump basic block profiling data. | 1705 // Dump basic block profiling data. |
1699 if (i::BasicBlockProfiler* profiler = | 1706 if (i::BasicBlockProfiler* profiler = |
1700 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { | 1707 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { |
1701 i::OFStream os(stdout); | 1708 i::OFStream os(stdout); |
1702 os << *profiler; | 1709 os << *profiler; |
1703 } | 1710 } |
1704 #endif // !V8_SHARED | 1711 #endif // !V8_SHARED |
1705 isolate->Dispose(); | 1712 isolate->Dispose(); |
1706 V8::Dispose(); | 1713 V8::Dispose(); |
1707 V8::ShutdownPlatform(); | 1714 V8::ShutdownPlatform(); |
1708 delete platform; | 1715 delete g_platform; |
1709 | 1716 |
1710 return result; | 1717 return result; |
1711 } | 1718 } |
1712 | 1719 |
1713 } // namespace v8 | 1720 } // namespace v8 |
1714 | 1721 |
1715 | 1722 |
1716 #ifndef GOOGLE3 | 1723 #ifndef GOOGLE3 |
1717 int main(int argc, char* argv[]) { | 1724 int main(int argc, char* argv[]) { |
1718 return v8::Shell::Main(argc, argv); | 1725 return v8::Shell::Main(argc, argv); |
1719 } | 1726 } |
1720 #endif | 1727 #endif |
OLD | NEW |