From 8bbe48c7b9520afc4383f74825e68a13a0cb9aef Mon Sep 17 00:00:00 2001 From: "olivf@chromium.org" Date: Wed, 15 May 2013 14:24:47 +0000 Subject: [PATCH] Add a HBreak instruction for debugging BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/14997008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14691 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 4 ++++ src/arm/lithium-arm.h | 7 +++++++ src/arm/lithium-codegen-arm.cc | 5 +++++ src/hydrogen-instructions.h | 12 ++++++++++++ src/ia32/lithium-codegen-ia32.cc | 5 +++++ src/ia32/lithium-ia32.cc | 5 +++++ src/ia32/lithium-ia32.h | 7 +++++++ src/mips/lithium-codegen-mips.cc | 5 +++++ src/mips/lithium-mips.cc | 4 ++++ src/mips/lithium-mips.h | 7 +++++++ src/x64/lithium-codegen-x64.cc | 5 +++++ src/x64/lithium-x64.cc | 5 +++++ src/x64/lithium-x64.h | 7 +++++++ 13 files changed, 78 insertions(+) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index edc1120..5032950 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -980,6 +980,10 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { } +LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { + return new(zone()) LDebugBreak(); +} + LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { ASSERT(instr->value()->representation().IsTagged()); diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 9deed58..9bcd44a 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -89,6 +89,7 @@ class LCodeGen; V(ConstantI) \ V(ConstantT) \ V(Context) \ + V(DebugBreak) \ V(DeclareGlobals) \ V(DeleteProperty) \ V(Deoptimize) \ @@ -695,6 +696,12 @@ class LMultiplySubD: public LTemplateInstruction<1, 3, 0> { }; +class LDebugBreak: public LTemplateInstruction<0, 0, 0> { + public: + DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break") +}; + + class LCmpIDAndBranch: public LControlInstruction<2, 0> { public: LCmpIDAndBranch(LOperand* left, LOperand* right) { diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 2b0f611..96adb2f 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2198,6 +2198,11 @@ void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) { } +void LCodeGen::DoDebugBreak(LDebugBreak* instr) { + __ stop("LBreak"); +} + + void LCodeGen::DoBranch(LBranch* instr) { int true_block = chunk_->LookupDestination(instr->true_block_id()); int false_block = chunk_->LookupDestination(instr->false_block_id()); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 138587c..5f84d64 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -103,6 +103,7 @@ class LChunkBuilder; V(CompareConstantEqAndBranch) \ V(Constant) \ V(Context) \ + V(DebugBreak) \ V(DeclareGlobals) \ V(DeleteProperty) \ V(Deoptimize) \ @@ -1463,6 +1464,17 @@ class HSoftDeoptimize: public HTemplateInstruction<0> { }; +// Inserts an int3/stop break instruction for debugging purposes. +class HDebugBreak: public HTemplateInstruction<0> { + public: + virtual Representation RequiredInputRepresentation(int index) { + return Representation::None(); + } + + DECLARE_CONCRETE_INSTRUCTION(DebugBreak) +}; + + class HDeoptimize: public HControlInstruction { public: HDeoptimize(int environment_length, Zone* zone) diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index f262fd6..b6244af 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3500,6 +3500,11 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) { } +void LCodeGen::DoDebugBreak(LDebugBreak* instr) { + __ int3(); +} + + void LCodeGen::DoPushArgument(LPushArgument* instr) { LOperand* argument = instr->value(); EmitPushTaggedOperand(argument); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index f10ab25..b655aec 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1049,6 +1049,11 @@ LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { } +LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { + return new(zone()) LDebugBreak(); +} + + LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { ASSERT(instr->value()->representation().IsTagged()); LOperand* value = UseRegisterAtStart(instr->value()); diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 5df6883..b32ead9 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -84,6 +84,7 @@ class LCodeGen; V(ConstantI) \ V(ConstantT) \ V(Context) \ + V(DebugBreak) \ V(DeclareGlobals) \ V(DeleteProperty) \ V(Deoptimize) \ @@ -569,6 +570,12 @@ class LArgumentsElements: public LTemplateInstruction<1, 0, 0> { }; +class LDebugBreak: public LTemplateInstruction<0, 0, 0> { + public: + DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break") +}; + + class LModI: public LTemplateInstruction<1, 2, 1> { public: LModI(LOperand* left, LOperand* right, LOperand* temp) { diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 47ef40a..ae0d628 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -1827,6 +1827,11 @@ void LCodeGen::EmitBranchF(int left_block, int right_block, } +void LCodeGen::DoDebugBreak(LDebugBreak* instr) { + __ stop("LDebugBreak"); +} + + void LCodeGen::DoBranch(LBranch* instr) { int true_block = chunk_->LookupDestination(instr->true_block_id()); int false_block = chunk_->LookupDestination(instr->false_block_id()); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 719acb3..2196325 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -208,6 +208,10 @@ void LBranch::PrintDataTo(StringStream* stream) { } +LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { + return new(zone()) LDebugBreak(); +} + void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { stream->Add("if "); left()->PrintTo(stream); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 4f8eecd..1abea90 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -89,6 +89,7 @@ class LCodeGen; V(ConstantI) \ V(ConstantT) \ V(Context) \ + V(DebugBreak) \ V(DeclareGlobals) \ V(DeleteProperty) \ V(Deoptimize) \ @@ -655,6 +656,12 @@ class LMultiplyAddD: public LTemplateInstruction<1, 3, 0> { }; +class LDebugBreak: public LTemplateInstruction<0, 0, 0> { + public: + DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break") +}; + + class LCmpIDAndBranch: public LControlInstruction<2, 0> { public: LCmpIDAndBranch(LOperand* left, LOperand* right) { diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index a2a6151..9a1ce98 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1863,6 +1863,11 @@ void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) { } +void LCodeGen::DoDebugBreak(LDebugBreak* instr) { + __ int3(); +} + + void LCodeGen::DoBranch(LBranch* instr) { int true_block = chunk_->LookupDestination(instr->true_block_id()); int false_block = chunk_->LookupDestination(instr->false_block_id()); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index e7bc08c..1217a40 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -967,6 +967,11 @@ LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { } +LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { + return new(zone()) LDebugBreak(); +} + + LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { HValue* value = instr->value(); if (value->EmitAtUses()) { diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index d6c3d95..747d8e7 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -89,6 +89,7 @@ class LCodeGen; V(ConstantI) \ V(ConstantT) \ V(Context) \ + V(DebugBreak) \ V(DeclareGlobals) \ V(DeleteProperty) \ V(Deoptimize) \ @@ -1172,6 +1173,12 @@ class LBranch: public LControlInstruction<1, 0> { }; +class LDebugBreak: public LTemplateInstruction<0, 0, 0> { + public: + DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break") +}; + + class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> { public: explicit LCmpMapAndBranch(LOperand* value) { -- 2.7.4