STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1);
// Check if the constructor in the map is a JS function.
- __ lw(v0, FieldMemOperand(v0, Map::kConstructorOffset));
- __ GetObjectType(v0, a1, a1);
- __ Branch(&non_function_constructor, ne, a1, Operand(JS_FUNCTION_TYPE));
+ Register instance_type = a2;
+ __ GetMapConstructor(v0, v0, a1, instance_type);
+ __ Branch(&non_function_constructor, ne, instance_type,
+ Operand(JS_FUNCTION_TYPE));
// v0 now contains the constructor function. Grab the
// instance class name from there.
// Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range.
// Check if the constructor in the map is a function.
- __ lw(temp, FieldMemOperand(temp, Map::kConstructorOffset));
+ Register instance_type = scratch1();
+ DCHECK(!instance_type.is(temp));
+ DCHECK(!instance_type.is(temp2));
+ __ GetMapConstructor(temp, temp, temp2, instance_type);
// Objects with a non-function constructor have class 'Object'.
- __ GetObjectType(temp, temp2, temp2);
if (String::Equals(class_name, isolate()->factory()->Object_string())) {
- __ Branch(is_true, ne, temp2, Operand(JS_FUNCTION_TYPE));
+ __ Branch(is_true, ne, instance_type, Operand(JS_FUNCTION_TYPE));
} else {
- __ Branch(is_false, ne, temp2, Operand(JS_FUNCTION_TYPE));
+ __ Branch(is_false, ne, instance_type, Operand(JS_FUNCTION_TYPE));
}
// temp now contains the constructor function. Grab the
// Support functions.
+void MacroAssembler::GetMapConstructor(Register result, Register map,
+ Register temp, Register temp2) {
+ Label done, loop;
+ lw(result, FieldMemOperand(map, Map::kConstructorOrBackPointerOffset));
+ bind(&loop);
+ JumpIfSmi(result, &done);
+ GetObjectType(result, temp, temp2);
+ Branch(&done, ne, temp2, Operand(MAP_TYPE));
+ lw(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset));
+ Branch(&loop);
+ bind(&done);
+}
+
+
void MacroAssembler::TryGetFunctionPrototype(Register function,
Register result,
Register scratch,
// Non-instance prototype: Fetch prototype from constructor field
// in initial map.
bind(&non_instance);
- lw(result, FieldMemOperand(result, Map::kConstructorOffset));
+ GetMapConstructor(result, result, scratch, at);
}
// All done.
// -------------------------------------------------------------------------
// Support functions.
+ // Machine code version of Map::GetConstructor().
+ // |temp| holds |result|'s map when done, and |temp2| its instance type.
+ void GetMapConstructor(Register result, Register map, Register temp,
+ Register temp2);
+
// Try to get function prototype of a function and puts the value in
// the result register. Checks that the function really is a
// function and jumps to the miss label if the fast checks fail. The
STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1);
// Check if the constructor in the map is a JS function.
- __ ld(v0, FieldMemOperand(v0, Map::kConstructorOffset));
- __ GetObjectType(v0, a1, a1);
- __ Branch(&non_function_constructor, ne, a1, Operand(JS_FUNCTION_TYPE));
+ Register instance_type = a2;
+ __ GetMapConstructor(v0, v0, a1, instance_type);
+ __ Branch(&non_function_constructor, ne, instance_type,
+ Operand(JS_FUNCTION_TYPE));
// v0 now contains the constructor function. Grab the
// instance class name from there.
// Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range.
// Check if the constructor in the map is a function.
- __ ld(temp, FieldMemOperand(temp, Map::kConstructorOffset));
+ Register instance_type = scratch1();
+ DCHECK(!instance_type.is(temp));
+ DCHECK(!instance_type.is(temp2));
+ __ GetMapConstructor(temp, temp, temp2, instance_type);
// Objects with a non-function constructor have class 'Object'.
- __ GetObjectType(temp, temp2, temp2);
if (String::Equals(class_name, isolate()->factory()->Object_string())) {
- __ Branch(is_true, ne, temp2, Operand(JS_FUNCTION_TYPE));
+ __ Branch(is_true, ne, instance_type, Operand(JS_FUNCTION_TYPE));
} else {
- __ Branch(is_false, ne, temp2, Operand(JS_FUNCTION_TYPE));
+ __ Branch(is_false, ne, instance_type, Operand(JS_FUNCTION_TYPE));
}
// temp now contains the constructor function. Grab the
// Support functions.
+void MacroAssembler::GetMapConstructor(Register result, Register map,
+ Register temp, Register temp2) {
+ Label done, loop;
+ ld(result, FieldMemOperand(map, Map::kConstructorOrBackPointerOffset));
+ bind(&loop);
+ JumpIfSmi(result, &done);
+ GetObjectType(result, temp, temp2);
+ Branch(&done, ne, temp2, Operand(MAP_TYPE));
+ ld(result, FieldMemOperand(result, Map::kConstructorOrBackPointerOffset));
+ Branch(&loop);
+ bind(&done);
+}
+
+
void MacroAssembler::TryGetFunctionPrototype(Register function,
Register result,
Register scratch,
// Non-instance prototype: Fetch prototype from constructor field
// in initial map.
bind(&non_instance);
- ld(result, FieldMemOperand(result, Map::kConstructorOffset));
+ GetMapConstructor(result, result, scratch, at);
}
// All done.
// -------------------------------------------------------------------------
// Support functions.
+ // Machine code version of Map::GetConstructor().
+ // |temp| holds |result|'s map when done, and |temp2| its instance type.
+ void GetMapConstructor(Register result, Register map, Register temp,
+ Register temp2);
+
// Try to get function prototype of a function and puts the value in
// the result register. Checks that the function really is a
// function and jumps to the miss label if the fast checks fail. The