OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 utility_context_->SetSecurityToken(Undefined()); | 1046 utility_context_->SetSecurityToken(Undefined()); |
1047 evaluation_context_->SetSecurityToken(Undefined()); | 1047 evaluation_context_->SetSecurityToken(Undefined()); |
1048 Context::Scope utility_scope(utility_context_); | 1048 Context::Scope utility_scope(utility_context_); |
1049 | 1049 |
1050 #ifdef ENABLE_DEBUGGER_SUPPORT | 1050 #ifdef ENABLE_DEBUGGER_SUPPORT |
1051 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); | 1051 if (i::FLAG_debugger) printf("JavaScript debugger enabled\n"); |
1052 // Install the debugger object in the utility scope | 1052 // Install the debugger object in the utility scope |
1053 i::Debug* debug = i::Isolate::Current()->debug(); | 1053 i::Debug* debug = i::Isolate::Current()->debug(); |
1054 debug->Load(); | 1054 debug->Load(); |
1055 i::Handle<i::JSObject> js_debug | 1055 i::Handle<i::JSObject> js_debug |
1056 = i::Handle<i::JSObject>(debug->debug_context()->global_object()); | 1056 = i::Handle<i::JSObject>(debug->debug_context()->global()); |
1057 utility_context_->Global()->Set(String::New("$debug"), | 1057 utility_context_->Global()->Set(String::New("$debug"), |
1058 Utils::ToLocal(js_debug)); | 1058 Utils::ToLocal(js_debug)); |
1059 debug->debug_context()->set_security_token(HEAP->undefined_value()); | 1059 debug->debug_context()->set_security_token(HEAP->undefined_value()); |
1060 #endif // ENABLE_DEBUGGER_SUPPORT | 1060 #endif // ENABLE_DEBUGGER_SUPPORT |
1061 | 1061 |
1062 // Run the d8 shell utility script in the utility context | 1062 // Run the d8 shell utility script in the utility context |
1063 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); | 1063 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); |
1064 i::Vector<const char> shell_source = | 1064 i::Vector<const char> shell_source = |
1065 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); | 1065 i::NativesCollection<i::D8>::GetRawScriptSource(source_index); |
1066 i::Vector<const char> shell_source_name = | 1066 i::Vector<const char> shell_source_name = |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 { | 1582 { |
1583 Isolate::Scope iscope(isolate); | 1583 Isolate::Scope iscope(isolate); |
1584 Locker lock(isolate); | 1584 Locker lock(isolate); |
1585 HandleScope scope; | 1585 HandleScope scope; |
1586 Persistent<Context> context = Shell::CreateEvaluationContext(); | 1586 Persistent<Context> context = Shell::CreateEvaluationContext(); |
1587 { | 1587 { |
1588 Context::Scope cscope(context); | 1588 Context::Scope cscope(context); |
1589 Execute(); | 1589 Execute(); |
1590 } | 1590 } |
1591 context.Dispose(); | 1591 context.Dispose(); |
1592 if (Shell::options.send_idle_notification) { | |
1593 const int kLongIdlePauseInMs = 1000; | |
1594 V8::ContextDisposedNotification(); | |
1595 V8::IdleNotification(kLongIdlePauseInMs); | |
1596 } | |
1597 } | 1592 } |
1598 if (done_semaphore_ != NULL) done_semaphore_->Signal(); | 1593 if (done_semaphore_ != NULL) done_semaphore_->Signal(); |
1599 } while (!Shell::options.last_run); | 1594 } while (!Shell::options.last_run); |
1600 isolate->Dispose(); | 1595 isolate->Dispose(); |
1601 } | 1596 } |
1602 | 1597 |
1603 | 1598 |
1604 void SourceGroup::StartExecuteInThread() { | 1599 void SourceGroup::StartExecuteInThread() { |
1605 if (thread_ == NULL) { | 1600 if (thread_ == NULL) { |
1606 thread_ = new IsolateThread(this); | 1601 thread_ = new IsolateThread(this); |
(...skipping 25 matching lines...) Expand all Loading... |
1632 } else if (strcmp(argv[i], "--noalways-opt") == 0) { | 1627 } else if (strcmp(argv[i], "--noalways-opt") == 0) { |
1633 // No support for stressing if we can't use --always-opt. | 1628 // No support for stressing if we can't use --always-opt. |
1634 options.stress_opt = false; | 1629 options.stress_opt = false; |
1635 options.stress_deopt = false; | 1630 options.stress_deopt = false; |
1636 } else if (strcmp(argv[i], "--shell") == 0) { | 1631 } else if (strcmp(argv[i], "--shell") == 0) { |
1637 options.interactive_shell = true; | 1632 options.interactive_shell = true; |
1638 argv[i] = NULL; | 1633 argv[i] = NULL; |
1639 } else if (strcmp(argv[i], "--test") == 0) { | 1634 } else if (strcmp(argv[i], "--test") == 0) { |
1640 options.test_shell = true; | 1635 options.test_shell = true; |
1641 argv[i] = NULL; | 1636 argv[i] = NULL; |
1642 } else if (strcmp(argv[i], "--send-idle-notification") == 0) { | |
1643 options.send_idle_notification = true; | |
1644 argv[i] = NULL; | |
1645 } else if (strcmp(argv[i], "--preemption") == 0) { | 1637 } else if (strcmp(argv[i], "--preemption") == 0) { |
1646 #ifdef V8_SHARED | 1638 #ifdef V8_SHARED |
1647 printf("D8 with shared library does not support multi-threading\n"); | 1639 printf("D8 with shared library does not support multi-threading\n"); |
1648 return false; | 1640 return false; |
1649 #else | 1641 #else |
1650 options.use_preemption = true; | 1642 options.use_preemption = true; |
1651 argv[i] = NULL; | 1643 argv[i] = NULL; |
1652 #endif // V8_SHARED | 1644 #endif // V8_SHARED |
1653 } else if (strcmp(argv[i], "--nopreemption") == 0) { | 1645 } else if (strcmp(argv[i], "--nopreemption") == 0) { |
1654 #ifdef V8_SHARED | 1646 #ifdef V8_SHARED |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 InstallUtilityScript(); | 1783 InstallUtilityScript(); |
1792 } | 1784 } |
1793 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT | 1785 #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT |
1794 } | 1786 } |
1795 { | 1787 { |
1796 Context::Scope cscope(context); | 1788 Context::Scope cscope(context); |
1797 options.isolate_sources[0].Execute(); | 1789 options.isolate_sources[0].Execute(); |
1798 } | 1790 } |
1799 if (!options.last_run) { | 1791 if (!options.last_run) { |
1800 context.Dispose(); | 1792 context.Dispose(); |
1801 if (options.send_idle_notification) { | 1793 #if !defined(V8_SHARED) |
| 1794 if (i::FLAG_send_idle_notification) { |
1802 const int kLongIdlePauseInMs = 1000; | 1795 const int kLongIdlePauseInMs = 1000; |
1803 V8::ContextDisposedNotification(); | 1796 V8::ContextDisposedNotification(); |
1804 V8::IdleNotification(kLongIdlePauseInMs); | 1797 V8::IdleNotification(kLongIdlePauseInMs); |
1805 } | 1798 } |
| 1799 #endif // !V8_SHARED |
1806 } | 1800 } |
1807 | 1801 |
1808 #ifndef V8_SHARED | 1802 #ifndef V8_SHARED |
1809 // Start preemption if threads have been created and preemption is enabled. | 1803 // Start preemption if threads have been created and preemption is enabled. |
1810 if (threads.length() > 0 | 1804 if (threads.length() > 0 |
1811 && options.use_preemption) { | 1805 && options.use_preemption) { |
1812 Locker::StartPreemption(options.preemption_interval); | 1806 Locker::StartPreemption(options.preemption_interval); |
1813 } | 1807 } |
1814 #endif // V8_SHARED | 1808 #endif // V8_SHARED |
1815 } | 1809 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 } | 1893 } |
1900 | 1894 |
1901 } // namespace v8 | 1895 } // namespace v8 |
1902 | 1896 |
1903 | 1897 |
1904 #ifndef GOOGLE3 | 1898 #ifndef GOOGLE3 |
1905 int main(int argc, char* argv[]) { | 1899 int main(int argc, char* argv[]) { |
1906 return v8::Shell::Main(argc, argv); | 1900 return v8::Shell::Main(argc, argv); |
1907 } | 1901 } |
1908 #endif | 1902 #endif |
OLD | NEW |