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

Side by Side Diff: src/compiler.cc

Issue 1649743002: Add counters to trace baseline code size. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_trace_bc
Patch Set: Review Comments Created 4 years, 10 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 | « no previous file | src/counters.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 #include "src/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "src/ast/ast-numbering.h" 9 #include "src/ast/ast-numbering.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 String* script_name = script->name()->IsString() 720 String* script_name = script->name()->IsString()
721 ? String::cast(script->name()) 721 ? String::cast(script->name())
722 : info->isolate()->heap()->empty_string(); 722 : info->isolate()->heap()->empty_string();
723 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script); 723 Logger::LogEventsAndTags log_tag = Logger::ToNativeByScript(tag, *script);
724 PROFILE(info->isolate(), 724 PROFILE(info->isolate(),
725 CodeCreateEvent(log_tag, *code, *shared, info, script_name, 725 CodeCreateEvent(log_tag, *code, *shared, info, script_name,
726 line_num, column_num)); 726 line_num, column_num));
727 } 727 }
728 } 728 }
729 729
730
731 static bool CompileUnoptimizedCode(CompilationInfo* info) { 730 static bool CompileUnoptimizedCode(CompilationInfo* info) {
732 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 731 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
733 if (!Compiler::Analyze(info->parse_info()) || 732 if (!Compiler::Analyze(info->parse_info()) ||
734 !FullCodeGenerator::MakeCode(info)) { 733 !FullCodeGenerator::MakeCode(info)) {
735 Isolate* isolate = info->isolate(); 734 Isolate* isolate = info->isolate();
736 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 735 if (!isolate->has_pending_exception()) isolate->StackOverflow();
737 return false; 736 return false;
738 } 737 }
739 return true; 738 return true;
740 } 739 }
741 740
742 741
743 static bool UseIgnition(CompilationInfo* info) { 742 static bool UseIgnition(CompilationInfo* info) {
744 // Cannot use Ignition when the {function_data} is already used. 743 // Cannot use Ignition when the {function_data} is already used.
745 if (info->has_shared_info() && info->shared_info()->HasBuiltinFunctionId()) { 744 if (info->has_shared_info() && info->shared_info()->HasBuiltinFunctionId()) {
746 return false; 745 return false;
747 } 746 }
748 747
749 // Checks whether top level functions should be passed by the filter. 748 // Checks whether top level functions should be passed by the filter.
750 if (info->closure().is_null()) { 749 if (info->closure().is_null()) {
751 Vector<const char> filter = CStrVector(FLAG_ignition_filter); 750 Vector<const char> filter = CStrVector(FLAG_ignition_filter);
752 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); 751 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
753 } 752 }
754 753
755 // Finally respect the filter. 754 // Finally respect the filter.
756 return info->closure()->PassesFilter(FLAG_ignition_filter); 755 return info->closure()->PassesFilter(FLAG_ignition_filter);
757 } 756 }
758 757
758 static int CodeAndMetadataSize(CompilationInfo* info) {
759 int size = 0;
760 if (info->has_bytecode_array()) {
761 Handle<BytecodeArray> bytecode_array = info->bytecode_array();
762 size += bytecode_array->BytecodeArraySize();
763 size += bytecode_array->constant_pool()->Size();
764 size += bytecode_array->handler_table()->Size();
765 size += bytecode_array->source_position_table()->Size();
766 } else {
767 Handle<Code> code = info->code();
768 size += code->CodeSize();
769 size += code->relocation_info()->Size();
770 size += code->deoptimization_data()->Size();
771 size += code->handler_table()->Size();
772 }
773 return size;
774 }
775
759 776
760 static bool GenerateBaselineCode(CompilationInfo* info) { 777 static bool GenerateBaselineCode(CompilationInfo* info) {
778 bool success;
761 if (FLAG_ignition && UseIgnition(info)) { 779 if (FLAG_ignition && UseIgnition(info)) {
762 return interpreter::Interpreter::MakeBytecode(info); 780 success = interpreter::Interpreter::MakeBytecode(info);
763 } else { 781 } else {
764 return FullCodeGenerator::MakeCode(info); 782 success = FullCodeGenerator::MakeCode(info);
765 } 783 }
784 if (success) {
785 Isolate* isolate = info->isolate();
786 Counters* counters = isolate->counters();
787 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info));
788 counters->total_baseline_compile_count()->Increment(1);
789 }
790 return success;
766 } 791 }
767 792
768 793
769 static bool CompileBaselineCode(CompilationInfo* info) { 794 static bool CompileBaselineCode(CompilationInfo* info) {
770 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 795 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
771 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) { 796 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) {
772 Isolate* isolate = info->isolate(); 797 Isolate* isolate = info->isolate();
773 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 798 if (!isolate->has_pending_exception()) isolate->StackOverflow();
774 return false; 799 return false;
775 } 800 }
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 } 1862 }
1838 1863
1839 #if DEBUG 1864 #if DEBUG
1840 void CompilationInfo::PrintAstForTesting() { 1865 void CompilationInfo::PrintAstForTesting() {
1841 PrintF("--- Source from AST ---\n%s\n", 1866 PrintF("--- Source from AST ---\n%s\n",
1842 PrettyPrinter(isolate()).PrintProgram(literal())); 1867 PrettyPrinter(isolate()).PrintProgram(literal()));
1843 } 1868 }
1844 #endif 1869 #endif
1845 } // namespace internal 1870 } // namespace internal
1846 } // namespace v8 1871 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698