| 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 2527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 ASSERT(args->length() == 1); | 2538 ASSERT(args->length() == 1); |
| 2539 Label done, null, function, non_function_constructor; | 2539 Label done, null, function, non_function_constructor; |
| 2540 | 2540 |
| 2541 VisitForAccumulatorValue(args->at(0)); | 2541 VisitForAccumulatorValue(args->at(0)); |
| 2542 | 2542 |
| 2543 // If the object is a smi, we return null. | 2543 // If the object is a smi, we return null. |
| 2544 __ JumpIfSmi(rax, &null); | 2544 __ JumpIfSmi(rax, &null); |
| 2545 | 2545 |
| 2546 // Check that the object is a JS object but take special care of JS | 2546 // Check that the object is a JS object but take special care of JS |
| 2547 // functions to make sure they have 'Function' as their class. | 2547 // functions to make sure they have 'Function' as their class. |
| 2548 // Assume that there are only two callable types, and one of them is at |
| 2549 // either end of the type range for JS object types. Saves extra comparisons. |
| 2550 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 2548 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax); | 2551 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax); |
| 2549 // Map is now in rax. | 2552 // Map is now in rax. |
| 2550 __ j(below, &null); | 2553 __ j(below, &null); |
| 2554 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2555 FIRST_SPEC_OBJECT_TYPE + 1); |
| 2556 __ j(equal, &function); |
| 2551 | 2557 |
| 2552 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and | 2558 __ CmpInstanceType(rax, LAST_SPEC_OBJECT_TYPE); |
| 2553 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | 2559 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2554 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | 2560 LAST_SPEC_OBJECT_TYPE - 1); |
| 2555 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | 2561 __ j(equal, &function); |
| 2556 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | 2562 // Assume that there is no larger type. |
| 2557 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | 2563 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
| 2558 __ CmpInstanceType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
| 2559 __ j(above_equal, &function); | |
| 2560 | 2564 |
| 2561 // Check if the constructor in the map is a function. | 2565 // Check if the constructor in the map is a JS function. |
| 2562 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset)); | 2566 __ movq(rax, FieldOperand(rax, Map::kConstructorOffset)); |
| 2563 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); | 2567 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); |
| 2564 __ j(not_equal, &non_function_constructor); | 2568 __ j(not_equal, &non_function_constructor); |
| 2565 | 2569 |
| 2566 // rax now contains the constructor function. Grab the | 2570 // rax now contains the constructor function. Grab the |
| 2567 // instance class name from there. | 2571 // instance class name from there. |
| 2568 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); | 2572 __ movq(rax, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); |
| 2569 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset)); | 2573 __ movq(rax, FieldOperand(rax, SharedFunctionInfo::kInstanceClassNameOffset)); |
| 2570 __ jmp(&done); | 2574 __ jmp(&done); |
| 2571 | 2575 |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3868 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 3872 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 3869 __ j(equal, if_true); | 3873 __ j(equal, if_true); |
| 3870 __ JumpIfSmi(rax, if_false); | 3874 __ JumpIfSmi(rax, if_false); |
| 3871 // Check for undetectable objects => true. | 3875 // Check for undetectable objects => true. |
| 3872 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 3876 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 3873 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), | 3877 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), |
| 3874 Immediate(1 << Map::kIsUndetectable)); | 3878 Immediate(1 << Map::kIsUndetectable)); |
| 3875 Split(not_zero, if_true, if_false, fall_through); | 3879 Split(not_zero, if_true, if_false, fall_through); |
| 3876 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 3880 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 3877 __ JumpIfSmi(rax, if_false); | 3881 __ JumpIfSmi(rax, if_false); |
| 3878 STATIC_ASSERT(LAST_CALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE); | 3882 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 3879 __ CmpObjectType(rax, FIRST_CALLABLE_SPEC_OBJECT_TYPE, rdx); | 3883 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rdx); |
| 3880 Split(above_equal, if_true, if_false, fall_through); | 3884 __ j(equal, if_true); |
| 3885 __ CmpInstanceType(rdx, JS_FUNCTION_PROXY_TYPE); |
| 3886 Split(equal, if_true, if_false, fall_through); |
| 3881 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 3887 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 3882 __ JumpIfSmi(rax, if_false); | 3888 __ JumpIfSmi(rax, if_false); |
| 3883 if (!FLAG_harmony_typeof) { | 3889 if (!FLAG_harmony_typeof) { |
| 3884 __ CompareRoot(rax, Heap::kNullValueRootIndex); | 3890 __ CompareRoot(rax, Heap::kNullValueRootIndex); |
| 3885 __ j(equal, if_true); | 3891 __ j(equal, if_true); |
| 3886 } | 3892 } |
| 3887 __ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx); | 3893 __ CmpObjectType(rax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, rdx); |
| 3888 __ j(below, if_false); | 3894 __ j(below, if_false); |
| 3889 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 3895 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 3890 __ j(above, if_false); | 3896 __ j(above, if_false); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4151 *context_length = 0; | 4157 *context_length = 0; |
| 4152 return previous_; | 4158 return previous_; |
| 4153 } | 4159 } |
| 4154 | 4160 |
| 4155 | 4161 |
| 4156 #undef __ | 4162 #undef __ |
| 4157 | 4163 |
| 4158 } } // namespace v8::internal | 4164 } } // namespace v8::internal |
| 4159 | 4165 |
| 4160 #endif // V8_TARGET_ARCH_X64 | 4166 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |