Chromium Code Reviews| 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) { | |
|
rmcilroy
2016/04/08 17:15:47
Actually thinking about it, let's move this functi
Stefano Sanfilippo
2016/04/08 18:10:02
Done.
| |
| 1282 std::ofstream stream(i::FLAG_trace_ignition_dispatches_output_file); | |
| 1283 | |
| 1284 uintptr_t* bytecode_dispatch_count_table = | |
| 1285 reinterpret_cast<i::Isolate*>(isolate) | |
| 1286 ->interpreter() | |
| 1287 ->bytecode_dispatch_count_table(); | |
| 1288 | |
| 1289 static const int kCountersTableRowSize = | |
| 1290 static_cast<int>(i::interpreter::Bytecode::kLast) + 1; | |
|
rmcilroy
2016/04/08 17:15:47
Update this constant name too.
Stefano Sanfilippo
2016/04/08 18:10:02
Done.
| |
| 1291 | |
| 1292 // Output is a JSON-encoded object of objects. | |
| 1293 // | |
| 1294 // Keys on the top level object are the source bytecodes, | |
| 1295 // and corresponding value are objects. Keys on these last are the | |
| 1296 // destinations of the dispatch and the value associated is a counter for | |
| 1297 // the correspondent source-destination dispatch chain. | |
| 1298 // | |
| 1299 // Only non-zero counters are written to file, but an entry in the top-level | |
| 1300 // object is always present, even if the value is empty because all counters | |
| 1301 // for that source are zero. | |
| 1302 | |
| 1303 stream << '{'; | |
| 1304 | |
| 1305 for (int from_index = 0; from_index < kCountersTableRowSize; ++from_index) { | |
| 1306 if (from_index > 0) stream << ",\n "; | |
| 1307 | |
| 1308 i::interpreter::Bytecode from_bytecode = | |
| 1309 i::interpreter::Bytecodes::FromByte(from_index); | |
| 1310 stream << "\"" << i::interpreter::Bytecodes::ToString(from_bytecode) | |
| 1311 << "\": {"; | |
| 1312 | |
| 1313 bool emitted_first = false; | |
| 1314 for (int to_index = 0; to_index < kCountersTableRowSize; ++to_index) { | |
| 1315 uintptr_t counter = | |
| 1316 bytecode_dispatch_count_table[from_index * kCountersTableRowSize + | |
| 1317 to_index]; | |
| 1318 if (counter > 0) { | |
| 1319 if (emitted_first) { | |
| 1320 stream << ", "; | |
| 1321 } else { | |
| 1322 emitted_first = true; | |
| 1323 } | |
| 1324 | |
| 1325 i::interpreter::Bytecode to_bytecode = | |
| 1326 i::interpreter::Bytecodes::FromByte(to_index); | |
| 1327 stream << '"' << i::interpreter::Bytecodes::ToString(to_bytecode) | |
| 1328 << "\": " << counter; | |
| 1329 } | |
| 1330 } | |
| 1331 | |
| 1332 stream << "}"; | |
| 1333 } | |
| 1334 stream << '}'; | |
| 1335 } | |
| 1336 | |
| 1278 #endif // !V8_SHARED | 1337 #endif // !V8_SHARED |
| 1279 | 1338 |
| 1280 | 1339 |
| 1281 void Shell::OnExit(v8::Isolate* isolate) { | 1340 void Shell::OnExit(v8::Isolate* isolate) { |
| 1282 #ifndef V8_SHARED | 1341 #ifndef V8_SHARED |
| 1283 if (i::FLAG_dump_counters) { | 1342 if (i::FLAG_dump_counters) { |
| 1284 int number_of_counters = 0; | 1343 int number_of_counters = 0; |
| 1285 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 1344 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
| 1286 number_of_counters++; | 1345 number_of_counters++; |
| 1287 } | 1346 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1305 printf("| c:%-60s | %11i |\n", key, counter->count()); | 1364 printf("| c:%-60s | %11i |\n", key, counter->count()); |
| 1306 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); | 1365 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); |
| 1307 } else { | 1366 } else { |
| 1308 printf("| %-62s | %11i |\n", key, counter->count()); | 1367 printf("| %-62s | %11i |\n", key, counter->count()); |
| 1309 } | 1368 } |
| 1310 } | 1369 } |
| 1311 printf("+----------------------------------------------------------------+" | 1370 printf("+----------------------------------------------------------------+" |
| 1312 "-------------+\n"); | 1371 "-------------+\n"); |
| 1313 delete [] counters; | 1372 delete [] counters; |
| 1314 } | 1373 } |
| 1374 | |
| 1375 if (i::FLAG_trace_ignition_dispatches) { | |
| 1376 WriteInterpreterDispatchCounters(isolate); | |
| 1377 } | |
| 1378 | |
| 1315 delete counters_file_; | 1379 delete counters_file_; |
| 1316 delete counter_map_; | 1380 delete counter_map_; |
| 1317 #endif // !V8_SHARED | 1381 #endif // !V8_SHARED |
| 1318 } | 1382 } |
| 1319 | 1383 |
| 1320 | 1384 |
| 1321 | 1385 |
| 1322 static FILE* FOpen(const char* path, const char* mode) { | 1386 static FILE* FOpen(const char* path, const char* mode) { |
| 1323 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) | 1387 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) |
| 1324 FILE* result; | 1388 FILE* result; |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2498 } | 2562 } |
| 2499 | 2563 |
| 2500 } // namespace v8 | 2564 } // namespace v8 |
| 2501 | 2565 |
| 2502 | 2566 |
| 2503 #ifndef GOOGLE3 | 2567 #ifndef GOOGLE3 |
| 2504 int main(int argc, char* argv[]) { | 2568 int main(int argc, char* argv[]) { |
| 2505 return v8::Shell::Main(argc, argv); | 2569 return v8::Shell::Main(argc, argv); |
| 2506 } | 2570 } |
| 2507 #endif | 2571 #endif |
| OLD | NEW |