Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/constant_propagator.h" | 10 #include "vm/constant_propagator.h" |
| (...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2579 const Object& constant_value = value()->BoundConstant(); | 2579 const Object& constant_value = value()->BoundConstant(); |
| 2580 if (constant_value.IsSmi() && | 2580 if (constant_value.IsSmi() && |
| 2581 Smi::Cast(constant_value).Value() == cid_) { | 2581 Smi::Cast(constant_value).Value() == cid_) { |
| 2582 return NULL; | 2582 return NULL; |
| 2583 } | 2583 } |
| 2584 } | 2584 } |
| 2585 return this; | 2585 return this; |
| 2586 } | 2586 } |
| 2587 | 2587 |
| 2588 | 2588 |
| 2589 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { | |
| 2590 CompileType* in_type = left()->Type(); | |
| 2591 intptr_t cid = in_type->ToCid(); | |
| 2592 if (cid == kDynamicCid) return this; | |
| 2593 | |
| 2594 const ZoneGrowableArray<intptr_t>& data = cid_results(); | |
| 2595 intptr_t result = -1; | |
| 2596 for (intptr_t i = 0; i < data.length(); i += 2) { | |
| 2597 if (data[i] == cid) { | |
| 2598 result = data[i + 1]; | |
| 2599 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.
| |
| 2600 } | |
| 2601 } | |
| 2602 if (result >= 0) { | |
| 2603 if (kind() != Token::kIS) { | |
| 2604 result = !result; | |
|
Ivan Posva
2016/04/18 04:37:46
intptr_t is not a boolean.
sra1
2016/04/19 03:19:18
Done.
| |
| 2605 } | |
| 2606 if (result) { | |
|
Ivan Posva
2016/04/18 04:37:46
ditto.
sra1
2016/04/19 03:19:18
Done.
| |
| 2607 return flow_graph->GetConstant(Bool::True()); | |
| 2608 } else { | |
|
Florian Schneider
2016/04/18 14:57:28
Please check that we have test coverage for the ca
| |
| 2609 return flow_graph->GetConstant(Bool::False()); | |
| 2610 } | |
| 2611 } | |
| 2612 | |
| 2613 // TODO(sra): Handle misses if the instruction is not deoptimizing. | |
| 2614 // TODO(sra): Handle nullable input, possible canonicalizing to a compare | |
| 2615 // 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.
| |
| 2616 return this; | |
| 2617 } | |
| 2618 | |
| 2619 | |
| 2589 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) { | 2620 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) { |
| 2590 if (field().guarded_cid() == kDynamicCid) { | 2621 if (field().guarded_cid() == kDynamicCid) { |
| 2591 return NULL; // Nothing to guard. | 2622 return NULL; // Nothing to guard. |
| 2592 } | 2623 } |
| 2593 | 2624 |
| 2594 if (field().is_nullable() && value()->Type()->IsNull()) { | 2625 if (field().is_nullable() && value()->Type()->IsNull()) { |
| 2595 return NULL; | 2626 return NULL; |
| 2596 } | 2627 } |
| 2597 | 2628 |
| 2598 const intptr_t cid = field().is_nullable() ? value()->Type()->ToNullableCid() | 2629 const intptr_t cid = field().is_nullable() ? value()->Type()->ToNullableCid() |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3753 set_native_c_function(native_function); | 3784 set_native_c_function(native_function); |
| 3754 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3785 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
| 3755 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3786 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 3756 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3787 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 3757 set_is_bootstrap_native(is_bootstrap_native); | 3788 set_is_bootstrap_native(is_bootstrap_native); |
| 3758 } | 3789 } |
| 3759 | 3790 |
| 3760 #undef __ | 3791 #undef __ |
| 3761 | 3792 |
| 3762 } // namespace dart | 3793 } // namespace dart |
| OLD | NEW |