From: whesse@chromium.org Date: Thu, 15 Oct 2009 11:52:53 +0000 (+0000) Subject: Fix X64 build in the case that debugger support is disabled. Change function name... X-Git-Tag: upstream/4.7.83~23141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99050519c43a673b88ec2b38afde4fdf10233a81;p=platform%2Fupstream%2Fv8.git Fix X64 build in the case that debugger support is disabled. Change function name from IsCallInstruction to IsPatchedReturnSequence on all platforms. Review URL: http://codereview.chromium.org/267116 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3072 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 5417ed7d3..48cc09081 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -110,7 +110,7 @@ Address* RelocInfo::target_reference_address() { Address RelocInfo::call_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); // The 2 instructions offset assumes patched return sequence. ASSERT(IsJSReturn(rmode())); return Memory::Address_at(pc_ + 2 * Assembler::kInstrSize); @@ -118,7 +118,7 @@ Address RelocInfo::call_address() { void RelocInfo::set_call_address(Address target) { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); // The 2 instructions offset assumes patched return sequence. ASSERT(IsJSReturn(rmode())); Memory::Address_at(pc_ + 2 * Assembler::kInstrSize) = target; @@ -131,7 +131,7 @@ Object* RelocInfo::call_object() { Object** RelocInfo::call_object_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); // The 2 instructions offset assumes patched return sequence. ASSERT(IsJSReturn(rmode())); return reinterpret_cast(pc_ + 2 * Assembler::kInstrSize); @@ -143,7 +143,7 @@ void RelocInfo::set_call_object(Object* target) { } -bool RelocInfo::IsCallInstruction() { +bool RelocInfo::IsPatchedReturnSequence() { // On ARM a "call instruction" is actually two instructions. // mov lr, pc // ldr pc, [pc, #XXX] diff --git a/src/arm/debug-arm.cc b/src/arm/debug-arm.cc index 4f45175a3..ef3365395 100644 --- a/src/arm/debug-arm.cc +++ b/src/arm/debug-arm.cc @@ -68,7 +68,7 @@ void BreakLocationIterator::ClearDebugBreakAtReturn() { // A debug break in the exit code is identified by a call. bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); - return rinfo->IsCallInstruction(); + return rinfo->IsPatchedReturnSequence(); } diff --git a/src/assembler.h b/src/assembler.h index 323e06aff..21a66dd50 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -217,10 +217,10 @@ class RelocInfo BASE_EMBEDDED { // Patch the code with a call. void PatchCodeWithCall(Address target, int guard_bytes); - // Check whether the current instruction is currently a call - // sequence (whether naturally or a return sequence overwritten - // to enter the debugger). - INLINE(bool IsCallInstruction()); + + // Check whether this return sequence has been patched + // with a call to the debugger. + INLINE(bool IsPatchedReturnSequence()); #ifdef ENABLE_DISASSEMBLER // Printing diff --git a/src/debug.cc b/src/debug.cc index 4f89f92e9..d4a0012a1 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1614,7 +1614,7 @@ void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) { if (RelocInfo::IsJSReturn(it.rinfo()->rmode())) { at_js_return = (it.rinfo()->pc() == addr - Assembler::kPatchReturnSequenceAddressOffset); - break_at_js_return_active = it.rinfo()->IsCallInstruction(); + break_at_js_return_active = it.rinfo()->IsPatchedReturnSequence(); } it.next(); } diff --git a/src/ia32/assembler-ia32-inl.h b/src/ia32/assembler-ia32-inl.h index 1de20f4e3..5fa75ec8d 100644 --- a/src/ia32/assembler-ia32-inl.h +++ b/src/ia32/assembler-ia32-inl.h @@ -52,7 +52,7 @@ void RelocInfo::apply(intptr_t delta) { if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { int32_t* p = reinterpret_cast(pc_); *p -= delta; // relocate entry - } else if (rmode_ == JS_RETURN && IsCallInstruction()) { + } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { // Special handling of js_return when a break point is set (call // instruction has been inserted). int32_t* p = reinterpret_cast(pc_ + 1); @@ -114,36 +114,36 @@ Address* RelocInfo::target_reference_address() { Address RelocInfo::call_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return Assembler::target_address_at(pc_ + 1); } void RelocInfo::set_call_address(Address target) { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); Assembler::set_target_address_at(pc_ + 1, target); } Object* RelocInfo::call_object() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return *call_object_address(); } Object** RelocInfo::call_object_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return reinterpret_cast(pc_ + 1); } void RelocInfo::set_call_object(Object* target) { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); *call_object_address() = target; } -bool RelocInfo::IsCallInstruction() { +bool RelocInfo::IsPatchedReturnSequence() { return *pc_ == 0xE8; } diff --git a/src/ia32/debug-ia32.cc b/src/ia32/debug-ia32.cc index 7e0dfd148..2d20117aa 100644 --- a/src/ia32/debug-ia32.cc +++ b/src/ia32/debug-ia32.cc @@ -63,7 +63,7 @@ void BreakLocationIterator::ClearDebugBreakAtReturn() { // having been patched with a call instruction. bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); - return rinfo->IsCallInstruction(); + return rinfo->IsPatchedReturnSequence(); } diff --git a/src/mark-compact.cc b/src/mark-compact.cc index a20245c38..5a3ab8905 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -279,7 +279,7 @@ class MarkingVisitor : public ObjectVisitor { void VisitDebugTarget(RelocInfo* rinfo) { ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && - rinfo->IsCallInstruction()); + rinfo->IsPatchedReturnSequence()); HeapObject* code = Code::GetCodeFromTargetAddress(rinfo->call_address()); MarkCompactCollector::MarkObject(code); } @@ -1382,7 +1382,8 @@ class UpdatingVisitor: public ObjectVisitor { } void VisitDebugTarget(RelocInfo* rinfo) { - ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && rinfo->IsCallInstruction()); + ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && + rinfo->IsPatchedReturnSequence()); Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); VisitPointer(&target); rinfo->set_call_address( diff --git a/src/objects.cc b/src/objects.cc index 30a384da3..ab1d35fbb 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4983,7 +4983,8 @@ void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) { - ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && rinfo->IsCallInstruction()); + ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && + rinfo->IsPatchedReturnSequence()); Object* target = Code::GetCodeFromTargetAddress(rinfo->call_address()); Object* old_target = target; VisitPointer(&target); @@ -5009,7 +5010,7 @@ void Code::CodeIterateBody(ObjectVisitor* v) { #ifdef ENABLE_DEBUGGER_SUPPORT } else if (Debug::has_break_points() && RelocInfo::IsJSReturn(rmode) && - it.rinfo()->IsCallInstruction()) { + it.rinfo()->IsPatchedReturnSequence()) { v->VisitDebugTarget(it.rinfo()); #endif } else if (rmode == RelocInfo::RUNTIME_ENTRY) { @@ -5047,7 +5048,7 @@ void Code::CopyFrom(const CodeDesc& desc) { desc.reloc_size); // unbox handles and relocate - int delta = instruction_start() - desc.buffer; + intptr_t delta = instruction_start() - desc.buffer; int mode_mask = RelocInfo::kCodeTargetMask | RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | RelocInfo::kApplyMask; diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index e18a3cd8d..8f078ff23 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -194,7 +194,7 @@ void RelocInfo::apply(intptr_t delta) { Memory::Address_at(pc_) += delta; } else if (IsCodeTarget(rmode_)) { Memory::int32_at(pc_) -= delta; - } else if (rmode_ == JS_RETURN && IsCallInstruction()) { + } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { // Special handling of js_return when a break point is set (call // instruction has been inserted). Memory::int32_at(pc_ + 1) -= delta; // relocate entry @@ -262,45 +262,49 @@ void RelocInfo::set_target_object(Object* target) { } -bool RelocInfo::IsCallInstruction() { +bool RelocInfo::IsPatchedReturnSequence() { // The recognized call sequence is: // movq(kScratchRegister, immediate64); call(kScratchRegister); // It only needs to be distinguished from a return sequence // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 // The 11th byte is int3 (0xCC) in the return sequence and // REX.WB (0x48+register bit) for the call sequence. +#ifdef ENABLE_DEBUGGER_SUPPORT return pc_[10] != 0xCC; +#else + return false; +#endif } Address RelocInfo::call_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return Memory::Address_at( pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); } void RelocInfo::set_call_address(Address target) { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = target; } Object* RelocInfo::call_object() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return *call_object_address(); } void RelocInfo::set_call_object(Object* target) { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); *call_object_address() = target; } Object** RelocInfo::call_object_address() { - ASSERT(IsCallInstruction()); + ASSERT(IsPatchedReturnSequence()); return reinterpret_cast( pc_ + Assembler::kPatchReturnSequenceAddressOffset); } diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc index 10092c55c..49240b407 100644 --- a/src/x64/debug-x64.cc +++ b/src/x64/debug-x64.cc @@ -39,10 +39,7 @@ namespace internal { bool Debug::IsDebugBreakAtReturn(v8::internal::RelocInfo* rinfo) { ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); - // 11th byte of patch is 0x49 (REX.WB byte of computed jump/call to r10), - // 11th byte of JS return is 0xCC (int3). - ASSERT(*(rinfo->pc() + 10) == 0x49 || *(rinfo->pc() + 10) == 0xCC); - return (*(rinfo->pc() + 10) != 0xCC); + return rinfo->IsPatchedReturnSequence(); } #define __ ACCESS_MASM(masm)