| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return i::SmartArrayPointer<char>(str ? i::StrDup(str) : str); | 110 return i::SmartArrayPointer<char>(str ? i::StrDup(str) : str); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 CounterMap* Shell::counter_map_; | 114 CounterMap* Shell::counter_map_; |
| 115 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; | 115 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; |
| 116 CounterCollection Shell::local_counters_; | 116 CounterCollection Shell::local_counters_; |
| 117 CounterCollection* Shell::counters_ = &local_counters_; | 117 CounterCollection* Shell::counters_ = &local_counters_; |
| 118 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); | 118 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); |
| 119 Persistent<Context> Shell::utility_context_; | 119 Persistent<Context> Shell::utility_context_; |
| 120 LineEditor* Shell::console = NULL; | |
| 121 #endif // V8_SHARED | 120 #endif // V8_SHARED |
| 122 | 121 |
| 123 Persistent<Context> Shell::evaluation_context_; | 122 Persistent<Context> Shell::evaluation_context_; |
| 124 ShellOptions Shell::options; | 123 ShellOptions Shell::options; |
| 125 const char* Shell::kPrompt = "d8> "; | 124 const char* Shell::kPrompt = "d8> "; |
| 126 | 125 |
| 127 | 126 |
| 128 #ifndef V8_SHARED | 127 #ifndef V8_SHARED |
| 129 bool CounterMap::Match(void* key1, void* key2) { | 128 bool CounterMap::Match(void* key1, void* key2) { |
| 130 const char* name1 = reinterpret_cast<const char*>(key1); | 129 const char* name1 = reinterpret_cast<const char*>(key1); |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // Use _exit instead of exit to avoid races between isolate | 784 // Use _exit instead of exit to avoid races between isolate |
| 786 // threads and static destructors. | 785 // threads and static destructors. |
| 787 fflush(stdout); | 786 fflush(stdout); |
| 788 fflush(stderr); | 787 fflush(stderr); |
| 789 _exit(exit_code); | 788 _exit(exit_code); |
| 790 } | 789 } |
| 791 | 790 |
| 792 | 791 |
| 793 #ifndef V8_SHARED | 792 #ifndef V8_SHARED |
| 794 void Shell::OnExit() { | 793 void Shell::OnExit() { |
| 795 console->Close(); | |
| 796 if (i::FLAG_dump_counters) { | 794 if (i::FLAG_dump_counters) { |
| 797 printf("+----------------------------------------+-------------+\n"); | 795 printf("+----------------------------------------+-------------+\n"); |
| 798 printf("| Name | Value |\n"); | 796 printf("| Name | Value |\n"); |
| 799 printf("+----------------------------------------+-------------+\n"); | 797 printf("+----------------------------------------+-------------+\n"); |
| 800 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 798 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
| 801 Counter* counter = i.CurrentValue(); | 799 Counter* counter = i.CurrentValue(); |
| 802 if (counter->is_histogram()) { | 800 if (counter->is_histogram()) { |
| 803 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); | 801 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); |
| 804 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); | 802 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); |
| 805 } else { | 803 } else { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 return result; | 888 return result; |
| 891 } | 889 } |
| 892 | 890 |
| 893 | 891 |
| 894 void Shell::RunShell() { | 892 void Shell::RunShell() { |
| 895 Locker locker; | 893 Locker locker; |
| 896 Context::Scope context_scope(evaluation_context_); | 894 Context::Scope context_scope(evaluation_context_); |
| 897 HandleScope outer_scope; | 895 HandleScope outer_scope; |
| 898 Handle<String> name = String::New("(d8)"); | 896 Handle<String> name = String::New("(d8)"); |
| 899 #ifndef V8_SHARED | 897 #ifndef V8_SHARED |
| 900 console = LineEditor::Get(); | 898 LineEditor* editor = LineEditor::Get(); |
| 901 printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name()); | 899 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); |
| 902 if (i::FLAG_debugger) { | 900 if (i::FLAG_debugger) { |
| 903 printf("JavaScript debugger enabled\n"); | 901 printf("JavaScript debugger enabled\n"); |
| 904 } | 902 } |
| 905 console->Open(); | 903 editor->Open(); |
| 906 while (true) { | 904 while (true) { |
| 907 i::SmartArrayPointer<char> input = console->Prompt(Shell::kPrompt); | 905 i::SmartArrayPointer<char> input = editor->Prompt(Shell::kPrompt); |
| 908 if (input.is_empty()) break; | 906 if (input.is_empty()) break; |
| 909 console->AddHistory(*input); | 907 editor->AddHistory(*input); |
| 910 HandleScope inner_scope; | 908 HandleScope inner_scope; |
| 911 ExecuteString(String::New(*input), name, true, true); | 909 ExecuteString(String::New(*input), name, true, true); |
| 912 } | 910 } |
| 913 console->Close(); | 911 editor->Close(); |
| 914 #else | 912 #else |
| 915 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); | 913 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); |
| 916 static const int kBufferSize = 256; | 914 static const int kBufferSize = 256; |
| 917 while (true) { | 915 while (true) { |
| 918 char buffer[kBufferSize]; | 916 char buffer[kBufferSize]; |
| 919 printf("%s", Shell::kPrompt); | 917 printf("%s", Shell::kPrompt); |
| 920 if (fgets(buffer, kBufferSize, stdin) == NULL) break; | 918 if (fgets(buffer, kBufferSize, stdin) == NULL) break; |
| 921 HandleScope inner_scope; | 919 HandleScope inner_scope; |
| 922 ExecuteString(String::New(buffer), name, true, true); | 920 ExecuteString(String::New(buffer), name, true, true); |
| 923 } | 921 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 } | 1345 } |
| 1348 | 1346 |
| 1349 } // namespace v8 | 1347 } // namespace v8 |
| 1350 | 1348 |
| 1351 | 1349 |
| 1352 #ifndef GOOGLE3 | 1350 #ifndef GOOGLE3 |
| 1353 int main(int argc, char* argv[]) { | 1351 int main(int argc, char* argv[]) { |
| 1354 return v8::Shell::Main(argc, argv); | 1352 return v8::Shell::Main(argc, argv); |
| 1355 } | 1353 } |
| 1356 #endif | 1354 #endif |
| OLD | NEW |