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 #include <errno.h> | 5 #include <errno.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 | 1192 |
1193 worker->Terminate(); | 1193 worker->Terminate(); |
1194 } | 1194 } |
1195 | 1195 |
1196 | 1196 |
1197 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { | 1197 void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) { |
1198 int exit_code = (*args)[0] | 1198 int exit_code = (*args)[0] |
1199 ->Int32Value(args->GetIsolate()->GetCurrentContext()) | 1199 ->Int32Value(args->GetIsolate()->GetCurrentContext()) |
1200 .FromMaybe(0); | 1200 .FromMaybe(0); |
1201 CleanupWorkers(); | 1201 CleanupWorkers(); |
| 1202 args->GetIsolate()->Exit(); |
1202 OnExit(args->GetIsolate()); | 1203 OnExit(args->GetIsolate()); |
1203 Exit(exit_code); | 1204 Exit(exit_code); |
1204 } | 1205 } |
1205 | 1206 |
1206 | 1207 |
1207 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { | 1208 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { |
1208 base::CallOnce(&quit_once_, &QuitOnce, | 1209 base::CallOnce(&quit_once_, &QuitOnce, |
1209 const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args)); | 1210 const_cast<v8::FunctionCallbackInfo<v8::Value>*>(&args)); |
1210 } | 1211 } |
1211 | 1212 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 ReadRange(&sink, &lines, script, &script_data.toplevel); | 1715 ReadRange(&sink, &lines, script, &script_data.toplevel); |
1715 // Write per-line coverage. LCOV uses 1-based line numbers. | 1716 // Write per-line coverage. LCOV uses 1-based line numbers. |
1716 for (size_t i = 0; i < lines.size(); i++) { | 1717 for (size_t i = 0; i < lines.size(); i++) { |
1717 sink << "DA:" << (i + 1) << "," << lines[i] << std::endl; | 1718 sink << "DA:" << (i + 1) << "," << lines[i] << std::endl; |
1718 } | 1719 } |
1719 sink << "end_of_record" << std::endl; | 1720 sink << "end_of_record" << std::endl; |
1720 } | 1721 } |
1721 } | 1722 } |
1722 | 1723 |
1723 void Shell::OnExit(v8::Isolate* isolate) { | 1724 void Shell::OnExit(v8::Isolate* isolate) { |
| 1725 // Dump basic block profiling data. |
| 1726 if (i::BasicBlockProfiler* profiler = |
| 1727 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { |
| 1728 i::OFStream os(stdout); |
| 1729 os << *profiler; |
| 1730 } |
| 1731 isolate->Dispose(); |
| 1732 |
1724 if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp) { | 1733 if (i::FLAG_dump_counters || i::FLAG_dump_counters_nvp) { |
1725 int number_of_counters = 0; | 1734 int number_of_counters = 0; |
1726 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 1735 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
1727 number_of_counters++; | 1736 number_of_counters++; |
1728 } | 1737 } |
1729 CounterAndKey* counters = new CounterAndKey[number_of_counters]; | 1738 CounterAndKey* counters = new CounterAndKey[number_of_counters]; |
1730 int j = 0; | 1739 int j = 0; |
1731 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { | 1740 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { |
1732 counters[j].counter = i.CurrentValue(); | 1741 counters[j].counter = i.CurrentValue(); |
1733 counters[j].key = i.CurrentKey(); | 1742 counters[j].key = i.CurrentKey(); |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 i::FLAG_trace_ignition_dispatches_output_file != nullptr) { | 2983 i::FLAG_trace_ignition_dispatches_output_file != nullptr) { |
2975 WriteIgnitionDispatchCountersFile(isolate); | 2984 WriteIgnitionDispatchCountersFile(isolate); |
2976 } | 2985 } |
2977 | 2986 |
2978 // Shut down contexts and collect garbage. | 2987 // Shut down contexts and collect garbage. |
2979 evaluation_context_.Reset(); | 2988 evaluation_context_.Reset(); |
2980 stringify_function_.Reset(); | 2989 stringify_function_.Reset(); |
2981 CollectGarbage(isolate); | 2990 CollectGarbage(isolate); |
2982 } | 2991 } |
2983 OnExit(isolate); | 2992 OnExit(isolate); |
2984 // Dump basic block profiling data. | |
2985 if (i::BasicBlockProfiler* profiler = | |
2986 reinterpret_cast<i::Isolate*>(isolate)->basic_block_profiler()) { | |
2987 i::OFStream os(stdout); | |
2988 os << *profiler; | |
2989 } | |
2990 isolate->Dispose(); | |
2991 V8::Dispose(); | 2993 V8::Dispose(); |
2992 V8::ShutdownPlatform(); | 2994 V8::ShutdownPlatform(); |
2993 delete g_platform; | 2995 delete g_platform; |
2994 if (i::FLAG_verify_predictable) { | 2996 if (i::FLAG_verify_predictable) { |
2995 delete tracing_controller; | 2997 delete tracing_controller; |
2996 } | 2998 } |
2997 | 2999 |
2998 return result; | 3000 return result; |
2999 } | 3001 } |
3000 | 3002 |
3001 } // namespace v8 | 3003 } // namespace v8 |
3002 | 3004 |
3003 | 3005 |
3004 #ifndef GOOGLE3 | 3006 #ifndef GOOGLE3 |
3005 int main(int argc, char* argv[]) { | 3007 int main(int argc, char* argv[]) { |
3006 return v8::Shell::Main(argc, argv); | 3008 return v8::Shell::Main(argc, argv); |
3007 } | 3009 } |
3008 #endif | 3010 #endif |
OLD | NEW |