OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1737 // the temp registers, but not the input. Only input and temp2 may alias. | 1737 // the temp registers, but not the input. Only input and temp2 may alias. |
1738 void LCodeGen::EmitClassOfTest(Label* is_true, | 1738 void LCodeGen::EmitClassOfTest(Label* is_true, |
1739 Label* is_false, | 1739 Label* is_false, |
1740 Handle<String>class_name, | 1740 Handle<String>class_name, |
1741 Register input, | 1741 Register input, |
1742 Register temp, | 1742 Register temp, |
1743 Register temp2) { | 1743 Register temp2) { |
1744 ASSERT(!input.is(temp)); | 1744 ASSERT(!input.is(temp)); |
1745 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. | 1745 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
1746 __ JumpIfSmi(input, is_false); | 1746 __ JumpIfSmi(input, is_false); |
1747 | |
1748 // Assuming the following assertions, we can do the same test for | |
1749 // 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.
| |
1750 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
1751 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
1752 FIRST_SPEC_OBJECT_TYPE + 1); | |
1753 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
1754 LAST_SPEC_OBJECT_TYPE - 1); | |
1755 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | |
1756 | |
1757 // Functions have class 'Function'. | |
1747 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); | 1758 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
1748 __ j(below, is_false); | |
1749 | |
1750 // Map is now in temp. | 1759 // Map is now in temp. |
1751 // Functions have class 'Function'. | |
1752 __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
1753 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1760 if (class_name->IsEqualTo(CStrVector("Function"))) { |
1754 __ j(above_equal, is_true); | 1761 __ j(below, is_false); |
1762 __ j(equal, is_true); | |
1763 } else { | |
1764 __ j(below_equal, is_false); | |
1765 } | |
1766 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); | |
1767 if (class_name->IsEqualTo(CStrVector("Function"))) { | |
1768 __ j(equal, is_true); | |
1755 } else { | 1769 } else { |
1756 __ j(above_equal, is_false); | 1770 __ j(above_equal, is_false); |
1757 } | 1771 } |
1758 | 1772 |
1773 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. | |
1759 // Check if the constructor in the map is a function. | 1774 // Check if the constructor in the map is a function. |
1760 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); | 1775 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); |
1761 | |
1762 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and | |
1763 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | |
1764 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | |
1765 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | |
1766 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | |
1767 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | |
1768 | |
1769 // Objects with a non-function constructor have class 'Object'. | 1776 // Objects with a non-function constructor have class 'Object'. |
1770 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); | 1777 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
1771 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1778 if (class_name->IsEqualTo(CStrVector("Object"))) { |
1772 __ j(not_equal, is_true); | 1779 __ j(not_equal, is_true); |
1773 } else { | 1780 } else { |
1774 __ j(not_equal, is_false); | 1781 __ j(not_equal, is_false); |
1775 } | 1782 } |
1776 | 1783 |
1777 // temp now contains the constructor function. Grab the | 1784 // temp now contains the constructor function. Grab the |
1778 // instance class name from there. | 1785 // instance class name from there. |
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4180 __ cmp(input, factory()->undefined_value()); | 4187 __ cmp(input, factory()->undefined_value()); |
4181 __ j(equal, true_label); | 4188 __ j(equal, true_label); |
4182 __ JumpIfSmi(input, false_label); | 4189 __ JumpIfSmi(input, false_label); |
4183 // Check for undetectable objects => true. | 4190 // Check for undetectable objects => true. |
4184 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); | 4191 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); |
4185 __ test_b(FieldOperand(input, Map::kBitFieldOffset), | 4192 __ test_b(FieldOperand(input, Map::kBitFieldOffset), |
4186 1 << Map::kIsUndetectable); | 4193 1 << Map::kIsUndetectable); |
4187 final_branch_condition = not_zero; | 4194 final_branch_condition = not_zero; |
4188 | 4195 |
4189 } else if (type_name->Equals(heap()->function_symbol())) { | 4196 } else if (type_name->Equals(heap()->function_symbol())) { |
4190 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | 4197 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
4191 __ JumpIfSmi(input, false_label); | 4198 __ JumpIfSmi(input, false_label); |
4192 __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); | 4199 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
4193 final_branch_condition = above_equal; | 4200 __ j(equal, true_label); |
4201 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); | |
4202 final_branch_condition = equal; | |
4194 | 4203 |
4195 } else if (type_name->Equals(heap()->object_symbol())) { | 4204 } else if (type_name->Equals(heap()->object_symbol())) { |
4196 __ JumpIfSmi(input, false_label); | 4205 __ JumpIfSmi(input, false_label); |
4197 if (!FLAG_harmony_typeof) { | 4206 if (!FLAG_harmony_typeof) { |
4198 __ cmp(input, factory()->null_value()); | 4207 __ cmp(input, factory()->null_value()); |
4199 __ j(equal, true_label); | 4208 __ j(equal, true_label); |
4200 } | 4209 } |
4201 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); | 4210 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
4202 __ j(below, false_label); | 4211 __ j(below, false_label); |
4203 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4212 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4377 env->deoptimization_index()); | 4386 env->deoptimization_index()); |
4378 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4387 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4379 } | 4388 } |
4380 | 4389 |
4381 | 4390 |
4382 #undef __ | 4391 #undef __ |
4383 | 4392 |
4384 } } // namespace v8::internal | 4393 } } // namespace v8::internal |
4385 | 4394 |
4386 #endif // V8_TARGET_ARCH_IA32 | 4395 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |