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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 Handle<Object> global = context->Global(); | 631 Handle<Object> global = context->Global(); |
632 Handle<Value> fun = | 632 Handle<Value> fun = |
633 global->Get(String::NewFromUtf8(isolate, "DebugCommandToJSONRequest")); | 633 global->Get(String::NewFromUtf8(isolate, "DebugCommandToJSONRequest")); |
634 static const int kArgc = 1; | 634 static const int kArgc = 1; |
635 Handle<Value> argv[kArgc] = { command }; | 635 Handle<Value> argv[kArgc] = { command }; |
636 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); | 636 Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv); |
637 return handle_scope.Escape(Local<Value>(val)); | 637 return handle_scope.Escape(Local<Value>(val)); |
638 } | 638 } |
639 | 639 |
640 | 640 |
641 void Shell::DispatchDebugMessages() { | |
642 Isolate* isolate = v8::Isolate::GetCurrent(); | |
643 HandleScope handle_scope(isolate); | |
644 v8::Local<v8::Context> context = | |
645 v8::Local<v8::Context>::New(isolate, Shell::evaluation_context_); | |
646 v8::Context::Scope context_scope(context); | |
647 v8::Debug::ProcessDebugMessages(); | |
648 } | |
649 | |
650 | |
651 int32_t* Counter::Bind(const char* name, bool is_histogram) { | 641 int32_t* Counter::Bind(const char* name, bool is_histogram) { |
652 int i; | 642 int i; |
653 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) | 643 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) |
654 name_[i] = static_cast<char>(name[i]); | 644 name_[i] = static_cast<char>(name[i]); |
655 name_[i] = '\0'; | 645 name_[i] = '\0'; |
656 is_histogram_ = is_histogram; | 646 is_histogram_ = is_histogram; |
657 return ptr(); | 647 return ptr(); |
658 } | 648 } |
659 | 649 |
660 | 650 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 // in the debugger. | 779 // in the debugger. |
790 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script); | 780 i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script); |
791 i::Handle<i::Script> script_object = compiled_script->IsJSFunction() | 781 i::Handle<i::Script> script_object = compiled_script->IsJSFunction() |
792 ? i::Handle<i::Script>(i::Script::cast( | 782 ? i::Handle<i::Script>(i::Script::cast( |
793 i::JSFunction::cast(*compiled_script)->shared()->script())) | 783 i::JSFunction::cast(*compiled_script)->shared()->script())) |
794 : i::Handle<i::Script>(i::Script::cast( | 784 : i::Handle<i::Script>(i::Script::cast( |
795 i::SharedFunctionInfo::cast(*compiled_script)->script())); | 785 i::SharedFunctionInfo::cast(*compiled_script)->script())); |
796 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); | 786 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); |
797 | 787 |
798 // Start the in-process debugger if requested. | 788 // Start the in-process debugger if requested. |
799 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { | 789 if (i::FLAG_debugger) v8::Debug::SetDebugEventListener2(HandleDebugEvent); |
800 v8::Debug::SetDebugEventListener2(HandleDebugEvent); | |
801 } | |
802 } | 790 } |
803 #endif // !V8_SHARED | 791 #endif // !V8_SHARED |
804 | 792 |
805 | 793 |
806 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 794 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
807 class BZip2Decompressor : public v8::StartupDataDecompressor { | 795 class BZip2Decompressor : public v8::StartupDataDecompressor { |
808 public: | 796 public: |
809 virtual ~BZip2Decompressor() { } | 797 virtual ~BZip2Decompressor() { } |
810 | 798 |
811 protected: | 799 protected: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 901 |
914 | 902 |
915 void Shell::InitializeDebugger(Isolate* isolate) { | 903 void Shell::InitializeDebugger(Isolate* isolate) { |
916 if (options.test_shell) return; | 904 if (options.test_shell) return; |
917 #ifndef V8_SHARED | 905 #ifndef V8_SHARED |
918 Locker lock(isolate); | 906 Locker lock(isolate); |
919 HandleScope scope(isolate); | 907 HandleScope scope(isolate); |
920 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 908 Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
921 utility_context_.Reset(isolate, | 909 utility_context_.Reset(isolate, |
922 Context::New(isolate, NULL, global_template)); | 910 Context::New(isolate, NULL, global_template)); |
923 | |
924 // Start the debugger agent if requested. | |
925 if (i::FLAG_debugger_agent) { | |
926 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port, true); | |
927 v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); | |
928 } | |
929 #endif // !V8_SHARED | 911 #endif // !V8_SHARED |
930 } | 912 } |
931 | 913 |
932 | 914 |
933 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { | 915 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { |
934 #ifndef V8_SHARED | 916 #ifndef V8_SHARED |
935 // This needs to be a critical section since this is not thread-safe | 917 // This needs to be a critical section since this is not thread-safe |
936 i::LockGuard<i::Mutex> lock_guard(&context_mutex_); | 918 i::LockGuard<i::Mutex> lock_guard(&context_mutex_); |
937 #endif // !V8_SHARED | 919 #endif // !V8_SHARED |
938 // Initialize the global objects | 920 // Initialize the global objects |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 for (int i = 0; i < stress_runs && result == 0; i++) { | 1527 for (int i = 0; i < stress_runs && result == 0; i++) { |
1546 printf("============ Run %d/%d ============\n", i + 1, stress_runs); | 1528 printf("============ Run %d/%d ============\n", i + 1, stress_runs); |
1547 options.last_run = (i == stress_runs - 1); | 1529 options.last_run = (i == stress_runs - 1); |
1548 result = RunMain(isolate, argc, argv); | 1530 result = RunMain(isolate, argc, argv); |
1549 } | 1531 } |
1550 #endif | 1532 #endif |
1551 } else { | 1533 } else { |
1552 result = RunMain(isolate, argc, argv); | 1534 result = RunMain(isolate, argc, argv); |
1553 } | 1535 } |
1554 | 1536 |
1555 | |
1556 #ifndef V8_SHARED | |
1557 // Run remote debugger if requested, but never on --test | |
1558 if (i::FLAG_remote_debugger && !options.test_shell) { | |
1559 InstallUtilityScript(isolate); | |
1560 RunRemoteDebugger(isolate, i::FLAG_debugger_port); | |
1561 return 0; | |
1562 } | |
1563 #endif // !V8_SHARED | |
1564 | |
1565 // Run interactive shell if explicitly requested or if no script has been | 1537 // Run interactive shell if explicitly requested or if no script has been |
1566 // executed, but never on --test | 1538 // executed, but never on --test |
1567 | |
1568 if (( options.interactive_shell || !options.script_executed ) | 1539 if (( options.interactive_shell || !options.script_executed ) |
1569 && !options.test_shell ) { | 1540 && !options.test_shell ) { |
1570 #ifndef V8_SHARED | 1541 #ifndef V8_SHARED |
1571 if (!i::FLAG_debugger) { | 1542 if (!i::FLAG_debugger) { |
1572 InstallUtilityScript(isolate); | 1543 InstallUtilityScript(isolate); |
1573 } | 1544 } |
1574 #endif // !V8_SHARED | 1545 #endif // !V8_SHARED |
1575 RunShell(isolate); | 1546 RunShell(isolate); |
1576 } | 1547 } |
1577 } | 1548 } |
1578 isolate->Dispose(); | 1549 isolate->Dispose(); |
1579 V8::Dispose(); | 1550 V8::Dispose(); |
1580 | 1551 |
1581 OnExit(); | 1552 OnExit(); |
1582 | 1553 |
1583 return result; | 1554 return result; |
1584 } | 1555 } |
1585 | 1556 |
1586 } // namespace v8 | 1557 } // namespace v8 |
1587 | 1558 |
1588 | 1559 |
1589 #ifndef GOOGLE3 | 1560 #ifndef GOOGLE3 |
1590 int main(int argc, char* argv[]) { | 1561 int main(int argc, char* argv[]) { |
1591 return v8::Shell::Main(argc, argv); | 1562 return v8::Shell::Main(argc, argv); |
1592 } | 1563 } |
1593 #endif | 1564 #endif |
OLD | NEW |