Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc |
| index 59cb8ab3e5827940d860dd5b0e9d4ed02c90e3be..b9382a9e39086d1ab25160eac9d99cb45822449f 100644 |
| --- a/runtime/vm/intermediate_language.cc |
| +++ b/runtime/vm/intermediate_language.cc |
| @@ -133,6 +133,7 @@ CheckClassInstr::CheckClassInstr(Value* value, |
| unary_checks_(unary_checks), |
| cids_(unary_checks.NumberOfChecks()), |
| licm_hoisted_(false), |
| + is_dense_switch_(IsDenseCidRange(unary_checks)), |
| token_pos_(token_pos) { |
| ASSERT(unary_checks.IsZoneHandle()); |
| // Expected useful check data. |
| @@ -231,14 +232,22 @@ bool CheckClassInstr::DeoptIfNotNull() const { |
| } |
| +bool CheckClassInstr::IsDenseCidRange(const ICData& unary_checks) { |
|
srdjan
2016/04/01 18:11:29
Assert that 'unary_checks' are unary.
Florian Schneider
2016/04/03 04:39:52
Done.
|
| + if (unary_checks.GetReceiverClassIdAt(0) == kSmiCid) return false; |
|
srdjan
2016/04/01 18:11:29
You may want to allow Smi checks since they have t
Florian Schneider
2016/04/03 04:39:52
I'll add a TODO for now.
|
| + if (unary_checks.NumberOfChecks() <= 2) return false; |
| + intptr_t max = 0; |
| + intptr_t min = kIntptrMax; |
| + for (intptr_t i = 0; i < unary_checks.NumberOfChecks(); ++i) { |
| + intptr_t cid = unary_checks.GetCidAt(i); |
| + if (cid < min) min = cid; |
| + if (cid > max) max = cid; |
| + } |
| + return (max - min) < kBitsPerWord; |
| +} |
| + |
| bool CheckClassInstr::IsDenseSwitch() const { |
| - if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) return false; |
| - if (cids_.length() > 2 && |
| - cids_[cids_.length() - 1] - cids_[0] < kBitsPerWord) { |
| - return true; |
| - } |
| - return false; |
| + return is_dense_switch_; |
| } |