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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 1847293002: VM: Improve single-target polymorphic calls. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 4 years, 9 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698