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

Side by Side Diff: src/compiler.cc

Issue 1661883003: [counters] adding more counters and log-events (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixing compilation issues 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 920
921 bool Compiler::ParseAndAnalyze(ParseInfo* info) { 921 bool Compiler::ParseAndAnalyze(ParseInfo* info) {
922 if (!Parser::ParseStatic(info)) return false; 922 if (!Parser::ParseStatic(info)) return false;
923 return Compiler::Analyze(info); 923 return Compiler::Analyze(info);
924 } 924 }
925 925
926 926
927 static bool GetOptimizedCodeNow(CompilationInfo* info) { 927 static bool GetOptimizedCodeNow(CompilationInfo* info) {
928 Isolate* isolate = info->isolate(); 928 Isolate* isolate = info->isolate();
929 CanonicalHandleScope canonical(isolate); 929 CanonicalHandleScope canonical(isolate);
930 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
930 931
931 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; 932 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false;
932 933
933 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate); 934 TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
934 935
935 OptimizedCompileJob job(info); 936 OptimizedCompileJob job(info);
936 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED || 937 if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED ||
937 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED || 938 job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED ||
938 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) { 939 job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) {
939 if (FLAG_trace_opt) { 940 if (FLAG_trace_opt) {
940 PrintF("[aborted optimizing "); 941 PrintF("[aborted optimizing ");
941 info->closure()->ShortPrint(); 942 info->closure()->ShortPrint();
942 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); 943 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
943 } 944 }
944 return false; 945 return false;
945 } 946 }
946 947
947 // Success! 948 // Success!
948 DCHECK(!isolate->has_pending_exception()); 949 DCHECK(!isolate->has_pending_exception());
949 InsertCodeIntoOptimizedCodeMap(info); 950 InsertCodeIntoOptimizedCodeMap(info);
950 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, 951 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info,
951 info->shared_info()); 952 info->shared_info());
952 return true; 953 return true;
953 } 954 }
954 955
955 956
956 static bool GetOptimizedCodeLater(CompilationInfo* info) { 957 static bool GetOptimizedCodeLater(CompilationInfo* info) {
957 Isolate* isolate = info->isolate(); 958 Isolate* isolate = info->isolate();
958 CanonicalHandleScope canonical(isolate); 959 CanonicalHandleScope canonical(isolate);
960 TimerEventScope<TimerEventOptimizeCode> optimize_code_timer(isolate);
959 961
960 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) { 962 if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) {
961 if (FLAG_trace_concurrent_recompilation) { 963 if (FLAG_trace_concurrent_recompilation) {
962 PrintF(" ** Compilation queue full, will retry optimizing "); 964 PrintF(" ** Compilation queue full, will retry optimizing ");
963 info->closure()->ShortPrint(); 965 info->closure()->ShortPrint();
964 PrintF(" later.\n"); 966 PrintF(" later.\n");
965 } 967 }
966 return false; 968 return false;
967 } 969 }
968 970
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 GetUnoptimizedCodeCommon(&info), 1008 GetUnoptimizedCodeCommon(&info),
1007 Code); 1009 Code);
1008 return result; 1010 return result;
1009 } 1011 }
1010 1012
1011 1013
1012 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) { 1014 MaybeHandle<Code> Compiler::GetLazyCode(Handle<JSFunction> function) {
1013 Isolate* isolate = function->GetIsolate(); 1015 Isolate* isolate = function->GetIsolate();
1014 DCHECK(!isolate->has_pending_exception()); 1016 DCHECK(!isolate->has_pending_exception());
1015 DCHECK(!function->is_compiled()); 1017 DCHECK(!function->is_compiled());
1018 TimerEventScope<TimerEventCompileCode> compile_timer(isolate);
1016 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); 1019 AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy());
1017 // If the debugger is active, do not compile with turbofan unless we can 1020 // If the debugger is active, do not compile with turbofan unless we can
1018 // deopt from turbofan code. 1021 // deopt from turbofan code.
1019 if (FLAG_turbo_asm && function->shared()->asm_function() && 1022 if (FLAG_turbo_asm && function->shared()->asm_function() &&
1020 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) && 1023 (FLAG_turbo_asm_deoptimization || !isolate->debug()->is_active()) &&
1021 !FLAG_turbo_osr) { 1024 !FLAG_turbo_osr) {
1022 CompilationInfoWithZone info(function); 1025 CompilationInfoWithZone info(function);
1023 1026
1024 VMState<COMPILER> state(isolate); 1027 VMState<COMPILER> state(isolate);
1025 PostponeInterruptsScope postpone(isolate); 1028 PostponeInterruptsScope postpone(isolate);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 Handle<ScopeInfo> scope_info = 1216 Handle<ScopeInfo> scope_info =
1214 ScopeInfo::Create(info.isolate(), info.zone(), info.scope()); 1217 ScopeInfo::Create(info.isolate(), info.zone(), info.scope());
1215 info.shared_info()->set_scope_info(*scope_info); 1218 info.shared_info()->set_scope_info(*scope_info);
1216 } 1219 }
1217 tracker.RecordRootFunctionInfo(info.code()); 1220 tracker.RecordRootFunctionInfo(info.code());
1218 } 1221 }
1219 1222
1220 1223
1221 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1224 static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1222 Isolate* isolate = info->isolate(); 1225 Isolate* isolate = info->isolate();
1226 TimerEventScope<TimerEventCompileCode> timer(isolate);
1223 PostponeInterruptsScope postpone(isolate); 1227 PostponeInterruptsScope postpone(isolate);
1224 DCHECK(!isolate->native_context().is_null()); 1228 DCHECK(!isolate->native_context().is_null());
1225 ParseInfo* parse_info = info->parse_info(); 1229 ParseInfo* parse_info = info->parse_info();
1226 Handle<Script> script = parse_info->script(); 1230 Handle<Script> script = parse_info->script();
1227 1231
1228 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 1232 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
1229 FixedArray* array = isolate->native_context()->embedder_data(); 1233 FixedArray* array = isolate->native_context()->embedder_data();
1230 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); 1234 script->set_context_data(array->get(v8::Context::kDebugIdIndex));
1231 1235
1232 isolate->debug()->OnBeforeCompile(script); 1236 isolate->debug()->OnBeforeCompile(script);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); 1614 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext();
1611 // Compile eagerly for live edit. When compiling debug code, eagerly compile 1615 // Compile eagerly for live edit. When compiling debug code, eagerly compile
1612 // unless we can lazily compile without the context. 1616 // unless we can lazily compile without the context.
1613 bool allow_lazy = literal->AllowsLazyCompilation() && 1617 bool allow_lazy = literal->AllowsLazyCompilation() &&
1614 !LiveEditFunctionTracker::IsActive(isolate) && 1618 !LiveEditFunctionTracker::IsActive(isolate) &&
1615 (!info.is_debug() || allow_lazy_without_ctx); 1619 (!info.is_debug() || allow_lazy_without_ctx);
1616 1620
1617 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile(); 1621 bool lazy = FLAG_lazy && allow_lazy && !literal->should_eager_compile();
1618 1622
1619 // Generate code 1623 // Generate code
1624 TimerEventScope<TimerEventCompileCode> timer(isolate);
1620 Handle<ScopeInfo> scope_info; 1625 Handle<ScopeInfo> scope_info;
1621 if (lazy) { 1626 if (lazy) {
1622 Handle<Code> code = isolate->builtins()->CompileLazy(); 1627 Handle<Code> code = isolate->builtins()->CompileLazy();
1623 info.SetCode(code); 1628 info.SetCode(code);
1624 // There's no need in theory for a lazy-compiled function to have a type 1629 // There's no need in theory for a lazy-compiled function to have a type
1625 // feedback vector, but some parts of the system expect all 1630 // feedback vector, but some parts of the system expect all
1626 // SharedFunctionInfo instances to have one. The size of the vector depends 1631 // SharedFunctionInfo instances to have one. The size of the vector depends
1627 // on how many feedback-needing nodes are in the tree, and when lazily 1632 // on how many feedback-needing nodes are in the tree, and when lazily
1628 // parsing we might not know that, if this function was never parsed before. 1633 // parsing we might not know that, if this function was never parsed before.
1629 // In that case the vector will be replaced the next time MakeCode is 1634 // In that case the vector will be replaced the next time MakeCode is
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 } 1873 }
1869 1874
1870 #if DEBUG 1875 #if DEBUG
1871 void CompilationInfo::PrintAstForTesting() { 1876 void CompilationInfo::PrintAstForTesting() {
1872 PrintF("--- Source from AST ---\n%s\n", 1877 PrintF("--- Source from AST ---\n%s\n",
1873 PrettyPrinter(isolate()).PrintProgram(literal())); 1878 PrettyPrinter(isolate()).PrintProgram(literal()));
1874 } 1879 }
1875 #endif 1880 #endif
1876 } // namespace internal 1881 } // namespace internal
1877 } // namespace v8 1882 } // 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