From 862909e762f41a733d82a7df997516f12eb10dbd Mon Sep 17 00:00:00 2001 From: "serya@chromium.org" Date: Mon, 8 Feb 2010 13:44:49 +0000 Subject: [PATCH] Review URL: http://codereview.chromium.org/561049 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3814 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/codegen-arm.cc | 3 +-- src/arm/macro-assembler-arm.cc | 19 ++++++++++++------- src/arm/macro-assembler-arm.h | 1 + src/arm/virtual-frame-arm.cc | 8 ++++++++ src/arm/virtual-frame-arm.h | 4 ++++ src/assembler.cc | 10 ++++++++++ src/assembler.h | 1 + src/codegen.cc | 7 ------- src/codegen.h | 15 --------------- src/debug.cc | 10 +--------- src/frames.cc | 7 +------ src/full-codegen.cc | 3 +-- src/heap.cc | 11 ----------- src/heap.h | 2 -- src/ia32/codegen-ia32.cc | 3 +-- src/ia32/macro-assembler-ia32.cc | 15 +++++++++------ src/ia32/macro-assembler-ia32.h | 1 + src/ia32/virtual-frame-ia32.cc | 11 +++++++++++ src/ia32/virtual-frame-ia32.h | 4 ++++ src/x64/codegen-x64.cc | 3 +-- src/x64/macro-assembler-x64.cc | 17 ++++++++++------- src/x64/macro-assembler-x64.h | 1 + src/x64/virtual-frame-x64.cc | 11 +++++++++++ src/x64/virtual-frame-x64.h | 4 ++++ 24 files changed, 93 insertions(+), 78 deletions(-) diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index 9afefac0b3..8557808c4c 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -2293,8 +2293,7 @@ void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) { Comment cmnt(masm_, "[ DebuggerStatament"); CodeForStatementPosition(node); #ifdef ENABLE_DEBUGGER_SUPPORT - DebuggerStatementStub ces; - frame_->CallStub(&ces, 0); + frame_->DebugBreak(); #endif // Ignore the return value. ASSERT(frame_->height() == original_height); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 1f08c7cf36..d0a548236e 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -331,14 +331,10 @@ void MacroAssembler::EnterExitFrame(ExitFrame::Mode mode) { // Push in reverse order: caller_fp, sp_on_exit, and caller_pc. stm(db_w, sp, fp.bit() | ip.bit() | lr.bit()); - mov(fp, Operand(sp)); // setup new frame pointer + mov(fp, Operand(sp)); // Setup new frame pointer. - if (mode == ExitFrame::MODE_DEBUG) { - mov(ip, Operand(Smi::FromInt(0))); - } else { - mov(ip, Operand(CodeObject())); - } - push(ip); + mov(ip, Operand(CodeObject())); + push(ip); // Accessed from ExitFrame::code_slot. // Save the frame pointer and the context in top. mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); @@ -608,6 +604,15 @@ void MacroAssembler::CopyRegistersFromStackToMemory(Register base, } } } + + +void MacroAssembler::DebugBreak() { + ASSERT(allow_stub_calls()); + mov(r0, Operand(0)); + mov(r1, Operand(ExternalReference(Runtime::kDebugBreak))); + CEntryStub ces(1); + Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); +} #endif diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index 66ef4f9a24..76382f82de 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -146,6 +146,7 @@ class MacroAssembler: public Assembler { void CopyRegistersFromStackToMemory(Register base, Register scratch, RegList regs); + void DebugBreak(); #endif // --------------------------------------------------------------------------- diff --git a/src/arm/virtual-frame-arm.cc b/src/arm/virtual-frame-arm.cc index 7a8ac7266a..6b48b90035 100644 --- a/src/arm/virtual-frame-arm.cc +++ b/src/arm/virtual-frame-arm.cc @@ -233,6 +233,14 @@ void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { } +#ifdef ENABLE_DEBUGGER_SUPPORT +void VirtualFrame::DebugBreak() { + ASSERT(cgen()->HasValidEntryRegisters()); + __ DebugBreak(); +} +#endif + + void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, InvokeJSFlags flags, int arg_count) { diff --git a/src/arm/virtual-frame-arm.h b/src/arm/virtual-frame-arm.h index 9a2f7d360d..0b8bea20ff 100644 --- a/src/arm/virtual-frame-arm.h +++ b/src/arm/virtual-frame-arm.h @@ -297,6 +297,10 @@ class VirtualFrame : public ZoneObject { void CallRuntime(Runtime::Function* f, int arg_count); void CallRuntime(Runtime::FunctionId id, int arg_count); +#ifdef ENABLE_DEBUGGER_SUPPORT + void DebugBreak(); +#endif + // Invoke builtin given the number of arguments it expects on (and // removes from) the stack. void InvokeBuiltin(Builtins::JavaScript id, diff --git a/src/assembler.cc b/src/assembler.cc index dbf2742b25..96d516f18e 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -430,6 +430,11 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) { return "code target (js construct call)"; case RelocInfo::CODE_TARGET_CONTEXT: return "code target (context)"; + case RelocInfo::DEBUG_BREAK: +#ifndef ENABLE_DEBUGGER_SUPPORT + UNREACHABLE(); +#endif + return "debug break"; case RelocInfo::CODE_TARGET: return "code target"; case RelocInfo::RUNTIME_ENTRY: @@ -485,6 +490,11 @@ void RelocInfo::Verify() { case EMBEDDED_OBJECT: Object::VerifyPointer(target_object()); break; + case DEBUG_BREAK: +#ifndef ENABLE_DEBUGGER_SUPPORT + UNREACHABLE(); + break; +#endif case CONSTRUCT_CALL: case CODE_TARGET_CONTEXT: case CODE_TARGET: { diff --git a/src/assembler.h b/src/assembler.h index 942ce476dc..f4013061eb 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -119,6 +119,7 @@ class RelocInfo BASE_EMBEDDED { // Please note the order is important (see IsCodeTarget, IsGCRelocMode). CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. CODE_TARGET_CONTEXT, // code target used for contextual loads. + DEBUG_BREAK, CODE_TARGET, // code target which is not any of the above. EMBEDDED_OBJECT, EMBEDDED_STRING, diff --git a/src/codegen.cc b/src/codegen.cc index 24eb476294..6bcf32444c 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -525,12 +525,5 @@ void ApiGetterEntryStub::SetCustomCache(Code* value) { info()->set_load_stub_cache(value); } -#ifdef ENABLE_DEBUGGER_SUPPORT -void DebuggerStatementStub::Generate(MacroAssembler* masm) { - Runtime::Function* f = Runtime::FunctionForId(Runtime::kDebugBreak); - masm->TailCallRuntime(ExternalReference(f), 0, f->result_size); -} -#endif - } } // namespace v8::internal diff --git a/src/codegen.h b/src/codegen.h index 3afa04146c..882b4844c5 100644 --- a/src/codegen.h +++ b/src/codegen.h @@ -415,21 +415,6 @@ class ApiGetterEntryStub : public CodeStub { }; -// Mark the debugger statement to be recognized by debugger (by the MajorKey) -class DebuggerStatementStub : public CodeStub { - public: - DebuggerStatementStub() { } - - void Generate(MacroAssembler* masm); - - private: - Major MajorKey() { return DebuggerStatement; } - int MinorKey() { return 0; } - - const char* GetName() { return "DebuggerStatementStub"; } -}; - - class JSEntryStub : public CodeStub { public: JSEntryStub() { } diff --git a/src/debug.cc b/src/debug.cc index fb9b23eb51..4e27b0f2a7 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -453,15 +453,7 @@ void BreakLocationIterator::ClearDebugBreakAtIC() { bool BreakLocationIterator::IsDebuggerStatement() { - if (RelocInfo::IsCodeTarget(rmode())) { - Address target = original_rinfo()->target_address(); - Code* code = Code::GetCodeFromTargetAddress(target); - if (code->kind() == Code::STUB) { - CodeStub::Major major_key = code->major_key(); - return (major_key == CodeStub::DebuggerStatement); - } - } - return false; + return RelocInfo::DEBUG_BREAK == rmode(); } diff --git a/src/frames.cc b/src/frames.cc index e56a2c83ed..5d88265c79 100644 --- a/src/frames.cc +++ b/src/frames.cc @@ -408,12 +408,7 @@ Object*& ExitFrame::code_slot() const { Code* ExitFrame::code() const { - Object* code = code_slot(); - if (code->IsSmi()) { - return Heap::debugger_statement_code(); - } else { - return Code::cast(code); - } + return Code::cast(code_slot()); } diff --git a/src/full-codegen.cc b/src/full-codegen.cc index 22510e9d79..5c66f7463b 100644 --- a/src/full-codegen.cc +++ b/src/full-codegen.cc @@ -986,8 +986,7 @@ void FullCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) { Comment cmnt(masm_, "[ DebuggerStatement"); SetStatementPosition(stmt); - DebuggerStatementStub ces; - __ CallStub(&ces); + __ DebugBreak(); // Ignore the return value. #endif } diff --git a/src/heap.cc b/src/heap.cc index 7263e23049..54f3d08d1e 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -1498,14 +1498,6 @@ void Heap::CreateRegExpCEntryStub() { #endif -#ifdef ENABLE_DEBUGGER_SUPPORT -void Heap::CreateCEntryDebugBreakStub() { - DebuggerStatementStub stub; - set_debugger_statement_code(*stub.GetCode()); -} -#endif - - void Heap::CreateJSEntryStub() { JSEntryStub stub; set_js_entry_code(*stub.GetCode()); @@ -1533,9 +1525,6 @@ void Heap::CreateFixedStubs() { // } // To workaround the problem, make separate functions without inlining. Heap::CreateCEntryStub(); -#ifdef ENABLE_DEBUGGER_SUPPORT - Heap::CreateCEntryDebugBreakStub(); -#endif Heap::CreateJSEntryStub(); Heap::CreateJSConstructEntryStub(); #if V8_TARGET_ARCH_ARM && V8_NATIVE_REGEXP diff --git a/src/heap.h b/src/heap.h index cbf0b73edf..22ab875bb1 100644 --- a/src/heap.h +++ b/src/heap.h @@ -101,7 +101,6 @@ namespace internal { V(Code, js_entry_code, JsEntryCode) \ V(Code, js_construct_entry_code, JsConstructEntryCode) \ V(Code, c_entry_code, CEntryCode) \ - V(Code, debugger_statement_code, DebuggerStatementCode) \ V(FixedArray, number_string_cache, NumberStringCache) \ V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ V(FixedArray, natives_source_cache, NativesSourceCache) \ @@ -1046,7 +1045,6 @@ class Heap : public AllStatic { // These four Create*EntryStub functions are here because of a gcc-4.4 bug // that assigns wrong vtable entries. static void CreateCEntryStub(); - static void CreateCEntryDebugBreakStub(); static void CreateJSEntryStub(); static void CreateJSConstructEntryStub(); static void CreateRegExpCEntryStub(); diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index d0fbabbace..a665261850 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -3906,8 +3906,7 @@ void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) { // Spill everything, even constants, to the frame. frame_->SpillAll(); - DebuggerStatementStub ces; - frame_->CallStub(&ces, 0); + frame_->DebugBreak(); // Ignore the return value. #endif } diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 4dd6a9bc30..97457f8748 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -308,6 +308,13 @@ void MacroAssembler::CopyRegistersFromStackToMemory(Register base, } } } + +void MacroAssembler::DebugBreak() { + Set(eax, Immediate(0)); + mov(ebx, Immediate(ExternalReference(Runtime::kDebugBreak))); + CEntryStub ces(1); + call(ces.GetCode(), RelocInfo::DEBUG_BREAK); +} #endif void MacroAssembler::Set(Register dst, const Immediate& x) { @@ -409,12 +416,8 @@ void MacroAssembler::EnterExitFramePrologue(ExitFrame::Mode mode) { // Reserve room for entry stack pointer and push the debug marker. ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); - push(Immediate(0)); // saved entry sp, patched before call - if (mode == ExitFrame::MODE_DEBUG) { - push(Immediate(0)); - } else { - push(Immediate(CodeObject())); - } + push(Immediate(0)); // Saved entry sp, patched before call. + push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. // Save the frame pointer and the context in top. ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h index 0ddbd5d3a2..d104b543ee 100644 --- a/src/ia32/macro-assembler-ia32.h +++ b/src/ia32/macro-assembler-ia32.h @@ -69,6 +69,7 @@ class MacroAssembler: public Assembler { void CopyRegistersFromStackToMemory(Register base, Register scratch, RegList regs); + void DebugBreak(); #endif // --------------------------------------------------------------------------- diff --git a/src/ia32/virtual-frame-ia32.cc b/src/ia32/virtual-frame-ia32.cc index 9267507c7e..f0309353e2 100644 --- a/src/ia32/virtual-frame-ia32.cc +++ b/src/ia32/virtual-frame-ia32.cc @@ -853,6 +853,17 @@ Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { } +#ifdef ENABLE_DEBUGGER_SUPPORT +void VirtualFrame::DebugBreak() { + PrepareForCall(0, 0); + ASSERT(cgen()->HasValidEntryRegisters()); + __ DebugBreak(); + Result result = cgen()->allocator()->Allocate(eax); + ASSERT(result.is_valid()); +} +#endif + + Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag, int arg_count) { diff --git a/src/ia32/virtual-frame-ia32.h b/src/ia32/virtual-frame-ia32.h index d6d55d12c9..672a31069d 100644 --- a/src/ia32/virtual-frame-ia32.h +++ b/src/ia32/virtual-frame-ia32.h @@ -324,6 +324,10 @@ class VirtualFrame: public ZoneObject { Result CallRuntime(Runtime::Function* f, int arg_count); Result CallRuntime(Runtime::FunctionId id, int arg_count); +#ifdef ENABLE_DEBUGGER_SUPPORT + void DebugBreak(); +#endif + // Invoke builtin given the number of arguments it expects on (and // removes from) the stack. Result InvokeBuiltin(Builtins::JavaScript id, InvokeFlag flag, int arg_count); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index ee8f251b05..ef9e493ba6 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -2218,8 +2218,7 @@ void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) { // Spill everything, even constants, to the frame. frame_->SpillAll(); - DebuggerStatementStub ces; - frame_->CallStub(&ces, 0); + frame_->DebugBreak(); // Ignore the return value. #endif } diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 56bbc202a3..fe766c9900 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -1774,6 +1774,13 @@ void MacroAssembler::CopyRegistersFromStackToMemory(Register base, } } +void MacroAssembler::DebugBreak() { + ASSERT(allow_stub_calls()); + xor_(rax, rax); // no arguments + movq(rbx, ExternalReference(Runtime::kDebugBreak)); + CEntryStub ces(1); + Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); +} #endif // ENABLE_DEBUGGER_SUPPORT @@ -1965,13 +1972,9 @@ void MacroAssembler::EnterExitFrame(ExitFrame::Mode mode, int result_size) { // Reserve room for entry stack pointer and push the debug marker. ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); - push(Immediate(0)); // saved entry sp, patched before call - if (mode == ExitFrame::MODE_DEBUG) { - push(Immediate(0)); - } else { - movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); - push(kScratchRegister); - } + push(Immediate(0)); // Saved entry sp, patched before call. + movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); + push(kScratchRegister); // Accessed from EditFrame::code_slot. // Save the frame pointer and the context in top. ExternalReference c_entry_fp_address(Top::k_c_entry_fp_address); diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index a975dcafbb..8c9170a586 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -98,6 +98,7 @@ class MacroAssembler: public Assembler { void CopyRegistersFromStackToMemory(Register base, Register scratch, RegList regs); + void DebugBreak(); #endif // --------------------------------------------------------------------------- diff --git a/src/x64/virtual-frame-x64.cc b/src/x64/virtual-frame-x64.cc index cb93d5d467..5551ed9170 100644 --- a/src/x64/virtual-frame-x64.cc +++ b/src/x64/virtual-frame-x64.cc @@ -969,6 +969,17 @@ Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { } +#ifdef ENABLE_DEBUGGER_SUPPORT +void VirtualFrame::DebugBreak() { + PrepareForCall(0, 0); + ASSERT(cgen()->HasValidEntryRegisters()); + __ DebugBreak(); + Result result = cgen()->allocator()->Allocate(rax); + ASSERT(result.is_valid()); +} +#endif + + Result VirtualFrame::CallLoadIC(RelocInfo::Mode mode) { // Name and receiver are on the top of the frame. The IC expects // name in rcx and receiver on the stack. It does not drop the diff --git a/src/x64/virtual-frame-x64.h b/src/x64/virtual-frame-x64.h index 8e3e40f07b..cecb3b0451 100644 --- a/src/x64/virtual-frame-x64.h +++ b/src/x64/virtual-frame-x64.h @@ -321,6 +321,10 @@ class VirtualFrame : public ZoneObject { Result CallRuntime(Runtime::Function* f, int arg_count); Result CallRuntime(Runtime::FunctionId id, int arg_count); +#ifdef ENABLE_DEBUGGER_SUPPORT + void DebugBreak(); +#endif + // Invoke builtin given the number of arguments it expects on (and // removes from) the stack. Result InvokeBuiltin(Builtins::JavaScript id,