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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 1891353003: Canonicalize TestCidsInstr (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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') | no next file » | 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 4a64db8459a4504fe5bbd197e70142a36f8fb652..3869329698d03e1673511807f032458ec79c6663 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -2590,6 +2590,28 @@ Instruction* CheckClassIdInstr::Canonicalize(FlowGraph* flow_graph) {
}
+Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) {
+ CompileType* in_type = left()->Type();
+ intptr_t cid = in_type->ToCid();
+ if (cid == kDynamicCid) return this;
+
+ const ZoneGrowableArray<intptr_t>& data = cid_results();
+ const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
+ for (intptr_t i = 0; i < data.length(); i += 2) {
+ if (data[i] == cid) {
+ return (data[i + 1] == true_result)
+ ? flow_graph->GetConstant(Bool::True())
+ : flow_graph->GetConstant(Bool::False());
+ }
+ }
+
+ // TODO(sra): Handle misses if the instruction is not deoptimizing.
+ // TODO(sra): Handle nullable input, possibly canonicalizing to a compare
+ // against `null`.
+ return this;
+}
+
+
Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) {
if (field().guarded_cid() == kDynamicCid) {
return NULL; // Nothing to guard.
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698