Chromium Code Reviews| 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 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); | 1747 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp); |
| 1748 __ j(below, is_false); | 1748 __ j(below, is_false); |
| 1749 ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | |
|
Kevin Millikin (Chromium)
2011/09/07 10:13:12
STATIC_ASSERT?
rossberg
2011/09/07 14:57:31
Done.
| |
| 1750 | |
| 1751 // Assuming the following assertions, we can do the same test for | |
| 1752 // either "Object" or "Function", only the branch conditions differ. | |
| 1753 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | |
| 1754 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 1755 FIRST_SPEC_OBJECT_TYPE + 1); | |
| 1756 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == | |
| 1757 LAST_SPEC_OBJECT_TYPE - 1); | |
| 1749 | 1758 |
| 1750 // Map is now in temp. | 1759 // Map is now in temp. |
| 1751 // Functions have class 'Function'. | 1760 // Functions have class 'Function'. |
| 1752 __ CmpInstanceType(temp, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | 1761 __ CmpInstanceType(temp, FIRST_SPEC_OBJECT_TYPE); |
|
Kevin Millikin (Chromium)
2011/09/07 10:13:12
Same comment about restructuring this code a bit a
rossberg
2011/09/07 14:57:31
Done. (And also on x64.)
| |
| 1753 if (class_name->IsEqualTo(CStrVector("Function"))) { | 1762 if (class_name->IsEqualTo(CStrVector("Function"))) { |
| 1754 __ j(above_equal, is_true); | 1763 __ j(equal, is_true); |
| 1764 } else { | |
| 1765 __ j(below_equal, is_false); | |
| 1766 } | |
| 1767 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE); | |
| 1768 if (class_name->IsEqualTo(CStrVector("Function"))) { | |
| 1769 __ j(equal, is_true); | |
| 1755 } else { | 1770 } else { |
| 1756 __ j(above_equal, is_false); | 1771 __ j(above_equal, is_false); |
| 1757 } | 1772 } |
| 1758 | 1773 |
| 1774 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. | |
| 1759 // Check if the constructor in the map is a function. | 1775 // Check if the constructor in the map is a function. |
| 1760 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); | 1776 __ 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'. | 1777 // Objects with a non-function constructor have class 'Object'. |
| 1770 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); | 1778 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); |
| 1771 if (class_name->IsEqualTo(CStrVector("Object"))) { | 1779 if (class_name->IsEqualTo(CStrVector("Object"))) { |
| 1772 __ j(not_equal, is_true); | 1780 __ j(not_equal, is_true); |
| 1773 } else { | 1781 } else { |
| 1774 __ j(not_equal, is_false); | 1782 __ j(not_equal, is_false); |
| 1775 } | 1783 } |
| 1776 | 1784 |
| 1777 // temp now contains the constructor function. Grab the | 1785 // temp now contains the constructor function. Grab the |
| 1778 // instance class name from there. | 1786 // instance class name from there. |
| (...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4180 __ cmp(input, factory()->undefined_value()); | 4188 __ cmp(input, factory()->undefined_value()); |
| 4181 __ j(equal, true_label); | 4189 __ j(equal, true_label); |
| 4182 __ JumpIfSmi(input, false_label); | 4190 __ JumpIfSmi(input, false_label); |
| 4183 // Check for undetectable objects => true. | 4191 // Check for undetectable objects => true. |
| 4184 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); | 4192 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); |
| 4185 __ test_b(FieldOperand(input, Map::kBitFieldOffset), | 4193 __ test_b(FieldOperand(input, Map::kBitFieldOffset), |
| 4186 1 << Map::kIsUndetectable); | 4194 1 << Map::kIsUndetectable); |
| 4187 final_branch_condition = not_zero; | 4195 final_branch_condition = not_zero; |
| 4188 | 4196 |
| 4189 } else if (type_name->Equals(heap()->function_symbol())) { | 4197 } else if (type_name->Equals(heap()->function_symbol())) { |
| 4190 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | 4198 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 4191 __ JumpIfSmi(input, false_label); | 4199 __ JumpIfSmi(input, false_label); |
| 4192 __ CmpObjectType(input, FIRST_CALLABLE_SPEC_OBJECT_TYPE, input); | 4200 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); |
| 4193 final_branch_condition = above_equal; | 4201 __ j(equal, true_label); |
| 4202 __ CmpInstanceType(input, JS_FUNCTION_PROXY_TYPE); | |
| 4203 final_branch_condition = equal; | |
| 4194 | 4204 |
| 4195 } else if (type_name->Equals(heap()->object_symbol())) { | 4205 } else if (type_name->Equals(heap()->object_symbol())) { |
| 4196 __ JumpIfSmi(input, false_label); | 4206 __ JumpIfSmi(input, false_label); |
| 4197 if (!FLAG_harmony_typeof) { | 4207 if (!FLAG_harmony_typeof) { |
| 4198 __ cmp(input, factory()->null_value()); | 4208 __ cmp(input, factory()->null_value()); |
| 4199 __ j(equal, true_label); | 4209 __ j(equal, true_label); |
| 4200 } | 4210 } |
| 4201 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); | 4211 __ CmpObjectType(input, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, input); |
| 4202 __ j(below, false_label); | 4212 __ j(below, false_label); |
| 4203 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4213 __ CmpInstanceType(input, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4377 env->deoptimization_index()); | 4387 env->deoptimization_index()); |
| 4378 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4388 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
| 4379 } | 4389 } |
| 4380 | 4390 |
| 4381 | 4391 |
| 4382 #undef __ | 4392 #undef __ |
| 4383 | 4393 |
| 4384 } } // namespace v8::internal | 4394 } } // namespace v8::internal |
| 4385 | 4395 |
| 4386 #endif // V8_TARGET_ARCH_IA32 | 4396 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |