[x64] Make r12 allocatable.
Review URL: https://codereview.chromium.org/926553004 Cr-Commit-Position: refs/heads/master@{#26907}
This commit is contained in:
parent
2e2c9b2ac8
commit
643f020cd2
@ -310,7 +310,6 @@ namespace internal {
|
||||
V(kUnexpectedUnusedPropertiesOfStringWrapper, \
|
||||
"Unexpected unused properties of string wrapper") \
|
||||
V(kUnimplemented, "unimplemented") \
|
||||
V(kUninitializedKSmiConstantRegister, "Uninitialized kSmiConstantRegister") \
|
||||
V(kUnsupportedConstCompoundAssignment, \
|
||||
"Unsupported const compound assignment") \
|
||||
V(kUnsupportedCountOperationWithConst, \
|
||||
@ -345,7 +344,8 @@ enum BailoutReason {
|
||||
|
||||
|
||||
const char* GetBailoutReason(BailoutReason reason);
|
||||
}
|
||||
} // namespace v8::internal
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_BAILOUT_REASON_H_
|
||||
|
@ -156,12 +156,12 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) {
|
||||
|
||||
const int
|
||||
Register::kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters] = {
|
||||
// rax, rbx, rdx, rcx, rsi, rdi, r8, r9, r11, r14, r15
|
||||
0, 3, 2, 1, 6, 7, 8, 9, 11, 14, 15
|
||||
// rax, rbx, rdx, rcx, rsi, rdi, r8, r9, r11, r12, r14, r15
|
||||
0, 3, 2, 1, 6, 7, 8, 9, 11, 12, 14, 15
|
||||
};
|
||||
|
||||
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 {
|
||||
// rsp - stack pointer
|
||||
// rbp - frame pointer
|
||||
// r10 - fixed scratch register
|
||||
// r12 - smi constant register
|
||||
// r13 - root register
|
||||
static const int kMaxNumAllocatableRegisters = 11;
|
||||
static const int kMaxNumAllocatableRegisters = 12;
|
||||
static int NumAllocatableRegisters() {
|
||||
return kMaxNumAllocatableRegisters;
|
||||
}
|
||||
@ -104,6 +103,7 @@ struct Register {
|
||||
"r8",
|
||||
"r9",
|
||||
"r11",
|
||||
"r12",
|
||||
"r14",
|
||||
"r15"
|
||||
};
|
||||
|
@ -2520,7 +2520,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
|
||||
|
||||
// Set up the roots and smi constant registers.
|
||||
// Needs to be done before any further smi loads.
|
||||
__ InitializeSmiConstantRegister();
|
||||
__ InitializeRootRegister();
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,6 @@ void Deoptimizer::EntryGenerator::Generate() {
|
||||
|
||||
// Set up the roots register.
|
||||
__ InitializeRootRegister();
|
||||
__ InitializeSmiConstantRegister();
|
||||
|
||||
// Return to the continuation point.
|
||||
__ ret(0);
|
||||
|
@ -920,67 +920,13 @@ Register MacroAssembler::GetSmiConstant(Smi* source) {
|
||||
xorl(kScratchRegister, kScratchRegister);
|
||||
return kScratchRegister;
|
||||
}
|
||||
if (value == 1) {
|
||||
return kSmiConstantRegister;
|
||||
}
|
||||
LoadSmiConstant(kScratchRegister, source);
|
||||
return kScratchRegister;
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
|
||||
if (emit_debug_code()) {
|
||||
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);
|
||||
}
|
||||
Move(dst, source, Assembler::RelocInfoNone());
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
if (SmiValuesAre32Bits()) {
|
||||
// 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) {
|
||||
return;
|
||||
} else if (dst.is(src)) {
|
||||
DCHECK(!dst.is(kScratchRegister));
|
||||
switch (constant->value()) {
|
||||
case 1:
|
||||
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;
|
||||
}
|
||||
Register constant_reg = GetSmiConstant(constant);
|
||||
addp(dst, constant_reg);
|
||||
} else {
|
||||
switch (constant->value()) {
|
||||
case 1:
|
||||
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;
|
||||
}
|
||||
LoadSmiConstant(dst, constant);
|
||||
addp(dst, src);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2789,15 +2695,13 @@ void MacroAssembler::Pop(const Operand& dst) {
|
||||
popq(dst);
|
||||
} else {
|
||||
Register scratch = dst.AddressUsesRegister(kScratchRegister)
|
||||
? kSmiConstantRegister : kScratchRegister;
|
||||
? kRootRegister : kScratchRegister;
|
||||
movp(scratch, Operand(rsp, 0));
|
||||
movp(dst, scratch);
|
||||
leal(rsp, Operand(rsp, 4));
|
||||
if (scratch.is(kSmiConstantRegister)) {
|
||||
// Restore kSmiConstantRegister.
|
||||
movp(kSmiConstantRegister,
|
||||
reinterpret_cast<void*>(Smi::FromInt(kSmiConstantRegisterValue)),
|
||||
Assembler::RelocInfoNone());
|
||||
if (scratch.is(kRootRegister)) {
|
||||
// Restore kRootRegister.
|
||||
InitializeRootRegister();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2940,11 +2844,11 @@ void MacroAssembler::Pushad() {
|
||||
Push(r9);
|
||||
// r10 is kScratchRegister.
|
||||
Push(r11);
|
||||
// r12 is kSmiConstantRegister.
|
||||
Push(r12);
|
||||
// r13 is kRootRegister.
|
||||
Push(r14);
|
||||
Push(r15);
|
||||
STATIC_ASSERT(11 == kNumSafepointSavedRegisters);
|
||||
STATIC_ASSERT(12 == kNumSafepointSavedRegisters);
|
||||
// Use lea for symmetry with Popad.
|
||||
int sp_delta =
|
||||
(kNumSafepointRegisters - kNumSafepointSavedRegisters) * kPointerSize;
|
||||
@ -2959,6 +2863,7 @@ void MacroAssembler::Popad() {
|
||||
leap(rsp, Operand(rsp, sp_delta));
|
||||
Pop(r15);
|
||||
Pop(r14);
|
||||
Pop(r12);
|
||||
Pop(r11);
|
||||
Pop(r9);
|
||||
Pop(r8);
|
||||
@ -2992,10 +2897,10 @@ MacroAssembler::kSafepointPushRegisterIndices[Register::kNumRegisters] = {
|
||||
7,
|
||||
-1,
|
||||
8,
|
||||
-1,
|
||||
-1,
|
||||
9,
|
||||
10
|
||||
-1,
|
||||
10,
|
||||
11
|
||||
};
|
||||
|
||||
|
||||
|
@ -17,10 +17,7 @@ namespace internal {
|
||||
// a spare register). The register isn't callee save, and not used by the
|
||||
// function calling convention.
|
||||
const Register kScratchRegister = { 10 }; // r10.
|
||||
const Register kSmiConstantRegister = { 12 }; // r12 (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
|
||||
// to take advantage of negitive 8-bit displacement values.
|
||||
const int kRootRegisterBias = 128;
|
||||
@ -390,11 +387,6 @@ class MacroAssembler: public Assembler {
|
||||
void SafeMove(Register dst, 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.
|
||||
|
||||
// Tag an integer value. The result must be known to be a valid smi value.
|
||||
@ -474,11 +466,6 @@ class MacroAssembler: public Assembler {
|
||||
Register second,
|
||||
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
|
||||
// to a smi.
|
||||
Condition CheckInteger32ValidSmiValue(Register src);
|
||||
@ -938,7 +925,7 @@ class MacroAssembler: public Assembler {
|
||||
// Non-x64 instructions.
|
||||
// Push/pop all general purpose registers.
|
||||
// Does not push rsp/rbp nor any of the assembler's special purpose registers
|
||||
// (kScratchRegister, kSmiConstantRegister, kRootRegister).
|
||||
// (kScratchRegister, kRootRegister).
|
||||
void Pushad();
|
||||
void Popad();
|
||||
// Sets the stack as after performing Popad, without actually loading the
|
||||
@ -1468,9 +1455,9 @@ class MacroAssembler: public Assembler {
|
||||
|
||||
private:
|
||||
// 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 kNumSafepointSavedRegisters = 11;
|
||||
static const int kNumSafepointSavedRegisters = 12;
|
||||
static const int kSmiShift = kSmiTagSize + kSmiShiftSize;
|
||||
|
||||
bool generating_stub_;
|
||||
|
@ -43,10 +43,9 @@ namespace internal {
|
||||
*
|
||||
* 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.
|
||||
* The macro assembler special registers r12 and r13 (kSmiConstantRegister,
|
||||
* kRootRegister) aren't special during execution of RegExp code (they don't
|
||||
* hold the values assumed when creating JS code), so no Smi or Root related
|
||||
* macro operations can be used.
|
||||
* The macro assembler special register r13 (kRootRegister) isn't special
|
||||
* during execution of RegExp code (it doesn't hold the value assumed when
|
||||
* creating JS code), so Root related macro operations can be used.
|
||||
*
|
||||
* Each call to a C++ method should retain these registers.
|
||||
*
|
||||
|
@ -98,21 +98,13 @@ typedef int (*F0)();
|
||||
|
||||
static void EntryCode(MacroAssembler* masm) {
|
||||
// Smi constant register is callee save.
|
||||
__ pushq(i::kSmiConstantRegister);
|
||||
__ pushq(i::kRootRegister);
|
||||
__ InitializeSmiConstantRegister();
|
||||
__ InitializeRootRegister();
|
||||
}
|
||||
|
||||
|
||||
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::kSmiConstantRegister);
|
||||
}
|
||||
|
||||
|
||||
@ -556,32 +548,6 @@ TEST(SmiCheck) {
|
||||
cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi.
|
||||
__ 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
|
||||
|
||||
__ incq(rax);
|
||||
|
Loading…
Reference in New Issue
Block a user