Index: src/full-codegen/arm/full-codegen-arm.cc |
diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc |
index ad3be4c92d6aa06ad74d61ca6311601304622923..bd361080bdb30b06a07071a8585d70924c564875 100644 |
--- a/src/full-codegen/arm/full-codegen-arm.cc |
+++ b/src/full-codegen/arm/full-codegen-arm.cc |
@@ -3676,7 +3676,7 @@ |
void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { |
ZoneList<Expression*>* args = expr->arguments(); |
- DCHECK_EQ(1, args->length()); |
+ DCHECK(args->length() == 1); |
Label done, null, function, non_function_constructor; |
VisitForAccumulatorValue(args->at(0)); |
@@ -3684,17 +3684,24 @@ |
// If the object is a smi, we return null. |
__ JumpIfSmi(r0, &null); |
- // If the object is not a receiver, we return null. |
- STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
- __ CompareObjectType(r0, r0, r1, FIRST_JS_RECEIVER_TYPE); |
+ // Check that the object is a JS object but take special care of JS |
+ // functions to make sure they have 'Function' as their class. |
+ // Assume that there are only two callable types, and one of them is at |
+ // either end of the type range for JS object types. Saves extra comparisons. |
+ STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
+ __ CompareObjectType(r0, r0, r1, FIRST_SPEC_OBJECT_TYPE); |
+ // Map is now in r0. |
__ b(lt, &null); |
- |
- // According to ES5 section 15 Standard Built-in ECMAScript Objects, the |
- // [[Class]] of builtin objects is "Function" if a [[Call]] internal |
- // method is present. |
- __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
- __ tst(r1, Operand(1 << Map::kIsCallable)); |
- __ b(ne, &function); |
+ STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
+ FIRST_SPEC_OBJECT_TYPE + 1); |
+ __ b(eq, &function); |
+ |
+ __ cmp(r1, Operand(LAST_SPEC_OBJECT_TYPE)); |
+ STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
+ LAST_SPEC_OBJECT_TYPE - 1); |
+ __ b(eq, &function); |
+ // Assume that there is no larger type. |
+ STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
// Check if the constructor in the map is a JS function. |
Register instance_type = r2; |