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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 1423063005: VM: Speculative inlining in precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add retry Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 4184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 new(Z) Value(left), 4195 new(Z) Value(left),
4196 new(Z) Value(instantiator), 4196 new(Z) Value(instantiator),
4197 new(Z) Value(type_args), 4197 new(Z) Value(type_args),
4198 type, 4198 type,
4199 dst_name, 4199 dst_name,
4200 call->deopt_id()); 4200 call->deopt_id());
4201 ReplaceCall(call, assert_as); 4201 ReplaceCall(call, assert_as);
4202 } 4202 }
4203 4203
4204 4204
4205 bool FlowGraphOptimizer::IsBlackListed(intptr_t deopt_id) {
srdjan 2015/11/17 17:35:23 s/deopt_id/call_deopt_id/ makes it clearer IMO.
srdjan 2015/11/17 17:35:23 s/IsBlackListed/ IsBlackListedForInlining/
Florian Schneider 2015/11/17 19:38:56 Done.
Florian Schneider 2015/11/17 19:38:56 Done.
4206 for (intptr_t i = 0; i < inlining_black_list_->length(); ++i) {
4207 if ((*inlining_black_list_)[i] == deopt_id) return true;
4208 }
4209 return false;
4210 }
4211
4205 // Special optimizations when running in --noopt mode. 4212 // Special optimizations when running in --noopt mode.
4206 void FlowGraphOptimizer::InstanceCallNoopt(InstanceCallInstr* instr) { 4213 void FlowGraphOptimizer::InstanceCallNoopt(InstanceCallInstr* instr) {
4207 // TODO(srdjan): Investigate other attempts, as they are not allowed to 4214 // TODO(srdjan): Investigate other attempts, as they are not allowed to
4208 // deoptimize. 4215 // deoptimize.
4209 4216
4210 // Type test is special as it always gets converted into inlined code. 4217 // Type test is special as it always gets converted into inlined code.
4211 const Token::Kind op_kind = instr->token_kind(); 4218 const Token::Kind op_kind = instr->token_kind();
4212 if (Token::IsTypeTestOperator(op_kind)) { 4219 if (Token::IsTypeTestOperator(op_kind)) {
4213 ReplaceWithInstanceOf(instr); 4220 ReplaceWithInstanceOf(instr);
4214 return; 4221 return;
4215 } 4222 }
4216 if (Token::IsTypeCastOperator(op_kind)) { 4223 if (Token::IsTypeCastOperator(op_kind)) {
4217 ReplaceWithTypeCast(instr); 4224 ReplaceWithTypeCast(instr);
4218 return; 4225 return;
4219 } 4226 }
4220 4227
4221 if ((op_kind == Token::kGET) && 4228 if ((op_kind == Token::kGET) &&
4222 TryInlineInstanceGetter(instr, false /* no checks allowed */)) { 4229 TryInlineInstanceGetter(instr, false /* no checks allowed */)) {
4223 return; 4230 return;
4224 } 4231 }
4225 const ICData& unary_checks = 4232 const ICData& unary_checks =
4226 ICData::ZoneHandle(Z, instr->ic_data()->AsUnaryClassChecks()); 4233 ICData::ZoneHandle(Z, instr->ic_data()->AsUnaryClassChecks());
4227 if ((unary_checks.NumberOfChecks() > 0) && 4234 if ((unary_checks.NumberOfChecks() > 0) &&
4228 (op_kind == Token::kSET) && 4235 (op_kind == Token::kSET) &&
4229 TryInlineInstanceSetter(instr, unary_checks, false /* no checks */)) { 4236 TryInlineInstanceSetter(instr, unary_checks, false /* no checks */)) {
4230 return; 4237 return;
4231 } 4238 }
4232 4239
4240 if (use_speculative_inlining_ &&
4241 !IsBlackListed(instr->deopt_id()) &&
4242 unary_checks.NumberOfChecks() > 0) {
srdjan 2015/11/17 17:35:23 Add parentheses
Florian Schneider 2015/11/17 19:38:56 Done.
4243 if ((op_kind == Token::kINDEX) && TryReplaceWithIndexedOp(instr)) {
4244 return;
4245 }
4246 if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) {
4247 return;
4248 }
4249 if (op_kind == Token::kEQ && TryReplaceWithEqualityOp(instr, op_kind)) {
srdjan 2015/11/17 17:35:23 Add parentheses
Florian Schneider 2015/11/17 19:38:56 Done.
4250 return;
4251 }
4252
4253 if (Token::IsRelationalOperator(op_kind) &&
4254 TryReplaceWithRelationalOp(instr, op_kind)) {
4255 return;
4256 }
4257
4258 if (Token::IsBinaryOperator(op_kind) &&
4259 TryReplaceWithBinaryOp(instr, op_kind)) {
4260 return;
4261 }
4262 if (Token::IsUnaryOperator(op_kind) &&
4263 TryReplaceWithUnaryOp(instr, op_kind)) {
4264 return;
4265 }
4266 }
4267
4233 bool has_one_target = 4268 bool has_one_target =
4234 (unary_checks.NumberOfChecks() > 0) && unary_checks.HasOneTarget(); 4269 (unary_checks.NumberOfChecks() > 0) && unary_checks.HasOneTarget();
4235 if (has_one_target) { 4270 if (has_one_target) {
4236 // Check if the single target is a polymorphic target, if it is, 4271 // Check if the single target is a polymorphic target, if it is,
4237 // we don't have one target. 4272 // we don't have one target.
4238 const Function& target = 4273 const Function& target =
4239 Function::Handle(Z, unary_checks.GetTargetAt(0)); 4274 Function::Handle(Z, unary_checks.GetTargetAt(0));
4240 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); 4275 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target);
4241 has_one_target = !polymorphic_target; 4276 has_one_target = !polymorphic_target;
4242 } 4277 }
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
5169 Instruction* instr) { 5204 Instruction* instr) {
5170 return IsLoadEliminationCandidate(instr) && 5205 return IsLoadEliminationCandidate(instr) &&
5171 (sets != NULL) && 5206 (sets != NULL) &&
5172 instr->HasPlaceId() && 5207 instr->HasPlaceId() &&
5173 ((*sets)[loop_header_index] != NULL) && 5208 ((*sets)[loop_header_index] != NULL) &&
5174 (*sets)[loop_header_index]->Contains(instr->place_id()); 5209 (*sets)[loop_header_index]->Contains(instr->place_id());
5175 } 5210 }
5176 5211
5177 5212
5178 void LICM::OptimisticallySpecializeSmiPhis() { 5213 void LICM::OptimisticallySpecializeSmiPhis() {
5179 if (!flow_graph()->function().allows_hoisting_check_class()) { 5214 if (!flow_graph()->function().allows_hoisting_check_class() ||
5215 Compiler::always_optimize()) {
srdjan 2015/11/17 17:35:23 Add comment why not do it for precompilation.
Florian Schneider 2015/11/17 19:38:56 Done.
5180 // Do not hoist any. 5216 // Do not hoist any.
5181 return; 5217 return;
5182 } 5218 }
5183 5219
5184 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers = 5220 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers =
5185 flow_graph()->LoopHeaders(); 5221 flow_graph()->LoopHeaders();
5186 5222
5187 for (intptr_t i = 0; i < loop_headers.length(); ++i) { 5223 for (intptr_t i = 0; i < loop_headers.length(); ++i) {
5188 JoinEntryInstr* header = loop_headers[i]->AsJoinEntry(); 5224 JoinEntryInstr* header = loop_headers[i]->AsJoinEntry();
5189 // Skip loop that don't have a pre-header block. 5225 // Skip loop that don't have a pre-header block.
(...skipping 3599 matching lines...) Expand 10 before | Expand all | Expand 10 after
8789 8825
8790 // Insert materializations at environment uses. 8826 // Insert materializations at environment uses.
8791 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { 8827 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) {
8792 CreateMaterializationAt( 8828 CreateMaterializationAt(
8793 exits_collector_.exits()[i], alloc, *slots); 8829 exits_collector_.exits()[i], alloc, *slots);
8794 } 8830 }
8795 } 8831 }
8796 8832
8797 8833
8798 } // namespace dart 8834 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698