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

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: 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 += FixedArray::SizeFor(bytecode_array->constant_pool()->length());
Michael Starzinger 2016/02/01 17:47:19 nit: Please use HeapObject::Size here.
rmcilroy 2016/02/02 16:21:39 Done.
764 size += FixedArray::SizeFor(bytecode_array->handler_table()->length());
Michael Starzinger 2016/02/01 17:47:19 Likewise.
rmcilroy 2016/02/02 16:21:39 Done.
765 size +=
766 FixedArray::SizeFor(bytecode_array->source_position_table()->length());
Michael Starzinger 2016/02/01 17:47:19 Likwise.
rmcilroy 2016/02/02 16:21:39 Done.
767 } else {
768 Handle<Code> code = info->code();
769 size += code->CodeSize();
770 size += code->relocation_info()->Size();
771 size += FixedArray::SizeFor(code->deoptimization_data()->length());
Michael Starzinger 2016/02/01 17:47:19 Likewise.
rmcilroy 2016/02/02 16:21:39 Done.
772 size += FixedArray::SizeFor(code->handler_table()->length());
Michael Starzinger 2016/02/01 17:47:19 Likewise.
rmcilroy 2016/02/02 16:21:39 Done.
773 }
774 return size;
775 }
776
759 777
760 static bool GenerateBaselineCode(CompilationInfo* info) { 778 static bool GenerateBaselineCode(CompilationInfo* info) {
779 bool success;
761 if (FLAG_ignition && UseIgnition(info)) { 780 if (FLAG_ignition && UseIgnition(info)) {
762 return interpreter::Interpreter::MakeBytecode(info); 781 success = interpreter::Interpreter::MakeBytecode(info);
763 } else { 782 } else {
764 return FullCodeGenerator::MakeCode(info); 783 success = FullCodeGenerator::MakeCode(info);
765 } 784 }
785 if (success) {
786 Isolate* isolate = info->isolate();
787 Counters* counters = isolate->counters();
788 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info));
789 counters->total_baseline_compile_count()->Increment(1);
790 }
791 return success;
766 } 792 }
767 793
768 794
769 static bool CompileBaselineCode(CompilationInfo* info) { 795 static bool CompileBaselineCode(CompilationInfo* info) {
770 DCHECK(AllowCompilation::IsAllowed(info->isolate())); 796 DCHECK(AllowCompilation::IsAllowed(info->isolate()));
771 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) { 797 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) {
772 Isolate* isolate = info->isolate(); 798 Isolate* isolate = info->isolate();
773 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 799 if (!isolate->has_pending_exception()) isolate->StackOverflow();
774 return false; 800 return false;
775 } 801 }
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 } 1863 }
1838 1864
1839 #if DEBUG 1865 #if DEBUG
1840 void CompilationInfo::PrintAstForTesting() { 1866 void CompilationInfo::PrintAstForTesting() {
1841 PrintF("--- Source from AST ---\n%s\n", 1867 PrintF("--- Source from AST ---\n%s\n",
1842 PrettyPrinter(isolate()).PrintProgram(literal())); 1868 PrettyPrinter(isolate()).PrintProgram(literal()));
1843 } 1869 }
1844 #endif 1870 #endif
1845 } // namespace internal 1871 } // namespace internal
1846 } // namespace v8 1872 } // 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