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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 2666283002: [turbofan] Constant propagation for JumpIfFalse/JumpIfTrue. (Closed)
Patch Set: REBASE Created 3 years, 10 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 | « src/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 2389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool. 2400 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool.
2401 void Interpreter::DoJumpConstant(InterpreterAssembler* assembler) { 2401 void Interpreter::DoJumpConstant(InterpreterAssembler* assembler) {
2402 Node* index = __ BytecodeOperandIdx(0); 2402 Node* index = __ BytecodeOperandIdx(0);
2403 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); 2403 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index);
2404 __ Jump(relative_jump); 2404 __ Jump(relative_jump);
2405 } 2405 }
2406 2406
2407 // JumpIfTrue <imm> 2407 // JumpIfTrue <imm>
2408 // 2408 //
2409 // Jump by number of bytes represented by an immediate operand if the 2409 // Jump by number of bytes represented by an immediate operand if the
2410 // accumulator contains true. 2410 // accumulator contains true. This only works for boolean inputs, and
2411 // will misbehave if passed arbitrary input values.
2411 void Interpreter::DoJumpIfTrue(InterpreterAssembler* assembler) { 2412 void Interpreter::DoJumpIfTrue(InterpreterAssembler* assembler) {
2412 Node* accumulator = __ GetAccumulator(); 2413 Node* accumulator = __ GetAccumulator();
2413 Node* relative_jump = __ BytecodeOperandUImmWord(0); 2414 Node* relative_jump = __ BytecodeOperandUImmWord(0);
2414 Node* true_value = __ BooleanConstant(true); 2415 Node* true_value = __ BooleanConstant(true);
2416 CSA_ASSERT(assembler, assembler->TaggedIsNotSmi(accumulator));
2417 CSA_ASSERT(assembler, assembler->IsBoolean(accumulator));
2415 __ JumpIfWordEqual(accumulator, true_value, relative_jump); 2418 __ JumpIfWordEqual(accumulator, true_value, relative_jump);
2416 } 2419 }
2417 2420
2418 // JumpIfTrueConstant <idx> 2421 // JumpIfTrueConstant <idx>
2419 // 2422 //
2420 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool 2423 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool
2421 // if the accumulator contains true. 2424 // if the accumulator contains true. This only works for boolean inputs, and
2425 // will misbehave if passed arbitrary input values.
2422 void Interpreter::DoJumpIfTrueConstant(InterpreterAssembler* assembler) { 2426 void Interpreter::DoJumpIfTrueConstant(InterpreterAssembler* assembler) {
2423 Node* accumulator = __ GetAccumulator(); 2427 Node* accumulator = __ GetAccumulator();
2424 Node* index = __ BytecodeOperandIdx(0); 2428 Node* index = __ BytecodeOperandIdx(0);
2425 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); 2429 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index);
2426 Node* true_value = __ BooleanConstant(true); 2430 Node* true_value = __ BooleanConstant(true);
2431 CSA_ASSERT(assembler, assembler->TaggedIsNotSmi(accumulator));
2432 CSA_ASSERT(assembler, assembler->IsBoolean(accumulator));
2427 __ JumpIfWordEqual(accumulator, true_value, relative_jump); 2433 __ JumpIfWordEqual(accumulator, true_value, relative_jump);
2428 } 2434 }
2429 2435
2430 // JumpIfFalse <imm> 2436 // JumpIfFalse <imm>
2431 // 2437 //
2432 // Jump by number of bytes represented by an immediate operand if the 2438 // Jump by number of bytes represented by an immediate operand if the
2433 // accumulator contains false. 2439 // accumulator contains false. This only works for boolean inputs, and
2440 // will misbehave if passed arbitrary input values.
2434 void Interpreter::DoJumpIfFalse(InterpreterAssembler* assembler) { 2441 void Interpreter::DoJumpIfFalse(InterpreterAssembler* assembler) {
2435 Node* accumulator = __ GetAccumulator(); 2442 Node* accumulator = __ GetAccumulator();
2436 Node* relative_jump = __ BytecodeOperandUImmWord(0); 2443 Node* relative_jump = __ BytecodeOperandUImmWord(0);
2437 Node* false_value = __ BooleanConstant(false); 2444 Node* false_value = __ BooleanConstant(false);
2445 CSA_ASSERT(assembler, assembler->TaggedIsNotSmi(accumulator));
2446 CSA_ASSERT(assembler, assembler->IsBoolean(accumulator));
2438 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 2447 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
2439 } 2448 }
2440 2449
2441 // JumpIfFalseConstant <idx> 2450 // JumpIfFalseConstant <idx>
2442 // 2451 //
2443 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool 2452 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool
2444 // if the accumulator contains false. 2453 // if the accumulator contains false. This only works for boolean inputs, and
2454 // will misbehave if passed arbitrary input values.
2445 void Interpreter::DoJumpIfFalseConstant(InterpreterAssembler* assembler) { 2455 void Interpreter::DoJumpIfFalseConstant(InterpreterAssembler* assembler) {
2446 Node* accumulator = __ GetAccumulator(); 2456 Node* accumulator = __ GetAccumulator();
2447 Node* index = __ BytecodeOperandIdx(0); 2457 Node* index = __ BytecodeOperandIdx(0);
2448 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index); 2458 Node* relative_jump = __ LoadAndUntagConstantPoolEntry(index);
2449 Node* false_value = __ BooleanConstant(false); 2459 Node* false_value = __ BooleanConstant(false);
2460 CSA_ASSERT(assembler, assembler->TaggedIsNotSmi(accumulator));
2461 CSA_ASSERT(assembler, assembler->IsBoolean(accumulator));
2450 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 2462 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
2451 } 2463 }
2452 2464
2453 // JumpIfToBooleanTrue <imm> 2465 // JumpIfToBooleanTrue <imm>
2454 // 2466 //
2455 // Jump by number of bytes represented by an immediate operand if the object 2467 // Jump by number of bytes represented by an immediate operand if the object
2456 // referenced by the accumulator is true when the object is cast to boolean. 2468 // referenced by the accumulator is true when the object is cast to boolean.
2457 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { 2469 void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) {
2458 Node* value = __ GetAccumulator(); 2470 Node* value = __ GetAccumulator();
2459 Node* relative_jump = __ BytecodeOperandUImmWord(0); 2471 Node* relative_jump = __ BytecodeOperandUImmWord(0);
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3299 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 3311 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
3300 __ SmiTag(new_state)); 3312 __ SmiTag(new_state));
3301 __ SetAccumulator(old_state); 3313 __ SetAccumulator(old_state);
3302 3314
3303 __ Dispatch(); 3315 __ Dispatch();
3304 } 3316 }
3305 3317
3306 } // namespace interpreter 3318 } // namespace interpreter
3307 } // namespace internal 3319 } // namespace internal
3308 } // namespace v8 3320 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698