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/interpreter/bytecode-peephole-optimizer.h" | 5 #include "src/interpreter/bytecode-peephole-optimizer.h" |
6 | 6 |
7 #include "src/interpreter/constant-array-builder.h" | 7 #include "src/interpreter/constant-array-builder.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/objects.h" | 9 #include "src/objects.h" |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 // | 166 // |
167 return (!last_.source_info().is_valid() || | 167 return (!last_.source_info().is_valid() || |
168 !current->source_info().is_valid()); | 168 !current->source_info().is_valid()); |
169 } | 169 } |
170 | 170 |
171 namespace { | 171 namespace { |
172 | 172 |
173 void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last, | 173 void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last, |
174 BytecodeNode* const current) { | 174 BytecodeNode* const current) { |
175 DCHECK_EQ(current->bytecode(), Bytecode::kStar); | 175 DCHECK_EQ(current->bytecode(), Bytecode::kStar); |
176 if (current->source_info().is_statement() && | |
177 last->source_info().is_statement()) { | |
rmcilroy
2016/06/07 09:46:10
As discussed offline, I think we need to not do th
oth
2016/06/07 13:46:17
Yes, thanks for examining this. I agree.
| |
178 // The transform won't maintain causal ordering for the debugger. | |
179 return; | |
rmcilroy
2016/06/07 09:46:11
This returns here without doing anything, but then
oth
2016/06/07 13:46:17
Done.
| |
180 } | |
181 | |
176 // | 182 // |
177 // An example transformation here would be: | 183 // An example transformation here would be: |
178 // | 184 // |
179 // LdaGlobal i0, i1 ____\ LdrGlobal i0, i1, R | 185 // LdaGlobal i0, i1 ____\ LdrGlobal i0, i1, R |
180 // Star R ====/ Ldar R | 186 // Star R ====/ Ldar R |
181 // | 187 // |
182 // which loads a global value into both a register and the | 188 // which loads a global value into both a register and the |
183 // accumulator. However, in the second form the Ldar can often be | 189 // accumulator. However, in the second form the Ldar can often be |
184 // peephole optimized away unlike the Star in the first form. | 190 // peephole optimized away unlike the Star in the first form. |
185 // | 191 // |
186 last->Transform(new_bytecode, current->operand(0), current->operand_scale()); | 192 last->Transform(new_bytecode, current->operand(0), current->operand_scale()); |
187 current->set_bytecode(Bytecode::kLdar, current->operand(0), | 193 current->set_bytecode(Bytecode::kLdar, current->operand(0), |
188 current->operand_scale()); | 194 current->operand_scale()); |
189 | 195 |
190 // If there was a source position on |current| transfer it to the | 196 // If there was a source position on |current| transfer it to the |
191 // updated |last| to maintain the debugger's causal view. ie. if an | 197 // updated |last| to maintain the debugger's causal view. |
192 // expression position LdrGlobal is the bytecode that could throw | 198 if (last->source_info().is_statement()) { |
193 // and if a statement position it needs to be placed before the | 199 last->source_info().Update(current->source_info()); |
194 // store to R occurs. | 200 current->source_info().set_invalid(); |
195 last->source_info().Update(current->source_info()); | 201 } |
rmcilroy
2016/06/07 09:46:11
As discussed offline - I don't think this block do
oth
2016/06/07 13:46:17
Done.
| |
196 current->source_info().set_invalid(); | |
197 } | 202 } |
198 | 203 |
199 } // namespace | 204 } // namespace |
200 | 205 |
201 bool BytecodePeepholeOptimizer::ChangeLdaToLdr(BytecodeNode* const current) { | 206 bool BytecodePeepholeOptimizer::ChangeLdaToLdr(BytecodeNode* const current) { |
202 if (current->bytecode() == Bytecode::kStar) { | 207 if (current->bytecode() == Bytecode::kStar) { |
203 switch (last_.bytecode()) { | 208 switch (last_.bytecode()) { |
204 case Bytecode::kLdaNamedProperty: | 209 case Bytecode::kLdaNamedProperty: |
205 TransformLdaStarToLdrLdar(Bytecode::kLdrNamedProperty, &last_, current); | 210 TransformLdaStarToLdrLdar(Bytecode::kLdrNamedProperty, &last_, current); |
206 return true; | 211 return true; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 next_stage_->Write(&last_); | 322 next_stage_->Write(&last_); |
318 InvalidateLast(); | 323 InvalidateLast(); |
319 } | 324 } |
320 } | 325 } |
321 return current; | 326 return current; |
322 } | 327 } |
323 | 328 |
324 } // namespace interpreter | 329 } // namespace interpreter |
325 } // namespace internal | 330 } // namespace internal |
326 } // namespace v8 | 331 } // namespace v8 |
OLD | NEW |