[vm/compiler] Partially revert "Replace LoadClassId for known cids."

We still need to check for concrete types in
ConstantPropagator::VisitLoadClassId to avoid benchmark regressions.

Change-Id: Ie3a7e3aaa3b261c34760308f3cb1d328ce2d8493
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103520
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Teagan Strickland 2019-05-24 09:56:59 +00:00 committed by commit-bot@chromium.org
parent c20802ce16
commit d7054690ab

View file

@ -856,9 +856,23 @@ void ConstantPropagator::VisitLoadUntagged(LoadUntaggedInstr* instr) {
}
void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) {
// This first part duplicates the work done in LoadClassIdInstr::Canonicalize,
// which replaces uses of LoadClassIdInstr where the object has a concrete
// type with a Constant. Canonicalize runs before the ConstantPropagation
// pass, so if that was all, this wouldn't be needed.
//
// However, the ConstantPropagator also runs as part of OptimizeBranches, and
// TypePropagation runs between it and the previous Canonicalize. Thus, the
// type may have become concrete and we should take that into account. Not
// doing so led to some benchmark regressions.
intptr_t cid = instr->object()->Type()->ToCid();
if (cid != kDynamicCid) {
SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid)));
return;
}
const Object& object = instr->object()->definition()->constant_value();
if (IsConstant(object)) {
const intptr_t cid = object.GetClassId();
cid = object.GetClassId();
SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid)));
return;
}