From 5debbc3693f177b334d609a7f13793daa8a5b093 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Mon, 30 Nov 2009 15:09:49 +0000 Subject: [PATCH] Move CPU-specific constants from debug.h into the platform-specific directories. The constant for the return sequence length (JSReturnSequenceLength) was defined in debug.h. Since this constant are also needed outside the debugger code I moved them into assembler-xxx.h. Otherwise compiling with debuggersupport=off would fail on ARM. BUG=http://code.google.com/p/v8/issues/detail?id=533 Review URL: http://codereview.chromium.org/456001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3383 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/assembler-arm.h | 1 + src/arm/codegen-arm.cc | 2 +- src/arm/debug-arm.cc | 2 +- src/arm/fast-codegen-arm.cc | 2 +- src/debug.h | 11 ----------- src/ia32/assembler-ia32.h | 2 ++ src/ia32/codegen-ia32.cc | 2 +- src/ia32/debug-ia32.cc | 8 ++++---- src/ia32/fast-codegen-ia32.cc | 2 +- src/x64/assembler-x64.h | 6 ++++++ src/x64/codegen-x64.cc | 4 ++-- src/x64/debug-x64.cc | 7 ++++--- src/x64/fast-codegen-x64.cc | 4 ++-- 13 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/arm/assembler-arm.h b/src/arm/assembler-arm.h index ca0184e..86bc18a 100644 --- a/src/arm/assembler-arm.h +++ b/src/arm/assembler-arm.h @@ -566,6 +566,7 @@ class Assembler : public Malloced { // register. static const int kPcLoadDelta = 8; + static const int kJSReturnSequenceLength = 4; // --------------------------------------------------------------------------- // Code generation diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index d09af71..dfa653c 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -326,7 +326,7 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) { // Calculate the exact length of the return sequence and make sure that // the constant pool is not emitted inside of the return sequence. int32_t sp_delta = (scope_->num_parameters() + 1) * kPointerSize; - int return_sequence_length = Debug::kARMJSReturnSequenceLength; + int return_sequence_length = Assembler::kJSReturnSequenceLength; if (!masm_->ImmediateFitsAddrMode1Instruction(sp_delta)) { // Additional mov instruction generated. return_sequence_length++; diff --git a/src/arm/debug-arm.cc b/src/arm/debug-arm.cc index 102952d..fc9808d 100644 --- a/src/arm/debug-arm.cc +++ b/src/arm/debug-arm.cc @@ -61,7 +61,7 @@ void BreakLocationIterator::SetDebugBreakAtReturn() { // Restore the JS frame exit code. void BreakLocationIterator::ClearDebugBreakAtReturn() { rinfo()->PatchCode(original_rinfo()->pc(), - Debug::kARMJSReturnSequenceLength); + Assembler::kJSReturnSequenceLength); } diff --git a/src/arm/fast-codegen-arm.cc b/src/arm/fast-codegen-arm.cc index f3c3245..ab636b6 100644 --- a/src/arm/fast-codegen-arm.cc +++ b/src/arm/fast-codegen-arm.cc @@ -188,7 +188,7 @@ void FastCodeGenerator::EmitReturnSequence(int position) { // the constant pool is not emitted inside of the return sequence. int num_parameters = function_->scope()->num_parameters(); int32_t sp_delta = (num_parameters + 1) * kPointerSize; - int return_sequence_length = Debug::kARMJSReturnSequenceLength; + int return_sequence_length = Assembler::kJSReturnSequenceLength; if (!masm_->ImmediateFitsAddrMode1Instruction(sp_delta)) { // Additional mov instruction generated. return_sequence_length++; diff --git a/src/debug.h b/src/debug.h index c5c6b5e..24f0db4 100644 --- a/src/debug.h +++ b/src/debug.h @@ -370,17 +370,6 @@ class Debug { // Garbage collection notifications. static void AfterGarbageCollection(); - // Code generation assumptions. - static const int kIa32CallInstructionLength = 5; - static const int kIa32JSReturnSequenceLength = 6; - - // The x64 JS return sequence is padded with int3 to make it large - // enough to hold a call instruction when the debugger patches it. - static const int kX64CallInstructionLength = 13; - static const int kX64JSReturnSequenceLength = 13; - - static const int kARMJSReturnSequenceLength = 4; - // Code generator routines. static void GenerateLoadICDebugBreak(MacroAssembler* masm); static void GenerateStoreICDebugBreak(MacroAssembler* masm); diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h index 962206f..662ebc9 100644 --- a/src/ia32/assembler-ia32.h +++ b/src/ia32/assembler-ia32.h @@ -464,6 +464,8 @@ class Assembler : public Malloced { // to jump to. static const int kPatchReturnSequenceAddressOffset = 1; // JMP imm32. + static const int kCallInstructionLength = 5; + static const int kJSReturnSequenceLength = 6; // --------------------------------------------------------------------------- // Code generation diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index 1a6d301..1c5e54a 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -2490,7 +2490,7 @@ void CodeGenerator::GenerateReturnSequence(Result* return_value) { #ifdef ENABLE_DEBUGGER_SUPPORT // Check that the size of the code used for returning matches what is // expected by the debugger. - ASSERT_EQ(Debug::kIa32JSReturnSequenceLength, + ASSERT_EQ(Assembler::kJSReturnSequenceLength, masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); #endif } diff --git a/src/ia32/debug-ia32.cc b/src/ia32/debug-ia32.cc index 2d20117..5ebe1e0 100644 --- a/src/ia32/debug-ia32.cc +++ b/src/ia32/debug-ia32.cc @@ -45,17 +45,17 @@ bool BreakLocationIterator::IsDebugBreakAtReturn() { // CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-ia32.cc // for the precise return instructions sequence. void BreakLocationIterator::SetDebugBreakAtReturn() { - ASSERT(Debug::kIa32JSReturnSequenceLength >= - Debug::kIa32CallInstructionLength); + ASSERT(Assembler::kJSReturnSequenceLength >= + Assembler::kCallInstructionLength); rinfo()->PatchCodeWithCall(Debug::debug_break_return()->entry(), - Debug::kIa32JSReturnSequenceLength - Debug::kIa32CallInstructionLength); + Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength); } // Restore the JS frame exit code. void BreakLocationIterator::ClearDebugBreakAtReturn() { rinfo()->PatchCode(original_rinfo()->pc(), - Debug::kIa32JSReturnSequenceLength); + Assembler::kJSReturnSequenceLength); } diff --git a/src/ia32/fast-codegen-ia32.cc b/src/ia32/fast-codegen-ia32.cc index d52acfd..c5d5441 100644 --- a/src/ia32/fast-codegen-ia32.cc +++ b/src/ia32/fast-codegen-ia32.cc @@ -187,7 +187,7 @@ void FastCodeGenerator::EmitReturnSequence(int position) { #ifdef ENABLE_DEBUGGER_SUPPORT // Check that the size of the code used for returning matches what is // expected by the debugger. - ASSERT_EQ(Debug::kIa32JSReturnSequenceLength, + ASSERT_EQ(Assembler::kJSReturnSequenceLength, masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); #endif } diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index 50f4e0e..fa7d33b 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -482,6 +482,12 @@ class Assembler : public Malloced { static const int kPatchReturnSequenceAddressOffset = 13 - 4; // TODO(X64): Rename this, removing the "Real", after changing the above. static const int kRealPatchReturnSequenceAddressOffset = 2; + + // The x64 JS return sequence is padded with int3 to make it large + // enough to hold a call instruction when the debugger patches it. + static const int kCallInstructionLength = 13; + static const int kJSReturnSequenceLength = 13; + // --------------------------------------------------------------------------- // Code generation // diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index a4c2096..889e2da 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -505,13 +505,13 @@ void CodeGenerator::GenerateReturnSequence(Result* return_value) { // Add padding that will be overwritten by a debugger breakpoint. // frame_->Exit() generates "movq rsp, rbp; pop rbp; ret k" // with length 7 (3 + 1 + 3). - const int kPadding = Debug::kX64JSReturnSequenceLength - 7; + const int kPadding = Assembler::kJSReturnSequenceLength - 7; for (int i = 0; i < kPadding; ++i) { masm_->int3(); } // Check that the size of the code used for returning matches what is // expected by the debugger. - ASSERT_EQ(Debug::kX64JSReturnSequenceLength, + ASSERT_EQ(Assembler::kJSReturnSequenceLength, masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); #endif DeleteFrame(); diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc index 49240b4..bc88d46 100644 --- a/src/x64/debug-x64.cc +++ b/src/x64/debug-x64.cc @@ -181,7 +181,7 @@ void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { void BreakLocationIterator::ClearDebugBreakAtReturn() { rinfo()->PatchCode(original_rinfo()->pc(), - Debug::kX64JSReturnSequenceLength); + Assembler::kJSReturnSequenceLength); } @@ -191,9 +191,10 @@ bool BreakLocationIterator::IsDebugBreakAtReturn() { void BreakLocationIterator::SetDebugBreakAtReturn() { - ASSERT(Debug::kX64JSReturnSequenceLength >= Debug::kX64CallInstructionLength); + ASSERT(Assembler::kJSReturnSequenceLength >= + Assembler::kCallInstructionLength); rinfo()->PatchCodeWithCall(Debug::debug_break_return()->entry(), - Debug::kX64JSReturnSequenceLength - Debug::kX64CallInstructionLength); + Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength); } #endif // ENABLE_DEBUGGER_SUPPORT diff --git a/src/x64/fast-codegen-x64.cc b/src/x64/fast-codegen-x64.cc index 33f213d..f73f2b9 100644 --- a/src/x64/fast-codegen-x64.cc +++ b/src/x64/fast-codegen-x64.cc @@ -189,13 +189,13 @@ void FastCodeGenerator::EmitReturnSequence(int position) { // Add padding that will be overwritten by a debugger breakpoint. We // have just generated "movq rsp, rbp; pop rbp; ret k" with length 7 // (3 + 1 + 3). - const int kPadding = Debug::kX64JSReturnSequenceLength - 7; + const int kPadding = Assembler::kJSReturnSequenceLength - 7; for (int i = 0; i < kPadding; ++i) { masm_->int3(); } // Check that the size of the code used for returning matches what is // expected by the debugger. - ASSERT_EQ(Debug::kX64JSReturnSequenceLength, + ASSERT_EQ(Assembler::kJSReturnSequenceLength, masm_->SizeOfCodeGeneratedSince(&check_exit_codesize)); #endif } -- 2.7.4