__ Branch(&bailout, ne, scratch2, Operand(JS_ARRAY_TYPE));
// Check that the array has fast elements.
- __ lbu(scratch2, FieldMemOperand(scratch1, Map::kBitField2Offset));
- __ And(scratch3, scratch2, Operand(1 << Map::kHasFastElements));
- __ Branch(&bailout, eq, scratch3, Operand(zero_reg));
+ __ CheckFastElements(scratch1, scratch2, &bailout);
// If the array has length zero, return the empty string.
__ lw(array_length, FieldMemOperand(array, JSArray::kLengthOffset));
GenerateKeyedLoadReceiverCheck(
masm, receiver, a2, a3, Map::kHasIndexedInterceptor, &slow);
- // Check the "has fast elements" bit in the receiver's map which is
- // now in a2.
- __ lbu(a3, FieldMemOperand(a2, Map::kBitField2Offset));
- __ And(at, a3, Operand(1 << Map::kHasFastElements));
- __ Branch(&check_number_dictionary, eq, at, Operand(zero_reg));
+ // Check the receiver's map to see if it has fast elements.
+ __ CheckFastElements(a2, a3, &check_number_dictionary);
GenerateFastArrayLoad(
masm, receiver, key, t0, a3, a2, v0, NULL, &slow);
}
+void MacroAssembler::CheckFastElements(Register map,
+ Register scratch,
+ Label* fail) {
+ STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0);
+ lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset));
+ And(scratch, scratch, Operand(Map::kMaximumBitField2FastElementValue));
+ Branch(fail, hi, scratch, Operand(zero_reg));
+}
+
+
void MacroAssembler::CheckMap(Register obj,
Register scratch,
Handle<Map> map,
Register map,
Register type_reg);
+ // Check if a map for a JSObject indicates that the object has fast elements.
+ // Jump to the specified label if it does not.
+ void CheckFastElements(Register map,
+ Register scratch,
+ Label* fail);
+
// Check if the map of an object is equal to a specified map (either
// given directly or as an index into the root list) and branch to
// label if not. Skip the smi check if not required (object is known