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

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

Issue 2185123003: [interpreter] Fix peephole rule on eliding last before jump. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months 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 | « no previous file | test/mjsunit/ignition/regress-629792-source-position-on-jump.js » ('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/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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 322
323 next_stage()->Write(last()); 323 next_stage()->Write(last());
324 InvalidateLast(); 324 InvalidateLast();
325 node->set_bytecode(action_data->bytecode, node->operand(0)); 325 node->set_bytecode(action_data->bytecode, node->operand(0));
326 } 326 }
327 327
328 void BytecodePeepholeOptimizer::ElideLastBeforeJumpAction( 328 void BytecodePeepholeOptimizer::ElideLastBeforeJumpAction(
329 BytecodeNode* const node, const PeepholeActionAndData* action_data) { 329 BytecodeNode* const node, const PeepholeActionAndData* action_data) {
330 DCHECK(LastIsValid()); 330 DCHECK(LastIsValid());
331 DCHECK(Bytecodes::IsJump(node->bytecode())); 331 DCHECK(Bytecodes::IsJump(node->bytecode()));
332 DCHECK(CanElideLastBasedOnSourcePosition(node));
333 332
334 if (!node->source_info().is_valid()) { 333 if (!CanElideLastBasedOnSourcePosition(node)) {
334 next_stage()->Write(last());
335 } else if (!node->source_info().is_valid()) {
335 node->source_info().Clone(last()->source_info()); 336 node->source_info().Clone(last()->source_info());
336 } else {
337 next_stage()->Write(last());
338 } 337 }
339 InvalidateLast(); 338 InvalidateLast();
340 } 339 }
341 340
342 void BytecodePeepholeOptimizer::ApplyPeepholeAction(BytecodeNode* const node) { 341 void BytecodePeepholeOptimizer::ApplyPeepholeAction(BytecodeNode* const node) {
343 // A single table is used for looking up peephole optimization 342 // A single table is used for looking up peephole optimization
344 // matches as it is observed to have better performance. This is 343 // matches as it is observed to have better performance. This is
345 // inspite of the fact that jump bytecodes and non-jump bytecodes 344 // inspite of the fact that jump bytecodes and non-jump bytecodes
346 // have different processing logic, in particular a jump bytecode 345 // have different processing logic, in particular a jump bytecode
347 // always needs to emit the jump via WriteJump(). 346 // always needs to emit the jump via WriteJump().
348 const PeepholeActionAndData* const action_data = 347 const PeepholeActionAndData* const action_data =
349 PeepholeActionTable::Lookup(last()->bytecode(), node->bytecode()); 348 PeepholeActionTable::Lookup(last()->bytecode(), node->bytecode());
350 switch (action_data->action) { 349 switch (action_data->action) {
351 #define CASE(Action) \ 350 #define CASE(Action) \
352 case PeepholeAction::k##Action: \ 351 case PeepholeAction::k##Action: \
353 Action(node, action_data); \ 352 Action(node, action_data); \
354 break; 353 break;
355 PEEPHOLE_ACTION_LIST(CASE) 354 PEEPHOLE_ACTION_LIST(CASE)
356 #undef CASE 355 #undef CASE
357 default: 356 default:
358 UNREACHABLE(); 357 UNREACHABLE();
359 break; 358 break;
360 } 359 }
361 } 360 }
362 361
363 } // namespace interpreter 362 } // namespace interpreter
364 } // namespace internal 363 } // namespace internal
365 } // namespace v8 364 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/ignition/regress-629792-source-position-on-jump.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698