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

Side by Side Diff: src/runtime/runtime-internal.cc

Issue 1967123002: Add callstats.py run --refresh flag (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/runtime/runtime.h ('k') | tools/callstats.py » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/ast/prettyprinter.h" 8 #include "src/ast/prettyprinter.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 if (args.length() == 0) { 543 if (args.length() == 0) {
544 // Without arguments, the result is returned as a string. 544 // Without arguments, the result is returned as a string.
545 DCHECK_EQ(0, args.length()); 545 DCHECK_EQ(0, args.length());
546 std::stringstream stats_stream; 546 std::stringstream stats_stream;
547 isolate->counters()->runtime_call_stats()->Print(stats_stream); 547 isolate->counters()->runtime_call_stats()->Print(stats_stream);
548 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked( 548 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(
549 stats_stream.str().c_str()); 549 stats_stream.str().c_str());
550 isolate->counters()->runtime_call_stats()->Reset(); 550 isolate->counters()->runtime_call_stats()->Reset();
551 return *result; 551 return *result;
552 } else { 552 } else {
553 DCHECK_EQ(1, args.length()); 553 DCHECK_LE(args.length(), 2);
554 std::FILE* f; 554 std::FILE* f;
555 if (args[0]->IsString()) { 555 if (args[0]->IsString()) {
556 // With a string argument, the results are appended to that file. 556 // With a string argument, the results are appended to that file.
557 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 0); 557 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 0);
558 String::FlatContent flat = arg0->GetFlatContent(); 558 String::FlatContent flat = arg0->GetFlatContent();
559 const char* filename = 559 const char* filename =
560 reinterpret_cast<const char*>(&(flat.ToOneByteVector()[0])); 560 reinterpret_cast<const char*>(&(flat.ToOneByteVector()[0]));
561 f = std::fopen(filename, "a"); 561 f = std::fopen(filename, "a");
562 DCHECK_NOT_NULL(f); 562 DCHECK_NOT_NULL(f);
563 } else { 563 } else {
564 // With an integer argument, the results are written to stdout/stderr. 564 // With an integer argument, the results are written to stdout/stderr.
565 CONVERT_SMI_ARG_CHECKED(fd, 0); 565 CONVERT_SMI_ARG_CHECKED(fd, 0);
566 DCHECK(fd == 1 || fd == 2); 566 DCHECK(fd == 1 || fd == 2);
567 f = fd == 1 ? stdout : stderr; 567 f = fd == 1 ? stdout : stderr;
568 } 568 }
569 // The second argument (if any) is a message header to be printed.
570 if (args.length() >= 2) {
571 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 1);
572 arg1->PrintOn(f);
573 std::fputc('\n', f);
574 std::fflush(f);
575 }
569 OFStream stats_stream(f); 576 OFStream stats_stream(f);
570 isolate->counters()->runtime_call_stats()->Print(stats_stream); 577 isolate->counters()->runtime_call_stats()->Print(stats_stream);
571 isolate->counters()->runtime_call_stats()->Reset(); 578 isolate->counters()->runtime_call_stats()->Reset();
572 if (args[0]->IsString()) 579 if (args[0]->IsString())
573 std::fclose(f); 580 std::fclose(f);
574 else 581 else
575 std::fflush(f); 582 std::fflush(f);
576 return isolate->heap()->undefined_value(); 583 return isolate->heap()->undefined_value();
577 } 584 }
578 } 585 }
579 586
580 RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) { 587 RUNTIME_FUNCTION(Runtime_EnqueueMicrotask) {
581 HandleScope scope(isolate); 588 HandleScope scope(isolate);
582 DCHECK(args.length() == 1); 589 DCHECK(args.length() == 1);
583 CONVERT_ARG_HANDLE_CHECKED(JSFunction, microtask, 0); 590 CONVERT_ARG_HANDLE_CHECKED(JSFunction, microtask, 0);
584 isolate->EnqueueMicrotask(microtask); 591 isolate->EnqueueMicrotask(microtask);
585 return isolate->heap()->undefined_value(); 592 return isolate->heap()->undefined_value();
586 } 593 }
587 594
588 RUNTIME_FUNCTION(Runtime_RunMicrotasks) { 595 RUNTIME_FUNCTION(Runtime_RunMicrotasks) {
589 HandleScope scope(isolate); 596 HandleScope scope(isolate);
590 DCHECK(args.length() == 0); 597 DCHECK(args.length() == 0);
591 isolate->RunMicrotasks(); 598 isolate->RunMicrotasks();
592 return isolate->heap()->undefined_value(); 599 return isolate->heap()->undefined_value();
593 } 600 }
594 } // namespace internal 601 } // namespace internal
595 } // namespace v8 602 } // namespace v8
OLDNEW
« 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