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

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: Remove unused bailout reason, rebase on master. 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
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 <inttypes.h>
12 #include <stdlib.h> 13 #include <stdlib.h>
13 #include <string.h> 14 #include <string.h>
14 #include <sys/stat.h> 15 #include <sys/stat.h>
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>
(...skipping 12 matching lines...) Expand all
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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 Counter* counter; 1299 Counter* counter;
1298 const char* key; 1300 const char* key;
1299 }; 1301 };
1300 1302
1301 1303
1302 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { 1304 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) {
1303 return strcmp(lhs.key, rhs.key) < 0; 1305 return strcmp(lhs.key, rhs.key) < 0;
1304 } 1306 }
1305 #endif // !V8_SHARED 1307 #endif // !V8_SHARED
1306 1308
1309 void Shell::DumpHandlersDispatchCounters(FILE* stream, Isolate* isolate) {
rmcilroy 2016/04/05 10:00:45 WriteInterpreterDispatchCounters
Stefano Sanfilippo 2016/04/05 14:01:45 Done.
1310 uint32_t* handler_dispatch_counters = reinterpret_cast<i::Isolate*>(isolate)
1311 ->interpreter()
1312 ->handlers_dispatch_counters();
1313
1314 fputc('{', stream);
rmcilroy 2016/04/05 10:00:45 Can we just use an ostream instead of the c file o
Stefano Sanfilippo 2016/04/05 14:01:45 Done.
1315 for (int i = 0; i < i::interpreter::Interpreter::kCountersTableRowSize; ++i) {
1316 if (i > 0) fputs(", ", stream);
1317 i::interpreter::Bytecode bytecode = i::interpreter::Bytecodes::FromByte(i);
1318 fprintf(stream, "\"%s\": %" PRIu32,
1319 i::interpreter::Bytecodes::ToString(bytecode),
1320 handler_dispatch_counters[i]);
1321 }
1322 fputc('}', stream);
1323 }
1307 1324
1308 void Shell::OnExit(v8::Isolate* isolate) { 1325 void Shell::OnExit(v8::Isolate* isolate) {
1309 #ifndef V8_SHARED 1326 #ifndef V8_SHARED
1310 if (i::FLAG_dump_counters) { 1327 if (i::FLAG_dump_counters) {
1311 int number_of_counters = 0; 1328 int number_of_counters = 0;
1312 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 1329 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
1313 number_of_counters++; 1330 number_of_counters++;
1314 } 1331 }
1315 CounterAndKey* counters = new CounterAndKey[number_of_counters]; 1332 CounterAndKey* counters = new CounterAndKey[number_of_counters];
1316 int j = 0; 1333 int j = 0;
(...skipping 15 matching lines...) Expand all
1332 printf("| c:%-60s | %11i |\n", key, counter->count()); 1349 printf("| c:%-60s | %11i |\n", key, counter->count());
1333 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); 1350 printf("| t:%-60s | %11i |\n", key, counter->sample_total());
1334 } else { 1351 } else {
1335 printf("| %-62s | %11i |\n", key, counter->count()); 1352 printf("| %-62s | %11i |\n", key, counter->count());
1336 } 1353 }
1337 } 1354 }
1338 printf("+----------------------------------------------------------------+" 1355 printf("+----------------------------------------------------------------+"
1339 "-------------+\n"); 1356 "-------------+\n");
1340 delete [] counters; 1357 delete [] counters;
1341 } 1358 }
1359
1360 if (i::FLAG_ignition_count_handler_dispatches) {
1361 FILE* ignition_counters_stream =
1362 fopen(i::FLAG_ignition_handler_to_handler_output_file, "w");
rmcilroy 2016/04/05 10:00:45 nit - just do the open / close in WriteInterpreter
Stefano Sanfilippo 2016/04/05 14:01:45 I'd rather open the stream externally and pass it
1363 CHECK_NOT_NULL(ignition_counters_stream);
1364 DumpHandlersDispatchCounters(ignition_counters_stream, isolate);
1365 fclose(ignition_counters_stream);
1366 }
1367
1342 delete counters_file_; 1368 delete counters_file_;
1343 delete counter_map_; 1369 delete counter_map_;
1344 #endif // !V8_SHARED 1370 #endif // !V8_SHARED
1345 } 1371 }
1346 1372
1347 1373
1348 1374
1349 static FILE* FOpen(const char* path, const char* mode) { 1375 static FILE* FOpen(const char* path, const char* mode) {
1350 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) 1376 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1351 FILE* result; 1377 FILE* result;
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2533 } 2559 }
2534 2560
2535 } // namespace v8 2561 } // namespace v8
2536 2562
2537 2563
2538 #ifndef GOOGLE3 2564 #ifndef GOOGLE3
2539 int main(int argc, char* argv[]) { 2565 int main(int argc, char* argv[]) {
2540 return v8::Shell::Main(argc, argv); 2566 return v8::Shell::Main(argc, argv);
2541 } 2567 }
2542 #endif 2568 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698