| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 bool BytecodePeepholeOptimizer::LastBytecodePutsNameInAccumulator() const { | 89 bool BytecodePeepholeOptimizer::LastBytecodePutsNameInAccumulator() const { |
| 90 DCHECK(LastIsValid()); | 90 DCHECK(LastIsValid()); |
| 91 return (last_.bytecode() == Bytecode::kTypeOf || | 91 return (last_.bytecode() == Bytecode::kTypeOf || |
| 92 last_.bytecode() == Bytecode::kToName || | 92 last_.bytecode() == Bytecode::kToName || |
| 93 (last_.bytecode() == Bytecode::kLdaConstant && | 93 (last_.bytecode() == Bytecode::kLdaConstant && |
| 94 GetConstantForIndexOperand(&last_, 0)->IsName())); | 94 GetConstantForIndexOperand(&last_, 0)->IsName())); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void BytecodePeepholeOptimizer::TryToRemoveLastExpressionPosition( | 97 void BytecodePeepholeOptimizer::TryToRemoveLastExpressionPosition( |
| 98 const BytecodeNode* const current) { | 98 const BytecodeNode* const current) { |
| 99 if (current->source_info().is_statement() && | 99 if (current->source_info().is_valid() && |
| 100 last_.source_info().is_expression() && | 100 last_.source_info().is_expression() && |
| 101 Bytecodes::IsWithoutExternalSideEffects(last_.bytecode())) { | 101 Bytecodes::IsWithoutExternalSideEffects(last_.bytecode())) { |
| 102 // The last bytecode has been marked as expression. It has no | 102 // The last bytecode has been marked as expression. It has no |
| 103 // external effects so can't throw and the current bytecode is a | 103 // external effects so can't throw and the current bytecode is a |
| 104 // source position. Remove the expression position on the last | 104 // source position. Remove the expression position on the last |
| 105 // bytecode to open up potential peephole optimizations and to | 105 // bytecode to open up potential peephole optimizations and to |
| 106 // save the memory and perf cost of storing the unneeded | 106 // save the memory and perf cost of storing the unneeded |
| 107 // expression position. | 107 // expression position. |
| 108 last_.source_info().set_invalid(); | 108 last_.source_info().set_invalid(); |
| 109 } | 109 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 next_stage_->Write(&last_); | 316 next_stage_->Write(&last_); |
| 317 InvalidateLast(); | 317 InvalidateLast(); |
| 318 } | 318 } |
| 319 } | 319 } |
| 320 return current; | 320 return current; |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace interpreter | 323 } // namespace interpreter |
| 324 } // namespace internal | 324 } // namespace internal |
| 325 } // namespace v8 | 325 } // namespace v8 |
| OLD | NEW |