| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // We don't use CmpObjectType because we manipulate the type field. | 261 // We don't use CmpObjectType because we manipulate the type field. |
| 262 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); | 262 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 263 __ movzxbq(rcx, FieldOperand(rdx, Map::kInstanceTypeOffset)); | 263 __ movzxbq(rcx, FieldOperand(rdx, Map::kInstanceTypeOffset)); |
| 264 | 264 |
| 265 // Undetectable => false. | 265 // Undetectable => false. |
| 266 __ movzxbq(rbx, FieldOperand(rdx, Map::kBitFieldOffset)); | 266 __ movzxbq(rbx, FieldOperand(rdx, Map::kBitFieldOffset)); |
| 267 __ and_(rbx, Immediate(1 << Map::kIsUndetectable)); | 267 __ and_(rbx, Immediate(1 << Map::kIsUndetectable)); |
| 268 __ j(not_zero, &false_result, Label::kNear); | 268 __ j(not_zero, &false_result, Label::kNear); |
| 269 | 269 |
| 270 // JavaScript object => true. | 270 // JavaScript object => true. |
| 271 __ cmpq(rcx, Immediate(FIRST_JS_OBJECT_TYPE)); | 271 __ cmpq(rcx, Immediate(FIRST_SPEC_OBJECT_TYPE)); |
| 272 __ j(above_equal, &true_result, Label::kNear); | 272 __ j(above_equal, &true_result, Label::kNear); |
| 273 | 273 |
| 274 // String value => false iff empty. | 274 // String value => false iff empty. |
| 275 __ cmpq(rcx, Immediate(FIRST_NONSTRING_TYPE)); | 275 __ cmpq(rcx, Immediate(FIRST_NONSTRING_TYPE)); |
| 276 __ j(above_equal, ¬_string, Label::kNear); | 276 __ j(above_equal, ¬_string, Label::kNear); |
| 277 __ movq(rdx, FieldOperand(rax, String::kLengthOffset)); | 277 __ movq(rdx, FieldOperand(rax, String::kLengthOffset)); |
| 278 __ SmiTest(rdx); | 278 __ SmiTest(rdx); |
| 279 __ j(zero, &false_result, Label::kNear); | 279 __ j(zero, &false_result, Label::kNear); |
| 280 __ jmp(&true_result, Label::kNear); | 280 __ jmp(&true_result, Label::kNear); |
| 281 | 281 |
| (...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 if (never_nan_nan_ && (cc_ == equal)) { | 2710 if (never_nan_nan_ && (cc_ == equal)) { |
| 2711 __ Set(rax, EQUAL); | 2711 __ Set(rax, EQUAL); |
| 2712 __ ret(0); | 2712 __ ret(0); |
| 2713 } else { | 2713 } else { |
| 2714 Label heap_number; | 2714 Label heap_number; |
| 2715 // If it's not a heap number, then return equal for (in)equality operator. | 2715 // If it's not a heap number, then return equal for (in)equality operator. |
| 2716 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), | 2716 __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), |
| 2717 factory->heap_number_map()); | 2717 factory->heap_number_map()); |
| 2718 __ j(equal, &heap_number, Label::kNear); | 2718 __ j(equal, &heap_number, Label::kNear); |
| 2719 if (cc_ != equal) { | 2719 if (cc_ != equal) { |
| 2720 // Call runtime on identical JSObjects. Otherwise return equal. | 2720 // Call runtime on identical objects. Otherwise return equal. |
| 2721 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); | 2721 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); |
| 2722 __ j(above_equal, ¬_identical, Label::kNear); | 2722 __ j(above_equal, ¬_identical, Label::kNear); |
| 2723 } | 2723 } |
| 2724 __ Set(rax, EQUAL); | 2724 __ Set(rax, EQUAL); |
| 2725 __ ret(0); | 2725 __ ret(0); |
| 2726 | 2726 |
| 2727 __ bind(&heap_number); | 2727 __ bind(&heap_number); |
| 2728 // It is a heap number, so return equal if it's not NaN. | 2728 // It is a heap number, so return equal if it's not NaN. |
| 2729 // For NaN, return 1 for every condition except greater and | 2729 // For NaN, return 1 for every condition except greater and |
| 2730 // greater-equal. Return -1 for them, so the comparison yields | 2730 // greater-equal. Return -1 for them, so the comparison yields |
| 2731 // false for all conditions except not-equal. | 2731 // false for all conditions except not-equal. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2767 __ ret(0); | 2767 __ ret(0); |
| 2768 | 2768 |
| 2769 __ bind(¬_smis); | 2769 __ bind(¬_smis); |
| 2770 } | 2770 } |
| 2771 | 2771 |
| 2772 // If either operand is a JSObject or an oddball value, then they are not | 2772 // If either operand is a JSObject or an oddball value, then they are not |
| 2773 // equal since their pointers are different | 2773 // equal since their pointers are different |
| 2774 // There is no test for undetectability in strict equality. | 2774 // There is no test for undetectability in strict equality. |
| 2775 | 2775 |
| 2776 // If the first object is a JS object, we have done pointer comparison. | 2776 // If the first object is a JS object, we have done pointer comparison. |
| 2777 STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 2777 STATIC_ASSERT(LAST_TYPE == LAST_SPEC_OBJECT_TYPE); |
| 2778 Label first_non_object; | 2778 Label first_non_object; |
| 2779 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); | 2779 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); |
| 2780 __ j(below, &first_non_object, Label::kNear); | 2780 __ j(below, &first_non_object, Label::kNear); |
| 2781 // Return non-zero (eax (not rax) is not zero) | 2781 // Return non-zero (eax (not rax) is not zero) |
| 2782 Label return_not_equal; | 2782 Label return_not_equal; |
| 2783 STATIC_ASSERT(kHeapObjectTag != 0); | 2783 STATIC_ASSERT(kHeapObjectTag != 0); |
| 2784 __ bind(&return_not_equal); | 2784 __ bind(&return_not_equal); |
| 2785 __ ret(0); | 2785 __ ret(0); |
| 2786 | 2786 |
| 2787 __ bind(&first_non_object); | 2787 __ bind(&first_non_object); |
| 2788 // Check for oddballs: true, false, null, undefined. | 2788 // Check for oddballs: true, false, null, undefined. |
| 2789 __ CmpInstanceType(rcx, ODDBALL_TYPE); | 2789 __ CmpInstanceType(rcx, ODDBALL_TYPE); |
| 2790 __ j(equal, &return_not_equal); | 2790 __ j(equal, &return_not_equal); |
| 2791 | 2791 |
| 2792 __ CmpObjectType(rdx, FIRST_JS_OBJECT_TYPE, rcx); | 2792 __ CmpObjectType(rdx, FIRST_SPEC_OBJECT_TYPE, rcx); |
| 2793 __ j(above_equal, &return_not_equal); | 2793 __ j(above_equal, &return_not_equal); |
| 2794 | 2794 |
| 2795 // Check for oddballs: true, false, null, undefined. | 2795 // Check for oddballs: true, false, null, undefined. |
| 2796 __ CmpInstanceType(rcx, ODDBALL_TYPE); | 2796 __ CmpInstanceType(rcx, ODDBALL_TYPE); |
| 2797 __ j(equal, &return_not_equal); | 2797 __ j(equal, &return_not_equal); |
| 2798 | 2798 |
| 2799 // Fall through to the general case. | 2799 // Fall through to the general case. |
| 2800 } | 2800 } |
| 2801 __ bind(&slow); | 2801 __ bind(&slow); |
| 2802 } | 2802 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2878 // and their pointers are different. | 2878 // and their pointers are different. |
| 2879 Label not_both_objects, return_unequal; | 2879 Label not_both_objects, return_unequal; |
| 2880 // At most one is a smi, so we can test for smi by adding the two. | 2880 // At most one is a smi, so we can test for smi by adding the two. |
| 2881 // A smi plus a heap object has the low bit set, a heap object plus | 2881 // A smi plus a heap object has the low bit set, a heap object plus |
| 2882 // a heap object has the low bit clear. | 2882 // a heap object has the low bit clear. |
| 2883 STATIC_ASSERT(kSmiTag == 0); | 2883 STATIC_ASSERT(kSmiTag == 0); |
| 2884 STATIC_ASSERT(kSmiTagMask == 1); | 2884 STATIC_ASSERT(kSmiTagMask == 1); |
| 2885 __ lea(rcx, Operand(rax, rdx, times_1, 0)); | 2885 __ lea(rcx, Operand(rax, rdx, times_1, 0)); |
| 2886 __ testb(rcx, Immediate(kSmiTagMask)); | 2886 __ testb(rcx, Immediate(kSmiTagMask)); |
| 2887 __ j(not_zero, ¬_both_objects, Label::kNear); | 2887 __ j(not_zero, ¬_both_objects, Label::kNear); |
| 2888 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx); | 2888 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rbx); |
| 2889 __ j(below, ¬_both_objects, Label::kNear); | 2889 __ j(below, ¬_both_objects, Label::kNear); |
| 2890 __ CmpObjectType(rdx, FIRST_JS_OBJECT_TYPE, rcx); | 2890 __ CmpObjectType(rdx, FIRST_SPEC_OBJECT_TYPE, rcx); |
| 2891 __ j(below, ¬_both_objects, Label::kNear); | 2891 __ j(below, ¬_both_objects, Label::kNear); |
| 2892 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), | 2892 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), |
| 2893 Immediate(1 << Map::kIsUndetectable)); | 2893 Immediate(1 << Map::kIsUndetectable)); |
| 2894 __ j(zero, &return_unequal, Label::kNear); | 2894 __ j(zero, &return_unequal, Label::kNear); |
| 2895 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | 2895 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), |
| 2896 Immediate(1 << Map::kIsUndetectable)); | 2896 Immediate(1 << Map::kIsUndetectable)); |
| 2897 __ j(zero, &return_unequal, Label::kNear); | 2897 __ j(zero, &return_unequal, Label::kNear); |
| 2898 // The objects are both undetectable, so they both compare as the value | 2898 // The objects are both undetectable, so they both compare as the value |
| 2899 // undefined, and are equal. | 2899 // undefined, and are equal. |
| 2900 __ Set(rax, EQUAL); | 2900 __ Set(rax, EQUAL); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3416 ASSERT(flags_ == kNoFlags || HasCallSiteInlineCheck()); | 3416 ASSERT(flags_ == kNoFlags || HasCallSiteInlineCheck()); |
| 3417 int extra_stack_space = HasCallSiteInlineCheck() ? kPointerSize : 0; | 3417 int extra_stack_space = HasCallSiteInlineCheck() ? kPointerSize : 0; |
| 3418 | 3418 |
| 3419 // Get the object - go slow case if it's a smi. | 3419 // Get the object - go slow case if it's a smi. |
| 3420 Label slow; | 3420 Label slow; |
| 3421 | 3421 |
| 3422 __ movq(rax, Operand(rsp, 2 * kPointerSize + extra_stack_space)); | 3422 __ movq(rax, Operand(rsp, 2 * kPointerSize + extra_stack_space)); |
| 3423 __ JumpIfSmi(rax, &slow); | 3423 __ JumpIfSmi(rax, &slow); |
| 3424 | 3424 |
| 3425 // Check that the left hand is a JS object. Leave its map in rax. | 3425 // Check that the left hand is a JS object. Leave its map in rax. |
| 3426 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rax); | 3426 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rax); |
| 3427 __ j(below, &slow); | 3427 __ j(below, &slow); |
| 3428 __ CmpInstanceType(rax, LAST_JS_OBJECT_TYPE); | 3428 __ CmpInstanceType(rax, LAST_SPEC_OBJECT_TYPE); |
| 3429 __ j(above, &slow); | 3429 __ j(above, &slow); |
| 3430 | 3430 |
| 3431 // Get the prototype of the function. | 3431 // Get the prototype of the function. |
| 3432 __ movq(rdx, Operand(rsp, 1 * kPointerSize + extra_stack_space)); | 3432 __ movq(rdx, Operand(rsp, 1 * kPointerSize + extra_stack_space)); |
| 3433 // rdx is function, rax is map. | 3433 // rdx is function, rax is map. |
| 3434 | 3434 |
| 3435 // If there is a call site cache don't look in the global cache, but do the | 3435 // If there is a call site cache don't look in the global cache, but do the |
| 3436 // real lookup and update the call site cache. | 3436 // real lookup and update the call site cache. |
| 3437 if (!HasCallSiteInlineCheck()) { | 3437 if (!HasCallSiteInlineCheck()) { |
| 3438 // Look up the function and the map in the instanceof cache. | 3438 // Look up the function and the map in the instanceof cache. |
| 3439 Label miss; | 3439 Label miss; |
| 3440 __ CompareRoot(rdx, Heap::kInstanceofCacheFunctionRootIndex); | 3440 __ CompareRoot(rdx, Heap::kInstanceofCacheFunctionRootIndex); |
| 3441 __ j(not_equal, &miss, Label::kNear); | 3441 __ j(not_equal, &miss, Label::kNear); |
| 3442 __ CompareRoot(rax, Heap::kInstanceofCacheMapRootIndex); | 3442 __ CompareRoot(rax, Heap::kInstanceofCacheMapRootIndex); |
| 3443 __ j(not_equal, &miss, Label::kNear); | 3443 __ j(not_equal, &miss, Label::kNear); |
| 3444 __ LoadRoot(rax, Heap::kInstanceofCacheAnswerRootIndex); | 3444 __ LoadRoot(rax, Heap::kInstanceofCacheAnswerRootIndex); |
| 3445 __ ret(2 * kPointerSize); | 3445 __ ret(2 * kPointerSize); |
| 3446 __ bind(&miss); | 3446 __ bind(&miss); |
| 3447 } | 3447 } |
| 3448 | 3448 |
| 3449 __ TryGetFunctionPrototype(rdx, rbx, &slow); | 3449 __ TryGetFunctionPrototype(rdx, rbx, &slow); |
| 3450 | 3450 |
| 3451 // Check that the function prototype is a JS object. | 3451 // Check that the function prototype is a JS object. |
| 3452 __ JumpIfSmi(rbx, &slow); | 3452 __ JumpIfSmi(rbx, &slow); |
| 3453 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, kScratchRegister); | 3453 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); |
| 3454 __ j(below, &slow); | 3454 __ j(below, &slow); |
| 3455 __ CmpInstanceType(kScratchRegister, LAST_JS_OBJECT_TYPE); | 3455 __ CmpInstanceType(kScratchRegister, LAST_SPEC_OBJECT_TYPE); |
| 3456 __ j(above, &slow); | 3456 __ j(above, &slow); |
| 3457 | 3457 |
| 3458 // Register mapping: | 3458 // Register mapping: |
| 3459 // rax is object map. | 3459 // rax is object map. |
| 3460 // rdx is function. | 3460 // rdx is function. |
| 3461 // rbx is function prototype. | 3461 // rbx is function prototype. |
| 3462 if (!HasCallSiteInlineCheck()) { | 3462 if (!HasCallSiteInlineCheck()) { |
| 3463 __ StoreRoot(rdx, Heap::kInstanceofCacheFunctionRootIndex); | 3463 __ StoreRoot(rdx, Heap::kInstanceofCacheFunctionRootIndex); |
| 3464 __ StoreRoot(rax, Heap::kInstanceofCacheMapRootIndex); | 3464 __ StoreRoot(rax, Heap::kInstanceofCacheMapRootIndex); |
| 3465 } else { | 3465 } else { |
| (...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5135 __ Drop(1); | 5135 __ Drop(1); |
| 5136 __ ret(2 * kPointerSize); | 5136 __ ret(2 * kPointerSize); |
| 5137 } | 5137 } |
| 5138 | 5138 |
| 5139 | 5139 |
| 5140 #undef __ | 5140 #undef __ |
| 5141 | 5141 |
| 5142 } } // namespace v8::internal | 5142 } } // namespace v8::internal |
| 5143 | 5143 |
| 5144 #endif // V8_TARGET_ARCH_X64 | 5144 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |