Reviewers: danno,
Message:
Addressed danno's comments on https://codereview.chromium.org/18014003/.
https://codereview.chromium.org/21721002/diff/1/src/x64/assembler-x64.h
File src/x64/assembler-x64.h (right):
https://codereview.chromium.org/21721002/diff/1/src/x64/assembler-x64.h#newcode598
src/x64/assembler-x64.h:598: static const int kDebugBreakSlotLength =
kCallSequenceLength;
It seems that we could use short call and RUNTIME_ENTRY to patch the JS
return and debug break slot as the patched site and target are all in
the code range for X64. I leave it to another CL.
Description:
Make some constants' meaning clear for X64
Please review this at https://codereview.chromium.org/21721002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/x64/assembler-x64-inl.h
M src/x64/assembler-x64.h
M src/x64/assembler-x64.cc
M src/x64/debug-x64.cc
M src/x64/deoptimizer-x64.cc
M src/x64/macro-assembler-x64.h
M src/x64/macro-assembler-x64.cc
Index: src/x64/assembler-x64-inl.h
diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h
index
ae9aeee8122d3f8eb1bec82a3ed6391860b11fc6..418c2a41278e763bb6986c5088d03250e736523a
100644
--- a/src/x64/assembler-x64-inl.h
+++ b/src/x64/assembler-x64-inl.h
@@ -373,13 +373,13 @@ void RelocInfo::set_target_cell(Cell* cell,
WriteBarrierMode mode) {
bool RelocInfo::IsPatchedReturnSequence() {
// The recognized call sequence is:
- // movq(kScratchRegister, immediate64); call(kScratchRegister);
+ // movq(kScratchRegister, address); 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_[2 + kPointerSize] != 0xCC;
+ return pc_[Assembler::kMoveAddressIntoScratchRegisterInstructionSize] !=
0xCC;
#else
return false;
#endif
Index: src/x64/assembler-x64.cc
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index
f5939c3b7e1f1604d18528fe2cdd5d9481061132..8969d89a6a75db3b8a021ea666db81cffb4c9033
100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -164,10 +164,7 @@ void CpuFeatures::Probe() {
// Patch the code at the current PC with a call to the target address.
// Additional guard int3 instructions can be added if required.
void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) {
- // Load register with immediate 64 and call through a register
instructions
- // takes up 13 bytes and int3 takes up one byte.
- static const int kCallCodeSize = 13;
- int code_size = kCallCodeSize + guard_bytes;
+ int code_size = Assembler::kCallSequenceLength + guard_bytes;
// Create a code patcher.
CodePatcher patcher(pc_, code_size);
@@ -183,7 +180,7 @@ void RelocInfo::PatchCodeWithCall(Address target, int
guard_bytes) {
patcher.masm()->call(r10);
// Check that the size of the code generated is as expected.
- ASSERT_EQ(kCallCodeSize,
+ ASSERT_EQ(Assembler::kCallSequenceLength,
patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
// Add the requested number of int3 instructions after the call.
Index: src/x64/assembler-x64.h
diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h
index
07afc129dc82c76b76a5eadb2c6bd3425eb0289e..0d7d058db09e58e83fc0bc51f5ad48a87101311d
100644
--- a/src/x64/assembler-x64.h
+++ b/src/x64/assembler-x64.h
@@ -579,29 +579,36 @@ class Assembler : public AssemblerBase {
// Distance between the address of the code target in the call
instruction
// and the return address pushed on the stack.
static const int kCallTargetAddressOffset = 4; // Use 32-bit
displacement.
- // Distance between the start of the JS return sequence and where the
- // 32-bit displacement of a near call would be, relative to the pushed
- // return address. TODO: Use return sequence length instead.
- // Should equal Debug::kX64JSReturnSequenceLength -
kCallTargetAddressOffset;
- static const int kPatchReturnSequenceAddressOffset = 13 - 4;
- // Distance between start of patched debug break slot and where the
- // 32-bit displacement of a near call would be, relative to the pushed
- // return address. TODO: Use return sequence length instead.
- // Should equal Debug::kX64JSReturnSequenceLength -
kCallTargetAddressOffset;
- static const int kPatchDebugBreakSlotAddressOffset = 13 - 4;
- // TODO(X64): Rename this, removing the "Real", after changing the above.
- static const int kRealPatchReturnSequenceAddressOffset = 2;
-
- // Some x64 JS code is padded with int3 to make it large
- // enough to hold an instruction when the debugger patches it.
- static const int kJumpInstructionLength = 13;
- static const int kCallInstructionLength = 13;
- static const int kJSReturnSequenceLength = 13;
+ // The length of call(kScratchRegister).
+ static const int kCallScratchRegisterInstructionSize = 3;
+ // The length of call(Immediate32).
static const int kShortCallInstructionLength = 5;
- static const int kPatchDebugBreakSlotReturnOffset = 4;
-
- // The debug break slot must be able to contain a call instruction.
- static const int kDebugBreakSlotLength = kCallInstructionLength;
+ // The length of movq(kScratchRegister, address).
+ static const int kMoveAddressIntoScratchRegisterInstructionSize =
+ 2 + kPointerSize;
+ // The length of movq(kScratchRegister, address) and
call(kScratchRegister).
+ static const int kCallSequenceLength =
+ kMoveAddressIntoScratchRegisterInstructionSize +
+ kCallScratchRegisterInstructionSize;
+
+ // The js return and debug break slot must be able to contain an indirect
+ // call sequence, some x64 JS code is padded with int3 to make it large
+ // enough to hold an instruction when the debugger patches it.
+ static const int kJSReturnSequenceLength = kCallSequenceLength;
+ static const int kDebugBreakSlotLength = kCallSequenceLength;
+ static const int kPatchDebugBreakSlotReturnOffset =
kCallTargetAddressOffset;
+ // Distance between the start of the JS return sequence and where the
+ // 32-bit displacement of a short call would be. The short call is from
+ // SetDebugBreakAtIC from debug-x64.cc.
+ static const int kPatchReturnSequenceAddressOffset =
+ kJSReturnSequenceLength - kPatchDebugBreakSlotReturnOffset;
+ // Distance between the start of the JS return sequence and where the
+ // 32-bit displacement of a short call would be. The short call is from
+ // SetDebugBreakAtIC from debug-x64.cc.
+ static const int kPatchDebugBreakSlotAddressOffset =
+ kDebugBreakSlotLength - kPatchDebugBreakSlotReturnOffset;
+ static const int kRealPatchReturnSequenceAddressOffset =
+ kMoveAddressIntoScratchRegisterInstructionSize - kPointerSize;
// One byte opcode for test eax,0xXXXXXXXX.
static const byte kTestEaxByte = 0xA9;
Index: src/x64/debug-x64.cc
diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc
index
a337b0d052f7252ea1baa0e3b1d0bfe608fd87a7..e6bc92950a9c43f984c9b87e275eb9e35c75fab6
100644
--- a/src/x64/debug-x64.cc
+++ b/src/x64/debug-x64.cc
@@ -48,11 +48,10 @@ bool BreakLocationIterator::IsDebugBreakAtReturn() {
// CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in
codegen-x64.cc
// for the precise return instructions sequence.
void BreakLocationIterator::SetDebugBreakAtReturn() {
- ASSERT(Assembler::kJSReturnSequenceLength >=
- Assembler::kCallInstructionLength);
+ ASSERT(Assembler::kJSReturnSequenceLength >=
Assembler::kCallSequenceLength);
rinfo()->PatchCodeWithCall(
Isolate::Current()->debug()->debug_break_return()->entry(),
- Assembler::kJSReturnSequenceLength -
Assembler::kCallInstructionLength);
+ Assembler::kJSReturnSequenceLength - Assembler::kCallSequenceLength);
}
@@ -82,7 +81,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() {
ASSERT(IsDebugBreakSlot());
rinfo()->PatchCodeWithCall(
Isolate::Current()->debug()->debug_break_slot()->entry(),
- Assembler::kDebugBreakSlotLength -
Assembler::kCallInstructionLength);
+ Assembler::kDebugBreakSlotLength - Assembler::kCallSequenceLength);
}
Index: src/x64/deoptimizer-x64.cc
diff --git a/src/x64/deoptimizer-x64.cc b/src/x64/deoptimizer-x64.cc
index
b45e9663e2a10c074178e0802aca949c3164f207..e9cf567f7e44d1aaa52653b03286ced8ad09f464
100644
--- a/src/x64/deoptimizer-x64.cc
+++ b/src/x64/deoptimizer-x64.cc
@@ -42,7 +42,7 @@ const int Deoptimizer::table_entry_size_ = 10;
int Deoptimizer::patch_size() {
- return Assembler::kCallInstructionLength;
+ return Assembler::kCallSequenceLength;
}
@@ -69,7 +69,7 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate*
isolate, Code* code) {
Address call_address = instruction_start + deopt_data->Pc(i)->value();
// There is room enough to write a long call instruction because we pad
// LLazyBailout instructions with nops if necessary.
- CodePatcher patcher(call_address, Assembler::kCallInstructionLength);
+ CodePatcher patcher(call_address, Assembler::kCallSequenceLength);
patcher.masm()->Call(GetDeoptimizationEntry(isolate, i, LAZY),
RelocInfo::NONE64);
ASSERT(prev_call_address == NULL ||
Index: src/x64/macro-assembler-x64.cc
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index
13d7ddaa685bf92e16a4adab1faa1dc17fee4aae..66dc68c481c08f1cc8da07ae3bd389406b6b5135
100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -155,7 +155,7 @@ int MacroAssembler::LoadAddressSize(ExternalReference
source) {
}
}
// Size of movq(destination, src);
- return 10;
+ return Assembler::kMoveAddressIntoScratchRegisterInstructionSize;
}
@@ -2510,8 +2510,7 @@ void MacroAssembler::Jump(Handle<Code> code_object,
RelocInfo::Mode rmode) {
int MacroAssembler::CallSize(ExternalReference ext) {
// Opcode for call kScratchRegister is: Rex.B FF D4 (three bytes).
- const int kCallInstructionSize = 3;
- return LoadAddressSize(ext) + kCallInstructionSize;
+ return LoadAddressSize(ext) +
Assembler::kCallScratchRegisterInstructionSize;
}
Index: src/x64/macro-assembler-x64.h
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index
e611c8ae27999a9520d0aa07bfa050b51a0bb831..de7d44c3b2591605d237bab452ed8a7f480ac601
100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -837,7 +837,7 @@ class MacroAssembler: public Assembler {
// The size of the code generated for different call instructions.
int CallSize(Address destination, RelocInfo::Mode rmode) {
- return kCallInstructionLength;
+ return kCallSequenceLength;
}
int CallSize(ExternalReference ext);
int CallSize(Handle<Code> code_object) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.