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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 | 1746 |
1747 | 1747 |
1748 // Branches to a label or falls through with the answer in the z flag. | 1748 // Branches to a label or falls through with the answer in the z flag. |
1749 // Trashes the temp register and possibly input (if it and temp are aliased). | 1749 // Trashes the temp register and possibly input (if it and temp are aliased). |
1750 void LCodeGen::EmitClassOfTest(Label* is_true, | 1750 void LCodeGen::EmitClassOfTest(Label* is_true, |
1751 Label* is_false, | 1751 Label* is_false, |
1752 Handle<String> class_name, | 1752 Handle<String> class_name, |
1753 Register input, | 1753 Register input, |
1754 Register temp) { | 1754 Register temp) { |
1755 __ JumpIfSmi(input, is_false); | 1755 __ JumpIfSmi(input, is_false); |
| 1756 |
| 1757 // Assuming the following assertions, we can do the same test for |
| 1758 // either "Object" or "Function", only the branch conditions differ. |
| 1759 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 1760 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1761 FIRST_SPEC_OBJECT_TYPE + 1); |
| 1762 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 1763 LAST_SPEC_OBJECT_TYPE - 1); |
| 1764 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 1765 |
| 1766 // Functions have class 'Function'. |
1756 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); | 1767 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
1757 __ j(below, is_false); | |
1758 | |
1759 // Map is now in temp. | 1768 // Map is now in temp. |
1760 // Functions have class 'Function'. | |
1761 __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
1762 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1769 if (class_name->IsEqualTo(CStrVector("Function"))) { |
1763 __ j(above_equal, is_true); | 1770 __ j(below, is_false); |
| 1771 __ j(equal, is_true); |
| 1772 } else { |
| 1773 __ j(below_equal, is_false); |
| 1774 } |
| 1775 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); |
| 1776 if (class_name->IsEqualTo(CStrVector("Function"))) { |
| 1777 __ j(equal, is_true); |
1764 } else { | 1778 } else { |
1765 __ j(above_equal, is_false); | 1779 __ j(above_equal, is_false); |
1766 } | 1780 } |
1767 | 1781 |
| 1782 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. |
1768 // Check if the constructor in the map is a function. | 1783 // Check if the constructor in the map is a function. |
1769 __ movq(temp, FieldOperand(temp, Map::kConstructorOffset)); | 1784 __ movq(temp, FieldOperand(temp, Map::kConstructorOffset)); |
1770 | 1785 |
1771 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last type and | |
1772 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | |
1773 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | |
1774 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | |
1775 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | |
1776 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | |
1777 | |
1778 // Objects with a non-function constructor have class 'Object'. | 1786 // Objects with a non-function constructor have class 'Object'. |
1779 __ CmpObjectType(temp, JS_FUNCTION_TYPE, kScratchRegister); | 1787 __ CmpObjectType(temp, JS_FUNCTION_TYPE, kScratchRegister); |
1780 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1788 if (class_name->IsEqualTo(CStrVector("Object"))) { |
1781 __ j(not_equal, is_true); | 1789 __ j(not_equal, is_true); |
1782 } else { | 1790 } else { |
1783 __ j(not_equal, is_false); | 1791 __ j(not_equal, is_false); |
1784 } | 1792 } |
1785 | 1793 |
1786 // temp now contains the constructor function. Grab the | 1794 // temp now contains the constructor function. Grab the |
1787 // instance class name from there. | 1795 // instance class name from there. |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3973 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); | 3981 __ CompareRoot(input, Heap::kUndefinedValueRootIndex); |
3974 __ j(equal, true_label); | 3982 __ j(equal, true_label); |
3975 __ JumpIfSmi(input, false_label); | 3983 __ JumpIfSmi(input, false_label); |
3976 // Check for undetectable objects => true. | 3984 // Check for undetectable objects => true. |
3977 __ movq(input, FieldOperand(input, HeapObject::kMapOffset)); | 3985 __ movq(input, FieldOperand(input, HeapObject::kMapOffset)); |
3978 __ testb(FieldOperand(input, Map::kBitFieldOffset), | 3986 __ testb(FieldOperand(input, Map::kBitFieldOffset), |
3979 Immediate(1 << Map::kIsUndetectable)); | 3987 Immediate(1 << Map::kIsUndetectable)); |
3980 final_branch_condition = not_zero; | 3988 final_branch_condition = not_zero; |
3981 | 3989 |
3982 } else if (type_name->Equals(heap()->function_symbol())) { | 3990 } else if (type_name->Equals(heap()->function_symbol())) { |
| 3991 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
3983 __ JumpIfSmi(input, false_label); | 3992 __ JumpIfSmi(input, false_label); |
3984 __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); | 3993 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
3985 final_branch_condition = above_equal; | 3994 __ j(equal, true_label); |
| 3995 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); |
| 3996 final_branch_condition = equal; |
3986 | 3997 |
3987 } else if (type_name->Equals(heap()->object_symbol())) { | 3998 } else if (type_name->Equals(heap()->object_symbol())) { |
3988 __ JumpIfSmi(input, false_label); | 3999 __ JumpIfSmi(input, false_label); |
3989 if (!FLAG_harmony_typeof) { | 4000 if (!FLAG_harmony_typeof) { |
3990 __ CompareRoot(input, Heap::kNullValueRootIndex); | 4001 __ CompareRoot(input, Heap::kNullValueRootIndex); |
3991 __ j(equal, true_label); | 4002 __ j(equal, true_label); |
3992 } | 4003 } |
3993 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); | 4004 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
3994 __ j(below, false_label); | 4005 __ j(below, false_label); |
3995 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4006 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 RegisterEnvironmentForDeoptimization(environment); | 4158 RegisterEnvironmentForDeoptimization(environment); |
4148 ASSERT(osr_pc_offset_ == -1); | 4159 ASSERT(osr_pc_offset_ == -1); |
4149 osr_pc_offset_ = masm()->pc_offset(); | 4160 osr_pc_offset_ = masm()->pc_offset(); |
4150 } | 4161 } |
4151 | 4162 |
4152 #undef __ | 4163 #undef __ |
4153 | 4164 |
4154 } } // namespace v8::internal | 4165 } } // namespace v8::internal |
4155 | 4166 |
4156 #endif // V8_TARGET_ARCH_X64 | 4167 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |