Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 03ea929d88ffb0fde58ccf6f718cd48997501e89..35afa2175e383ecbbc31d1e9b97588a8679755e3 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -1917,28 +1917,36 @@ void LCodeGen::EmitClassOfTest(Label* is_true, |
ASSERT(!input.is(temp)); |
ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
__ JumpIfSmi(input, is_false); |
- __ CompareObjectType(input, temp, temp2, FIRST_SPEC_OBJECT_TYPE); |
- __ b(lt, is_false); |
- // Map is now in temp. |
+ // Assuming the following assertions, we can do the same test for |
+ // either "Object" or "Function", only the branch conditions differ. |
+ STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
+ STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
+ FIRST_SPEC_OBJECT_TYPE + 1); |
+ STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
+ LAST_SPEC_OBJECT_TYPE - 1); |
+ STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
+ |
// Functions have class 'Function'. |
- __ CompareInstanceType(temp, temp2, FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
+ __ CompareObjectType(input, temp, temp2, FIRST_SPEC_OBJECT_TYPE); |
+ // Map is now in temp, type in temp2. |
+ if (class_name->IsEqualTo(CStrVector("Function"))) { |
+ __ b(lt, is_false); |
+ __ b(eq, is_true); |
+ } else { |
+ __ b(le, is_false); |
+ } |
+ __ cmp(temp2, Operand(LAST_SPEC_OBJECT_TYPE)); |
if (class_name->IsEqualTo(CStrVector("Function"))) { |
- __ b(ge, is_true); |
+ __ b(eq, is_true); |
} else { |
__ b(ge, is_false); |
} |
+ // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
// Check if the constructor in the map is a function. |
__ ldr(temp, FieldMemOperand(temp, Map::kConstructorOffset)); |
- // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type and |
- // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after |
- // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. |
- STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); |
- STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == |
- LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); |
- |
// Objects with a non-function constructor have class 'Object'. |
__ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE); |
if (class_name->IsEqualTo(CStrVector("Object"))) { |
@@ -4342,10 +4350,12 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label, |
final_branch_condition = ne; |
} else if (type_name->Equals(heap()->function_symbol())) { |
+ STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
__ JumpIfSmi(input, false_label); |
- __ CompareObjectType(input, input, scratch, |
- FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
- final_branch_condition = ge; |
+ __ CompareObjectType(input, scratch, input, JS_FUNCTION_TYPE); |
+ __ b(eq, true_label); |
+ __ cmp(input, Operand(JS_FUNCTION_PROXY_TYPE)); |
+ final_branch_condition = eq; |
} else if (type_name->Equals(heap()->object_symbol())) { |
__ JumpIfSmi(input, false_label); |