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

Unified Diff: src/runtime/runtime-internal.cc

Issue 1966193002: Add script injection when replaying with callstats.py (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | tools/callstats.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-internal.cc
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc
index ffaea8d1a1200242f13d23b6492bc35a7ee46963..d42c45bc4fc4ab4f2008fa98c2dff6295094a969 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -497,13 +497,41 @@ RUNTIME_FUNCTION(Runtime_GetOrdinaryHasInstance) {
RUNTIME_FUNCTION(Runtime_GetAndResetRuntimeCallStats) {
HandleScope scope(isolate);
- DCHECK_EQ(0, args.length());
- std::stringstream stats_stream;
- isolate->counters()->runtime_call_stats()->Print(stats_stream);
- Handle<String> result =
- isolate->factory()->NewStringFromAsciiChecked(stats_stream.str().c_str());
- isolate->counters()->runtime_call_stats()->Reset();
- return *result;
+ if (args.length() == 0) {
+ // Without arguments, the result is returned as a string.
+ DCHECK_EQ(0, args.length());
+ std::stringstream stats_stream;
+ isolate->counters()->runtime_call_stats()->Print(stats_stream);
+ Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(
+ stats_stream.str().c_str());
+ isolate->counters()->runtime_call_stats()->Reset();
+ return *result;
+ } else {
+ DCHECK_EQ(1, args.length());
+ std::FILE* f;
+ if (args[0]->IsString()) {
+ // With a string argument, the results are appended to that file.
+ CONVERT_ARG_HANDLE_CHECKED(String, arg0, 0);
+ String::FlatContent flat = arg0->GetFlatContent();
+ const char* filename =
+ reinterpret_cast<const char*>(&(flat.ToOneByteVector()[0]));
+ f = std::fopen(filename, "a");
+ DCHECK_NOT_NULL(f);
+ } else {
+ // With an integer argument, the results are written to stdout/stderr.
+ CONVERT_SMI_ARG_CHECKED(fd, 0);
+ DCHECK(fd == 1 || fd == 2);
+ f = fd == 1 ? stdout : stderr;
+ }
+ OFStream stats_stream(f);
+ isolate->counters()->runtime_call_stats()->Print(stats_stream);
+ isolate->counters()->runtime_call_stats()->Reset();
+ if (args[0]->IsString())
+ std::fclose(f);
+ else
+ std::fflush(f);
+ return isolate->heap()->undefined_value();
+ }
}
RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
« no previous file with comments | « src/runtime/runtime.h ('k') | tools/callstats.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698