Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: src/d8.cc

Issue 1817033002: [Interpreter] Add dispatch counters for each bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@fix-abort
Patch Set: Minor code cleanups. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/d8.h ('k') | src/external-reference-table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_dispatch_counters = reinterpret_cast<i::Isolate*>(isolate)
1285 ->interpreter()
1286 ->dispatch_counters();
1287 stream << '{';
1288 for (int counter_index = 0;
1289 counter_index <= static_cast<int>(i::interpreter::Bytecode::kLast);
1290 ++counter_index) {
1291 if (counter_index > 0) stream << ", ";
1292 i::interpreter::Bytecode bytecode =
1293 i::interpreter::Bytecodes::FromByte(counter_index);
1294 stream << '\"' << i::interpreter::Bytecodes::ToString(bytecode)
1295 << "\": " << handler_dispatch_counters[counter_index];
1296 }
1297 stream << '}';
1298 }
1278 #endif // !V8_SHARED 1299 #endif // !V8_SHARED
1279 1300
1280 1301
1281 void Shell::OnExit(v8::Isolate* isolate) { 1302 void Shell::OnExit(v8::Isolate* isolate) {
1282 #ifndef V8_SHARED 1303 #ifndef V8_SHARED
1283 if (i::FLAG_dump_counters) { 1304 if (i::FLAG_dump_counters) {
1284 int number_of_counters = 0; 1305 int number_of_counters = 0;
1285 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 1306 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
1286 number_of_counters++; 1307 number_of_counters++;
1287 } 1308 }
(...skipping 17 matching lines...) Expand all
1305 printf("| c:%-60s | %11i |\n", key, counter->count()); 1326 printf("| c:%-60s | %11i |\n", key, counter->count());
1306 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); 1327 printf("| t:%-60s | %11i |\n", key, counter->sample_total());
1307 } else { 1328 } else {
1308 printf("| %-62s | %11i |\n", key, counter->count()); 1329 printf("| %-62s | %11i |\n", key, counter->count());
1309 } 1330 }
1310 } 1331 }
1311 printf("+----------------------------------------------------------------+" 1332 printf("+----------------------------------------------------------------+"
1312 "-------------+\n"); 1333 "-------------+\n");
1313 delete [] counters; 1334 delete [] counters;
1314 } 1335 }
1336
1337 if (i::FLAG_trace_ignition_dispatches) {
1338 WriteInterpreterDispatchCounters(isolate);
1339 }
1340
1315 delete counters_file_; 1341 delete counters_file_;
1316 delete counter_map_; 1342 delete counter_map_;
1317 #endif // !V8_SHARED 1343 #endif // !V8_SHARED
1318 } 1344 }
1319 1345
1320 1346
1321 1347
1322 static FILE* FOpen(const char* path, const char* mode) { 1348 static FILE* FOpen(const char* path, const char* mode) {
1323 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) 1349 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1324 FILE* result; 1350 FILE* result;
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 } 2524 }
2499 2525
2500 } // namespace v8 2526 } // namespace v8
2501 2527
2502 2528
2503 #ifndef GOOGLE3 2529 #ifndef GOOGLE3
2504 int main(int argc, char* argv[]) { 2530 int main(int argc, char* argv[]) {
2505 return v8::Shell::Main(argc, argv); 2531 return v8::Shell::Main(argc, argv);
2506 } 2532 }
2507 #endif 2533 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | src/external-reference-table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698