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

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

Issue 1873143003: - Use a hash table to canonicalize instances/arrays to avoid having to iterate over a linear list a… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review Created 4 years, 8 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
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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 case kUnboxedUint32: // Only truncating Uint32 arithmetic is supported. 1644 case kUnboxedUint32: // Only truncating Uint32 arithmetic is supported.
1645 default: 1645 default:
1646 UNREACHABLE(); 1646 UNREACHABLE();
1647 } 1647 }
1648 1648
1649 return false; 1649 return false;
1650 } 1650 }
1651 1651
1652 1652
1653 RawInteger* UnaryIntegerOpInstr::Evaluate(const Integer& value) const { 1653 RawInteger* UnaryIntegerOpInstr::Evaluate(const Integer& value) const {
1654 Integer& result = Integer::Handle(); 1654 Thread* thread = Thread::Current();
1655 Zone* zone = thread->zone();
1656 Integer& result = Integer::Handle(zone);
1655 1657
1656 switch (op_kind()) { 1658 switch (op_kind()) {
1657 case Token::kNEGATE: 1659 case Token::kNEGATE:
1658 result = value.ArithmeticOp(Token::kMUL, 1660 result = value.ArithmeticOp(Token::kMUL,
1659 Smi::Handle(Smi::New(-1)), 1661 Smi::Handle(zone, Smi::New(-1)),
1660 Heap::kOld); 1662 Heap::kOld);
1661 break; 1663 break;
1662 1664
1663 case Token::kBIT_NOT: 1665 case Token::kBIT_NOT:
1664 if (value.IsSmi()) { 1666 if (value.IsSmi()) {
1665 result = Integer::New(~Smi::Cast(value).Value()); 1667 result = Integer::New(~Smi::Cast(value).Value());
1666 } else if (value.IsMint()) { 1668 } else if (value.IsMint()) {
1667 result = Integer::New(~Mint::Cast(value).value()); 1669 result = Integer::New(~Mint::Cast(value).value());
1668 } 1670 }
1669 break; 1671 break;
1670 1672
1671 default: 1673 default:
1672 UNREACHABLE(); 1674 UNREACHABLE();
1673 } 1675 }
1674 1676
1675 if (!result.IsNull()) { 1677 if (!result.IsNull()) {
1676 if (!IsRepresentable(result, representation())) { 1678 if (!IsRepresentable(result, representation())) {
1677 // If this operation is not truncating it would deoptimize on overflow. 1679 // If this operation is not truncating it would deoptimize on overflow.
1678 // Check that we match this behavior and don't produce a value that is 1680 // Check that we match this behavior and don't produce a value that is
1679 // larger than something this operation can produce. We could have 1681 // larger than something this operation can produce. We could have
1680 // specialized instructions that use this value under this assumption. 1682 // specialized instructions that use this value under this assumption.
1681 return Integer::null(); 1683 return Integer::null();
1682 } 1684 }
1683 result ^= result.CheckAndCanonicalize(NULL); 1685 result ^= result.CheckAndCanonicalize(thread, NULL);
1684 } 1686 }
1685 1687
1686 return result.raw(); 1688 return result.raw();
1687 } 1689 }
1688 1690
1689 1691
1690 RawInteger* BinaryIntegerOpInstr::Evaluate(const Integer& left, 1692 RawInteger* BinaryIntegerOpInstr::Evaluate(const Integer& left,
1691 const Integer& right) const { 1693 const Integer& right) const {
1692 Integer& result = Integer::Handle(); 1694 Thread* thread = Thread::Current();
1695 Zone* zone = thread->zone();
1696 Integer& result = Integer::Handle(zone);
1693 1697
1694 switch (op_kind()) { 1698 switch (op_kind()) {
1695 case Token::kTRUNCDIV: 1699 case Token::kTRUNCDIV:
1696 case Token::kMOD: 1700 case Token::kMOD:
1697 // Check right value for zero. 1701 // Check right value for zero.
1698 if (right.IsSmi() && right.AsInt64Value() == 0) { 1702 if (right.IsSmi() && right.AsInt64Value() == 0) {
1699 break; // Will throw. 1703 break; // Will throw.
1700 } 1704 }
1701 // Fall through. 1705 // Fall through.
1702 case Token::kADD: 1706 case Token::kADD:
(...skipping 28 matching lines...) Expand all
1731 truncated &= RepresentationMask(representation()); 1735 truncated &= RepresentationMask(representation());
1732 result = Integer::New(truncated); 1736 result = Integer::New(truncated);
1733 ASSERT(IsRepresentable(result, representation())); 1737 ASSERT(IsRepresentable(result, representation()));
1734 } else if (!IsRepresentable(result, representation())) { 1738 } else if (!IsRepresentable(result, representation())) {
1735 // If this operation is not truncating it would deoptimize on overflow. 1739 // If this operation is not truncating it would deoptimize on overflow.
1736 // Check that we match this behavior and don't produce a value that is 1740 // Check that we match this behavior and don't produce a value that is
1737 // larger than something this operation can produce. We could have 1741 // larger than something this operation can produce. We could have
1738 // specialized instructions that use this value under this assumption. 1742 // specialized instructions that use this value under this assumption.
1739 return Integer::null(); 1743 return Integer::null();
1740 } 1744 }
1741 result ^= result.CheckAndCanonicalize(NULL); 1745 result ^= result.CheckAndCanonicalize(thread, NULL);
1742 } 1746 }
1743 1747
1744 return result.raw(); 1748 return result.raw();
1745 } 1749 }
1746 1750
1747 1751
1748 Definition* BinaryIntegerOpInstr::CreateConstantResult(FlowGraph* flow_graph, 1752 Definition* BinaryIntegerOpInstr::CreateConstantResult(FlowGraph* flow_graph,
1749 const Integer& result) { 1753 const Integer& result) {
1750 Definition* result_defn = flow_graph->GetConstant(result); 1754 Definition* result_defn = flow_graph->GetConstant(result);
1751 if (representation() != kTagged) { 1755 if (representation() != kTagged) {
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3753 set_native_c_function(native_function); 3757 set_native_c_function(native_function);
3754 function().SetIsNativeAutoSetupScope(auto_setup_scope); 3758 function().SetIsNativeAutoSetupScope(auto_setup_scope);
3755 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 3759 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
3756 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); 3760 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver);
3757 set_is_bootstrap_native(is_bootstrap_native); 3761 set_is_bootstrap_native(is_bootstrap_native);
3758 } 3762 }
3759 3763
3760 #undef __ 3764 #undef __
3761 3765
3762 } // namespace dart 3766 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698