OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 id_after_(BailoutId::None()), | 102 id_after_(BailoutId::None()), |
103 added_to_node_(false), | 103 added_to_node_(false), |
104 frame_states_unused_(false), | 104 frame_states_unused_(false), |
105 output_poke_offset_(0), | 105 output_poke_offset_(0), |
106 output_poke_count_(0) { | 106 output_poke_count_(0) { |
107 BailoutId id_before(builder->bytecode_iterator().current_offset()); | 107 BailoutId id_before(builder->bytecode_iterator().current_offset()); |
108 frame_state_before_ = builder_->environment()->Checkpoint( | 108 frame_state_before_ = builder_->environment()->Checkpoint( |
109 id_before, OutputFrameStateCombine::Ignore()); | 109 id_before, OutputFrameStateCombine::Ignore()); |
110 id_after_ = BailoutId(id_before.ToInt() + | 110 id_after_ = BailoutId(id_before.ToInt() + |
111 builder->bytecode_iterator().current_bytecode_size()); | 111 builder->bytecode_iterator().current_bytecode_size()); |
| 112 // Create an explicit checkpoint node for before the operation. |
| 113 Node* node = builder_->NewNode(builder_->common()->Checkpoint()); |
| 114 DCHECK_EQ(IrOpcode::kDead, |
| 115 NodeProperties::GetFrameStateInput(node, 0)->opcode()); |
| 116 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_before_); |
112 } | 117 } |
113 | 118 |
114 ~FrameStateBeforeAndAfter() { | 119 ~FrameStateBeforeAndAfter() { |
115 DCHECK(added_to_node_); | 120 DCHECK(added_to_node_); |
116 DCHECK(frame_states_unused_ || | 121 DCHECK(frame_states_unused_ || |
117 builder_->environment()->StateValuesAreUpToDate(output_poke_offset_, | 122 builder_->environment()->StateValuesAreUpToDate(output_poke_offset_, |
118 output_poke_count_)); | 123 output_poke_count_)); |
119 } | 124 } |
120 | 125 |
121 private: | 126 private: |
122 friend class Environment; | 127 friend class Environment; |
123 | 128 |
124 void AddToNode(Node* node, OutputFrameStateCombine combine) { | 129 void AddToNode(Node* node, OutputFrameStateCombine combine) { |
125 DCHECK(!added_to_node_); | 130 DCHECK(!added_to_node_); |
126 int count = OperatorProperties::GetFrameStateInputCount(node->op()); | 131 int count = OperatorProperties::GetFrameStateInputCount(node->op()); |
127 DCHECK_LE(count, 2); | 132 DCHECK_LE(count, 2); |
128 if (count >= 1) { | 133 if (count >= 1) { |
129 // Add the frame state for after the operation. | 134 // Add the frame state for after the operation. |
130 DCHECK_EQ(IrOpcode::kDead, | 135 DCHECK_EQ(IrOpcode::kDead, |
131 NodeProperties::GetFrameStateInput(node, 0)->opcode()); | 136 NodeProperties::GetFrameStateInput(node, 0)->opcode()); |
132 Node* frame_state_after = | 137 Node* frame_state_after = |
133 builder_->environment()->Checkpoint(id_after_, combine); | 138 builder_->environment()->Checkpoint(id_after_, combine); |
134 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after); | 139 NodeProperties::ReplaceFrameStateInput(node, 0, frame_state_after); |
135 } | 140 } |
136 | 141 |
137 if (count >= 2) { | 142 if (count >= 2) { |
138 // Add the frame state for before the operation. | 143 // Add the frame state for before the operation. |
| 144 // TODO(mstarzinger): Get rid of frame state input before! |
139 DCHECK_EQ(IrOpcode::kDead, | 145 DCHECK_EQ(IrOpcode::kDead, |
140 NodeProperties::GetFrameStateInput(node, 1)->opcode()); | 146 NodeProperties::GetFrameStateInput(node, 1)->opcode()); |
141 NodeProperties::ReplaceFrameStateInput(node, 1, frame_state_before_); | 147 NodeProperties::ReplaceFrameStateInput(node, 1, frame_state_before_); |
142 } | 148 } |
143 | 149 |
144 if (!combine.IsOutputIgnored()) { | 150 if (!combine.IsOutputIgnored()) { |
145 output_poke_offset_ = static_cast<int>(combine.GetOffsetToPokeAt()); | 151 output_poke_offset_ = static_cast<int>(combine.GetOffsetToPokeAt()); |
146 output_poke_count_ = node->op()->ValueOutputCount(); | 152 output_poke_count_ = node->op()->ValueOutputCount(); |
147 } | 153 } |
148 frame_states_unused_ = count == 0; | 154 frame_states_unused_ = count == 0; |
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 // Phi does not exist yet, introduce one. | 1729 // Phi does not exist yet, introduce one. |
1724 value = NewPhi(inputs, value, control); | 1730 value = NewPhi(inputs, value, control); |
1725 value->ReplaceInput(inputs - 1, other); | 1731 value->ReplaceInput(inputs - 1, other); |
1726 } | 1732 } |
1727 return value; | 1733 return value; |
1728 } | 1734 } |
1729 | 1735 |
1730 } // namespace compiler | 1736 } // namespace compiler |
1731 } // namespace internal | 1737 } // namespace internal |
1732 } // namespace v8 | 1738 } // namespace v8 |
OLD | NEW |