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

Side by Side Diff: vm/intermediate_language.cc

Issue 11745022: - Make Boolean 'true' and 'false' singleton VM isolate objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « vm/handles.h ('k') | vm/intermediate_language_ia32.cc » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 return this; 1484 return this;
1485 } 1485 }
1486 1486
1487 Definition* StrictCompareInstr::Canonicalize(FlowGraphOptimizer* optimizer) { 1487 Definition* StrictCompareInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1488 if (!right()->BindsToConstant()) return this; 1488 if (!right()->BindsToConstant()) return this;
1489 const Object& right_constant = right()->BoundConstant(); 1489 const Object& right_constant = right()->BoundConstant();
1490 Definition* left_defn = left()->definition(); 1490 Definition* left_defn = left()->definition();
1491 // TODO(fschneider): Handle other cases: e === false and e !== true/false. 1491 // TODO(fschneider): Handle other cases: e === false and e !== true/false.
1492 // Handles e === true. 1492 // Handles e === true.
1493 if ((kind() == Token::kEQ_STRICT) && 1493 if ((kind() == Token::kEQ_STRICT) &&
1494 (right_constant.raw() == Bool::True()) && 1494 (right_constant.raw() == Bool::True().raw()) &&
1495 (left()->ResultCid() == kBoolCid)) { 1495 (left()->ResultCid() == kBoolCid)) {
1496 // Return left subexpression as the replacement for this instruction. 1496 // Return left subexpression as the replacement for this instruction.
1497 return left_defn; 1497 return left_defn;
1498 } 1498 }
1499 return this; 1499 return this;
1500 } 1500 }
1501 1501
1502 1502
1503 Instruction* CheckClassInstr::Canonicalize(FlowGraphOptimizer* optimizer) { 1503 Instruction* CheckClassInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
1504 const intptr_t value_cid = value()->ResultCid(); 1504 const intptr_t value_cid = value()->ResultCid();
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 // Special code for numbers (compare values instead of references.) 1784 // Special code for numbers (compare values instead of references.)
1785 void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1785 void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1786 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); 1786 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
1787 Location left = locs()->in(0); 1787 Location left = locs()->in(0);
1788 Location right = locs()->in(1); 1788 Location right = locs()->in(1);
1789 if (left.IsConstant() && right.IsConstant()) { 1789 if (left.IsConstant() && right.IsConstant()) {
1790 // TODO(vegorov): should be eliminated earlier by constant propagation. 1790 // TODO(vegorov): should be eliminated earlier by constant propagation.
1791 const bool result = (kind() == Token::kEQ_STRICT) ? 1791 const bool result = (kind() == Token::kEQ_STRICT) ?
1792 left.constant().raw() == right.constant().raw() : 1792 left.constant().raw() == right.constant().raw() :
1793 left.constant().raw() != right.constant().raw(); 1793 left.constant().raw() != right.constant().raw();
1794 __ LoadObject(locs()->out().reg(), result ? compiler->bool_true() : 1794 __ LoadObject(locs()->out().reg(), result ? Bool::True() : Bool::False());
1795 compiler->bool_false());
1796 return; 1795 return;
1797 } 1796 }
1798 if (left.IsConstant()) { 1797 if (left.IsConstant()) {
1799 compiler->EmitEqualityRegConstCompare(right.reg(), 1798 compiler->EmitEqualityRegConstCompare(right.reg(),
1800 left.constant(), 1799 left.constant(),
1801 needs_number_check()); 1800 needs_number_check());
1802 } else if (right.IsConstant()) { 1801 } else if (right.IsConstant()) {
1803 compiler->EmitEqualityRegConstCompare(left.reg(), 1802 compiler->EmitEqualityRegConstCompare(left.reg(),
1804 right.constant(), 1803 right.constant(),
1805 needs_number_check()); 1804 needs_number_check());
1806 } else { 1805 } else {
1807 compiler->EmitEqualityRegRegCompare(left.reg(), 1806 compiler->EmitEqualityRegRegCompare(left.reg(),
1808 right.reg(), 1807 right.reg(),
1809 needs_number_check()); 1808 needs_number_check());
1810 } 1809 }
1811 1810
1812 Register result = locs()->out().reg(); 1811 Register result = locs()->out().reg();
1813 Label load_true, done; 1812 Label load_true, done;
1814 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; 1813 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL;
1815 __ j(true_condition, &load_true, Assembler::kNearJump); 1814 __ j(true_condition, &load_true, Assembler::kNearJump);
1816 __ LoadObject(result, compiler->bool_false()); 1815 __ LoadObject(result, Bool::False());
1817 __ jmp(&done, Assembler::kNearJump); 1816 __ jmp(&done, Assembler::kNearJump);
1818 __ Bind(&load_true); 1817 __ Bind(&load_true);
1819 __ LoadObject(result, compiler->bool_true()); 1818 __ LoadObject(result, Bool::True());
1820 __ Bind(&done); 1819 __ Bind(&done);
1821 } 1820 }
1822 1821
1823 1822
1824 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, 1823 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler,
1825 BranchInstr* branch) { 1824 BranchInstr* branch) {
1826 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); 1825 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT);
1827 Location left = locs()->in(0); 1826 Location left = locs()->in(0);
1828 Location right = locs()->in(1); 1827 Location right = locs()->in(1);
1829 if (left.IsConstant() && right.IsConstant()) { 1828 if (left.IsConstant() && right.IsConstant()) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 Location::RequiresRegister(), 1955 Location::RequiresRegister(),
1957 LocationSummary::kNoCall); 1956 LocationSummary::kNoCall);
1958 } 1957 }
1959 1958
1960 1959
1961 void BooleanNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1960 void BooleanNegateInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1962 Register value = locs()->in(0).reg(); 1961 Register value = locs()->in(0).reg();
1963 Register result = locs()->out().reg(); 1962 Register result = locs()->out().reg();
1964 1963
1965 Label done; 1964 Label done;
1966 __ LoadObject(result, compiler->bool_true()); 1965 __ LoadObject(result, Bool::True());
1967 __ CompareRegisters(result, value); 1966 __ CompareRegisters(result, value);
1968 __ j(NOT_EQUAL, &done, Assembler::kNearJump); 1967 __ j(NOT_EQUAL, &done, Assembler::kNearJump);
1969 __ LoadObject(result, compiler->bool_false()); 1968 __ LoadObject(result, Bool::False());
1970 __ Bind(&done); 1969 __ Bind(&done);
1971 } 1970 }
1972 1971
1973 1972
1974 LocationSummary* ChainContextInstr::MakeLocationSummary() const { 1973 LocationSummary* ChainContextInstr::MakeLocationSummary() const {
1975 return LocationSummary::Make(1, 1974 return LocationSummary::Make(1,
1976 Location::NoLocation(), 1975 Location::NoLocation(),
1977 LocationSummary::kNoCall); 1976 LocationSummary::kNoCall);
1978 } 1977 }
1979 1978
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 default: 2704 default:
2706 UNREACHABLE(); 2705 UNREACHABLE();
2707 return -1; 2706 return -1;
2708 } 2707 }
2709 } 2708 }
2710 2709
2711 2710
2712 #undef __ 2711 #undef __
2713 2712
2714 } // namespace dart 2713 } // namespace dart
OLDNEW
« no previous file with comments | « vm/handles.h ('k') | vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698