Commit 78b1585f authored by danno's avatar danno Committed by Commit bot

[turbofan] Add DebugBreak machine operator and support

Review-Url: https://codereview.chromium.org/1995543003
Cr-Commit-Position: refs/heads/master@{#36355}
parent 452b7f24
...@@ -22,6 +22,18 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone, ...@@ -22,6 +22,18 @@ CodeStubAssembler::CodeStubAssembler(Isolate* isolate, Zone* zone,
const char* name) const char* name)
: compiler::CodeAssembler(isolate, zone, parameter_count, flags, name) {} : compiler::CodeAssembler(isolate, zone, parameter_count, flags, name) {}
void CodeStubAssembler::Assert(Node* condition) {
#if defined(DEBUG)
Label ok(this);
Label not_ok(this);
Branch(condition, &ok, &not_ok);
Bind(&not_ok);
DebugBreak();
Goto(&ok);
Bind(&ok);
#endif
}
Node* CodeStubAssembler::BooleanMapConstant() { Node* CodeStubAssembler::BooleanMapConstant() {
return HeapConstant(isolate()->factory()->boolean_map()); return HeapConstant(isolate()->factory()->boolean_map());
} }
......
...@@ -75,6 +75,8 @@ class CodeStubAssembler : public compiler::CodeAssembler { ...@@ -75,6 +75,8 @@ class CodeStubAssembler : public compiler::CodeAssembler {
compiler::Node* InnerAllocate(compiler::Node* previous, compiler::Node* InnerAllocate(compiler::Node* previous,
compiler::Node* offset); compiler::Node* offset);
void Assert(compiler::Node* condition);
// Check a value for smi-ness // Check a value for smi-ness
compiler::Node* WordIsSmi(compiler::Node* a); compiler::Node* WordIsSmi(compiler::Node* a);
// Check that the value is a positive smi. // Check that the value is a positive smi.
......
...@@ -584,6 +584,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -584,6 +584,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
AssembleArchTableSwitch(instr); AssembleArchTableSwitch(instr);
DCHECK_EQ(LeaveCC, i.OutputSBit()); DCHECK_EQ(LeaveCC, i.OutputSBit());
break; break;
case kArchDebugBreak:
__ stop("kArchDebugBreak");
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
...@@ -711,6 +711,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -711,6 +711,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchLookupSwitch: case kArchLookupSwitch:
AssembleArchLookupSwitch(instr); AssembleArchLookupSwitch(instr);
break; break;
case kArchDebugBreak:
__ Debug("kArchDebugBreak", 0, BREAK);
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
...@@ -131,6 +131,8 @@ void CodeAssembler::Return(Node* value) { ...@@ -131,6 +131,8 @@ void CodeAssembler::Return(Node* value) {
return raw_assembler_->Return(value); return raw_assembler_->Return(value);
} }
void CodeAssembler::DebugBreak() { raw_assembler_->DebugBreak(); }
void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); } void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); }
Node* CodeAssembler::LoadFramePointer() { Node* CodeAssembler::LoadFramePointer() {
......
...@@ -203,6 +203,8 @@ class CodeAssembler { ...@@ -203,6 +203,8 @@ class CodeAssembler {
Node* Parameter(int value); Node* Parameter(int value);
void Return(Node* value); void Return(Node* value);
void DebugBreak();
void Bind(Label* label); void Bind(Label* label);
void Goto(Label* label); void Goto(Label* label);
void GotoIf(Node* condition, Label* true_label); void GotoIf(Node* condition, Label* true_label);
......
...@@ -539,6 +539,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -539,6 +539,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTableSwitch: case kArchTableSwitch:
AssembleArchTableSwitch(instr); AssembleArchTableSwitch(instr);
break; break;
case kArchDebugBreak:
__ int3();
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
...@@ -56,6 +56,7 @@ enum class RecordWriteMode { kValueIsMap, kValueIsPointer, kValueIsAny }; ...@@ -56,6 +56,7 @@ enum class RecordWriteMode { kValueIsMap, kValueIsPointer, kValueIsAny };
V(ArchLookupSwitch) \ V(ArchLookupSwitch) \
V(ArchTableSwitch) \ V(ArchTableSwitch) \
V(ArchNop) \ V(ArchNop) \
V(ArchDebugBreak) \
V(ArchThrowTerminator) \ V(ArchThrowTerminator) \
V(ArchDeoptimize) \ V(ArchDeoptimize) \
V(ArchRet) \ V(ArchRet) \
......
...@@ -222,6 +222,7 @@ int InstructionScheduler::GetInstructionFlags(const Instruction* instr) const { ...@@ -222,6 +222,7 @@ int InstructionScheduler::GetInstructionFlags(const Instruction* instr) const {
case kArchParentFramePointer: case kArchParentFramePointer:
case kArchTruncateDoubleToI: case kArchTruncateDoubleToI:
case kArchStackSlot: case kArchStackSlot:
case kArchDebugBreak:
return kNoOpcodeFlags; return kNoOpcodeFlags;
case kArchStackPointer: case kArchStackPointer:
......
...@@ -900,6 +900,9 @@ void InstructionSelector::VisitNode(Node* node) { ...@@ -900,6 +900,9 @@ void InstructionSelector::VisitNode(Node* node) {
case IrOpcode::kStateValues: case IrOpcode::kStateValues:
case IrOpcode::kObjectState: case IrOpcode::kObjectState:
return; return;
case IrOpcode::kDebugBreak:
VisitDebugBreak();
return;
case IrOpcode::kLoad: { case IrOpcode::kLoad: {
LoadRepresentation type = LoadRepresentationOf(node->op()); LoadRepresentation type = LoadRepresentationOf(node->op());
MarkAsRepresentation(type.representation(), node); MarkAsRepresentation(type.representation(), node);
...@@ -1785,6 +1788,10 @@ void InstructionSelector::VisitThrow(Node* value) { ...@@ -1785,6 +1788,10 @@ void InstructionSelector::VisitThrow(Node* value) {
Emit(kArchThrowTerminator, g.NoOutput()); Emit(kArchThrowTerminator, g.NoOutput());
} }
void InstructionSelector::VisitDebugBreak() {
OperandGenerator g(this);
Emit(kArchDebugBreak, g.NoOutput());
}
FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor( FrameStateDescriptor* InstructionSelector::GetFrameStateDescriptor(
Node* state) { Node* state) {
......
...@@ -263,6 +263,7 @@ class InstructionSelector final { ...@@ -263,6 +263,7 @@ class InstructionSelector final {
void VisitDeoptimize(DeoptimizeKind kind, Node* value); void VisitDeoptimize(DeoptimizeKind kind, Node* value);
void VisitReturn(Node* ret); void VisitReturn(Node* ret);
void VisitThrow(Node* value); void VisitThrow(Node* value);
void VisitDebugBreak();
void EmitPrepareArguments(ZoneVector<compiler::PushParameter>* arguments, void EmitPrepareArguments(ZoneVector<compiler::PushParameter>* arguments,
const CallDescriptor* descriptor, Node* node); const CallDescriptor* descriptor, Node* node);
......
...@@ -526,6 +526,13 @@ struct MachineOperatorGlobalCache { ...@@ -526,6 +526,13 @@ struct MachineOperatorGlobalCache {
AtomicStore##Type##Operator kAtomicStore##Type; AtomicStore##Type##Operator kAtomicStore##Type;
ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE) ATOMIC_REPRESENTATION_LIST(ATOMIC_STORE)
#undef STORE #undef STORE
struct DebugBreakOperator : public Operator {
DebugBreakOperator()
: Operator(IrOpcode::kDebugBreak, Operator::kNoThrow, "DebugBreak", 0,
0, 0, 0, 0, 0) {}
};
DebugBreakOperator kDebugBreak;
}; };
...@@ -604,6 +611,9 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) { ...@@ -604,6 +611,9 @@ const Operator* MachineOperatorBuilder::Store(StoreRepresentation store_rep) {
return nullptr; return nullptr;
} }
const Operator* MachineOperatorBuilder::DebugBreak() {
return &cache_.kDebugBreak;
}
const Operator* MachineOperatorBuilder::CheckedLoad( const Operator* MachineOperatorBuilder::CheckedLoad(
CheckedLoadRepresentation rep) { CheckedLoadRepresentation rep) {
......
...@@ -128,6 +128,8 @@ class MachineOperatorBuilder final : public ZoneObject { ...@@ -128,6 +128,8 @@ class MachineOperatorBuilder final : public ZoneObject {
MachineRepresentation word = MachineType::PointerRepresentation(), MachineRepresentation word = MachineType::PointerRepresentation(),
Flags supportedOperators = kNoFlags); Flags supportedOperators = kNoFlags);
const Operator* DebugBreak();
const Operator* Word32And(); const Operator* Word32And();
const Operator* Word32Or(); const Operator* Word32Or();
const Operator* Word32Xor(); const Operator* Word32Xor();
......
...@@ -652,6 +652,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -652,6 +652,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTableSwitch: case kArchTableSwitch:
AssembleArchTableSwitch(instr); AssembleArchTableSwitch(instr);
break; break;
case kArchDebugBreak:
__ stop("kArchDebugBreak");
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
...@@ -661,6 +661,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -661,6 +661,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTableSwitch: case kArchTableSwitch:
AssembleArchTableSwitch(instr); AssembleArchTableSwitch(instr);
break; break;
case kArchDebugBreak:
__ stop("kArchDebugBreak");
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
#define MACHINE_OP_LIST(V) \ #define MACHINE_OP_LIST(V) \
MACHINE_COMPARE_BINOP_LIST(V) \ MACHINE_COMPARE_BINOP_LIST(V) \
V(DebugBreak) \
V(Load) \ V(Load) \
V(Store) \ V(Store) \
V(StackSlot) \ V(StackSlot) \
......
...@@ -135,6 +135,7 @@ void RawMachineAssembler::Return(Node* v1, Node* v2, Node* v3) { ...@@ -135,6 +135,7 @@ void RawMachineAssembler::Return(Node* v1, Node* v2, Node* v3) {
current_block_ = nullptr; current_block_ = nullptr;
} }
void RawMachineAssembler::DebugBreak() { AddNode(machine()->DebugBreak()); }
Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function, Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function,
Node** args) { Node** args) {
......
...@@ -697,6 +697,7 @@ class RawMachineAssembler { ...@@ -697,6 +697,7 @@ class RawMachineAssembler {
void Return(Node* v1, Node* v2, Node* v3); void Return(Node* v1, Node* v2, Node* v3);
void Bind(RawMachineLabel* label); void Bind(RawMachineLabel* label);
void Deoptimize(Node* state); void Deoptimize(Node* state);
void DebugBreak();
// Variables. // Variables.
Node* Phi(MachineRepresentation rep, Node* n1, Node* n2) { Node* Phi(MachineRepresentation rep, Node* n1, Node* n2) {
......
...@@ -2008,6 +2008,8 @@ Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) { ...@@ -2008,6 +2008,8 @@ Type* Typer::Visitor::TypeObjectIsUndetectable(Node* node) {
// Machine operators. // Machine operators.
Type* Typer::Visitor::TypeDebugBreak(Node* node) { return Type::None(); }
Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); } Type* Typer::Visitor::TypeLoad(Node* node) { return Type::Any(); }
Type* Typer::Visitor::TypeStackSlot(Node* node) { return Type::Any(); } Type* Typer::Visitor::TypeStackSlot(Node* node) { return Type::Any(); }
......
...@@ -641,6 +641,10 @@ void Verifier::Visitor::Check(Node* node) { ...@@ -641,6 +641,10 @@ void Verifier::Visitor::Check(Node* node) {
CheckNotTyped(node); CheckNotTyped(node);
break; break;
case IrOpcode::kDebugBreak:
CheckNotTyped(node);
break;
// Simplified operators // Simplified operators
// ------------------------------- // -------------------------------
case IrOpcode::kBooleanNot: case IrOpcode::kBooleanNot:
......
...@@ -763,6 +763,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -763,6 +763,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTableSwitch: case kArchTableSwitch:
AssembleArchTableSwitch(instr); AssembleArchTableSwitch(instr);
break; break;
case kArchDebugBreak:
__ int3();
break;
case kArchNop: case kArchNop:
case kArchThrowTerminator: case kArchThrowTerminator:
// don't emit code for nops. // don't emit code for nops.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment