X64: Change kSmiConstantRegister to r12.
We never use the smi register in places where it matters that r12 as a base register needs an extra SIB byte. Might as well free up the unencumbered r15 register instead. Review URL: http://codereview.chromium.org/6647015 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7113 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
34c399d205
commit
d57a8b0a07
@ -191,12 +191,12 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) {
|
||||
// Register constants.
|
||||
|
||||
const int Register::kRegisterCodeByAllocationIndex[kNumAllocatableRegisters] = {
|
||||
// rax, rbx, rdx, rcx, rdi, r8, r9, r11, r14, r12
|
||||
0, 3, 2, 1, 7, 8, 9, 11, 14, 12
|
||||
// rax, rbx, rdx, rcx, rdi, r8, r9, r11, r14, r15
|
||||
0, 3, 2, 1, 7, 8, 9, 11, 14, 15
|
||||
};
|
||||
|
||||
const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = {
|
||||
0, 3, 2, 1, -1, -1, -1, 4, 5, 6, -1, 7, 9, -1, 8, -1
|
||||
0, 3, 2, 1, -1, -1, -1, 4, 5, 6, -1, 7, -1, -1, 8, 9
|
||||
};
|
||||
|
||||
|
||||
|
@ -93,8 +93,8 @@ struct Register {
|
||||
// rbp - frame pointer
|
||||
// rsi - context register
|
||||
// r10 - fixed scratch register
|
||||
// r12 - smi constant register
|
||||
// r13 - root register
|
||||
// r15 - smi constant register
|
||||
static const int kNumRegisters = 16;
|
||||
static const int kNumAllocatableRegisters = 10;
|
||||
|
||||
@ -120,7 +120,7 @@ struct Register {
|
||||
"r9",
|
||||
"r11",
|
||||
"r14",
|
||||
"r12"
|
||||
"r15"
|
||||
};
|
||||
return names[index];
|
||||
}
|
||||
|
@ -3321,7 +3321,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
|
||||
// rbp: frame pointer (restored after C call).
|
||||
// rsp: stack pointer (restored after C call).
|
||||
// r14: number of arguments including receiver (C callee-saved).
|
||||
// r12: pointer to the first argument (C callee-saved).
|
||||
// r15: pointer to the first argument (C callee-saved).
|
||||
// This pointer is reused in LeaveExitFrame(), so it is stored in a
|
||||
// callee-saved register.
|
||||
|
||||
@ -3362,7 +3362,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
|
||||
// Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9
|
||||
// Store Arguments object on stack, below the 4 WIN64 ABI parameter slots.
|
||||
__ movq(StackSpaceOperand(0), r14); // argc.
|
||||
__ movq(StackSpaceOperand(1), r12); // argv.
|
||||
__ movq(StackSpaceOperand(1), r15); // argv.
|
||||
if (result_size_ < 2) {
|
||||
// Pass a pointer to the Arguments object as the first argument.
|
||||
// Return result in single register (rax).
|
||||
@ -3378,7 +3378,7 @@ void CEntryStub::GenerateCore(MacroAssembler* masm,
|
||||
#else // _WIN64
|
||||
// GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9.
|
||||
__ movq(rdi, r14); // argc.
|
||||
__ movq(rsi, r12); // argv.
|
||||
__ movq(rsi, r15); // argv.
|
||||
#endif
|
||||
__ call(rbx);
|
||||
// Result is in rax - do not destroy this register!
|
||||
@ -3482,7 +3482,7 @@ void CEntryStub::Generate(MacroAssembler* masm) {
|
||||
// rbp: frame pointer of exit frame (restored after C call).
|
||||
// rsp: stack pointer (restored after C call).
|
||||
// r14: number of arguments including receiver (C callee-saved).
|
||||
// r12: argv pointer (C callee-saved).
|
||||
// r15: argv pointer (C callee-saved).
|
||||
|
||||
Label throw_normal_exception;
|
||||
Label throw_termination_exception;
|
||||
@ -4173,7 +4173,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
|
||||
// just allocate a new one.
|
||||
Label make_two_character_string, make_flat_ascii_string;
|
||||
StringHelper::GenerateTwoCharacterSymbolTableProbe(
|
||||
masm, rbx, rcx, r14, r11, rdi, r12, &make_two_character_string);
|
||||
masm, rbx, rcx, r14, r11, rdi, r15, &make_two_character_string);
|
||||
__ IncrementCounter(&Counters::string_add_native, 1);
|
||||
__ ret(2 * kPointerSize);
|
||||
|
||||
|
@ -7961,7 +7961,7 @@ bool CodeGenerator::HasValidEntryRegisters() {
|
||||
&& (allocator()->count(r9) == (frame()->is_used(r9) ? 1 : 0))
|
||||
&& (allocator()->count(r11) == (frame()->is_used(r11) ? 1 : 0))
|
||||
&& (allocator()->count(r14) == (frame()->is_used(r14) ? 1 : 0))
|
||||
&& (allocator()->count(r12) == (frame()->is_used(r12) ? 1 : 0));
|
||||
&& (allocator()->count(r15) == (frame()->is_used(r15) ? 1 : 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -555,7 +555,7 @@ MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(
|
||||
// Allocate HandleScope in callee-save registers.
|
||||
Register prev_next_address_reg = r14;
|
||||
Register prev_limit_reg = rbx;
|
||||
Register base_reg = r12;
|
||||
Register base_reg = r15;
|
||||
movq(base_reg, next_address);
|
||||
movq(prev_next_address_reg, Operand(base_reg, kNextOffset));
|
||||
movq(prev_limit_reg, Operand(base_reg, kLimitOffset));
|
||||
@ -721,11 +721,11 @@ void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
|
||||
bind(&ok);
|
||||
}
|
||||
}
|
||||
if (source->value() == 0) {
|
||||
int value = source->value();
|
||||
if (value == 0) {
|
||||
xorl(dst, dst);
|
||||
return;
|
||||
}
|
||||
int value = source->value();
|
||||
bool negative = value < 0;
|
||||
unsigned int uvalue = negative ? -value : value;
|
||||
|
||||
@ -1474,10 +1474,10 @@ void MacroAssembler::Pushad() {
|
||||
push(r9);
|
||||
// r10 is kScratchRegister.
|
||||
push(r11);
|
||||
push(r12);
|
||||
// r12 is kSmiConstantRegister.
|
||||
// r13 is kRootRegister.
|
||||
push(r14);
|
||||
// r15 is kSmiConstantRegister
|
||||
push(r15);
|
||||
STATIC_ASSERT(11 == kNumSafepointSavedRegisters);
|
||||
// Use lea for symmetry with Popad.
|
||||
int sp_delta =
|
||||
@ -1491,8 +1491,8 @@ void MacroAssembler::Popad() {
|
||||
int sp_delta =
|
||||
(kNumSafepointRegisters - kNumSafepointSavedRegisters) * kPointerSize;
|
||||
lea(rsp, Operand(rsp, sp_delta));
|
||||
pop(r15);
|
||||
pop(r14);
|
||||
pop(r12);
|
||||
pop(r11);
|
||||
pop(r9);
|
||||
pop(r8);
|
||||
@ -1511,7 +1511,7 @@ void MacroAssembler::Dropad() {
|
||||
|
||||
|
||||
// Order general registers are pushed by Pushad:
|
||||
// rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r12, r14.
|
||||
// rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15.
|
||||
int MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = {
|
||||
0,
|
||||
1,
|
||||
@ -1525,10 +1525,10 @@ int MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = {
|
||||
7,
|
||||
-1,
|
||||
8,
|
||||
9,
|
||||
-1,
|
||||
10,
|
||||
-1
|
||||
-1,
|
||||
9,
|
||||
10
|
||||
};
|
||||
|
||||
|
||||
@ -2077,10 +2077,10 @@ void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space,
|
||||
void MacroAssembler::EnterExitFrame(int arg_stack_space, bool save_doubles) {
|
||||
EnterExitFramePrologue(true);
|
||||
|
||||
// Setup argv in callee-saved register r12. It is reused in LeaveExitFrame,
|
||||
// Setup argv in callee-saved register r15. It is reused in LeaveExitFrame,
|
||||
// so it must be retained across the C-call.
|
||||
int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
|
||||
lea(r12, Operand(rbp, r14, times_pointer_size, offset));
|
||||
lea(r15, Operand(rbp, r14, times_pointer_size, offset));
|
||||
|
||||
EnterExitFrameEpilogue(arg_stack_space, save_doubles);
|
||||
}
|
||||
@ -2094,7 +2094,7 @@ void MacroAssembler::EnterApiExitFrame(int arg_stack_space) {
|
||||
|
||||
void MacroAssembler::LeaveExitFrame(bool save_doubles) {
|
||||
// Registers:
|
||||
// r12 : argv
|
||||
// r15 : argv
|
||||
if (save_doubles) {
|
||||
int offset = -2 * kPointerSize;
|
||||
for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; i++) {
|
||||
@ -2108,7 +2108,7 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles) {
|
||||
|
||||
// Drop everything up to and including the arguments and the receiver
|
||||
// from the caller stack.
|
||||
lea(rsp, Operand(r12, 1 * kPointerSize));
|
||||
lea(rsp, Operand(r15, 1 * kPointerSize));
|
||||
|
||||
// Push the return address to get ready to return.
|
||||
push(rcx);
|
||||
|
@ -48,7 +48,7 @@ enum AllocationFlags {
|
||||
// a spare register). The register isn't callee save, and not used by the
|
||||
// function calling convention.
|
||||
static const Register kScratchRegister = { 10 }; // r10.
|
||||
static const Register kSmiConstantRegister = { 15 }; // r15 (callee save).
|
||||
static const Register kSmiConstantRegister = { 12 }; // r12 (callee save).
|
||||
static const Register kRootRegister = { 13 }; // r13 (callee save).
|
||||
// Value of smi in kSmiConstantRegister.
|
||||
static const int kSmiConstantRegisterValue = 1;
|
||||
@ -941,7 +941,7 @@ class MacroAssembler: public Assembler {
|
||||
|
||||
// Calls an API function. Allocates HandleScope, extracts
|
||||
// returned value from handle and propagates exceptions.
|
||||
// Clobbers r12, r14, rbx and caller-save registers. Restores context.
|
||||
// Clobbers r14, r15, rbx and caller-save registers. Restores context.
|
||||
// On return removes stack_space * kPointerSize (GCed).
|
||||
MUST_USE_RESULT MaybeObject* TryCallApiFunctionAndReturn(
|
||||
ApiFunction* function, int stack_space);
|
||||
@ -1013,7 +1013,7 @@ class MacroAssembler: public Assembler {
|
||||
|
||||
private:
|
||||
// Order general registers are pushed by Pushad.
|
||||
// rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r12, r14.
|
||||
// rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15.
|
||||
static int kSafepointPushRegisterIndices[Register::kNumRegisters];
|
||||
static const int kNumSafepointSavedRegisters = 11;
|
||||
|
||||
|
@ -60,10 +60,10 @@ int RegisterAllocator::ToNumber(Register reg) {
|
||||
6, // r9
|
||||
-1, // r10 Scratch register.
|
||||
8, // r11
|
||||
9, // r12
|
||||
-1, // r12 Smi constant.
|
||||
-1, // r13 Roots array. This is callee saved.
|
||||
7, // r14
|
||||
-1 // r15 Smi constant register.
|
||||
9 // r15
|
||||
};
|
||||
return kNumbers[reg.code()];
|
||||
}
|
||||
@ -72,7 +72,7 @@ int RegisterAllocator::ToNumber(Register reg) {
|
||||
Register RegisterAllocator::ToRegister(int num) {
|
||||
ASSERT(num >= 0 && num < kNumRegisters);
|
||||
const Register kRegisters[] =
|
||||
{ rax, rbx, rcx, rdx, rdi, r8, r9, r14, r11, r12 };
|
||||
{ rax, rbx, rcx, rdx, rdi, r8, r9, r14, r11, r15 };
|
||||
return kRegisters[num];
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,8 @@ using v8::internal::rbp;
|
||||
using v8::internal::rsp;
|
||||
using v8::internal::r8;
|
||||
using v8::internal::r9;
|
||||
using v8::internal::r12;
|
||||
using v8::internal::r13;
|
||||
using v8::internal::r15;
|
||||
using v8::internal::times_1;
|
||||
|
||||
using v8::internal::FUNCTION_CAST;
|
||||
@ -317,7 +317,7 @@ TEST(OperandRegisterDependency) {
|
||||
|
||||
CHECK(Operand(rsp, offset).AddressUsesRegister(rsp));
|
||||
CHECK(!Operand(rsp, offset).AddressUsesRegister(rax));
|
||||
CHECK(!Operand(rsp, offset).AddressUsesRegister(r12));
|
||||
CHECK(!Operand(rsp, offset).AddressUsesRegister(r15));
|
||||
|
||||
CHECK(Operand(rbp, offset).AddressUsesRegister(rbp));
|
||||
CHECK(!Operand(rbp, offset).AddressUsesRegister(rax));
|
||||
@ -333,7 +333,7 @@ TEST(OperandRegisterDependency) {
|
||||
CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rsp));
|
||||
CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rbp));
|
||||
CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rax));
|
||||
CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r12));
|
||||
CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r15));
|
||||
CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r13));
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ using v8::internal::rsp;
|
||||
using v8::internal::r8;
|
||||
using v8::internal::r9;
|
||||
using v8::internal::r11;
|
||||
using v8::internal::r12;
|
||||
using v8::internal::r13;
|
||||
using v8::internal::r14;
|
||||
using v8::internal::r15;
|
||||
using v8::internal::times_pointer_size;
|
||||
using v8::internal::FUNCTION_CAST;
|
||||
using v8::internal::CodeDesc;
|
||||
@ -1120,30 +1120,30 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) {
|
||||
if (!fraction && !overflow && !negative_zero && !division_by_zero) {
|
||||
// Division succeeds
|
||||
__ movq(rcx, r11);
|
||||
__ movq(r12, Immediate(id));
|
||||
__ movq(r15, Immediate(id));
|
||||
int result = x / y;
|
||||
__ Move(r8, Smi::FromInt(result));
|
||||
__ SmiDiv(r9, rcx, r14, exit);
|
||||
// Might have destroyed rcx and r14.
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(r9, r8);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ movq(rcx, r11);
|
||||
__ Move(r14, Smi::FromInt(y));
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiDiv(rcx, rcx, r14, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r8);
|
||||
__ j(not_equal, exit);
|
||||
} else {
|
||||
// Division fails.
|
||||
__ movq(r12, Immediate(id + 8));
|
||||
__ movq(r15, Immediate(id + 8));
|
||||
|
||||
Label fail_ok, fail_ok2;
|
||||
__ movq(rcx, r11);
|
||||
@ -1151,16 +1151,16 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) {
|
||||
__ jmp(exit);
|
||||
__ bind(&fail_ok);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiDiv(rcx, rcx, r14, &fail_ok2);
|
||||
__ jmp(exit);
|
||||
__ bind(&fail_ok2);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
}
|
||||
@ -1184,7 +1184,7 @@ TEST(SmiDiv) {
|
||||
Label exit;
|
||||
|
||||
__ push(r14);
|
||||
__ push(r12);
|
||||
__ push(r15);
|
||||
TestSmiDiv(masm, &exit, 0x10, 1, 1);
|
||||
TestSmiDiv(masm, &exit, 0x20, 1, 0);
|
||||
TestSmiDiv(masm, &exit, 0x30, -1, 0);
|
||||
@ -1206,10 +1206,10 @@ TEST(SmiDiv) {
|
||||
TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
|
||||
TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1);
|
||||
|
||||
__ xor_(r12, r12); // Success.
|
||||
__ xor_(r15, r15); // Success.
|
||||
__ bind(&exit);
|
||||
__ movq(rax, r12);
|
||||
__ pop(r12);
|
||||
__ movq(rax, r15);
|
||||
__ pop(r15);
|
||||
__ pop(r14);
|
||||
ExitCode(masm);
|
||||
__ ret(0);
|
||||
@ -1232,44 +1232,44 @@ void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) {
|
||||
__ Move(r14, Smi::FromInt(y));
|
||||
if (!division_overflow && !negative_zero && !division_by_zero) {
|
||||
// Modulo succeeds
|
||||
__ movq(r12, Immediate(id));
|
||||
__ movq(r15, Immediate(id));
|
||||
int result = x % y;
|
||||
__ Move(r8, Smi::FromInt(result));
|
||||
__ SmiMod(r9, rcx, r14, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(r9, r8);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiMod(rcx, rcx, r14, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r8);
|
||||
__ j(not_equal, exit);
|
||||
} else {
|
||||
// Modulo fails.
|
||||
__ movq(r12, Immediate(id + 8));
|
||||
__ movq(r15, Immediate(id + 8));
|
||||
|
||||
Label fail_ok, fail_ok2;
|
||||
__ SmiMod(r9, rcx, r14, &fail_ok);
|
||||
__ jmp(exit);
|
||||
__ bind(&fail_ok);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiMod(rcx, rcx, r14, &fail_ok2);
|
||||
__ jmp(exit);
|
||||
__ bind(&fail_ok2);
|
||||
|
||||
__ incq(r12);
|
||||
__ incq(r15);
|
||||
__ SmiCompare(rcx, r11);
|
||||
__ j(not_equal, exit);
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ TEST(SmiMod) {
|
||||
Label exit;
|
||||
|
||||
__ push(r14);
|
||||
__ push(r12);
|
||||
__ push(r15);
|
||||
TestSmiMod(masm, &exit, 0x10, 1, 1);
|
||||
TestSmiMod(masm, &exit, 0x20, 1, 0);
|
||||
TestSmiMod(masm, &exit, 0x30, -1, 0);
|
||||
@ -1315,10 +1315,10 @@ TEST(SmiMod) {
|
||||
TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
|
||||
TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1);
|
||||
|
||||
__ xor_(r12, r12); // Success.
|
||||
__ xor_(r15, r15); // Success.
|
||||
__ bind(&exit);
|
||||
__ movq(rax, r12);
|
||||
__ pop(r12);
|
||||
__ movq(rax, r15);
|
||||
__ pop(r15);
|
||||
__ pop(r14);
|
||||
ExitCode(masm);
|
||||
__ ret(0);
|
||||
@ -2150,7 +2150,7 @@ TEST(OperandOffset) {
|
||||
__ push(Immediate(0x108));
|
||||
__ push(Immediate(0x109)); // <-- rsp
|
||||
// rbp = rsp[9]
|
||||
// r12 = rsp[3]
|
||||
// r15 = rsp[3]
|
||||
// rbx = rsp[5]
|
||||
// r13 = rsp[7]
|
||||
__ lea(r14, Operand(rsp, 3 * kPointerSize));
|
||||
|
Loading…
Reference in New Issue
Block a user