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 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 ASSERT(args->length() == 1); | 2720 ASSERT(args->length() == 1); |
2721 Label done, null, function, non_function_constructor; | 2721 Label done, null, function, non_function_constructor; |
2722 | 2722 |
2723 VisitForAccumulatorValue(args->at(0)); | 2723 VisitForAccumulatorValue(args->at(0)); |
2724 | 2724 |
2725 // If the object is a smi, we return null. | 2725 // If the object is a smi, we return null. |
2726 __ JumpIfSmi(eax, &null); | 2726 __ JumpIfSmi(eax, &null); |
2727 | 2727 |
2728 // Check that the object is a JS object but take special care of JS | 2728 // Check that the object is a JS object but take special care of JS |
2729 // functions to make sure they have 'Function' as their class. | 2729 // functions to make sure they have 'Function' as their class. |
| 2730 // Assume that there are only two callable types, and one of them is at |
| 2731 // either end of the type range for JS object types. Saves extra comparisons. |
| 2732 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
2730 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, eax); | 2733 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, eax); |
2731 // Map is now in eax. | 2734 // Map is now in eax. |
2732 __ j(below, &null); | 2735 __ j(below, &null); |
| 2736 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 2737 FIRST_SPEC_OBJECT_TYPE + 1); |
| 2738 __ j(equal, &function); |
2733 | 2739 |
2734 // As long as LAST_CALLABLE_SPEC_OBJECT_TYPE is the last instance type, and | 2740 __ CmpInstanceType(eax, LAST_SPEC_OBJECT_TYPE); |
2735 // FIRST_CALLABLE_SPEC_OBJECT_TYPE comes right after | 2741 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
2736 // LAST_NONCALLABLE_SPEC_OBJECT_TYPE, we can avoid checking for the latter. | 2742 LAST_SPEC_OBJECT_TYPE - 1); |
2737 STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE); | 2743 __ j(equal, &function); |
2738 STATIC_ASSERT(FIRST_CALLABLE_SPEC_OBJECT_TYPE == | 2744 // Assume that there is no larger type. |
2739 LAST_NONCALLABLE_SPEC_OBJECT_TYPE + 1); | 2745 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
2740 __ CmpInstanceType(eax, FIRST_CALLABLE_SPEC_OBJECT_TYPE); | |
2741 __ j(above_equal, &function); | |
2742 | 2746 |
2743 // Check if the constructor in the map is a function. | 2747 // Check if the constructor in the map is a JS function. |
2744 __ mov(eax, FieldOperand(eax, Map::kConstructorOffset)); | 2748 __ mov(eax, FieldOperand(eax, Map::kConstructorOffset)); |
2745 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 2749 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
2746 __ j(not_equal, &non_function_constructor); | 2750 __ j(not_equal, &non_function_constructor); |
2747 | 2751 |
2748 // eax now contains the constructor function. Grab the | 2752 // eax now contains the constructor function. Grab the |
2749 // instance class name from there. | 2753 // instance class name from there. |
2750 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); | 2754 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset)); |
2751 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); | 2755 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset)); |
2752 __ jmp(&done); | 2756 __ jmp(&done); |
2753 | 2757 |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4074 __ cmp(eax, isolate()->factory()->undefined_value()); | 4078 __ cmp(eax, isolate()->factory()->undefined_value()); |
4075 __ j(equal, if_true); | 4079 __ j(equal, if_true); |
4076 __ JumpIfSmi(eax, if_false); | 4080 __ JumpIfSmi(eax, if_false); |
4077 // Check for undetectable objects => true. | 4081 // Check for undetectable objects => true. |
4078 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 4082 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
4079 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); | 4083 __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset)); |
4080 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 4084 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); |
4081 Split(not_zero, if_true, if_false, fall_through); | 4085 Split(not_zero, if_true, if_false, fall_through); |
4082 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 4086 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
4083 __ JumpIfSmi(eax, if_false); | 4087 __ JumpIfSmi(eax, if_false); |
4084 __ CmpObjectType(eax, FIRST_CALLABLE_SPEC_OBJECT_TYPE, edx); | 4088 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
4085 Split(above_equal, if_true, if_false, fall_through); | 4089 __ CmpObjectType(eax, JS_FUNCTION_TYPE, edx); |
| 4090 __ j(equal, if_true); |
| 4091 __ CmpInstanceType(edx, JS_FUNCTION_PROXY_TYPE); |
| 4092 Split(equal, if_true, if_false, fall_through); |
4086 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 4093 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
4087 __ JumpIfSmi(eax, if_false); | 4094 __ JumpIfSmi(eax, if_false); |
4088 if (!FLAG_harmony_typeof) { | 4095 if (!FLAG_harmony_typeof) { |
4089 __ cmp(eax, isolate()->factory()->null_value()); | 4096 __ cmp(eax, isolate()->factory()->null_value()); |
4090 __ j(equal, if_true); | 4097 __ j(equal, if_true); |
4091 } | 4098 } |
4092 __ CmpObjectType(eax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, edx); | 4099 __ CmpObjectType(eax, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE, edx); |
4093 __ j(below, if_false); | 4100 __ j(below, if_false); |
4094 __ CmpInstanceType(edx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 4101 __ CmpInstanceType(edx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
4095 __ j(above, if_false); | 4102 __ j(above, if_false); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4331 __ add(Operand(edx), Immediate(masm_->CodeObject())); | 4338 __ add(Operand(edx), Immediate(masm_->CodeObject())); |
4332 __ jmp(Operand(edx)); | 4339 __ jmp(Operand(edx)); |
4333 } | 4340 } |
4334 | 4341 |
4335 | 4342 |
4336 #undef __ | 4343 #undef __ |
4337 | 4344 |
4338 } } // namespace v8::internal | 4345 } } // namespace v8::internal |
4339 | 4346 |
4340 #endif // V8_TARGET_ARCH_IA32 | 4347 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |