OLD | NEW |
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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 } | 1553 } |
1554 | 1554 |
1555 | 1555 |
1556 void StoreContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1556 void StoreContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1557 // Nothing to do. Context register were loaded by register allocator. | 1557 // Nothing to do. Context register were loaded by register allocator. |
1558 ASSERT(locs()->in(0).reg() == CTX); | 1558 ASSERT(locs()->in(0).reg() == CTX); |
1559 } | 1559 } |
1560 | 1560 |
1561 | 1561 |
1562 LocationSummary* StrictCompareInstr::MakeLocationSummary() const { | 1562 LocationSummary* StrictCompareInstr::MakeLocationSummary() const { |
1563 return LocationSummary::Make(2, | 1563 const intptr_t kNumInputs = 2; |
1564 Location::SameAsFirstInput(), | 1564 const intptr_t kNumTemps = 0; |
1565 LocationSummary::kNoCall); | 1565 LocationSummary* locs = |
| 1566 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 1567 locs->set_in(0, Location::RegisterOrConstant(left())); |
| 1568 locs->set_in(1, Location::RegisterOrConstant(right())); |
| 1569 locs->set_out(Location::RequiresRegister()); |
| 1570 return locs; |
1566 } | 1571 } |
1567 | 1572 |
1568 | 1573 |
1569 void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1574 void StrictCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1570 Register left = locs()->in(0).reg(); | |
1571 Register right = locs()->in(1).reg(); | |
1572 | |
1573 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); | 1575 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
1574 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; | 1576 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; |
1575 __ CompareRegisters(left, right); | 1577 Location left = locs()->in(0); |
| 1578 Location right = locs()->in(1); |
| 1579 if (left.IsConstant() && right.IsConstant()) { |
| 1580 // TODO(vegorov): should be eliminated earlier by constant propagation. |
| 1581 const bool result = left.constant().raw() == right.constant().raw(); |
| 1582 __ LoadObject(locs()->out().reg(), result ? compiler->bool_true() : |
| 1583 compiler->bool_false()); |
| 1584 return; |
| 1585 } |
| 1586 if (left.IsConstant()) { |
| 1587 __ CompareObject(right.reg(), left.constant()); |
| 1588 } else if (right.IsConstant()) { |
| 1589 __ CompareObject(left.reg(), right.constant()); |
| 1590 } else { |
| 1591 __ CompareRegisters(left.reg(), right.reg()); |
| 1592 } |
1576 | 1593 |
1577 Register result = locs()->out().reg(); | 1594 Register result = locs()->out().reg(); |
1578 Label load_true, done; | 1595 Label load_true, done; |
1579 __ j(true_condition, &load_true, Assembler::kNearJump); | 1596 __ j(true_condition, &load_true, Assembler::kNearJump); |
1580 __ LoadObject(result, compiler->bool_false()); | 1597 __ LoadObject(result, compiler->bool_false()); |
1581 __ jmp(&done, Assembler::kNearJump); | 1598 __ jmp(&done, Assembler::kNearJump); |
1582 __ Bind(&load_true); | 1599 __ Bind(&load_true); |
1583 __ LoadObject(result, compiler->bool_true()); | 1600 __ LoadObject(result, compiler->bool_true()); |
1584 __ Bind(&done); | 1601 __ Bind(&done); |
1585 } | 1602 } |
1586 | 1603 |
1587 | 1604 |
1588 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, | 1605 void StrictCompareInstr::EmitBranchCode(FlowGraphCompiler* compiler, |
1589 BranchInstr* branch) { | 1606 BranchInstr* branch) { |
1590 Register left = locs()->in(0).reg(); | |
1591 Register right = locs()->in(1).reg(); | |
1592 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); | 1607 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
1593 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; | 1608 Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL; |
1594 __ CompareRegisters(left, right); | 1609 Location left = locs()->in(0); |
| 1610 Location right = locs()->in(1); |
| 1611 if (left.IsConstant() && right.IsConstant()) { |
| 1612 // TODO(vegorov): should be eliminated earlier by constant propagation. |
| 1613 const bool result = left.constant().raw() == right.constant().raw(); |
| 1614 branch->EmitBranchOnValue(compiler, result); |
| 1615 return; |
| 1616 } |
| 1617 if (left.IsConstant()) { |
| 1618 __ CompareObject(right.reg(), left.constant()); |
| 1619 } else if (right.IsConstant()) { |
| 1620 __ CompareObject(left.reg(), right.constant()); |
| 1621 } else { |
| 1622 __ CompareRegisters(left.reg(), right.reg()); |
| 1623 } |
| 1624 |
1595 branch->EmitBranchOnCondition(compiler, true_condition); | 1625 branch->EmitBranchOnCondition(compiler, true_condition); |
1596 } | 1626 } |
1597 | 1627 |
1598 | 1628 |
1599 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 1629 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
1600 // The arguments to the stub include the closure. The arguments | 1630 // The arguments to the stub include the closure. The arguments |
1601 // descriptor describes the closure's arguments (and so does not include | 1631 // descriptor describes the closure's arguments (and so does not include |
1602 // the closure). | 1632 // the closure). |
1603 Register temp_reg = locs()->temp(0).reg(); | 1633 Register temp_reg = locs()->temp(0).reg(); |
1604 int argument_count = ArgumentCount(); | 1634 int argument_count = ArgumentCount(); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 new_max = new_max.Clamp(); | 2030 new_max = new_max.Clamp(); |
2001 } | 2031 } |
2002 | 2032 |
2003 return Range::Update(&range_, new_min, new_max); | 2033 return Range::Update(&range_, new_min, new_max); |
2004 } | 2034 } |
2005 | 2035 |
2006 | 2036 |
2007 #undef __ | 2037 #undef __ |
2008 | 2038 |
2009 } // namespace dart | 2039 } // namespace dart |
OLD | NEW |