Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 8b3cb47b4a525b936cd51d41853bfd3a163b1786..1ea22703b219c8f74b095c2662093c4ae63fa5f0 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -1744,28 +1744,35 @@ 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); |
- __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
- __ j(below, 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. |
Erik Corry
2011/09/15 09:13:46
The test for Object involves two comparisons and t
rossberg
2011/09/15 14:06:07
Done, here and in other backends.
|
+ 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'. |
- __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); |
+ __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
+ // Map is now in temp. |
+ if (class_name->IsEqualTo(CStrVector("Function"))) { |
+ __ j(below, is_false); |
+ __ j(equal, is_true); |
+ } else { |
+ __ j(below_equal, is_false); |
+ } |
+ __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); |
if (class_name->IsEqualTo(CStrVector("Function"))) { |
- __ j(above_equal, is_true); |
+ __ j(equal, is_true); |
} else { |
__ j(above_equal, is_false); |
} |
+ // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
// Check if the constructor in the map is a function. |
__ mov(temp, FieldOperand(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'. |
__ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
if (class_name->IsEqualTo(CStrVector("Object"))) { |
@@ -4187,10 +4194,12 @@ Condition LCodeGen::EmitTypeofIs(Label* true_label, |
final_branch_condition = not_zero; |
} else if (type_name->Equals(heap()->function_symbol())) { |
- STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); |
+ STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
__ JumpIfSmi(input, false_label); |
- __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); |
- final_branch_condition = above_equal; |
+ __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
+ __ j(equal, true_label); |
+ __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); |
+ final_branch_condition = equal; |
} else if (type_name->Equals(heap()->object_symbol())) { |
__ JumpIfSmi(input, false_label); |