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 |
11 #include <errno.h> | 11 #include <errno.h> |
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
15 #include <fstream> | |
15 | 16 |
16 #ifdef V8_SHARED | 17 #ifdef V8_SHARED |
17 #include <assert.h> | 18 #include <assert.h> |
18 #endif // V8_SHARED | 19 #endif // V8_SHARED |
19 | 20 |
20 #ifndef V8_SHARED | 21 #ifndef V8_SHARED |
21 #include <algorithm> | 22 #include <algorithm> |
22 #include <vector> | 23 #include <vector> |
23 #endif // !V8_SHARED | 24 #endif // !V8_SHARED |
24 | 25 |
25 #ifdef V8_SHARED | 26 #ifdef V8_SHARED |
26 #include "include/v8-testing.h" | 27 #include "include/v8-testing.h" |
27 #endif // V8_SHARED | 28 #endif // V8_SHARED |
28 | 29 |
29 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 30 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
30 #include "src/third_party/vtune/v8-vtune.h" | 31 #include "src/third_party/vtune/v8-vtune.h" |
31 #endif | 32 #endif |
32 | 33 |
33 #include "src/d8.h" | 34 #include "src/d8.h" |
34 #include "src/ostreams.h" | 35 #include "src/ostreams.h" |
35 | 36 |
36 #include "include/libplatform/libplatform.h" | 37 #include "include/libplatform/libplatform.h" |
37 #ifndef V8_SHARED | 38 #ifndef V8_SHARED |
38 #include "src/api.h" | 39 #include "src/api.h" |
39 #include "src/base/cpu.h" | 40 #include "src/base/cpu.h" |
40 #include "src/base/logging.h" | 41 #include "src/base/logging.h" |
41 #include "src/base/platform/platform.h" | 42 #include "src/base/platform/platform.h" |
42 #include "src/base/sys-info.h" | 43 #include "src/base/sys-info.h" |
43 #include "src/basic-block-profiler.h" | 44 #include "src/basic-block-profiler.h" |
45 #include "src/interpreter/interpreter.h" | |
44 #include "src/snapshot/natives.h" | 46 #include "src/snapshot/natives.h" |
45 #include "src/utils.h" | 47 #include "src/utils.h" |
46 #include "src/v8.h" | 48 #include "src/v8.h" |
47 #endif // !V8_SHARED | 49 #endif // !V8_SHARED |
48 | 50 |
49 #if !defined(_WIN32) && !defined(_WIN64) | 51 #if !defined(_WIN32) && !defined(_WIN64) |
50 #include <unistd.h> // NOLINT | 52 #include <unistd.h> // NOLINT |
51 #else | 53 #else |
52 #include <windows.h> // NOLINT | 54 #include <windows.h> // NOLINT |
53 #if defined(_MSC_VER) | 55 #if defined(_MSC_VER) |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 #ifndef V8_SHARED | 1270 #ifndef V8_SHARED |
1269 struct CounterAndKey { | 1271 struct CounterAndKey { |
1270 Counter* counter; | 1272 Counter* counter; |
1271 const char* key; | 1273 const char* key; |
1272 }; | 1274 }; |
1273 | 1275 |
1274 | 1276 |
1275 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { | 1277 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { |
1276 return strcmp(lhs.key, rhs.key) < 0; | 1278 return strcmp(lhs.key, rhs.key) < 0; |
1277 } | 1279 } |
1280 | |
1281 void Shell::WriteInterpreterDispatchCounters(Isolate* isolate) { | |
1282 std::ofstream stream(i::FLAG_trace_ignition_dispatches_output_file); | |
1283 | |
1284 uintptr_t* handler_to_handler_dispatch_counters = | |
1285 reinterpret_cast<i::Isolate*>(isolate) | |
1286 ->interpreter() | |
1287 ->handler_to_handler_dispatch_counters(); | |
1288 | |
1289 int kCountersTableRowSize = | |
rmcilroy
2016/04/08 11:24:43
static const
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
1290 static_cast<int>(i::interpreter::Bytecode::kLast) + 1; | |
1291 | |
1292 stream << '['; | |
1293 | |
1294 for (int from_index = 0; from_index < kCountersTableRowSize; ++from_index) { | |
1295 if (from_index > 0) stream << ",\n "; | |
1296 | |
1297 // Do not use an object, we need the order of entries to be preserved | |
rmcilroy
2016/04/08 11:24:43
Not sure what this comment means? Also, could we h
Stefano Sanfilippo
2016/04/08 14:42:44
Replaced with dictionary of dictionaries.
| |
1298 i::interpreter::Bytecode from_bytecode = | |
1299 i::interpreter::Bytecodes::FromByte(from_index); | |
1300 stream << "[\"" << i::interpreter::Bytecodes::ToString(from_bytecode) | |
1301 << "\", ["; | |
1302 | |
1303 for (int to_index = 0; to_index < kCountersTableRowSize; ++to_index) { | |
1304 if (to_index > 0) stream << ", "; | |
1305 stream << handler_to_handler_dispatch_counters[from_index * | |
1306 kCountersTableRowSize + | |
1307 to_index]; | |
1308 } | |
1309 stream << "]]"; | |
1310 } | |
1311 stream << ']'; | |
1312 } | |
1313 | |
1278 #endif // !V8_SHARED | 1314 #endif // !V8_SHARED |
1279 | 1315 |
1280 | 1316 |
1281 void Shell::OnExit(v8::Isolate* isolate) { | 1317 void Shell::OnExit(v8::Isolate* isolate) { |
1282 #ifndef V8_SHARED | 1318 #ifndef V8_SHARED |
1283 if (i::FLAG_dump_counters) { | 1319 if (i::FLAG_dump_counters) { |
1284 int number_of_counters = 0; | 1320 int number_of_counters = 0; |
1285 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 1321 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
1286 number_of_counters++; | 1322 number_of_counters++; |
1287 } | 1323 } |
(...skipping 17 matching lines...) Expand all Loading... | |
1305 printf("| c:%-60s | %11i |\n", key, counter->count()); | 1341 printf("| c:%-60s | %11i |\n", key, counter->count()); |
1306 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); | 1342 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); |
1307 } else { | 1343 } else { |
1308 printf("| %-62s | %11i |\n", key, counter->count()); | 1344 printf("| %-62s | %11i |\n", key, counter->count()); |
1309 } | 1345 } |
1310 } | 1346 } |
1311 printf("+----------------------------------------------------------------+" | 1347 printf("+----------------------------------------------------------------+" |
1312 "-------------+\n"); | 1348 "-------------+\n"); |
1313 delete [] counters; | 1349 delete [] counters; |
1314 } | 1350 } |
1351 | |
1352 if (i::FLAG_trace_ignition_dispatches) { | |
1353 WriteInterpreterDispatchCounters(isolate); | |
1354 } | |
1355 | |
1315 delete counters_file_; | 1356 delete counters_file_; |
1316 delete counter_map_; | 1357 delete counter_map_; |
1317 #endif // !V8_SHARED | 1358 #endif // !V8_SHARED |
1318 } | 1359 } |
1319 | 1360 |
1320 | 1361 |
1321 | 1362 |
1322 static FILE* FOpen(const char* path, const char* mode) { | 1363 static FILE* FOpen(const char* path, const char* mode) { |
1323 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) | 1364 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) |
1324 FILE* result; | 1365 FILE* result; |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2498 } | 2539 } |
2499 | 2540 |
2500 } // namespace v8 | 2541 } // namespace v8 |
2501 | 2542 |
2502 | 2543 |
2503 #ifndef GOOGLE3 | 2544 #ifndef GOOGLE3 |
2504 int main(int argc, char* argv[]) { | 2545 int main(int argc, char* argv[]) { |
2505 return v8::Shell::Main(argc, argv); | 2546 return v8::Shell::Main(argc, argv); |
2506 } | 2547 } |
2507 #endif | 2548 #endif |
OLD | NEW |