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

Unified Diff: runtime/vm/jit_optimizer.cc

Issue 2856543002: Use off-heap data for class check instructions (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/jit_optimizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/jit_optimizer.cc
diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc
index fb6ee1d43be1d01be334cbb573a14b2f57af868e..94205c9518b69cf52080e1d98b1d349a227a3ba3 100644
--- a/runtime/vm/jit_optimizer.cc
+++ b/runtime/vm/jit_optimizer.cc
@@ -389,35 +389,23 @@ void JitOptimizer::AddCheckSmi(Definition* to_check,
}
-Instruction* JitOptimizer::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 JitOptimizer::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 JitOptimizer::AddReceiverCheck(InstanceCallInstr* call) {
- AddCheckClass(call->ArgumentAt(0),
- ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()),
- call->deopt_id(), call->env(), call);
+ AddCheckClass(
+ call->ArgumentAt(0),
+ *CallTargets::Create(Z, *call->ic_data(), /* argument_number = */ 0),
+ call->deopt_id(), call->env(), call);
}
@@ -516,9 +504,9 @@ bool JitOptimizer::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);
// String-to-char-code instructions returns -1 (illegal charcode) if
// string is not of length one.
StringToCharCodeInstr* char_code_right = new (Z)
@@ -609,13 +597,13 @@ bool JitOptimizer::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 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);
cid = kSmiCid;
} else {
// Shortcut for equality with null.
@@ -980,12 +968,10 @@ bool JitOptimizer::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(
@@ -1005,12 +991,10 @@ bool JitOptimizer::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(
@@ -1029,13 +1013,11 @@ bool JitOptimizer::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());
@@ -1509,9 +1491,9 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
return;
}
- CallTargets* targets = CallTargets::Create(Z, unary_checks);
+ const CallTargets& targets = *CallTargets::CreateAndExpand(Z, unary_checks);
- bool has_one_target = targets->HasSingleTarget();
+ bool has_one_target = targets.HasSingleTarget();
if (has_one_target) {
// Check if the single target is a polymorphic target, if it is,
@@ -1519,7 +1501,7 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
const Function& target = Function::Handle(Z, unary_checks.GetTargetAt(0));
if (target.recognized_kind() == MethodRecognizer::kObjectRuntimeType) {
has_one_target = PolymorphicInstanceCallInstr::ComputeRuntimeType(
- *targets) != Type::null();
+ targets) != Type::null();
} else {
const bool polymorphic_target =
MethodRecognizer::PolymorphicTarget(target);
@@ -1532,7 +1514,7 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
const RawFunction::Kind function_kind = target.kind();
if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) {
PolymorphicInstanceCallInstr* call =
- new (Z) PolymorphicInstanceCallInstr(instr, *targets,
+ new (Z) PolymorphicInstanceCallInstr(instr, targets,
/* call_with_checks = */ false,
/* complete = */ false);
instr->ReplaceWith(call, current_iterator());
@@ -1564,7 +1546,7 @@ void JitOptimizer::VisitInstanceCall(InstanceCallInstr* instr) {
call_with_checks = true;
}
PolymorphicInstanceCallInstr* call =
- new (Z) PolymorphicInstanceCallInstr(instr, *targets, call_with_checks,
+ new (Z) PolymorphicInstanceCallInstr(instr, targets, call_with_checks,
/* complete = */ false);
instr->ReplaceWith(call, current_iterator());
}
@@ -1617,11 +1599,10 @@ void JitOptimizer::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);
}
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/jit_optimizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698