Commit 643f020c authored by bmeurer's avatar bmeurer Committed by Commit bot

[x64] Make r12 allocatable.

Review URL: https://codereview.chromium.org/926553004

Cr-Commit-Position: refs/heads/master@{#26907}
parent 2e2c9b2a
...@@ -310,7 +310,6 @@ namespace internal { ...@@ -310,7 +310,6 @@ namespace internal {
V(kUnexpectedUnusedPropertiesOfStringWrapper, \ V(kUnexpectedUnusedPropertiesOfStringWrapper, \
"Unexpected unused properties of string wrapper") \ "Unexpected unused properties of string wrapper") \
V(kUnimplemented, "unimplemented") \ V(kUnimplemented, "unimplemented") \
V(kUninitializedKSmiConstantRegister, "Uninitialized kSmiConstantRegister") \
V(kUnsupportedConstCompoundAssignment, \ V(kUnsupportedConstCompoundAssignment, \
"Unsupported const compound assignment") \ "Unsupported const compound assignment") \
V(kUnsupportedCountOperationWithConst, \ V(kUnsupportedCountOperationWithConst, \
...@@ -345,7 +344,8 @@ enum BailoutReason { ...@@ -345,7 +344,8 @@ enum BailoutReason {
const char* GetBailoutReason(BailoutReason reason); const char* GetBailoutReason(BailoutReason reason);
}
} // namespace v8::internal } // namespace internal
} // namespace v8
#endif // V8_BAILOUT_REASON_H_ #endif // V8_BAILOUT_REASON_H_
...@@ -156,12 +156,12 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { ...@@ -156,12 +156,12 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) {
const int const int
Register::kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters] = { Register::kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters] = {
// rax, rbx, rdx, rcx, rsi, rdi, r8, r9, r11, r14, r15 // rax, rbx, rdx, rcx, rsi, rdi, r8, r9, r11, r12, r14, r15
0, 3, 2, 1, 6, 7, 8, 9, 11, 14, 15 0, 3, 2, 1, 6, 7, 8, 9, 11, 12, 14, 15
}; };
const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = { const int Register::kAllocationIndexByRegisterCode[kNumRegisters] = {
0, 3, 2, 1, -1, -1, 4, 5, 6, 7, -1, 8, -1, -1, 9, 10 0, 3, 2, 1, -1, -1, 4, 5, 6, 7, -1, 8, 9, -1, 10, 11
}; };
......
...@@ -74,9 +74,8 @@ struct Register { ...@@ -74,9 +74,8 @@ struct Register {
// rsp - stack pointer // rsp - stack pointer
// rbp - frame pointer // rbp - frame pointer
// r10 - fixed scratch register // r10 - fixed scratch register
// r12 - smi constant register
// r13 - root register // r13 - root register
static const int kMaxNumAllocatableRegisters = 11; static const int kMaxNumAllocatableRegisters = 12;
static int NumAllocatableRegisters() { static int NumAllocatableRegisters() {
return kMaxNumAllocatableRegisters; return kMaxNumAllocatableRegisters;
} }
...@@ -104,6 +103,7 @@ struct Register { ...@@ -104,6 +103,7 @@ struct Register {
"r8", "r8",
"r9", "r9",
"r11", "r11",
"r12",
"r14", "r14",
"r15" "r15"
}; };
......
...@@ -2520,7 +2520,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -2520,7 +2520,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// Set up the roots and smi constant registers. // Set up the roots and smi constant registers.
// Needs to be done before any further smi loads. // Needs to be done before any further smi loads.
__ InitializeSmiConstantRegister();
__ InitializeRootRegister(); __ InitializeRootRegister();
} }
......
...@@ -307,7 +307,6 @@ void Deoptimizer::EntryGenerator::Generate() { ...@@ -307,7 +307,6 @@ void Deoptimizer::EntryGenerator::Generate() {
// Set up the roots register. // Set up the roots register.
__ InitializeRootRegister(); __ InitializeRootRegister();
__ InitializeSmiConstantRegister();
// Return to the continuation point. // Return to the continuation point.
__ ret(0); __ ret(0);
......
...@@ -920,67 +920,13 @@ Register MacroAssembler::GetSmiConstant(Smi* source) { ...@@ -920,67 +920,13 @@ Register MacroAssembler::GetSmiConstant(Smi* source) {
xorl(kScratchRegister, kScratchRegister); xorl(kScratchRegister, kScratchRegister);
return kScratchRegister; return kScratchRegister;
} }
if (value == 1) {
return kSmiConstantRegister;
}
LoadSmiConstant(kScratchRegister, source); LoadSmiConstant(kScratchRegister, source);
return kScratchRegister; return kScratchRegister;
} }
void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) { void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
if (emit_debug_code()) { Move(dst, source, Assembler::RelocInfoNone());
Move(dst, Smi::FromInt(kSmiConstantRegisterValue),
Assembler::RelocInfoNone());
cmpp(dst, kSmiConstantRegister);
Assert(equal, kUninitializedKSmiConstantRegister);
}
int value = source->value();
if (value == 0) {
xorl(dst, dst);
return;
}
bool negative = value < 0;
unsigned int uvalue = negative ? -value : value;
switch (uvalue) {
case 9:
leap(dst,
Operand(kSmiConstantRegister, kSmiConstantRegister, times_8, 0));
break;
case 8:
xorl(dst, dst);
leap(dst, Operand(dst, kSmiConstantRegister, times_8, 0));
break;
case 4:
xorl(dst, dst);
leap(dst, Operand(dst, kSmiConstantRegister, times_4, 0));
break;
case 5:
leap(dst,
Operand(kSmiConstantRegister, kSmiConstantRegister, times_4, 0));
break;
case 3:
leap(dst,
Operand(kSmiConstantRegister, kSmiConstantRegister, times_2, 0));
break;
case 2:
leap(dst,
Operand(kSmiConstantRegister, kSmiConstantRegister, times_1, 0));
break;
case 1:
movp(dst, kSmiConstantRegister);
break;
case 0:
UNREACHABLE();
return;
default:
Move(dst, source, Assembler::RelocInfoNone());
return;
}
if (negative) {
negp(dst);
}
} }
...@@ -1273,14 +1219,6 @@ Condition MacroAssembler::CheckEitherSmi(Register first, ...@@ -1273,14 +1219,6 @@ Condition MacroAssembler::CheckEitherSmi(Register first,
} }
Condition MacroAssembler::CheckIsMinSmi(Register src) {
DCHECK(!src.is(kScratchRegister));
// If we overflow by subtracting one, it's the minimal smi value.
cmpp(src, kSmiConstantRegister);
return overflow;
}
Condition MacroAssembler::CheckInteger32ValidSmiValue(Register src) { Condition MacroAssembler::CheckInteger32ValidSmiValue(Register src) {
if (SmiValuesAre32Bits()) { if (SmiValuesAre32Bits()) {
// A 32-bit integer value can always be converted to a smi. // A 32-bit integer value can always be converted to a smi.
...@@ -1419,43 +1357,11 @@ void MacroAssembler::SmiAddConstant(Register dst, Register src, Smi* constant) { ...@@ -1419,43 +1357,11 @@ void MacroAssembler::SmiAddConstant(Register dst, Register src, Smi* constant) {
return; return;
} else if (dst.is(src)) { } else if (dst.is(src)) {
DCHECK(!dst.is(kScratchRegister)); DCHECK(!dst.is(kScratchRegister));
switch (constant->value()) { Register constant_reg = GetSmiConstant(constant);
case 1: addp(dst, constant_reg);
addp(dst, kSmiConstantRegister);
return;
case 2:
leap(dst, Operand(src, kSmiConstantRegister, times_2, 0));
return;
case 4:
leap(dst, Operand(src, kSmiConstantRegister, times_4, 0));
return;
case 8:
leap(dst, Operand(src, kSmiConstantRegister, times_8, 0));
return;
default:
Register constant_reg = GetSmiConstant(constant);
addp(dst, constant_reg);
return;
}
} else { } else {
switch (constant->value()) { LoadSmiConstant(dst, constant);
case 1: addp(dst, src);
leap(dst, Operand(src, kSmiConstantRegister, times_1, 0));
return;
case 2:
leap(dst, Operand(src, kSmiConstantRegister, times_2, 0));
return;
case 4:
leap(dst, Operand(src, kSmiConstantRegister, times_4, 0));
return;
case 8:
leap(dst, Operand(src, kSmiConstantRegister, times_8, 0));
return;
default:
LoadSmiConstant(dst, constant);
addp(dst, src);
return;
}
} }
} }
...@@ -2789,15 +2695,13 @@ void MacroAssembler::Pop(const Operand& dst) { ...@@ -2789,15 +2695,13 @@ void MacroAssembler::Pop(const Operand& dst) {
popq(dst); popq(dst);
} else { } else {
Register scratch = dst.AddressUsesRegister(kScratchRegister) Register scratch = dst.AddressUsesRegister(kScratchRegister)
? kSmiConstantRegister : kScratchRegister; ? kRootRegister : kScratchRegister;
movp(scratch, Operand(rsp, 0)); movp(scratch, Operand(rsp, 0));
movp(dst, scratch); movp(dst, scratch);
leal(rsp, Operand(rsp, 4)); leal(rsp, Operand(rsp, 4));
if (scratch.is(kSmiConstantRegister)) { if (scratch.is(kRootRegister)) {
// Restore kSmiConstantRegister. // Restore kRootRegister.
movp(kSmiConstantRegister, InitializeRootRegister();
reinterpret_cast<void*>(Smi::FromInt(kSmiConstantRegisterValue)),
Assembler::RelocInfoNone());
} }
} }
} }
...@@ -2940,11 +2844,11 @@ void MacroAssembler::Pushad() { ...@@ -2940,11 +2844,11 @@ void MacroAssembler::Pushad() {
Push(r9); Push(r9);
// r10 is kScratchRegister. // r10 is kScratchRegister.
Push(r11); Push(r11);
// r12 is kSmiConstantRegister. Push(r12);
// r13 is kRootRegister. // r13 is kRootRegister.
Push(r14); Push(r14);
Push(r15); Push(r15);
STATIC_ASSERT(11 == kNumSafepointSavedRegisters); STATIC_ASSERT(12 == kNumSafepointSavedRegisters);
// Use lea for symmetry with Popad. // Use lea for symmetry with Popad.
int sp_delta = int sp_delta =
(kNumSafepointRegisters - kNumSafepointSavedRegisters) * kPointerSize; (kNumSafepointRegisters - kNumSafepointSavedRegisters) * kPointerSize;
...@@ -2959,6 +2863,7 @@ void MacroAssembler::Popad() { ...@@ -2959,6 +2863,7 @@ void MacroAssembler::Popad() {
leap(rsp, Operand(rsp, sp_delta)); leap(rsp, Operand(rsp, sp_delta));
Pop(r15); Pop(r15);
Pop(r14); Pop(r14);
Pop(r12);
Pop(r11); Pop(r11);
Pop(r9); Pop(r9);
Pop(r8); Pop(r8);
...@@ -2992,10 +2897,10 @@ MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = { ...@@ -2992,10 +2897,10 @@ MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = {
7, 7,
-1, -1,
8, 8,
-1,
-1,
9, 9,
10 -1,
10,
11
}; };
......
...@@ -17,10 +17,7 @@ namespace internal { ...@@ -17,10 +17,7 @@ namespace internal {
// a spare register). The register isn't callee save, and not used by the // a spare register). The register isn't callee save, and not used by the
// function calling convention. // function calling convention.
const Register kScratchRegister = { 10 }; // r10. const Register kScratchRegister = { 10 }; // r10.
const Register kSmiConstantRegister = { 12 }; // r12 (callee save).
const Register kRootRegister = { 13 }; // r13 (callee save). const Register kRootRegister = { 13 }; // r13 (callee save).
// Value of smi in kSmiConstantRegister.
const int kSmiConstantRegisterValue = 1;
// Actual value of root register is offset from the root array's start // Actual value of root register is offset from the root array's start
// to take advantage of negitive 8-bit displacement values. // to take advantage of negitive 8-bit displacement values.
const int kRootRegisterBias = 128; const int kRootRegisterBias = 128;
...@@ -390,11 +387,6 @@ class MacroAssembler: public Assembler { ...@@ -390,11 +387,6 @@ class MacroAssembler: public Assembler {
void SafeMove(Register dst, Smi* src); void SafeMove(Register dst, Smi* src);
void SafePush(Smi* src); void SafePush(Smi* src);
void InitializeSmiConstantRegister() {
Move(kSmiConstantRegister, Smi::FromInt(kSmiConstantRegisterValue),
Assembler::RelocInfoNone());
}
// Conversions between tagged smi values and non-tagged integer values. // Conversions between tagged smi values and non-tagged integer values.
// Tag an integer value. The result must be known to be a valid smi value. // Tag an integer value. The result must be known to be a valid smi value.
...@@ -474,11 +466,6 @@ class MacroAssembler: public Assembler { ...@@ -474,11 +466,6 @@ class MacroAssembler: public Assembler {
Register second, Register second,
Register scratch = kScratchRegister); Register scratch = kScratchRegister);
// Is the value the minimum smi value (since we are using
// two's complement numbers, negating the value is known to yield
// a non-smi value).
Condition CheckIsMinSmi(Register src);
// Checks whether an 32-bit integer value is a valid for conversion // Checks whether an 32-bit integer value is a valid for conversion
// to a smi. // to a smi.
Condition CheckInteger32ValidSmiValue(Register src); Condition CheckInteger32ValidSmiValue(Register src);
...@@ -938,7 +925,7 @@ class MacroAssembler: public Assembler { ...@@ -938,7 +925,7 @@ class MacroAssembler: public Assembler {
// Non-x64 instructions. // Non-x64 instructions.
// Push/pop all general purpose registers. // Push/pop all general purpose registers.
// Does not push rsp/rbp nor any of the assembler's special purpose registers // Does not push rsp/rbp nor any of the assembler's special purpose registers
// (kScratchRegister, kSmiConstantRegister, kRootRegister). // (kScratchRegister, kRootRegister).
void Pushad(); void Pushad();
void Popad(); void Popad();
// Sets the stack as after performing Popad, without actually loading the // Sets the stack as after performing Popad, without actually loading the
...@@ -1468,9 +1455,9 @@ class MacroAssembler: public Assembler { ...@@ -1468,9 +1455,9 @@ class MacroAssembler: public Assembler {
private: private:
// Order general registers are pushed by Pushad. // Order general registers are pushed by Pushad.
// rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r14, r15. // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r12, r14, r15.
static const int kSafepointPushRegisterIndices[Register::kNumRegisters]; static const int kSafepointPushRegisterIndices[Register::kNumRegisters];
static const int kNumSafepointSavedRegisters = 11; static const int kNumSafepointSavedRegisters = 12;
static const int kSmiShift = kSmiTagSize + kSmiShiftSize; static const int kSmiShift = kSmiTagSize + kSmiShiftSize;
bool generating_stub_; bool generating_stub_;
......
...@@ -43,10 +43,9 @@ namespace internal { ...@@ -43,10 +43,9 @@ namespace internal {
* *
* The registers rax, rbx, r9 and r11 are free to use for computations. * The registers rax, rbx, r9 and r11 are free to use for computations.
* If changed to use r12+, they should be saved as callee-save registers. * If changed to use r12+, they should be saved as callee-save registers.
* The macro assembler special registers r12 and r13 (kSmiConstantRegister, * The macro assembler special register r13 (kRootRegister) isn't special
* kRootRegister) aren't special during execution of RegExp code (they don't * during execution of RegExp code (it doesn't hold the value assumed when
* hold the values assumed when creating JS code), so no Smi or Root related * creating JS code), so Root related macro operations can be used.
* macro operations can be used.
* *
* Each call to a C++ method should retain these registers. * Each call to a C++ method should retain these registers.
* *
......
...@@ -98,21 +98,13 @@ typedef int (*F0)(); ...@@ -98,21 +98,13 @@ typedef int (*F0)();
static void EntryCode(MacroAssembler* masm) { static void EntryCode(MacroAssembler* masm) {
// Smi constant register is callee save. // Smi constant register is callee save.
__ pushq(i::kSmiConstantRegister);
__ pushq(i::kRootRegister); __ pushq(i::kRootRegister);
__ InitializeSmiConstantRegister();
__ InitializeRootRegister(); __ InitializeRootRegister();
} }
static void ExitCode(MacroAssembler* masm) { static void ExitCode(MacroAssembler* masm) {
// Return -1 if kSmiConstantRegister was clobbered during the test.
__ Move(rdx, Smi::FromInt(1));
__ cmpq(rdx, i::kSmiConstantRegister);
__ movq(rdx, Immediate(-1));
__ cmovq(not_equal, rax, rdx);
__ popq(i::kRootRegister); __ popq(i::kRootRegister);
__ popq(i::kSmiConstantRegister);
} }
...@@ -556,32 +548,6 @@ TEST(SmiCheck) { ...@@ -556,32 +548,6 @@ TEST(SmiCheck) {
cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi. cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi.
__ j(cond, &exit); __ j(cond, &exit);
// CheckIsMinSmi
__ incq(rax);
__ movq(rcx, Immediate(Smi::kMaxValue));
__ Integer32ToSmi(rcx, rcx);
cond = masm->CheckIsMinSmi(rcx);
__ j(cond, &exit);
__ incq(rax);
__ movq(rcx, Immediate(0));
__ Integer32ToSmi(rcx, rcx);
cond = masm->CheckIsMinSmi(rcx);
__ j(cond, &exit);
__ incq(rax);
__ movq(rcx, Immediate(Smi::kMinValue));
__ Integer32ToSmi(rcx, rcx);
cond = masm->CheckIsMinSmi(rcx);
__ j(NegateCondition(cond), &exit);
__ incq(rax);
__ movq(rcx, Immediate(Smi::kMinValue + 1));
__ Integer32ToSmi(rcx, rcx);
cond = masm->CheckIsMinSmi(rcx);
__ j(cond, &exit);
// CheckBothSmi // CheckBothSmi
__ incq(rax); __ incq(rax);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment