From bed254fac9189cbc91fb94bcc491d12eb8d81e7d Mon Sep 17 00:00:00 2001 From: "vegorov@chromium.org" Date: Thu, 5 Aug 2010 13:38:27 +0000 Subject: [PATCH] Do not apply JS_RETURN and DEBUG_BREAK_SLOT relocations on x64. Improve tests for debug API to check behavior of JS_RETURN and DEBUG_BREAK_SLOT relocations. Review URL: http://codereview.chromium.org/3058049 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5180 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/assembler-arm-inl.h | 18 ++++++++---------- src/assembler.h | 2 +- src/ia32/assembler-ia32-inl.h | 19 ++++++++++--------- src/x64/assembler-x64-inl.h | 19 ++++++------------- src/x64/assembler-x64.cc | 4 +--- test/cctest/test-debug.cc | 44 +++++++++++++++++++++++++++++++++++-------- 6 files changed, 62 insertions(+), 44 deletions(-) diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 114ec23..5be5770 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -120,9 +120,8 @@ Address RelocInfo::call_address() { void RelocInfo::set_call_address(Address target) { - ASSERT(IsPatchedReturnSequence()); - // The 2 instructions offset assumes patched return sequence. - ASSERT(IsJSReturn(rmode())); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); Memory::Address_at(pc_ + 2 * Assembler::kInstrSize) = target; } @@ -132,16 +131,15 @@ Object* RelocInfo::call_object() { } -Object** RelocInfo::call_object_address() { - ASSERT(IsPatchedReturnSequence()); - // The 2 instructions offset assumes patched return sequence. - ASSERT(IsJSReturn(rmode())); - return reinterpret_cast(pc_ + 2 * Assembler::kInstrSize); +void RelocInfo::set_call_object(Object* target) { + *call_object_address() = target; } -void RelocInfo::set_call_object(Object* target) { - *call_object_address() = target; +Object** RelocInfo::call_object_address() { + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); + return reinterpret_cast(pc_ + 2 * Assembler::kInstrSize); } diff --git a/src/assembler.h b/src/assembler.h index fb75d6d..cf7020e 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -232,8 +232,8 @@ class RelocInfo BASE_EMBEDDED { INLINE(Address call_address()); INLINE(void set_call_address(Address target)); INLINE(Object* call_object()); - INLINE(Object** call_object_address()); INLINE(void set_call_object(Object* target)); + INLINE(Object** call_object_address()); inline void Visit(ObjectVisitor* v); diff --git a/src/ia32/assembler-ia32-inl.h b/src/ia32/assembler-ia32-inl.h index eb2a04d..7fa151e 100644 --- a/src/ia32/assembler-ia32-inl.h +++ b/src/ia32/assembler-ia32-inl.h @@ -121,32 +121,33 @@ Address* RelocInfo::target_reference_address() { Address RelocInfo::call_address() { - ASSERT(IsPatchedReturnSequence()); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); return Assembler::target_address_at(pc_ + 1); } void RelocInfo::set_call_address(Address target) { - ASSERT(IsPatchedReturnSequence()); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); Assembler::set_target_address_at(pc_ + 1, target); } Object* RelocInfo::call_object() { - ASSERT(IsPatchedReturnSequence()); return *call_object_address(); } -Object** RelocInfo::call_object_address() { - ASSERT(IsPatchedReturnSequence()); - return reinterpret_cast(pc_ + 1); +void RelocInfo::set_call_object(Object* target) { + *call_object_address() = target; } -void RelocInfo::set_call_object(Object* target) { - ASSERT(IsPatchedReturnSequence()); - *call_object_address() = target; +Object** RelocInfo::call_object_address() { + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); + return reinterpret_cast(pc_ + 1); } diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index 01c60aa..c8abd22 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -201,14 +201,6 @@ void RelocInfo::apply(intptr_t delta) { Memory::Address_at(pc_) += static_cast(delta); } else if (IsCodeTarget(rmode_)) { Memory::int32_at(pc_) -= static_cast(delta); - } 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) -= static_cast(delta); // relocate entry - } else if (rmode_ == DEBUG_BREAK_SLOT && IsPatchedDebugBreakSlotSequence()) { - // Special handling of debug break slot when a break point is set (call - // instruction has been inserted). - Memory::int32_at(pc_ + 1) -= static_cast(delta); // relocate entry } } @@ -303,33 +295,34 @@ bool RelocInfo::IsPatchedDebugBreakSlotSequence() { Address RelocInfo::call_address() { - ASSERT(IsPatchedReturnSequence()); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); return Memory::Address_at( pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); } void RelocInfo::set_call_address(Address target) { - ASSERT(IsPatchedReturnSequence()); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = target; } Object* RelocInfo::call_object() { - ASSERT(IsPatchedReturnSequence()); return *call_object_address(); } void RelocInfo::set_call_object(Object* target) { - ASSERT(IsPatchedReturnSequence()); *call_object_address() = target; } Object** RelocInfo::call_object_address() { - ASSERT(IsPatchedReturnSequence()); + ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || + (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); return reinterpret_cast( pc_ + Assembler::kPatchReturnSequenceAddressOffset); } diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index d700cc5..d90655b 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -2941,9 +2941,7 @@ bool Assembler::WriteRecordedPositions() { const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | - 1 << RelocInfo::INTERNAL_REFERENCE | - 1 << RelocInfo::JS_RETURN | - 1 << RelocInfo::DEBUG_BREAK_SLOT; + 1 << RelocInfo::INTERNAL_REFERENCE; bool RelocInfo::IsCodedSpecially() { diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 5ffe362..0455790 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -1277,25 +1277,53 @@ static void TestBreakPointSurviveGC(bool force_compaction) { v8::Local foo; // Test IC store break point with garbage collection. - foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); - SetBreakPoint(foo, 0); + { + v8::Local bar = + CompileFunction(&env, "function foo(){}", "foo"); + foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); + SetBreakPoint(foo, 0); + } CallAndGC(env->Global(), foo, force_compaction); // Test IC load break point with garbage collection. - foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); - SetBreakPoint(foo, 0); + { + v8::Local bar = + CompileFunction(&env, "function foo(){}", "foo"); + foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); + SetBreakPoint(foo, 0); + } CallAndGC(env->Global(), foo, force_compaction); // Test IC call break point with garbage collection. - foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo"); - SetBreakPoint(foo, 0); + { + v8::Local bar = + CompileFunction(&env, "function foo(){}", "foo"); + foo = CompileFunction(&env, + "function bar(){};function foo(){bar();}", + "foo"); + SetBreakPoint(foo, 0); + } CallAndGC(env->Global(), foo, force_compaction); // Test return break point with garbage collection. - foo = CompileFunction(&env, "function foo(){}", "foo"); - SetBreakPoint(foo, 0); + { + v8::Local bar = + CompileFunction(&env, "function foo(){}", "foo"); + foo = CompileFunction(&env, "function foo(){}", "foo"); + SetBreakPoint(foo, 0); + } CallAndGC(env->Global(), foo, force_compaction); + // Test non IC break point with garbage collection. + { + v8::Local bar = + CompileFunction(&env, "function foo(){}", "foo"); + foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); + SetBreakPoint(foo, 0); + } + CallAndGC(env->Global(), foo, force_compaction); + + v8::Debug::SetDebugEventListener(NULL); CheckDebuggerUnloaded(); } -- 2.7.4