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

Side by Side Diff: src/compiler.cc

Issue 1863333004: [turbofan] Deprecate CompilationInfo::has_scope predicate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/compiler.h ('k') | src/compiler/ast-graph-builder.cc » ('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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 bool CompilationInfo::has_shared_info() const { 108 bool CompilationInfo::has_shared_info() const {
109 return parse_info_ && !parse_info_->shared_info().is_null(); 109 return parse_info_ && !parse_info_->shared_info().is_null();
110 } 110 }
111 111
112 112
113 bool CompilationInfo::has_context() const { 113 bool CompilationInfo::has_context() const {
114 return parse_info_ && !parse_info_->context().is_null(); 114 return parse_info_ && !parse_info_->context().is_null();
115 } 115 }
116 116
117 117
118 bool CompilationInfo::has_scope() const {
119 return parse_info_ && parse_info_->scope() != nullptr;
120 }
121
122
123 CompilationInfo::CompilationInfo(ParseInfo* parse_info) 118 CompilationInfo::CompilationInfo(ParseInfo* parse_info)
124 : CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION), 119 : CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION),
125 BASE, parse_info->isolate(), parse_info->zone()) { 120 BASE, parse_info->isolate(), parse_info->zone()) {
126 // Compiling for the snapshot typically results in different code than 121 // Compiling for the snapshot typically results in different code than
127 // compiling later on. This means that code recompiled with deoptimization 122 // compiling later on. This means that code recompiled with deoptimization
128 // support won't be "equivalent" (as defined by SharedFunctionInfo:: 123 // support won't be "equivalent" (as defined by SharedFunctionInfo::
129 // EnableDeoptimizationSupport), so it will replace the old code and all 124 // EnableDeoptimizationSupport), so it will replace the old code and all
130 // its type feedback. To avoid this, always compile functions in the snapshot 125 // its type feedback. To avoid this, always compile functions in the snapshot
131 // with deoptimization support. 126 // with deoptimization support.
132 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); 127 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 delete deferred_handles_; 169 delete deferred_handles_;
175 #ifdef DEBUG 170 #ifdef DEBUG
176 // Check that no dependent maps have been added or added dependent maps have 171 // Check that no dependent maps have been added or added dependent maps have
177 // been rolled back or committed. 172 // been rolled back or committed.
178 DCHECK(dependencies()->IsEmpty()); 173 DCHECK(dependencies()->IsEmpty());
179 #endif // DEBUG 174 #endif // DEBUG
180 } 175 }
181 176
182 177
183 int CompilationInfo::num_parameters() const { 178 int CompilationInfo::num_parameters() const {
184 return has_scope() ? scope()->num_parameters() : parameter_count_; 179 return !IsStub() ? scope()->num_parameters() : parameter_count_;
185 } 180 }
186 181
187 182
188 int CompilationInfo::num_parameters_including_this() const { 183 int CompilationInfo::num_parameters_including_this() const {
189 return num_parameters() + (is_this_defined() ? 1 : 0); 184 return num_parameters() + (is_this_defined() ? 1 : 0);
190 } 185 }
191 186
192 187
193 bool CompilationInfo::is_this_defined() const { return !IsStub(); } 188 bool CompilationInfo::is_this_defined() const { return !IsStub(); }
194 189
195 190
196 int CompilationInfo::num_heap_slots() const {
197 return has_scope() ? scope()->num_heap_slots() : 0;
198 }
199
200
201 // Primitive functions are unlikely to be picked up by the stack-walking 191 // Primitive functions are unlikely to be picked up by the stack-walking
202 // profiler, so they trigger their own optimization when they're called 192 // profiler, so they trigger their own optimization when they're called
203 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. 193 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time.
204 bool CompilationInfo::ShouldSelfOptimize() { 194 bool CompilationInfo::ShouldSelfOptimize() {
205 return FLAG_crankshaft && 195 return FLAG_crankshaft &&
206 !(literal()->flags() & AstProperties::kDontSelfOptimize) && 196 !(literal()->flags() & AstProperties::kDontSelfOptimize) &&
207 !literal()->dont_optimize() && 197 !literal()->dont_optimize() &&
208 literal()->scope()->AllowsLazyCompilation() && 198 literal()->scope()->AllowsLazyCompilation() &&
209 (!has_shared_info() || !shared_info()->optimization_disabled()); 199 (!has_shared_info() || !shared_info()->optimization_disabled());
210 } 200 }
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 Zone zone(shared->GetIsolate()->allocator()); 1380 Zone zone(shared->GetIsolate()->allocator());
1391 ParseInfo parse_info(&zone, shared); 1381 ParseInfo parse_info(&zone, shared);
1392 CompilationInfo info(&parse_info); 1382 CompilationInfo info(&parse_info);
1393 return CompileForDebugging(&info); 1383 return CompileForDebugging(&info);
1394 } 1384 }
1395 1385
1396 // TODO(turbofan): In the future, unoptimized code with deopt support could 1386 // TODO(turbofan): In the future, unoptimized code with deopt support could
1397 // be generated lazily once deopt is triggered. 1387 // be generated lazily once deopt is triggered.
1398 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { 1388 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
1399 DCHECK_NOT_NULL(info->literal()); 1389 DCHECK_NOT_NULL(info->literal());
1400 DCHECK(info->has_scope()); 1390 DCHECK_NOT_NULL(info->scope());
1401 Handle<SharedFunctionInfo> shared = info->shared_info(); 1391 Handle<SharedFunctionInfo> shared = info->shared_info();
1402 if (!shared->has_deoptimization_support()) { 1392 if (!shared->has_deoptimization_support()) {
1403 // TODO(titzer): just reuse the ParseInfo for the unoptimized compile. 1393 // TODO(titzer): just reuse the ParseInfo for the unoptimized compile.
1404 CompilationInfoWithZone unoptimized(info->closure()); 1394 CompilationInfoWithZone unoptimized(info->closure());
1405 // Note that we use the same AST that we will use for generating the 1395 // Note that we use the same AST that we will use for generating the
1406 // optimized code. 1396 // optimized code.
1407 ParseInfo* parse_info = unoptimized.parse_info(); 1397 ParseInfo* parse_info = unoptimized.parse_info();
1408 parse_info->set_literal(info->literal()); 1398 parse_info->set_literal(info->literal());
1409 parse_info->set_scope(info->scope()); 1399 parse_info->set_scope(info->scope());
1410 parse_info->set_context(info->context()); 1400 parse_info->set_context(info->context());
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 MaybeHandle<Code> code; 1898 MaybeHandle<Code> code;
1909 if (cached.code != nullptr) code = handle(cached.code); 1899 if (cached.code != nullptr) code = handle(cached.code);
1910 Handle<Context> native_context(function->context()->native_context()); 1900 Handle<Context> native_context(function->context()->native_context());
1911 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, 1901 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
1912 literals, BailoutId::None()); 1902 literals, BailoutId::None());
1913 } 1903 }
1914 } 1904 }
1915 1905
1916 } // namespace internal 1906 } // namespace internal
1917 } // namespace v8 1907 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698