X87: Convert String array index/length hash to BitField.

Port r21533 (736c779)

BUG=
R=danno@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21549 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
weiliang.lin@intel.com 2014-05-28 08:18:39 +00:00
parent d5c4ad309e
commit 0f2f60bd37
2 changed files with 18 additions and 8 deletions

View File

@ -1940,16 +1940,10 @@ void MacroAssembler::IndexFromHash(Register hash, Register index) {
// reserved for it does not conflict.
ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
(1 << String::kArrayIndexValueBits));
// We want the smi-tagged index in key. kArrayIndexValueMask has zeros in
// the low kHashShift bits.
and_(hash, String::kArrayIndexValueMask);
STATIC_ASSERT(String::kHashShift >= kSmiTagSize && kSmiTag == 0);
if (String::kHashShift > kSmiTagSize) {
shr(hash, String::kHashShift - kSmiTagSize);
}
if (!index.is(hash)) {
mov(index, hash);
}
DecodeFieldToSmi<String::ArrayIndexValueBits>(index);
}

View File

@ -478,7 +478,23 @@ class MacroAssembler: public Assembler {
void DecodeField(Register reg) {
static const int shift = Field::kShift;
static const int mask = Field::kMask >> Field::kShift;
sar(reg, shift);
if (shift != 0) {
sar(reg, shift);
}
and_(reg, Immediate(mask));
}
template<typename Field>
void DecodeFieldToSmi(Register reg) {
static const int shift = Field::kShift;
static const int mask = (Field::kMask >> Field::kShift) << kSmiTagSize;
STATIC_ASSERT((mask & (0x80000000u >> (kSmiTagSize - 1))) == 0);
STATIC_ASSERT(kSmiTag == 0);
if (shift < kSmiTagSize) {
shl(reg, kSmiTagSize - shift);
} else if (shift > kSmiTagSize) {
sar(reg, shift - kSmiTagSize);
}
and_(reg, Immediate(mask));
}