Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 #include "src/objects.h" | 8 #include "src/objects.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 BytecodeNode* const last, | 131 BytecodeNode* const last, |
| 132 BytecodeNode* const current) { | 132 BytecodeNode* const current) { |
| 133 DCHECK_EQ(last->bytecode(), Bytecode::kLdaZero); | 133 DCHECK_EQ(last->bytecode(), Bytecode::kLdaZero); |
| 134 current->set_bytecode(new_bytecode, 0, current->operand(0), | 134 current->set_bytecode(new_bytecode, 0, current->operand(0), |
| 135 current->operand(1)); | 135 current->operand(1)); |
| 136 if (last->source_info().is_valid()) { | 136 if (last->source_info().is_valid()) { |
| 137 current->set_source_info(last->source_info()); | 137 current->set_source_info(last->source_info()); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 void TransformEqualityWithNullOrUndefinedToTestUndetectable( | |
| 142 BytecodeNode* const last, BytecodeNode* const current) { | |
| 143 DCHECK((last->bytecode() == Bytecode::kLdaNull) || | |
| 144 (last->bytecode() == Bytecode::kLdaUndefined)); | |
|
rmcilroy
2016/12/05 19:08:09
Do you want to DCHECK that this current bytecode i
mythria
2016/12/06 10:13:27
Done.
| |
| 145 current->set_bytecode(Bytecode::kTestUndetectable, current->operand(0)); | |
| 146 if (last->source_info().is_valid()) { | |
| 147 current->set_source_info(last->source_info()); | |
| 148 } | |
| 149 } | |
| 150 | |
| 141 } // namespace | 151 } // namespace |
| 142 | 152 |
| 143 void BytecodePeepholeOptimizer::DefaultAction( | 153 void BytecodePeepholeOptimizer::DefaultAction( |
| 144 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | 154 BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| 145 DCHECK(LastIsValid()); | 155 DCHECK(LastIsValid()); |
| 146 DCHECK(!Bytecodes::IsJump(node->bytecode())); | 156 DCHECK(!Bytecodes::IsJump(node->bytecode())); |
| 147 | 157 |
| 148 next_stage()->Write(last()); | 158 next_stage()->Write(last()); |
| 149 SetLast(node); | 159 SetLast(node); |
| 150 } | 160 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { | 254 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { |
| 245 // Fused last and current into current. | 255 // Fused last and current into current. |
| 246 TransformLdaZeroBinaryOpToBinaryOpWithZero(action_data->bytecode, last(), | 256 TransformLdaZeroBinaryOpToBinaryOpWithZero(action_data->bytecode, last(), |
| 247 node); | 257 node); |
| 248 SetLast(node); | 258 SetLast(node); |
| 249 } else { | 259 } else { |
| 250 DefaultAction(node); | 260 DefaultAction(node); |
| 251 } | 261 } |
| 252 } | 262 } |
| 253 | 263 |
| 264 void BytecodePeepholeOptimizer:: | |
| 265 TransformEqualityWithNullOrUndefinedToTestUndetectableAction( | |
| 266 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | |
| 267 DCHECK(LastIsValid()); | |
| 268 DCHECK(!Bytecodes::IsJump(node->bytecode())); | |
| 269 // Fused last and current into current. | |
| 270 TransformEqualityWithNullOrUndefinedToTestUndetectable(last(), node); | |
| 271 SetLast(node); | |
| 272 } | |
| 273 | |
| 254 void BytecodePeepholeOptimizer::DefaultJumpAction( | 274 void BytecodePeepholeOptimizer::DefaultJumpAction( |
| 255 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | 275 BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| 256 DCHECK(LastIsValid()); | 276 DCHECK(LastIsValid()); |
| 257 DCHECK(Bytecodes::IsJump(node->bytecode())); | 277 DCHECK(Bytecodes::IsJump(node->bytecode())); |
| 258 | 278 |
| 259 next_stage()->Write(last()); | 279 next_stage()->Write(last()); |
| 260 InvalidateLast(); | 280 InvalidateLast(); |
| 261 } | 281 } |
| 262 | 282 |
| 263 void BytecodePeepholeOptimizer::UpdateLastJumpAction( | 283 void BytecodePeepholeOptimizer::UpdateLastJumpAction( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 #undef CASE | 326 #undef CASE |
| 307 default: | 327 default: |
| 308 UNREACHABLE(); | 328 UNREACHABLE(); |
| 309 break; | 329 break; |
| 310 } | 330 } |
| 311 } | 331 } |
| 312 | 332 |
| 313 } // namespace interpreter | 333 } // namespace interpreter |
| 314 } // namespace internal | 334 } // namespace internal |
| 315 } // namespace v8 | 335 } // namespace v8 |
| OLD | NEW |