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

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 c68f277692311605272ee04f5a0cced09fcf3624..5cd9aa82fbdc0161103c19e84e7edfd6dc308474 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -2586,6 +2586,37 @@ 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();
+ intptr_t result = -1;
+ for (intptr_t i = 0; i < data.length(); i += 2) {
+ if (data[i] == cid) {
+ result = data[i + 1];
+ break;
Florian Schneider 2016/04/18 14:57:28 Maybe something like: const intptr_t true_result
sra1 2016/04/19 03:19:18 Done.
+ }
+ }
+ if (result >= 0) {
+ if (kind() != Token::kIS) {
+ result = !result;
Ivan Posva 2016/04/18 04:37:46 intptr_t is not a boolean.
sra1 2016/04/19 03:19:18 Done.
+ }
+ if (result) {
Ivan Posva 2016/04/18 04:37:46 ditto.
sra1 2016/04/19 03:19:18 Done.
+ return flow_graph->GetConstant(Bool::True());
+ } else {
Florian Schneider 2016/04/18 14:57:28 Please check that we have test coverage for the ca
+ return flow_graph->GetConstant(Bool::False());
+ }
+ }
+
+ // TODO(sra): Handle misses if the instruction is not deoptimizing.
+ // TODO(sra): Handle nullable input, possible canonicalizing to a compare
+ // against `null`.
Florian Schneider 2016/04/18 14:59:41 Add a TODO to add support in the constant propagat
sra1 2016/04/19 03:19:18 Done.
+ 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