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

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 2094613003: Canonicalize CheckedSmiOp if compile type turns out to be smi. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 switch (op_kind()) {
1770 case Token::kBIT_AND:
Vyacheslav Egorov (Google) 2016/06/23 17:17:57 Please add a comment here about deoptimizations -
Florian Schneider 2016/06/23 17:35:04 Done.
1771 case Token::kBIT_OR:
1772 case Token::kBIT_XOR:
1773 replacement =
1774 new BinarySmiOpInstr(op_kind(),
1775 new Value(left()->definition()),
1776 new Value(right()->definition()),
1777 Thread::kNoDeoptId);
1778 default:
1779 break;
1780 }
1781 if (Token::IsRelationalOperator(op_kind())) {
1782 replacement = new RelationalOpInstr(token_pos(), op_kind(),
1783 new Value(left()->definition()),
1784 new Value(right()->definition()),
1785 kSmiCid,
1786 Thread::kNoDeoptId);
1787 } else if (Token::IsEqualityOperator(op_kind())) {
1788 replacement = new EqualityCompareInstr(token_pos(), op_kind(),
1789 new Value(left()->definition()),
1790 new Value(right()->definition()),
1791 kSmiCid,
1792 Thread::kNoDeoptId);
1793 }
1794 if (replacement != NULL) {
1795 flow_graph->InsertBefore(this, replacement, env(), FlowGraph::kValue);
1796 return replacement;
1797 }
1798 }
1799 return this;
1800 }
1801
1802
1765 Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) { 1803 Definition* BinaryIntegerOpInstr::Canonicalize(FlowGraph* flow_graph) {
1766 // If both operands are constants evaluate this expression. Might 1804 // If both operands are constants evaluate this expression. Might
1767 // occur due to load forwarding after constant propagation pass 1805 // occur due to load forwarding after constant propagation pass
1768 // have already been run. 1806 // have already been run.
1769 if (left()->BindsToConstant() && 1807 if (left()->BindsToConstant() &&
1770 left()->BoundConstant().IsInteger() && 1808 left()->BoundConstant().IsInteger() &&
1771 right()->BindsToConstant() && 1809 right()->BindsToConstant() &&
1772 right()->BoundConstant().IsInteger()) { 1810 right()->BoundConstant().IsInteger()) {
1773 const Integer& result = Integer::Handle( 1811 const Integer& result = Integer::Handle(
1774 Evaluate(Integer::Cast(left()->BoundConstant()), 1812 Evaluate(Integer::Cast(left()->BoundConstant()),
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3882 set_native_c_function(native_function); 3920 set_native_c_function(native_function);
3883 function().SetIsNativeAutoSetupScope(auto_setup_scope); 3921 function().SetIsNativeAutoSetupScope(auto_setup_scope);
3884 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 3922 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
3885 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); 3923 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver);
3886 set_is_bootstrap_native(is_bootstrap_native); 3924 set_is_bootstrap_native(is_bootstrap_native);
3887 } 3925 }
3888 3926
3889 #undef __ 3927 #undef __
3890 3928
3891 } // namespace dart 3929 } // namespace dart
OLDNEW
« 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