| 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 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 if (representation() != kTagged) { | 1755 if (representation() != kTagged) { |
| 1756 result_defn = UnboxInstr::Create(representation(), | 1756 result_defn = UnboxInstr::Create(representation(), |
| 1757 new Value(result_defn), | 1757 new Value(result_defn), |
| 1758 GetDeoptId()); | 1758 GetDeoptId()); |
| 1759 flow_graph->InsertBefore(this, result_defn, env(), FlowGraph::kValue); | 1759 flow_graph->InsertBefore(this, result_defn, env(), FlowGraph::kValue); |
| 1760 } | 1760 } |
| 1761 return result_defn; | 1761 return result_defn; |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 | 1764 |
| 1765 Definition* CheckedSmiOpInstr::Canonicalize(FlowGraph* flow_graph) { |
| 1766 if ((left()->Type()->ToCid() == kSmiCid) && |
| 1767 (right()->Type()->ToCid() == kSmiCid)) { |
| 1768 Definition* replacement = NULL; |
| 1769 // Operations that can't deoptimize are specialized here: These include |
| 1770 // bit-wise operators and comparisons. Other arithmetic operations can |
| 1771 // overflow or divide by 0 and can't be specialized unless we have extra |
| 1772 // range information. |
| 1773 switch (op_kind()) { |
| 1774 case Token::kBIT_AND: |
| 1775 case Token::kBIT_OR: |
| 1776 case Token::kBIT_XOR: |
| 1777 replacement = |
| 1778 new BinarySmiOpInstr(op_kind(), |
| 1779 new Value(left()->definition()), |
| 1780 new Value(right()->definition()), |
| 1781 Thread::kNoDeoptId); |
| 1782 default: |
| 1783 break; |
| 1784 } |
| 1785 if (Token::IsRelationalOperator(op_kind())) { |
| 1786 replacement = new RelationalOpInstr(token_pos(), op_kind(), |
| 1787 new Value(left()->definition()), |
| 1788 new Value(right()->definition()), |
| 1789 kSmiCid, |
| 1790 Thread::kNoDeoptId); |
| 1791 } else if (Token::IsEqualityOperator(op_kind())) { |
| 1792 replacement = new EqualityCompareInstr(token_pos(), op_kind(), |
| 1793 new Value(left()->definition()), |
| 1794 new Value(right()->definition()), |
| 1795 kSmiCid, |
| 1796 Thread::kNoDeoptId); |
| 1797 } |
| 1798 if (replacement != NULL) { |
| 1799 flow_graph->InsertBefore(this, replacement, env(), FlowGraph::kValue); |
| 1800 return replacement; |
| 1801 } |
| 1802 } |
| 1803 return this; |
| 1804 } |
| 1805 |
| 1806 |
| 1765 Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) { | 1807 Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) { |
| 1766 // If both operands are constants evaluate this expression. Might | 1808 // If both operands are constants evaluate this expression. Might |
| 1767 // occur due to load forwarding after constant propagation pass | 1809 // occur due to load forwarding after constant propagation pass |
| 1768 // have already been run. | 1810 // have already been run. |
| 1769 if (left()->BindsToConstant() && | 1811 if (left()->BindsToConstant() && |
| 1770 left()->BoundConstant().IsInteger() && | 1812 left()->BoundConstant().IsInteger() && |
| 1771 right()->BindsToConstant() && | 1813 right()->BindsToConstant() && |
| 1772 right()->BoundConstant().IsInteger()) { | 1814 right()->BoundConstant().IsInteger()) { |
| 1773 const Integer& result = Integer::Handle( | 1815 const Integer& result = Integer::Handle( |
| 1774 Evaluate(Integer::Cast(left()->BoundConstant()), | 1816 Evaluate(Integer::Cast(left()->BoundConstant()), |
| (...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3882 set_native_c_function(native_function); | 3924 set_native_c_function(native_function); |
| 3883 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3925 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
| 3884 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3926 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 3885 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3927 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 3886 set_is_bootstrap_native(is_bootstrap_native); | 3928 set_is_bootstrap_native(is_bootstrap_native); |
| 3887 } | 3929 } |
| 3888 | 3930 |
| 3889 #undef __ | 3931 #undef __ |
| 3890 | 3932 |
| 3891 } // namespace dart | 3933 } // namespace dart |
| OLD | NEW |