Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: src/interpreter/bytecode-peephole-optimizer.cc

Issue 2547043002: [Interpreter] Optimize equality check with null/undefined with a check on the map. (Closed)
Patch Set: Address comments from Ross. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/bytecode-peephole-table.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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));
145 DCHECK_EQ(current->bytecode(), Bytecode::kTestEqual);
146 current->set_bytecode(Bytecode::kTestUndetectable, current->operand(0));
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
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 // Fused last and current into current.
271 TransformEqualityWithNullOrUndefinedToTestUndetectable(last(), node);
272 SetLast(node);
273 }
274
254 void BytecodePeepholeOptimizer::DefaultJumpAction( 275 void BytecodePeepholeOptimizer::DefaultJumpAction(
255 BytecodeNode* const node, const PeepholeActionAndData* action_data) { 276 BytecodeNode* const node, const PeepholeActionAndData* action_data) {
256 DCHECK(LastIsValid()); 277 DCHECK(LastIsValid());
257 DCHECK(Bytecodes::IsJump(node->bytecode())); 278 DCHECK(Bytecodes::IsJump(node->bytecode()));
258 279
259 next_stage()->Write(last()); 280 next_stage()->Write(last());
260 InvalidateLast(); 281 InvalidateLast();
261 } 282 }
262 283
263 void BytecodePeepholeOptimizer::UpdateLastJumpAction( 284 void BytecodePeepholeOptimizer::UpdateLastJumpAction(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 #undef CASE 327 #undef CASE
307 default: 328 default:
308 UNREACHABLE(); 329 UNREACHABLE();
309 break; 330 break;
310 } 331 }
311 } 332 }
312 333
313 } // namespace interpreter 334 } // namespace interpreter
314 } // namespace internal 335 } // namespace internal
315 } // namespace v8 336 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/bytecode-peephole-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698