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

Side by Side Diff: src/d8.cc

Issue 1899133004: [Interpreter] Add Ignition statistics JavaScript extension. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 7 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/extensions/ignition-statistics-extension.h » ('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 15
16 #ifdef V8_SHARED 16 #ifdef V8_SHARED
17 #include <assert.h> 17 #include <assert.h>
18 #endif // V8_SHARED 18 #endif // V8_SHARED
19 19
20 #ifndef V8_SHARED 20 #ifndef V8_SHARED
21 #include <algorithm> 21 #include <algorithm>
22 #include <fstream>
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
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 #ifndef V8_SHARED 1270 #ifndef V8_SHARED
1270 struct CounterAndKey { 1271 struct CounterAndKey {
1271 Counter* counter; 1272 Counter* counter;
1272 const char* key; 1273 const char* key;
1273 }; 1274 };
1274 1275
1275 1276
1276 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { 1277 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) {
1277 return strcmp(lhs.key, rhs.key) < 0; 1278 return strcmp(lhs.key, rhs.key) < 0;
1278 } 1279 }
1280
1281 void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
1282 HandleScope handle_scope(isolate);
1283 Local<Context> context = Context::New(isolate);
1284 Context::Scope context_scope(context);
1285
1286 Local<Object> dispatch_counters = reinterpret_cast<i::Isolate*>(isolate)
1287 ->interpreter()
1288 ->GetDispatchCountersObject();
1289 std::ofstream dispatch_counters_stream(
1290 i::FLAG_trace_ignition_dispatches_output_file);
1291 dispatch_counters_stream << *String::Utf8Value(
1292 JSON::Stringify(context, dispatch_counters).ToLocalChecked());
1293 }
1294
1279 #endif // !V8_SHARED 1295 #endif // !V8_SHARED
1280 1296
1281 1297
1282 void Shell::OnExit(v8::Isolate* isolate) { 1298 void Shell::OnExit(v8::Isolate* isolate) {
1283 #ifndef V8_SHARED 1299 #ifndef V8_SHARED
1284 if (i::FLAG_dump_counters) { 1300 if (i::FLAG_dump_counters) {
1285 int number_of_counters = 0; 1301 int number_of_counters = 0;
1286 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 1302 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
1287 number_of_counters++; 1303 number_of_counters++;
1288 } 1304 }
(...skipping 18 matching lines...) Expand all
1307 printf("| t:%-60s | %11i |\n", key, counter->sample_total()); 1323 printf("| t:%-60s | %11i |\n", key, counter->sample_total());
1308 } else { 1324 } else {
1309 printf("| %-62s | %11i |\n", key, counter->count()); 1325 printf("| %-62s | %11i |\n", key, counter->count());
1310 } 1326 }
1311 } 1327 }
1312 printf("+----------------------------------------------------------------+" 1328 printf("+----------------------------------------------------------------+"
1313 "-------------+\n"); 1329 "-------------+\n");
1314 delete [] counters; 1330 delete [] counters;
1315 } 1331 }
1316 1332
1317 if (i::FLAG_trace_ignition_dispatches) {
1318 reinterpret_cast<i::Isolate*>(isolate)
1319 ->interpreter()
1320 ->WriteDispatchCounters();
1321 }
1322
1323 delete counters_file_; 1333 delete counters_file_;
1324 delete counter_map_; 1334 delete counter_map_;
1325 #endif // !V8_SHARED 1335 #endif // !V8_SHARED
1326 } 1336 }
1327 1337
1328 1338
1329 1339
1330 static FILE* FOpen(const char* path, const char* mode) { 1340 static FILE* FOpen(const char* path, const char* mode) {
1331 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) 1341 #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
1332 FILE* result; 1342 FILE* result;
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 bool last_run = true; 2487 bool last_run = true;
2478 result = RunMain(isolate, argc, argv, last_run); 2488 result = RunMain(isolate, argc, argv, last_run);
2479 } 2489 }
2480 2490
2481 // Run interactive shell if explicitly requested or if no script has been 2491 // Run interactive shell if explicitly requested or if no script has been
2482 // executed, but never on --test 2492 // executed, but never on --test
2483 if (options.use_interactive_shell()) { 2493 if (options.use_interactive_shell()) {
2484 RunShell(isolate); 2494 RunShell(isolate);
2485 } 2495 }
2486 2496
2497 #ifndef V8_SHARED
2498 if (i::FLAG_ignition && i::FLAG_trace_ignition_dispatches) {
2499 WriteIgnitionDispatchCountersFile(isolate);
2500 }
2501 #endif
2502
2487 // Shut down contexts and collect garbage. 2503 // Shut down contexts and collect garbage.
2488 evaluation_context_.Reset(); 2504 evaluation_context_.Reset();
2489 #ifndef V8_SHARED 2505 #ifndef V8_SHARED
2490 stringify_function_.Reset(); 2506 stringify_function_.Reset();
2491 #endif // !V8_SHARED 2507 #endif // !V8_SHARED
2492 CollectGarbage(isolate); 2508 CollectGarbage(isolate);
2493 } 2509 }
2494 OnExit(isolate); 2510 OnExit(isolate);
2495 #ifndef V8_SHARED 2511 #ifndef V8_SHARED
2496 // Dump basic block profiling data. 2512 // Dump basic block profiling data.
(...skipping 12 matching lines...) Expand all
2509 } 2525 }
2510 2526
2511 } // namespace v8 2527 } // namespace v8
2512 2528
2513 2529
2514 #ifndef GOOGLE3 2530 #ifndef GOOGLE3
2515 int main(int argc, char* argv[]) { 2531 int main(int argc, char* argv[]) {
2516 return v8::Shell::Main(argc, argv); 2532 return v8::Shell::Main(argc, argv);
2517 } 2533 }
2518 #endif 2534 #endif
OLDNEW
« no previous file with comments | « src/d8.h ('k') | src/extensions/ignition-statistics-extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698