| 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 2572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 const Object& constant_value = value()->BoundConstant(); | 2583 const Object& constant_value = value()->BoundConstant(); |
| 2584 if (constant_value.IsSmi() && | 2584 if (constant_value.IsSmi() && |
| 2585 Smi::Cast(constant_value).Value() == cid_) { | 2585 Smi::Cast(constant_value).Value() == cid_) { |
| 2586 return NULL; | 2586 return NULL; |
| 2587 } | 2587 } |
| 2588 } | 2588 } |
| 2589 return this; | 2589 return this; |
| 2590 } | 2590 } |
| 2591 | 2591 |
| 2592 | 2592 |
| 2593 Definition* TestCidsInstr::Canonicalize(FlowGraph* flow_graph) { |
| 2594 CompileType* in_type = left()->Type(); |
| 2595 intptr_t cid = in_type->ToCid(); |
| 2596 if (cid == kDynamicCid) return this; |
| 2597 |
| 2598 const ZoneGrowableArray<intptr_t>& data = cid_results(); |
| 2599 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0; |
| 2600 for (intptr_t i = 0; i < data.length(); i += 2) { |
| 2601 if (data[i] == cid) { |
| 2602 return (data[i + 1] == true_result) |
| 2603 ? flow_graph->GetConstant(Bool::True()) |
| 2604 : flow_graph->GetConstant(Bool::False()); |
| 2605 } |
| 2606 } |
| 2607 |
| 2608 // TODO(sra): Handle misses if the instruction is not deoptimizing. |
| 2609 // TODO(sra): Handle nullable input, possibly canonicalizing to a compare |
| 2610 // against `null`. |
| 2611 return this; |
| 2612 } |
| 2613 |
| 2614 |
| 2593 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) { | 2615 Instruction* GuardFieldClassInstr::Canonicalize(FlowGraph* flow_graph) { |
| 2594 if (field().guarded_cid() == kDynamicCid) { | 2616 if (field().guarded_cid() == kDynamicCid) { |
| 2595 return NULL; // Nothing to guard. | 2617 return NULL; // Nothing to guard. |
| 2596 } | 2618 } |
| 2597 | 2619 |
| 2598 if (field().is_nullable() && value()->Type()->IsNull()) { | 2620 if (field().is_nullable() && value()->Type()->IsNull()) { |
| 2599 return NULL; | 2621 return NULL; |
| 2600 } | 2622 } |
| 2601 | 2623 |
| 2602 const intptr_t cid = field().is_nullable() ? value()->Type()->ToNullableCid() | 2624 const intptr_t cid = field().is_nullable() ? value()->Type()->ToNullableCid() |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3848 set_native_c_function(native_function); | 3870 set_native_c_function(native_function); |
| 3849 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3871 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
| 3850 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3872 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 3851 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3873 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 3852 set_is_bootstrap_native(is_bootstrap_native); | 3874 set_is_bootstrap_native(is_bootstrap_native); |
| 3853 } | 3875 } |
| 3854 | 3876 |
| 3855 #undef __ | 3877 #undef __ |
| 3856 | 3878 |
| 3857 } // namespace dart | 3879 } // namespace dart |
| OLD | NEW |