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

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

Issue 2877713003: Eliminated with_checks variable (Closed)
Patch Set: Use return type from recognized methods for static calls Created 3 years, 7 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
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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 3338
3339 intptr_t PolymorphicInstanceCallInstr::CallCount() const { 3339 intptr_t PolymorphicInstanceCallInstr::CallCount() const {
3340 return targets().AggregateCallCount(); 3340 return targets().AggregateCallCount();
3341 } 3341 }
3342 3342
3343 3343
3344 // DBC does not support optimizing compiler and thus doesn't emit 3344 // DBC does not support optimizing compiler and thus doesn't emit
3345 // PolymorphicInstanceCallInstr. 3345 // PolymorphicInstanceCallInstr.
3346 #if !defined(TARGET_ARCH_DBC) 3346 #if !defined(TARGET_ARCH_DBC)
3347 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 3347 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
3348 if (!with_checks()) {
3349 ASSERT(targets().HasSingleTarget());
3350 const Function& target = targets().FirstTarget();
3351 compiler->GenerateStaticCall(deopt_id(), instance_call()->token_pos(),
3352 target, instance_call()->ArgumentCount(),
3353 instance_call()->argument_names(), locs(),
3354 ICData::Handle());
3355 return;
3356 }
3357
3358 compiler->EmitPolymorphicInstanceCall( 3348 compiler->EmitPolymorphicInstanceCall(
3359 targets_, *instance_call(), instance_call()->ArgumentCount(), 3349 targets_, *instance_call(), instance_call()->ArgumentCount(),
3360 instance_call()->argument_names(), deopt_id(), 3350 instance_call()->argument_names(), deopt_id(),
3361 instance_call()->token_pos(), locs(), complete(), total_call_count()); 3351 instance_call()->token_pos(), locs(), complete(), total_call_count());
3362 } 3352 }
3363 #endif 3353 #endif
3364 3354
3365 3355
3366 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType( 3356 RawType* PolymorphicInstanceCallInstr::ComputeRuntimeType(
3367 const CallTargets& targets) { 3357 const CallTargets& targets) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 const CallTargets* new_target = 3398 const CallTargets* new_target =
3409 FlowGraphCompiler::ResolveCallTargetsForReceiverCid( 3399 FlowGraphCompiler::ResolveCallTargetsForReceiverCid(
3410 receiver_cid, 3400 receiver_cid,
3411 String::Handle(flow_graph->zone(), ic_data()->target_name()), 3401 String::Handle(flow_graph->zone(), ic_data()->target_name()),
3412 Array::Handle(flow_graph->zone(), ic_data()->arguments_descriptor())); 3402 Array::Handle(flow_graph->zone(), ic_data()->arguments_descriptor()));
3413 if (new_target == NULL) { 3403 if (new_target == NULL) {
3414 // No specialization. 3404 // No specialization.
3415 return this; 3405 return this;
3416 } 3406 }
3417 3407
3418 const bool with_checks = false; 3408 ASSERT(new_target->HasSingleTarget());
Vyacheslav Egorov (Google) 2017/05/18 07:03:11 similar pattern
3419 const bool complete = false; 3409 const Function& target = new_target->FirstTarget();
3420 PolymorphicInstanceCallInstr* specialized = new PolymorphicInstanceCallInstr( 3410 ZoneGrowableArray<PushArgumentInstr*>* args = new (flow_graph->zone())
3421 this, *new_target, with_checks, complete); 3411 ZoneGrowableArray<PushArgumentInstr*>(ArgumentCount());
3412 for (intptr_t i = 0; i < ArgumentCount(); i++) {
3413 args->Add(PushArgumentAt(i));
3414 }
3415 StaticCallInstr* specialized = new (flow_graph->zone()) StaticCallInstr(
3416 token_pos(), target, argument_names(), args, deopt_id(), CallCount());
3422 flow_graph->InsertBefore(this, specialized, env(), FlowGraph::kValue); 3417 flow_graph->InsertBefore(this, specialized, env(), FlowGraph::kValue);
3423 return specialized; 3418 return specialized;
3424 } 3419 }
3425 3420
3426 3421
3427 Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) { 3422 Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) {
3428 if (!IsSureToCallSingleRecognizedTarget()) { 3423 if (!IsSureToCallSingleRecognizedTarget()) {
3429 return this; 3424 return this;
3430 } 3425 }
3431 3426
3432 const Function& target = targets().FirstTarget(); 3427 const Function& target = targets().FirstTarget();
3433 if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) { 3428 if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
3434 const AbstractType& type = 3429 const AbstractType& type =
3435 AbstractType::Handle(ComputeRuntimeType(targets_)); 3430 AbstractType::Handle(ComputeRuntimeType(targets_));
3436 if (!type.IsNull()) { 3431 if (!type.IsNull()) {
3437 return flow_graph->GetConstant(type); 3432 return flow_graph->GetConstant(type);
3438 } 3433 }
3439 } 3434 }
3440 3435
3441 return this; 3436 return this;
3442 } 3437 }
3443 3438
3444 3439
3445 bool PolymorphicInstanceCallInstr::IsSureToCallSingleRecognizedTarget() const { 3440 bool PolymorphicInstanceCallInstr::IsSureToCallSingleRecognizedTarget() const {
3446 if (FLAG_precompiled_mode && with_checks()) return false; 3441 if (FLAG_precompiled_mode) return false;
Vyacheslav Egorov (Google) 2017/05/18 07:03:11 You can check for && !complete() here to make this
3447 return targets_.HasSingleRecognizedTarget(); 3442 return targets_.HasSingleRecognizedTarget();
3448 } 3443 }
3449 3444
3450 3445
3451 Definition* StaticCallInstr::Canonicalize(FlowGraph* flow_graph) { 3446 Definition* StaticCallInstr::Canonicalize(FlowGraph* flow_graph) {
3452 if (!FLAG_precompiled_mode) { 3447 if (!FLAG_precompiled_mode) {
3453 return this; 3448 return this;
3454 } 3449 }
3455 3450
3456 if (function().recognized_kind() == MethodRecognizer::kObjectRuntimeType) { 3451 if (function().recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 "native function '%s' (%" Pd " arguments) cannot be found", 4178 "native function '%s' (%" Pd " arguments) cannot be found",
4184 native_name().ToCString(), function().NumParameters()); 4179 native_name().ToCString(), function().NumParameters());
4185 } 4180 }
4186 set_is_auto_scope(auto_setup_scope); 4181 set_is_auto_scope(auto_setup_scope);
4187 set_native_c_function(native_function); 4182 set_native_c_function(native_function);
4188 } 4183 }
4189 4184
4190 #undef __ 4185 #undef __
4191 4186
4192 } // namespace dart 4187 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698