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 Bytecode new_bytecode, BytecodeNode* const last, | |
| 143 BytecodeNode* const current) { | |
| 144 DCHECK((last->bytecode() == Bytecode::kLdaNull) || | |
| 145 (last->bytecode() == Bytecode::kLdaUndefined)); | |
| 146 current->set_bytecode(new_bytecode, current->operand(0)); | |
|
rmcilroy
2016/12/05 10:57:19
I don't think you need to pass the new_bytecode (
mythria
2016/12/05 14:53:11
Yes, we don't need action data. I did not think ab
| |
| 147 if (last->source_info().is_valid()) { | |
| 148 current->set_source_info(last->source_info()); | |
| 149 } | |
| 150 } | |
| 151 | |
| 141 } // namespace | 152 } // namespace |
| 142 | 153 |
| 143 void BytecodePeepholeOptimizer::DefaultAction( | 154 void BytecodePeepholeOptimizer::DefaultAction( |
| 144 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | 155 BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| 145 DCHECK(LastIsValid()); | 156 DCHECK(LastIsValid()); |
| 146 DCHECK(!Bytecodes::IsJump(node->bytecode())); | 157 DCHECK(!Bytecodes::IsJump(node->bytecode())); |
| 147 | 158 |
| 148 next_stage()->Write(last()); | 159 next_stage()->Write(last()); |
| 149 SetLast(node); | 160 SetLast(node); |
| 150 } | 161 } |
| (...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()) { | 255 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { |
| 245 // Fused last and current into current. | 256 // Fused last and current into current. |
| 246 TransformLdaZeroBinaryOpToBinaryOpWithZero(action_data->bytecode, last(), | 257 TransformLdaZeroBinaryOpToBinaryOpWithZero(action_data->bytecode, last(), |
| 247 node); | 258 node); |
| 248 SetLast(node); | 259 SetLast(node); |
| 249 } else { | 260 } else { |
| 250 DefaultAction(node); | 261 DefaultAction(node); |
| 251 } | 262 } |
| 252 } | 263 } |
| 253 | 264 |
| 265 void BytecodePeepholeOptimizer:: | |
| 266 TransformEqualityWithNullOrUndefinedToTestUndetectableAction( | |
| 267 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | |
| 268 DCHECK(LastIsValid()); | |
| 269 DCHECK(!Bytecodes::IsJump(node->bytecode())); | |
| 270 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { | |
|
rmcilroy
2016/12/05 10:57:19
Do we need to do this check? LdaUndefined/null can
mythria
2016/12/05 14:53:11
I don't think we need, because if my understanding
rmcilroy
2016/12/05 19:08:09
Yeah we could think about removing for BinaryOpWit
| |
| 271 // Fused last and current into current. | |
| 272 TransformEqualityWithNullOrUndefinedToTestUndetectable( | |
| 273 action_data->bytecode, last(), node); | |
| 274 SetLast(node); | |
| 275 } else { | |
| 276 DefaultAction(node); | |
| 277 } | |
| 278 } | |
| 279 | |
| 254 void BytecodePeepholeOptimizer::DefaultJumpAction( | 280 void BytecodePeepholeOptimizer::DefaultJumpAction( |
| 255 BytecodeNode* const node, const PeepholeActionAndData* action_data) { | 281 BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| 256 DCHECK(LastIsValid()); | 282 DCHECK(LastIsValid()); |
| 257 DCHECK(Bytecodes::IsJump(node->bytecode())); | 283 DCHECK(Bytecodes::IsJump(node->bytecode())); |
| 258 | 284 |
| 259 next_stage()->Write(last()); | 285 next_stage()->Write(last()); |
| 260 InvalidateLast(); | 286 InvalidateLast(); |
| 261 } | 287 } |
| 262 | 288 |
| 263 void BytecodePeepholeOptimizer::UpdateLastJumpAction( | 289 void BytecodePeepholeOptimizer::UpdateLastJumpAction( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 #undef CASE | 332 #undef CASE |
| 307 default: | 333 default: |
| 308 UNREACHABLE(); | 334 UNREACHABLE(); |
| 309 break; | 335 break; |
| 310 } | 336 } |
| 311 } | 337 } |
| 312 | 338 |
| 313 } // namespace interpreter | 339 } // namespace interpreter |
| 314 } // namespace internal | 340 } // namespace internal |
| 315 } // namespace v8 | 341 } // namespace v8 |
| OLD | NEW |