Convert ElementsKind into a BitField

R=yangguo@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21515 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
danno@chromium.org 2014-05-27 09:38:01 +00:00
parent 06086a90e0
commit 621c7eb673
13 changed files with 21 additions and 34 deletions

View File

@ -5134,7 +5134,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// but the following bit field extraction takes care of that anyway.
__ ldr(r3, FieldMemOperand(r3, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ Ubfx(r3, r3, Map::kElementsKindShift, Map::kElementsKindBitCount);
__ DecodeField<Map::ElementsKindBits>(r3);
if (FLAG_debug_code) {
Label done;

View File

@ -3951,7 +3951,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
bind(&loop_again);
ldr(current, FieldMemOperand(current, HeapObject::kMapOffset));
ldr(scratch1, FieldMemOperand(current, Map::kBitField2Offset));
Ubfx(scratch1, scratch1, Map::kElementsKindShift, Map::kElementsKindBitCount);
DecodeField<Map::ElementsKindBits>(scratch1);
cmp(scratch1, Operand(DICTIONARY_ELEMENTS));
b(eq, found);
ldr(current, FieldMemOperand(current, Map::kPrototypeOffset));

View File

@ -4687,7 +4687,7 @@ void StoreArrayLiteralElementStub::Generate(MacroAssembler* masm) {
__ JumpIfSmi(value, &smi_element);
// Jump if array's ElementsKind is not FAST_ELEMENTS or FAST_HOLEY_ELEMENTS.
__ Tbnz(bitfield2, MaskToBit(FAST_ELEMENTS << Map::kElementsKindShift),
__ Tbnz(bitfield2, MaskToBit(FAST_ELEMENTS << Map::ElementsKindBits::kShift),
&fast_elements);
// Store into the array literal requires an elements transition. Call into

View File

@ -3769,7 +3769,7 @@ void MacroAssembler::LoadElementsKindFromMap(Register result, Register map) {
// Load the map's "bit field 2".
__ Ldrb(result, FieldMemOperand(map, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ Ubfx(result, result, Map::kElementsKindShift, Map::kElementsKindBitCount);
DecodeField<Map::ElementsKindBits>(result);
}
@ -4544,7 +4544,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
Bind(&loop_again);
Ldr(current, FieldMemOperand(current, HeapObject::kMapOffset));
Ldrb(scratch1, FieldMemOperand(current, Map::kBitField2Offset));
Ubfx(scratch1, scratch1, Map::kElementsKindShift, Map::kElementsKindBitCount);
DecodeField<Map::ElementsKindBits>(scratch1);
CompareAndBranch(scratch1, DICTIONARY_ELEMENTS, eq, found);
Ldr(current, FieldMemOperand(current, Map::kPrototypeOffset));
CompareAndBranch(current, Operand(factory->null_value()), ne, &loop_again);

View File

@ -4952,8 +4952,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// but the following masking takes care of that anyway.
__ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ and_(ecx, Map::kElementsKindMask);
__ shr(ecx, Map::kElementsKindShift);
__ DecodeField<Map::ElementsKindBits>(ecx);
if (FLAG_debug_code) {
Label done;

View File

@ -3422,8 +3422,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
bind(&loop_again);
mov(current, FieldOperand(current, HeapObject::kMapOffset));
mov(scratch1, FieldOperand(current, Map::kBitField2Offset));
and_(scratch1, Map::kElementsKindMask);
shr(scratch1, Map::kElementsKindShift);
DecodeField<Map::ElementsKindBits>(scratch1);
cmp(scratch1, Immediate(DICTIONARY_ELEMENTS));
j(equal, found);
mov(current, FieldOperand(current, Map::kPrototypeOffset));

View File

@ -5349,7 +5349,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// but the following bit field extraction takes care of that anyway.
__ lbu(a3, FieldMemOperand(a3, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ Ext(a3, a3, Map::kElementsKindShift, Map::kElementsKindBitCount);
__ DecodeField<Map::ElementsKindBits>(a3);
if (FLAG_debug_code) {
Label done;

View File

@ -5627,7 +5627,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
bind(&loop_again);
lw(current, FieldMemOperand(current, HeapObject::kMapOffset));
lb(scratch1, FieldMemOperand(current, Map::kBitField2Offset));
Ext(scratch1, scratch1, Map::kElementsKindShift, Map::kElementsKindBitCount);
DecodeField<Map::ElementsKindBits>(scratch1);
Branch(found, eq, scratch1, Operand(DICTIONARY_ELEMENTS));
lw(current, FieldMemOperand(current, Map::kPrototypeOffset));
Branch(&loop_again, ne, current, Operand(factory->null_value()));

View File

@ -6084,15 +6084,13 @@ class Map: public HeapObject {
inline void set_elements_kind(ElementsKind elements_kind) {
ASSERT(elements_kind < kElementsKindCount);
ASSERT(kElementsKindCount <= (1 << kElementsKindBitCount));
set_bit_field2((bit_field2() & ~kElementsKindMask) |
(elements_kind << kElementsKindShift));
ASSERT(kElementsKindCount <= (1 << Map::ElementsKindBits::kSize));
set_bit_field2(Map::ElementsKindBits::update(bit_field2(), elements_kind));
ASSERT(this->elements_kind() == elements_kind);
}
inline ElementsKind elements_kind() {
return static_cast<ElementsKind>(
(bit_field2() & kElementsKindMask) >> kElementsKindShift);
return Map::ElementsKindBits::decode(bit_field2());
}
// Tells whether the instance has fast elements that are only Smis.
@ -6573,25 +6571,20 @@ class Map: public HeapObject {
static const int kIsExtensible = 0;
static const int kStringWrapperSafeForDefaultValueOf = 1;
// Currently bit 2 is not used.
// No bits can be used after kElementsKindFirstBit, they are all reserved for
// storing ElementKind.
static const int kElementsKindShift = 3;
static const int kElementsKindBitCount = 5;
class ElementsKindBits: public BitField<ElementsKind, 3, 5> {};
// Derived values from bit field 2
static const int kElementsKindMask = (-1 << kElementsKindShift) &
((1 << (kElementsKindShift + kElementsKindBitCount)) - 1);
static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>(
(FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1;
(FAST_ELEMENTS + 1) << Map::ElementsKindBits::kShift) - 1;
static const int8_t kMaximumBitField2FastSmiElementValue =
static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) <<
Map::kElementsKindShift) - 1;
Map::ElementsKindBits::kShift) - 1;
static const int8_t kMaximumBitField2FastHoleyElementValue =
static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) <<
Map::kElementsKindShift) - 1;
Map::ElementsKindBits::kShift) - 1;
static const int8_t kMaximumBitField2FastHoleySmiElementValue =
static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) <<
Map::kElementsKindShift) - 1;
Map::ElementsKindBits::kShift) - 1;
typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
kPointerFieldsEndOffset,

View File

@ -4895,8 +4895,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// but the following masking takes care of that anyway.
__ movzxbp(rcx, FieldOperand(rcx, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ andp(rcx, Immediate(Map::kElementsKindMask));
__ shrp(rcx, Immediate(Map::kElementsKindShift));
__ DecodeField<Map::ElementsKindBits>(rcx);
if (FLAG_debug_code) {
Label done;

View File

@ -5197,8 +5197,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
bind(&loop_again);
movp(current, FieldOperand(current, HeapObject::kMapOffset));
movp(scratch1, FieldOperand(current, Map::kBitField2Offset));
andp(scratch1, Immediate(Map::kElementsKindMask));
shrp(scratch1, Immediate(Map::kElementsKindShift));
DecodeField<Map::ElementsKindBits>(scratch1);
cmpp(scratch1, Immediate(DICTIONARY_ELEMENTS));
j(equal, found);
movp(current, FieldOperand(current, Map::kPrototypeOffset));

View File

@ -4592,8 +4592,7 @@ void InternalArrayConstructorStub::Generate(MacroAssembler* masm) {
// but the following masking takes care of that anyway.
__ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset));
// Retrieve elements_kind from bit field 2.
__ and_(ecx, Map::kElementsKindMask);
__ shr(ecx, Map::kElementsKindShift);
DecodeField<Map::ElementsKindBits>(ecx);
if (FLAG_debug_code) {
Label done;

View File

@ -3304,8 +3304,7 @@ void MacroAssembler::JumpIfDictionaryInPrototypeChain(
bind(&loop_again);
mov(current, FieldOperand(current, HeapObject::kMapOffset));
mov(scratch1, FieldOperand(current, Map::kBitField2Offset));
and_(scratch1, Map::kElementsKindMask);
shr(scratch1, Map::kElementsKindShift);
DecodeField<Map::ElementsKindBits>(scratch1);
cmp(scratch1, Immediate(DICTIONARY_ELEMENTS));
j(equal, found);
mov(current, FieldOperand(current, Map::kPrototypeOffset));