[maglev] Support JumpIf[Not]Null and JumpIf[Not]Undefined
Additionally, the CL creates a BranchIfRootConstant node and updates JumpIfTrue and JumpIfFalse. Bug: v8:7700 Change-Id: I7ee98f4b726ffef0f7969231b598d6216b09ccfc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3769828 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Auto-Submit: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#81798}
This commit is contained in:
parent
4e8b60af11
commit
5f1b06e366
@ -1794,12 +1794,30 @@ void MaglevGraphBuilder::MergeIntoInlinedReturnFrameState(
|
||||
}
|
||||
}
|
||||
|
||||
void MaglevGraphBuilder::BuildBranchIfRootConstant(ValueNode* node,
|
||||
int true_target,
|
||||
int false_target,
|
||||
RootIndex root_index) {
|
||||
BasicBlock* block = FinishBlock<BranchIfRootConstant>(
|
||||
next_offset(), {node}, &jump_targets_[true_target],
|
||||
&jump_targets_[false_target], root_index);
|
||||
MergeIntoFrameState(block, iterator_.GetJumpTargetOffset());
|
||||
}
|
||||
void MaglevGraphBuilder::BuildBranchIfTrue(ValueNode* node, int true_target,
|
||||
int false_target) {
|
||||
BasicBlock* block = FinishBlock<BranchIfTrue>(next_offset(), {node},
|
||||
&jump_targets_[true_target],
|
||||
&jump_targets_[false_target]);
|
||||
MergeIntoFrameState(block, iterator_.GetJumpTargetOffset());
|
||||
BuildBranchIfRootConstant(node, true_target, false_target,
|
||||
RootIndex::kTrueValue);
|
||||
}
|
||||
void MaglevGraphBuilder::BuildBranchIfNull(ValueNode* node, int true_target,
|
||||
int false_target) {
|
||||
BuildBranchIfRootConstant(node, true_target, false_target,
|
||||
RootIndex::kNullValue);
|
||||
}
|
||||
void MaglevGraphBuilder::BuildBranchIfUndefined(ValueNode* node,
|
||||
int true_target,
|
||||
int false_target) {
|
||||
BuildBranchIfRootConstant(node, true_target, false_target,
|
||||
RootIndex::kUndefinedValue);
|
||||
}
|
||||
void MaglevGraphBuilder::BuildBranchIfToBooleanTrue(ValueNode* node,
|
||||
int true_target,
|
||||
@ -1825,10 +1843,22 @@ void MaglevGraphBuilder::VisitJumpIfFalse() {
|
||||
BuildBranchIfTrue(GetAccumulatorTagged(), next_offset(),
|
||||
iterator_.GetJumpTargetOffset());
|
||||
}
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNull)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNotNull)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfUndefined)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNotUndefined)
|
||||
void MaglevGraphBuilder::VisitJumpIfNull() {
|
||||
BuildBranchIfNull(GetAccumulatorTagged(), iterator_.GetJumpTargetOffset(),
|
||||
next_offset());
|
||||
}
|
||||
void MaglevGraphBuilder::VisitJumpIfNotNull() {
|
||||
BuildBranchIfNull(GetAccumulatorTagged(), next_offset(),
|
||||
iterator_.GetJumpTargetOffset());
|
||||
}
|
||||
void MaglevGraphBuilder::VisitJumpIfUndefined() {
|
||||
BuildBranchIfUndefined(GetAccumulatorTagged(),
|
||||
iterator_.GetJumpTargetOffset(), next_offset());
|
||||
}
|
||||
void MaglevGraphBuilder::VisitJumpIfNotUndefined() {
|
||||
BuildBranchIfUndefined(GetAccumulatorTagged(), next_offset(),
|
||||
iterator_.GetJumpTargetOffset());
|
||||
}
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfUndefinedOrNull)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfJSReceiver)
|
||||
MAGLEV_UNIMPLEMENTED_BYTECODE(SwitchOnSmiNoFeedback)
|
||||
|
@ -698,7 +698,12 @@ class MaglevGraphBuilder {
|
||||
void MergeDeadIntoFrameState(int target);
|
||||
void MergeDeadLoopIntoFrameState(int target);
|
||||
void MergeIntoInlinedReturnFrameState(BasicBlock* block);
|
||||
void BuildBranchIfRootConstant(ValueNode* node, int true_target,
|
||||
int false_target, RootIndex root_index);
|
||||
void BuildBranchIfTrue(ValueNode* node, int true_target, int false_target);
|
||||
void BuildBranchIfNull(ValueNode* node, int true_target, int false_target);
|
||||
void BuildBranchIfUndefined(ValueNode* node, int true_target,
|
||||
int false_target);
|
||||
void BuildBranchIfToBooleanTrue(ValueNode* node, int true_target,
|
||||
int false_target);
|
||||
|
||||
|
@ -101,7 +101,7 @@ class MaglevGraphVerifier {
|
||||
case Opcode::kCheckedInternalizedString:
|
||||
// TODO(victorgomes): Can we check that the input is Boolean?
|
||||
case Opcode::kBranchIfToBooleanTrue:
|
||||
case Opcode::kBranchIfTrue:
|
||||
case Opcode::kBranchIfRootConstant:
|
||||
case Opcode::kCheckedFloat64Unbox:
|
||||
case Opcode::kCreateFunctionContext:
|
||||
case Opcode::kCreateClosure:
|
||||
|
@ -2117,11 +2117,11 @@ void JumpLoop::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
__ jmp(target()->label());
|
||||
}
|
||||
|
||||
void BranchIfTrue::AllocateVreg(MaglevVregAllocationState* vreg_state) {
|
||||
void BranchIfRootConstant::AllocateVreg(MaglevVregAllocationState* vreg_state) {
|
||||
UseRegister(condition_input());
|
||||
}
|
||||
void BranchIfTrue::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
const ProcessingState& state) {
|
||||
void BranchIfRootConstant::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
const ProcessingState& state) {
|
||||
Register value = ToRegister(condition_input());
|
||||
|
||||
auto* next_block = state.next_block();
|
||||
@ -2130,10 +2130,10 @@ void BranchIfTrue::GenerateCode(MaglevCodeGenState* code_gen_state,
|
||||
// over whatever the next block emitted is.
|
||||
if (if_false() == next_block) {
|
||||
// Jump over the false block if true, otherwise fall through into it.
|
||||
__ JumpIfRoot(value, RootIndex::kTrueValue, if_true()->label());
|
||||
__ JumpIfRoot(value, root_index(), if_true()->label());
|
||||
} else {
|
||||
// Jump to the false block if true.
|
||||
__ JumpIfNotRoot(value, RootIndex::kTrueValue, if_false()->label());
|
||||
__ JumpIfNotRoot(value, root_index(), if_false()->label());
|
||||
// Jump to the true block if it's not the next block.
|
||||
if (if_true() != next_block) {
|
||||
__ jmp(if_true()->label());
|
||||
|
@ -172,7 +172,7 @@ class CompactInterpreterFrameState;
|
||||
VALUE_NODE_LIST(V)
|
||||
|
||||
#define CONDITIONAL_CONTROL_NODE_LIST(V) \
|
||||
V(BranchIfTrue) \
|
||||
V(BranchIfRootConstant) \
|
||||
V(BranchIfToBooleanTrue) \
|
||||
V(BranchIfReferenceCompare) \
|
||||
V(BranchIfInt32Compare) \
|
||||
@ -2898,19 +2898,25 @@ class Deopt : public ControlNode {
|
||||
DeoptimizeReason reason_;
|
||||
};
|
||||
|
||||
class BranchIfTrue : public ConditionalControlNodeT<1, BranchIfTrue> {
|
||||
using Base = ConditionalControlNodeT<1, BranchIfTrue>;
|
||||
class BranchIfRootConstant
|
||||
: public ConditionalControlNodeT<1, BranchIfRootConstant> {
|
||||
using Base = ConditionalControlNodeT<1, BranchIfRootConstant>;
|
||||
|
||||
public:
|
||||
explicit BranchIfTrue(uint64_t bitfield, BasicBlockRef* if_true_refs,
|
||||
BasicBlockRef* if_false_refs)
|
||||
: Base(bitfield, if_true_refs, if_false_refs) {}
|
||||
explicit BranchIfRootConstant(uint64_t bitfield, BasicBlockRef* if_true_refs,
|
||||
BasicBlockRef* if_false_refs,
|
||||
RootIndex root_index)
|
||||
: Base(bitfield, if_true_refs, if_false_refs), root_index_(root_index) {}
|
||||
|
||||
RootIndex root_index() { return root_index_; }
|
||||
Input& condition_input() { return input(0); }
|
||||
|
||||
void AllocateVreg(MaglevVregAllocationState*);
|
||||
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
|
||||
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
|
||||
|
||||
private:
|
||||
RootIndex root_index_;
|
||||
};
|
||||
|
||||
class BranchIfToBooleanTrue
|
||||
|
Loading…
Reference in New Issue
Block a user