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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 2891713002: Cleanup: Make CheckClassId instruction more general so it (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intermediate_language.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index cb1ed6f25e7b06495c70471598ae2ed39fd5974b..50112c99bef37eb86dfc262de6670c118aa4a307 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -144,8 +144,8 @@ bool Value::Equals(Value* other) const {
static int OrderById(CidRange* const* a, CidRange* const* b) {
// Negative if 'a' should sort before 'b'.
- ASSERT((*a)->cid_start == (*a)->cid_end);
- ASSERT((*b)->cid_start == (*b)->cid_end);
+ ASSERT((*a)->IsSingleCid());
+ ASSERT((*b)->IsSingleCid());
return (*a)->cid_start - (*b)->cid_start;
}
@@ -203,7 +203,7 @@ intptr_t Cids::ComputeHighestCid() const {
bool Cids::HasClassId(intptr_t cid) const {
for (int i = 0; i < length(); i++) {
- if (cid_ranges_[i]->cid_start <= cid && cid <= cid_ranges_[i]->cid_end) {
+ if (cid_ranges_[i]->Contains(cid)) {
return true;
}
}
@@ -277,7 +277,7 @@ void Cids::CreateHelper(Zone* zone,
bool Cids::IsMonomorphic() const {
if (length() != 1) return false;
- return cid_ranges_[0]->cid_start == cid_ranges_[0]->cid_end;
+ return cid_ranges_[0]->IsSingleCid();
}
@@ -301,7 +301,7 @@ CheckClassInstr::CheckClassInstr(Value* value,
ASSERT(number_of_checks > 0);
SetInputAt(0, value);
// Otherwise use CheckSmiInstr.
- ASSERT(number_of_checks != 1 || cids[0].cid_start != cids[0].cid_end ||
+ ASSERT(number_of_checks != 1 || !cids[0].IsSingleCid() ||
cids[0].cid_start != kSmiCid);
}
@@ -322,8 +322,10 @@ EffectSet CheckClassInstr::Dependencies() const {
EffectSet CheckClassIdInstr::Dependencies() const {
// Externalization of strings via the API can change the class-id.
- return Field::IsExternalizableCid(cid_) ? EffectSet::Externalization()
- : EffectSet::None();
+ for (intptr_t i = cids_.cid_start; i <= cids_.cid_end; i++) {
+ if (Field::IsExternalizableCid(i)) return EffectSet::Externalization();
+ }
+ return EffectSet::None();
}
@@ -2688,7 +2690,8 @@ Instruction* CheckClassInstr::Canonicalize(FlowGraph* flow_graph) {
Instruction* CheckClassIdInstr::Canonicalize(FlowGraph* flow_graph) {
if (value()->BindsToConstant()) {
const Object& constant_value = value()->BoundConstant();
- if (constant_value.IsSmi() && Smi::Cast(constant_value).Value() == cid_) {
+ if (constant_value.IsSmi() &&
+ cids_.Contains(Smi::Cast(constant_value).Value())) {
return NULL;
}
}

Powered by Google App Engine
This is Rietveld 408576698