Skip to content

Commit

Permalink
[vm/compiler] Fix recent regressions due to inaccurate type merging
Browse files Browse the repository at this point in the history
This is the follow-up fix for
dart-lang/sdk@f81709c

As part of that change, merging of known cid and abstract type in
LoadFieldInstr::ComputeType() was done less precisely, loosing a chance
to calculate a more accurate abstract type if cid is known.

This change fixes the problem by resetting abstract type if cid is known.
Similar change is also applied to LoadStaticFieldInstr::ComputeType().

Change-Id: I2b7dfa961e26c0ea98e66aaf9b9afb235dfa5684
Reviewed-on: https://dart-review.googlesource.com/76723
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
  • Loading branch information
alexmarkov authored and commit-bot@chromium.org committed Sep 26, 2018
1 parent dcad8fe commit d9fb4b0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions runtime/vm/compiler/backend/type_propagator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ CompileType LoadStaticFieldInstr::ComputeType() const {
const Field& field = this->StaticField();
const Isolate* isolate = Isolate::Current();
if (isolate->can_use_strong_mode_types() || isolate->type_checks()) {
cid = kIllegalCid;
cid = kIllegalCid; // Abstract type is known, calculate cid lazily.
abstract_type = &AbstractType::ZoneHandle(field.type());
TraceStrongModeType(this, *abstract_type);
}
Expand All @@ -1262,12 +1262,14 @@ CompileType LoadStaticFieldInstr::ComputeType() const {
(obj.raw() != Object::transition_sentinel().raw()) && !obj.IsNull()) {
is_nullable = CompileType::kNonNullable;
cid = obj.GetClassId();
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
}
}
if ((field.guarded_cid() != kIllegalCid) &&
(field.guarded_cid() != kDynamicCid)) {
cid = field.guarded_cid();
is_nullable = field.is_nullable();
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
}
return CompileType(is_nullable, cid, abstract_type);
}
Expand Down Expand Up @@ -1310,16 +1312,20 @@ CompileType LoadFieldInstr::ComputeType() const {
if (isolate->can_use_strong_mode_types() ||
(isolate->type_checks() &&
(type().IsFunctionType() || type().HasResolvedTypeClass()))) {
cid = kIllegalCid;
cid = kIllegalCid; // Abstract type is known, calculate cid lazily.
abstract_type = &type();
TraceStrongModeType(this, *abstract_type);
}
if ((field_ != NULL) && (field_->guarded_cid() != kIllegalCid) &&
(field_->guarded_cid() != kDynamicCid)) {
cid = field_->guarded_cid();
is_nullable = field_->is_nullable();
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
} else {
cid = result_cid_;
if ((cid != kIllegalCid) && (cid != kDynamicCid)) {
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
}
}
return CompileType(is_nullable, cid, abstract_type);
}
Expand Down

0 comments on commit d9fb4b0

Please sign in to comment.