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 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 // the temp registers, but not the input. Only input and temp2 may alias. | 1738 // the temp registers, but not the input. Only input and temp2 may alias. |
1739 void LCodeGen::EmitClassOfTest(Label* is_true, | 1739 void LCodeGen::EmitClassOfTest(Label* is_true, |
1740 Label* is_false, | 1740 Label* is_false, |
1741 Handle<String>class_name, | 1741 Handle<String>class_name, |
1742 Register input, | 1742 Register input, |
1743 Register temp, | 1743 Register temp, |
1744 Register temp2) { | 1744 Register temp2) { |
1745 ASSERT(!input.is(temp)); | 1745 ASSERT(!input.is(temp)); |
1746 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. | 1746 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. |
1747 __ JumpIfSmi(input, is_false); | 1747 __ JumpIfSmi(input, is_false); |
1748 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); | |
1749 __ j(below, is_false); | |
1750 | 1748 |
1751 // Map is now in temp. | |
1752 // Functions have class 'Function'. | |
1753 __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
1754 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1749 if (class_name->IsEqualTo(CStrVector("Function"))) { |
1755 __ j(above_equal, is_true); | 1750 // Assuming the following assertions, we can use the same compares to test |
| 1751 // for both being a function type and being in the object type range. |
| 1752 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 1753 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1754 FIRST_SPEC_OBJECT_TYPE + 1); |
| 1755 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1756 LAST_SPEC_OBJECT_TYPE - 1); |
| 1757 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 1758 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
| 1759 __ j(below, is_false); |
| 1760 __ j(equal, is_true); |
| 1761 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); |
| 1762 __ j(equal, is_true); |
1756 } else { | 1763 } else { |
1757 __ j(above_equal, is_false); | 1764 // Faster code path to avoid two compares: subtract lower bound from the |
| 1765 // actual type and do a signed compare with the width of the type range. |
| 1766 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset)); |
| 1767 __ mov(temp2, FieldOperand(temp, Map::kInstanceTypeOffset)); |
| 1768 __ sub(Operand(temp2), Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 1769 __ cmpb(Operand(temp2), |
| 1770 static_cast<int8_t>(LAST_NONCALLABLE_SPEC_OBJECT_TYPE - |
| 1771 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 1772 __ j(above, is_false); |
1758 } | 1773 } |
1759 | 1774 |
| 1775 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
1760 // Check if the constructor in the map is a function. | 1776 // Check if the constructor in the map is a function. |
1761 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); | 1777 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); |
1762 | |
1763 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and | |
1764 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | |
1765 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | |
1766 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | |
1767 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | |
1768 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | |
1769 | |
1770 // Objects with a non-function constructor have class 'Object'. | 1778 // Objects with a non-function constructor have class 'Object'. |
1771 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); | 1779 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
1772 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1780 if (class_name->IsEqualTo(CStrVector("Object"))) { |
1773 __ j(not_equal, is_true); | 1781 __ j(not_equal, is_true); |
1774 } else { | 1782 } else { |
1775 __ j(not_equal, is_false); | 1783 __ j(not_equal, is_false); |
1776 } | 1784 } |
1777 | 1785 |
1778 // temp now contains the constructor function. Grab the | 1786 // temp now contains the constructor function. Grab the |
1779 // instance class name from there. | 1787 // instance class name from there. |
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4181 __ cmp(input, factory()->undefined_value()); | 4189 __ cmp(input, factory()->undefined_value()); |
4182 __ j(equal, true_label); | 4190 __ j(equal, true_label); |
4183 __ JumpIfSmi(input, false_label); | 4191 __ JumpIfSmi(input, false_label); |
4184 // Check for undetectable objects => true. | 4192 // Check for undetectable objects => true. |
4185 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); | 4193 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); |
4186 __ test_b(FieldOperand(input, Map::kBitFieldOffset), | 4194 __ test_b(FieldOperand(input, Map::kBitFieldOffset), |
4187 1 << Map::kIsUndetectable); | 4195 1 << Map::kIsUndetectable); |
4188 final_branch_condition = not_zero; | 4196 final_branch_condition = not_zero; |
4189 | 4197 |
4190 } else if (type_name->Equals(heap()->function_symbol())) { | 4198 } else if (type_name->Equals(heap()->function_symbol())) { |
4191 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | 4199 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
4192 __ JumpIfSmi(input, false_label); | 4200 __ JumpIfSmi(input, false_label); |
4193 __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); | 4201 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
4194 final_branch_condition = above_equal; | 4202 __ j(equal, true_label); |
| 4203 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); |
| 4204 final_branch_condition = equal; |
4195 | 4205 |
4196 } else if (type_name->Equals(heap()->object_symbol())) { | 4206 } else if (type_name->Equals(heap()->object_symbol())) { |
4197 __ JumpIfSmi(input, false_label); | 4207 __ JumpIfSmi(input, false_label); |
4198 if (!FLAG_harmony_typeof) { | 4208 if (!FLAG_harmony_typeof) { |
4199 __ cmp(input, factory()->null_value()); | 4209 __ cmp(input, factory()->null_value()); |
4200 __ j(equal, true_label); | 4210 __ j(equal, true_label); |
4201 } | 4211 } |
4202 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); | 4212 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
4203 __ j(below, false_label); | 4213 __ j(below, false_label); |
4204 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4214 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4378 env->deoptimization_index()); | 4388 env->deoptimization_index()); |
4379 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4389 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
4380 } | 4390 } |
4381 | 4391 |
4382 | 4392 |
4383 #undef __ | 4393 #undef __ |
4384 | 4394 |
4385 } } // namespace v8::internal | 4395 } } // namespace v8::internal |
4386 | 4396 |
4387 #endif // V8_TARGET_ARCH_IA32 | 4397 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |