| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // Preserve the source information by replacing the current bytecode | 290 // Preserve the source information by replacing the current bytecode |
| 291 // with a no op bytecode. | 291 // with a no op bytecode. |
| 292 current->set_bytecode(Bytecode::kNop); | 292 current->set_bytecode(Bytecode::kNop); |
| 293 } else { | 293 } else { |
| 294 current = nullptr; | 294 current = nullptr; |
| 295 } | 295 } |
| 296 return current; | 296 return current; |
| 297 } | 297 } |
| 298 | 298 |
| 299 if (CanElideLast(current) && CanElideLastBasedOnSourcePosition(current)) { | 299 if (CanElideLast(current) && CanElideLastBasedOnSourcePosition(current)) { |
| 300 current->source_info().Update(last_.source_info()); | 300 if (last_.source_info().is_valid()) { |
| 301 // Current can not be valid per CanElideLastBasedOnSourcePosition(). |
| 302 current->source_info().Clone(last_.source_info()); |
| 303 } |
| 301 InvalidateLast(); | 304 InvalidateLast(); |
| 302 return current; | 305 return current; |
| 303 } | 306 } |
| 304 | 307 |
| 305 return current; | 308 return current; |
| 306 } | 309 } |
| 307 | 310 |
| 308 BytecodeNode* BytecodePeepholeOptimizer::OptimizeAndEmitLast( | 311 BytecodeNode* BytecodePeepholeOptimizer::OptimizeAndEmitLast( |
| 309 BytecodeNode* current) { | 312 BytecodeNode* current) { |
| 310 // Attempt optimization if there is an earlier node to optimize with. | 313 // Attempt optimization if there is an earlier node to optimize with. |
| 311 if (LastIsValid()) { | 314 if (LastIsValid()) { |
| 312 current = Optimize(current); | 315 current = Optimize(current); |
| 313 // Only output the last node if it wasn't invalidated by the optimization. | 316 // Only output the last node if it wasn't invalidated by the optimization. |
| 314 if (LastIsValid()) { | 317 if (LastIsValid()) { |
| 315 next_stage_->Write(&last_); | 318 next_stage_->Write(&last_); |
| 316 InvalidateLast(); | 319 InvalidateLast(); |
| 317 } | 320 } |
| 318 } | 321 } |
| 319 return current; | 322 return current; |
| 320 } | 323 } |
| 321 | 324 |
| 322 } // namespace interpreter | 325 } // namespace interpreter |
| 323 } // namespace internal | 326 } // namespace internal |
| 324 } // namespace v8 | 327 } // namespace v8 |
| OLD | NEW |