Update CheckBothSmi, CheckInteger32ValidSmiValue, CheckUInteger32ValidSmiValue, SmiAddConstant, SmiNot, AddSmiField and Test to support x32 port.

R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20862 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
haitao.feng@intel.com 2014-04-17 23:17:08 +00:00
parent c8c951204c
commit 6e40573330

View File

@ -1330,8 +1330,15 @@ Condition MacroAssembler::CheckBothSmi(Register first, Register second) {
return CheckSmi(first);
}
STATIC_ASSERT(kSmiTag == 0 && kHeapObjectTag == 1 && kHeapObjectTagMask == 3);
leal(kScratchRegister, Operand(first, second, times_1, 0));
testb(kScratchRegister, Immediate(0x03));
if (SmiValuesAre32Bits()) {
leal(kScratchRegister, Operand(first, second, times_1, 0));
testb(kScratchRegister, Immediate(0x03));
} else {
ASSERT(SmiValuesAre31Bits());
movl(kScratchRegister, first);
orl(kScratchRegister, second);
testb(kScratchRegister, Immediate(kSmiTagMask));
}
return zero;
}
@ -1377,16 +1384,28 @@ Condition MacroAssembler::CheckIsMinSmi(Register src) {
Condition MacroAssembler::CheckInteger32ValidSmiValue(Register src) {
// A 32-bit integer value can always be converted to a smi.
return always;
if (SmiValuesAre32Bits()) {
// A 32-bit integer value can always be converted to a smi.
return always;
} else {
ASSERT(SmiValuesAre31Bits());
cmpl(src, Immediate(0xc0000000));
return positive;
}
}
Condition MacroAssembler::CheckUInteger32ValidSmiValue(Register src) {
// An unsigned 32-bit integer value is valid as long as the high bit
// is not set.
testl(src, src);
return positive;
if (SmiValuesAre32Bits()) {
// An unsigned 32-bit integer value is valid as long as the high bit
// is not set.
testl(src, src);
return positive;
} else {
ASSERT(SmiValuesAre31Bits());
testl(src, Immediate(0xc0000000));
return zero;
}
}
@ -1529,7 +1548,13 @@ void MacroAssembler::SmiAddConstant(Register dst, Register src, Smi* constant) {
void MacroAssembler::SmiAddConstant(const Operand& dst, Smi* constant) {
if (constant->value() != 0) {
addl(Operand(dst, kSmiShift / kBitsPerByte), Immediate(constant->value()));
if (SmiValuesAre32Bits()) {
addl(Operand(dst, kSmiShift / kBitsPerByte),
Immediate(constant->value()));
} else {
ASSERT(SmiValuesAre31Bits());
addp(dst, Immediate(constant));
}
}
}
@ -1987,8 +2012,14 @@ void MacroAssembler::SmiMod(Register dst,
void MacroAssembler::SmiNot(Register dst, Register src) {
ASSERT(!dst.is(kScratchRegister));
ASSERT(!src.is(kScratchRegister));
// Set tag and padding bits before negating, so that they are zero afterwards.
movl(kScratchRegister, Immediate(~0));
if (SmiValuesAre32Bits()) {
// Set tag and padding bits before negating, so that they are zero
// afterwards.
movl(kScratchRegister, Immediate(~0));
} else {
ASSERT(SmiValuesAre31Bits());
movl(kScratchRegister, Immediate(1));
}
if (dst.is(src)) {
xorp(dst, kScratchRegister);
} else {
@ -2262,8 +2293,14 @@ SmiIndex MacroAssembler::SmiToNegativeIndex(Register dst,
void MacroAssembler::AddSmiField(Register dst, const Operand& src) {
ASSERT_EQ(0, kSmiShift % kBitsPerByte);
addl(dst, Operand(src, kSmiShift / kBitsPerByte));
if (SmiValuesAre32Bits()) {
ASSERT_EQ(0, kSmiShift % kBitsPerByte);
addl(dst, Operand(src, kSmiShift / kBitsPerByte));
} else {
ASSERT(SmiValuesAre31Bits());
SmiToInteger32(kScratchRegister, src);
addl(dst, kScratchRegister);
}
}
@ -2305,7 +2342,12 @@ void MacroAssembler::PopRegisterAsTwoSmis(Register dst, Register scratch) {
void MacroAssembler::Test(const Operand& src, Smi* source) {
testl(Operand(src, kIntSize), Immediate(source->value()));
if (SmiValuesAre32Bits()) {
testl(Operand(src, kIntSize), Immediate(source->value()));
} else {
ASSERT(SmiValuesAre31Bits());
testl(src, Immediate(source));
}
}