Index: runtime/vm/aot_optimizer.cc |
diff --git a/runtime/vm/aot_optimizer.cc b/runtime/vm/aot_optimizer.cc |
index a30e36b328a0b24abbbb54cc6b4e084b11729764..f8b36d16dd7021ecfd9d660430d727e4efb3e867 100644 |
--- a/runtime/vm/aot_optimizer.cc |
+++ b/runtime/vm/aot_optimizer.cc |
@@ -448,35 +448,22 @@ void AotOptimizer::AddCheckSmi(Definition* to_check, |
} |
-Instruction* AotOptimizer::GetCheckClass(Definition* to_check, |
- const ICData& unary_checks, |
- intptr_t deopt_id, |
- TokenPosition token_pos) { |
- if ((unary_checks.NumberOfUsedChecks() == 1) && |
- unary_checks.HasReceiverClassId(kSmiCid)) { |
- return new (Z) CheckSmiInstr(new (Z) Value(to_check), deopt_id, token_pos); |
- } |
- return new (Z) CheckClassInstr(new (Z) Value(to_check), deopt_id, |
- unary_checks, token_pos); |
-} |
- |
- |
void AotOptimizer::AddCheckClass(Definition* to_check, |
- const ICData& unary_checks, |
+ const CallTargets& targets, |
intptr_t deopt_id, |
Environment* deopt_environment, |
Instruction* insert_before) { |
// Type propagation has not run yet, we cannot eliminate the check. |
- Instruction* check = GetCheckClass(to_check, unary_checks, deopt_id, |
- insert_before->token_pos()); |
+ Instruction* check = flow_graph_->GetCheckClass(to_check, targets, deopt_id, |
+ insert_before->token_pos()); |
InsertBefore(insert_before, check, deopt_environment, FlowGraph::kEffect); |
} |
void AotOptimizer::AddReceiverCheck(InstanceCallInstr* call) { |
AddCheckClass(call->ArgumentAt(0), |
- ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()), |
- call->deopt_id(), call->env(), call); |
+ *CallTargets::Create(Z, *call->ic_data(), 0), call->deopt_id(), |
Vyacheslav Egorov (Google)
2017/05/01 12:21:24
please add a comment to the numeric argument here
erikcorry
2017/05/05 15:15:51
Done.
|
+ call->env(), call); |
} |
@@ -500,9 +487,7 @@ static bool ArgIsAlways(intptr_t cid, |
bool AotOptimizer::TryReplaceWithIndexedOp(InstanceCallInstr* call) { |
// Check for monomorphic IC data. |
if (!call->HasICData()) return false; |
- const ICData& ic_data = |
- ICData::Handle(Z, call->ic_data()->AsUnaryClassChecks()); |
- if (!ic_data.NumberOfChecksIs(1)) { |
+ if (!call->ic_data()->NumberOfChecksIs(1)) { |
Vyacheslav Egorov (Google)
2017/05/01 12:21:24
these are not equivalent - as unary checks collaps
erikcorry
2017/05/05 15:15:51
Good catch, it does matter.
|
return false; |
} |
return FlowGraphInliner::TryReplaceInstanceCallWithInline( |
@@ -575,9 +560,9 @@ bool AotOptimizer::TryStringLengthOneEquality(InstanceCallInstr* call, |
right_val = new (Z) Value(right_instr->char_code()->definition()); |
to_remove_right = right_instr; |
} else { |
- const ICData& unary_checks_1 = |
- ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecksForArgNr(1)); |
- AddCheckClass(right, unary_checks_1, call->deopt_id(), call->env(), call); |
+ const CallTargets* targets_1 = |
+ CallTargets::Create(Z, *call->ic_data(), 1); |
+ AddCheckClass(right, *targets_1, call->deopt_id(), call->env(), call); |
Vyacheslav Egorov (Google)
2017/05/01 12:21:24
This code is repeated, so it could be a helper:
A
erikcorry
2017/05/05 15:15:51
Done.
|
// String-to-char-code instructions returns -1 (illegal charcode) if |
// string is not of length one. |
StringToCharCodeInstr* char_code_right = new (Z) |
@@ -713,13 +698,14 @@ bool AotOptimizer::TryReplaceWithEqualityOp(InstanceCallInstr* call, |
smi_or_null.Add(kNullCid); |
if (ICDataHasOnlyReceiverArgumentClassIds(ic_data, smi_or_null, |
smi_or_null)) { |
- const ICData& unary_checks_0 = |
- ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); |
- AddCheckClass(left, unary_checks_0, call->deopt_id(), call->env(), call); |
+ const CallTargets* targets_0 = |
+ CallTargets::Create(Z, *call->ic_data(), 0); |
+ AddCheckClass(left, *targets_0, call->deopt_id(), call->env(), call); |
+ |
+ const CallTargets* targets_1 = |
+ CallTargets::Create(Z, *call->ic_data(), 1); |
+ AddCheckClass(right, *targets_1, call->deopt_id(), call->env(), call); |
- const ICData& unary_checks_1 = |
- ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecksForArgNr(1)); |
- AddCheckClass(right, unary_checks_1, call->deopt_id(), call->env(), call); |
cid = kSmiCid; |
} else { |
// Shortcut for equality with null. |
@@ -1080,12 +1066,10 @@ bool AotOptimizer::InlineFloat32x4BinaryOp(InstanceCallInstr* call, |
Definition* left = call->ArgumentAt(0); |
Definition* right = call->ArgumentAt(1); |
// Type check left. |
- AddCheckClass(left, ICData::ZoneHandle( |
- Z, call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
+ AddCheckClass(left, *CallTargets::Create(Z, *call->ic_data(), 0), |
call->deopt_id(), call->env(), call); |
// Type check right. |
- AddCheckClass(right, ICData::ZoneHandle( |
- Z, call->ic_data()->AsUnaryClassChecksForArgNr(1)), |
+ AddCheckClass(right, *CallTargets::Create(Z, *call->ic_data(), 1), |
call->deopt_id(), call->env(), call); |
// Replace call. |
BinaryFloat32x4OpInstr* float32x4_bin_op = new (Z) BinaryFloat32x4OpInstr( |
@@ -1105,12 +1089,10 @@ bool AotOptimizer::InlineInt32x4BinaryOp(InstanceCallInstr* call, |
Definition* left = call->ArgumentAt(0); |
Definition* right = call->ArgumentAt(1); |
// Type check left. |
- AddCheckClass(left, ICData::ZoneHandle( |
- Z, call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
+ AddCheckClass(left, *CallTargets::Create(Z, *call->ic_data(), 0), |
call->deopt_id(), call->env(), call); |
// Type check right. |
- AddCheckClass(right, ICData::ZoneHandle( |
- Z, call->ic_data()->AsUnaryClassChecksForArgNr(1)), |
+ AddCheckClass(right, *CallTargets::Create(Z, *call->ic_data(), 1), |
call->deopt_id(), call->env(), call); |
// Replace call. |
BinaryInt32x4OpInstr* int32x4_bin_op = new (Z) BinaryInt32x4OpInstr( |
@@ -1129,13 +1111,11 @@ bool AotOptimizer::InlineFloat64x2BinaryOp(InstanceCallInstr* call, |
Definition* left = call->ArgumentAt(0); |
Definition* right = call->ArgumentAt(1); |
// Type check left. |
- AddCheckClass( |
- left, ICData::ZoneHandle(call->ic_data()->AsUnaryClassChecksForArgNr(0)), |
- call->deopt_id(), call->env(), call); |
+ AddCheckClass(left, *CallTargets::Create(Z, *call->ic_data(), 0), |
+ call->deopt_id(), call->env(), call); |
// Type check right. |
- AddCheckClass( |
- right, ICData::ZoneHandle(call->ic_data()->AsUnaryClassChecksForArgNr(1)), |
- call->deopt_id(), call->env(), call); |
+ AddCheckClass(right, *CallTargets::Create(Z, *call->ic_data(), 1), |
+ call->deopt_id(), call->env(), call); |
// Replace call. |
BinaryFloat64x2OpInstr* float64x2_bin_op = new (Z) BinaryFloat64x2OpInstr( |
op_kind, new (Z) Value(left), new (Z) Value(right), call->deopt_id()); |
@@ -1842,7 +1822,7 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
RawFunction::Kind function_kind = |
Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); |
if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { |
- CallTargets* targets = CallTargets::Create(Z, unary_checks); |
+ CallTargets* targets = CallTargets::Create(Z, unary_checks, 0); |
PolymorphicInstanceCallInstr* call = |
new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
/* with_checks = */ false, |
@@ -2037,7 +2017,7 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
return; |
} else if ((ic_data.raw() != ICData::null()) && |
!ic_data.NumberOfChecksIs(0)) { |
- CallTargets* targets = CallTargets::Create(Z, ic_data); |
+ CallTargets* targets = CallTargets::Create(Z, ic_data, 0); |
PolymorphicInstanceCallInstr* call = |
new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
/* with_checks = */ true, |
@@ -2054,7 +2034,7 @@ void AotOptimizer::VisitInstanceCall(InstanceCallInstr* instr) { |
ASSERT(!FLAG_polymorphic_with_deopt); |
// OK to use checks with PolymorphicInstanceCallInstr since no |
// deoptimization is allowed. |
- CallTargets* targets = CallTargets::Create(Z, *instr->ic_data()); |
+ CallTargets* targets = CallTargets::Create(Z, *instr->ic_data(), 0); |
PolymorphicInstanceCallInstr* call = |
new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
/* with_checks = */ true, |
@@ -2141,11 +2121,10 @@ void AotOptimizer::VisitStaticCall(StaticCallInstr* call) { |
MathMinMaxInstr* min_max = new (Z) MathMinMaxInstr( |
recognized_kind, new (Z) Value(call->ArgumentAt(0)), |
new (Z) Value(call->ArgumentAt(1)), call->deopt_id(), result_cid); |
- const ICData& unary_checks = |
- ICData::ZoneHandle(Z, ic_data.AsUnaryClassChecks()); |
- AddCheckClass(min_max->left()->definition(), unary_checks, |
+ const CallTargets* targets = CallTargets::Create(Z, ic_data, 0); |
+ AddCheckClass(min_max->left()->definition(), *targets, |
call->deopt_id(), call->env(), call); |
- AddCheckClass(min_max->right()->definition(), unary_checks, |
+ AddCheckClass(min_max->right()->definition(), *targets, |
call->deopt_id(), call->env(), call); |
ReplaceCall(call, min_max); |
} |