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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 // TODO(fschneider): Avoid special-casing for SSA mode here. | 1646 // TODO(fschneider): Avoid special-casing for SSA mode here. |
1647 if (compiler->is_optimizing()) { | 1647 if (compiler->is_optimizing()) { |
1648 ASSERT(locs()->in(0).IsRegister()); | 1648 ASSERT(locs()->in(0).IsRegister()); |
1649 __ PushRegister(locs()->in(0).reg()); | 1649 __ PushRegister(locs()->in(0).reg()); |
1650 } | 1650 } |
1651 } | 1651 } |
1652 | 1652 |
1653 | 1653 |
1654 Environment* Environment::From(const GrowableArray<Definition*>& definitions, | 1654 Environment* Environment::From(const GrowableArray<Definition*>& definitions, |
1655 intptr_t fixed_parameter_count, | 1655 intptr_t fixed_parameter_count, |
1656 const Environment* outer) { | 1656 const Function& function) { |
1657 Environment* env = | 1657 Environment* env = |
1658 new Environment(definitions.length(), | 1658 new Environment(definitions.length(), |
1659 fixed_parameter_count, | 1659 fixed_parameter_count, |
1660 Isolate::kNoDeoptId, | 1660 Isolate::kNoDeoptId, |
1661 (outer == NULL) ? NULL : outer->DeepCopy()); | 1661 function, |
| 1662 NULL); |
1662 for (intptr_t i = 0; i < definitions.length(); ++i) { | 1663 for (intptr_t i = 0; i < definitions.length(); ++i) { |
1663 env->values_.Add(new Value(definitions[i])); | 1664 env->values_.Add(new Value(definitions[i])); |
1664 } | 1665 } |
1665 return env; | 1666 return env; |
1666 } | 1667 } |
1667 | 1668 |
1668 | 1669 |
1669 Environment* Environment::DeepCopy() const { | 1670 Environment* Environment::DeepCopy() const { |
1670 Environment* copy = | 1671 Environment* copy = |
1671 new Environment(values_.length(), | 1672 new Environment(values_.length(), |
1672 fixed_parameter_count_, | 1673 fixed_parameter_count_, |
1673 deopt_id_, | 1674 deopt_id_, |
| 1675 function_, |
1674 (outer_ == NULL) ? NULL : outer_->DeepCopy()); | 1676 (outer_ == NULL) ? NULL : outer_->DeepCopy()); |
1675 for (intptr_t i = 0; i < values_.length(); ++i) { | 1677 for (intptr_t i = 0; i < values_.length(); ++i) { |
1676 copy->values_.Add(values_[i]->Copy()); | 1678 copy->values_.Add(values_[i]->Copy()); |
1677 } | 1679 } |
1678 return copy; | 1680 return copy; |
1679 } | 1681 } |
1680 | 1682 |
1681 | 1683 |
1682 // Copies the environment and updates the environment use lists. | 1684 // Copies the environment and updates the environment use lists. |
1683 void Environment::DeepCopyTo(Instruction* instr) const { | 1685 void Environment::DeepCopyTo(Instruction* instr) const { |
1684 Environment* copy = DeepCopy(); | 1686 Environment* copy = DeepCopy(); |
1685 intptr_t use_index = 0; | 1687 intptr_t use_index = 0; |
1686 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { | 1688 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { |
1687 Value* value = it.CurrentValue(); | 1689 Value* value = it.CurrentValue(); |
1688 value->set_instruction(instr); | 1690 value->set_instruction(instr); |
1689 value->set_use_index(use_index++); | 1691 value->set_use_index(use_index++); |
1690 value->AddToEnvUseList(); | 1692 value->AddToEnvUseList(); |
1691 } | 1693 } |
1692 instr->set_env(copy); | 1694 instr->set_env(copy); |
1693 } | 1695 } |
1694 | 1696 |
1695 | 1697 |
| 1698 // Copies the environment as outer on an inlined instruction and updates the |
| 1699 // environment use lists. |
| 1700 void Environment::DeepCopyToOuter(Instruction* instr) const { |
| 1701 ASSERT(instr->env()->outer() == NULL); |
| 1702 Environment* copy = DeepCopy(); |
| 1703 intptr_t use_index = instr->env()->Length(); // Start index after inner. |
| 1704 for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { |
| 1705 Value* value = it.CurrentValue(); |
| 1706 value->set_instruction(instr); |
| 1707 value->set_use_index(use_index++); |
| 1708 value->AddToEnvUseList(); |
| 1709 } |
| 1710 instr->env()->outer_ = copy; |
| 1711 } |
| 1712 |
| 1713 |
1696 #undef __ | 1714 #undef __ |
1697 | 1715 |
1698 } // namespace dart | 1716 } // namespace dart |
OLD | NEW |