[turbofan] Improve graph for JumpIfTrue/False and JumpIfToBooleanTrue/False.
Avoid the useless strict equality comparisons with true/false being generated for the JumpIfTrue, JumpIfFalse, JumpIfToBooleanTrue and JumpIfToBooleanFalse bytecodes. Instead feed the accumulator (or the outcome of ToBoolean) directly to the Branch node and do the negation as part of the control flow. The previous subraphs would render the loop variable analysis useless, and would cause a lot of unnecessary bit materialization, because many of our optimizations don't kick in. Note: This is only part of the problem, there are more subtle differences in the bytecode pipeline that prevent several important optimizations to kick in. R=mstarzinger@chromium.org BUG=v8:5267,v8:5348 Review-Url: https://codereview.chromium.org/2309733002 Cr-Commit-Position: refs/heads/master@{#39151}
This commit is contained in:
parent
c79e163ba8
commit
776a5c1008
@ -1465,37 +1465,28 @@ void BytecodeGraphBuilder::VisitJump() { BuildJump(); }
|
|||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); }
|
void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); }
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::VisitJumpIfTrue() { BuildJumpIfTrue(); }
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfTrue() {
|
void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { BuildJumpIfTrue(); }
|
||||||
BuildJumpIfEqual(jsgraph()->TrueConstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfTrueConstant() {
|
void BytecodeGraphBuilder::VisitJumpIfFalse() { BuildJumpIfFalse(); }
|
||||||
BuildJumpIfEqual(jsgraph()->TrueConstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfFalse() {
|
void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { BuildJumpIfFalse(); }
|
||||||
BuildJumpIfEqual(jsgraph()->FalseConstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfFalseConstant() {
|
|
||||||
BuildJumpIfEqual(jsgraph()->FalseConstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() {
|
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() {
|
||||||
BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant());
|
BuildJumpIfToBooleanTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() {
|
void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() {
|
||||||
BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant());
|
BuildJumpIfToBooleanTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() {
|
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() {
|
||||||
BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant());
|
BuildJumpIfToBooleanFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() {
|
void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() {
|
||||||
BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant());
|
BuildJumpIfToBooleanFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); }
|
void BytecodeGraphBuilder::VisitJumpIfNotHole() { BuildJumpIfNotHole(); }
|
||||||
@ -1731,8 +1722,7 @@ void BytecodeGraphBuilder::BuildJump() {
|
|||||||
MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset());
|
MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::BuildJumpIf(Node* condition) {
|
||||||
void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) {
|
|
||||||
NewBranch(condition);
|
NewBranch(condition);
|
||||||
Environment* if_false_environment = environment()->CopyForConditional();
|
Environment* if_false_environment = environment()->CopyForConditional();
|
||||||
NewIfTrue();
|
NewIfTrue();
|
||||||
@ -1741,24 +1731,43 @@ void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) {
|
|||||||
NewIfFalse();
|
NewIfFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::BuildJumpIfNot(Node* condition) {
|
||||||
|
NewBranch(condition);
|
||||||
|
Environment* if_true_environment = environment()->CopyForConditional();
|
||||||
|
NewIfFalse();
|
||||||
|
MergeIntoSuccessorEnvironment(bytecode_iterator().GetJumpTargetOffset());
|
||||||
|
set_environment(if_true_environment);
|
||||||
|
NewIfTrue();
|
||||||
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) {
|
void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) {
|
||||||
Node* accumulator = environment()->LookupAccumulator();
|
Node* accumulator = environment()->LookupAccumulator();
|
||||||
Node* condition =
|
Node* condition =
|
||||||
NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
|
NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
|
||||||
accumulator, comperand);
|
accumulator, comperand);
|
||||||
BuildConditionalJump(condition);
|
BuildJumpIf(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::BuildJumpIfFalse() {
|
||||||
|
BuildJumpIfNot(environment()->LookupAccumulator());
|
||||||
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::BuildJumpIfToBooleanEqual(Node* comperand) {
|
void BytecodeGraphBuilder::BuildJumpIfTrue() {
|
||||||
|
BuildJumpIf(environment()->LookupAccumulator());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::BuildJumpIfToBooleanTrue() {
|
||||||
Node* accumulator = environment()->LookupAccumulator();
|
Node* accumulator = environment()->LookupAccumulator();
|
||||||
Node* to_boolean =
|
|
||||||
NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator);
|
|
||||||
Node* condition =
|
Node* condition =
|
||||||
NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), to_boolean,
|
NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator);
|
||||||
comperand);
|
BuildJumpIf(condition);
|
||||||
BuildConditionalJump(condition);
|
}
|
||||||
|
|
||||||
|
void BytecodeGraphBuilder::BuildJumpIfToBooleanFalse() {
|
||||||
|
Node* accumulator = environment()->LookupAccumulator();
|
||||||
|
Node* condition =
|
||||||
|
NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), accumulator);
|
||||||
|
BuildJumpIfNot(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeGraphBuilder::BuildJumpIfNotHole() {
|
void BytecodeGraphBuilder::BuildJumpIfNotHole() {
|
||||||
@ -1766,10 +1775,7 @@ void BytecodeGraphBuilder::BuildJumpIfNotHole() {
|
|||||||
Node* condition =
|
Node* condition =
|
||||||
NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
|
NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
|
||||||
accumulator, jsgraph()->TheHoleConstant());
|
accumulator, jsgraph()->TheHoleConstant());
|
||||||
Node* node =
|
BuildJumpIfNot(condition);
|
||||||
NewNode(common()->Select(MachineRepresentation::kTagged), condition,
|
|
||||||
jsgraph()->FalseConstant(), jsgraph()->TrueConstant());
|
|
||||||
BuildConditionalJump(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) {
|
Node** BytecodeGraphBuilder::EnsureInputBufferSize(int size) {
|
||||||
|
@ -147,9 +147,13 @@ class BytecodeGraphBuilder {
|
|||||||
|
|
||||||
// Control flow plumbing.
|
// Control flow plumbing.
|
||||||
void BuildJump();
|
void BuildJump();
|
||||||
void BuildConditionalJump(Node* condition);
|
void BuildJumpIf(Node* condition);
|
||||||
|
void BuildJumpIfNot(Node* condition);
|
||||||
void BuildJumpIfEqual(Node* comperand);
|
void BuildJumpIfEqual(Node* comperand);
|
||||||
void BuildJumpIfToBooleanEqual(Node* boolean_comperand);
|
void BuildJumpIfTrue();
|
||||||
|
void BuildJumpIfFalse();
|
||||||
|
void BuildJumpIfToBooleanTrue();
|
||||||
|
void BuildJumpIfToBooleanFalse();
|
||||||
void BuildJumpIfNotHole();
|
void BuildJumpIfNotHole();
|
||||||
|
|
||||||
// Simulates control flow by forward-propagating environments.
|
// Simulates control flow by forward-propagating environments.
|
||||||
|
Loading…
Reference in New Issue
Block a user