Chromium Code Reviews| 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. |