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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 __ j(not_equal, &shift_arguments); | 659 __ j(not_equal, &shift_arguments); |
660 | 660 |
661 // Do not transform the receiver for natives. | 661 // Do not transform the receiver for natives. |
662 // SharedFunctionInfo is already loaded into rbx. | 662 // SharedFunctionInfo is already loaded into rbx. |
663 __ testb(FieldOperand(rbx, SharedFunctionInfo::kES5NativeByteOffset), | 663 __ testb(FieldOperand(rbx, SharedFunctionInfo::kES5NativeByteOffset), |
664 Immediate(1 << SharedFunctionInfo::kES5NativeBitWithinByte)); | 664 Immediate(1 << SharedFunctionInfo::kES5NativeBitWithinByte)); |
665 __ j(not_zero, &shift_arguments); | 665 __ j(not_zero, &shift_arguments); |
666 | 666 |
667 // Compute the receiver in non-strict mode. | 667 // Compute the receiver in non-strict mode. |
668 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 668 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); |
669 __ JumpIfSmi(rbx, &convert_to_object); | 669 __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); |
670 | 670 |
671 __ CompareRoot(rbx, Heap::kNullValueRootIndex); | 671 __ CompareRoot(rbx, Heap::kNullValueRootIndex); |
672 __ j(equal, &use_global_receiver); | 672 __ j(equal, &use_global_receiver); |
673 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); | 673 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); |
674 __ j(equal, &use_global_receiver); | 674 __ j(equal, &use_global_receiver); |
675 | 675 |
| 676 STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE); |
| 677 STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
676 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, rcx); | 678 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, rcx); |
677 __ j(below, &convert_to_object); | 679 __ j(above_equal, &shift_arguments); |
678 __ CmpInstanceType(rcx, LAST_JS_OBJECT_TYPE); | |
679 __ j(below_equal, &shift_arguments); | |
680 | 680 |
681 __ bind(&convert_to_object); | 681 __ bind(&convert_to_object); |
682 __ EnterInternalFrame(); // In order to preserve argument count. | 682 __ EnterInternalFrame(); // In order to preserve argument count. |
683 __ Integer32ToSmi(rax, rax); | 683 __ Integer32ToSmi(rax, rax); |
684 __ push(rax); | 684 __ push(rax); |
685 | 685 |
686 __ push(rbx); | 686 __ push(rbx); |
687 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 687 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
688 __ movq(rbx, rax); | 688 __ movq(rbx, rax); |
689 | 689 |
690 __ pop(rax); | 690 __ pop(rax); |
691 __ SmiToInteger32(rax, rax); | 691 __ SmiToInteger32(rax, rax); |
692 __ LeaveInternalFrame(); | 692 __ LeaveInternalFrame(); |
693 // Restore the function to rdi. | 693 // Restore the function to rdi. |
694 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 694 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); |
695 __ jmp(&patch_receiver); | 695 __ jmp(&patch_receiver, Label::kNear); |
696 | 696 |
697 // Use the global receiver object from the called function as the | 697 // Use the global receiver object from the called function as the |
698 // receiver. | 698 // receiver. |
699 __ bind(&use_global_receiver); | 699 __ bind(&use_global_receiver); |
700 const int kGlobalIndex = | 700 const int kGlobalIndex = |
701 Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; | 701 Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
702 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); | 702 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); |
703 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalContextOffset)); | 703 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalContextOffset)); |
704 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); | 704 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); |
705 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); | 705 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 __ testb(FieldOperand(rdx, SharedFunctionInfo::kStrictModeByteOffset), | 827 __ testb(FieldOperand(rdx, SharedFunctionInfo::kStrictModeByteOffset), |
828 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 828 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
829 __ j(not_equal, &push_receiver); | 829 __ j(not_equal, &push_receiver); |
830 | 830 |
831 // Do not transform the receiver for natives. | 831 // Do not transform the receiver for natives. |
832 __ testb(FieldOperand(rdx, SharedFunctionInfo::kES5NativeByteOffset), | 832 __ testb(FieldOperand(rdx, SharedFunctionInfo::kES5NativeByteOffset), |
833 Immediate(1 << SharedFunctionInfo::kES5NativeBitWithinByte)); | 833 Immediate(1 << SharedFunctionInfo::kES5NativeBitWithinByte)); |
834 __ j(not_zero, &push_receiver); | 834 __ j(not_zero, &push_receiver); |
835 | 835 |
836 // Compute the receiver in non-strict mode. | 836 // Compute the receiver in non-strict mode. |
837 __ JumpIfSmi(rbx, &call_to_object); | 837 __ JumpIfSmi(rbx, &call_to_object, Label::kNear); |
838 __ CompareRoot(rbx, Heap::kNullValueRootIndex); | 838 __ CompareRoot(rbx, Heap::kNullValueRootIndex); |
839 __ j(equal, &use_global_receiver); | 839 __ j(equal, &use_global_receiver); |
840 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); | 840 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); |
841 __ j(equal, &use_global_receiver); | 841 __ j(equal, &use_global_receiver); |
842 | 842 |
843 // If given receiver is already a JavaScript object then there's no | 843 // If given receiver is already a JavaScript object then there's no |
844 // reason for converting it. | 844 // reason for converting it. |
| 845 STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE); |
| 846 STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
845 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, rcx); | 847 __ CmpObjectType(rbx, FIRST_JS_OBJECT_TYPE, rcx); |
846 __ j(below, &call_to_object); | 848 __ j(above_equal, &push_receiver); |
847 __ CmpInstanceType(rcx, LAST_JS_OBJECT_TYPE); | |
848 __ j(below_equal, &push_receiver); | |
849 | 849 |
850 // Convert the receiver to an object. | 850 // Convert the receiver to an object. |
851 __ bind(&call_to_object); | 851 __ bind(&call_to_object); |
852 __ push(rbx); | 852 __ push(rbx); |
853 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 853 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
854 __ movq(rbx, rax); | 854 __ movq(rbx, rax); |
855 __ jmp(&push_receiver); | 855 __ jmp(&push_receiver, Label::kNear); |
856 | 856 |
857 // Use the current global receiver object as the receiver. | 857 // Use the current global receiver object as the receiver. |
858 __ bind(&use_global_receiver); | 858 __ bind(&use_global_receiver); |
859 const int kGlobalOffset = | 859 const int kGlobalOffset = |
860 Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; | 860 Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
861 __ movq(rbx, FieldOperand(rsi, kGlobalOffset)); | 861 __ movq(rbx, FieldOperand(rsi, kGlobalOffset)); |
862 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalContextOffset)); | 862 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalContextOffset)); |
863 __ movq(rbx, FieldOperand(rbx, kGlobalOffset)); | 863 __ movq(rbx, FieldOperand(rbx, kGlobalOffset)); |
864 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); | 864 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
865 | 865 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1495 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1496 generator.Generate(); | 1496 generator.Generate(); |
1497 } | 1497 } |
1498 | 1498 |
1499 | 1499 |
1500 #undef __ | 1500 #undef __ |
1501 | 1501 |
1502 } } // namespace v8::internal | 1502 } } // namespace v8::internal |
1503 | 1503 |
1504 #endif // V8_TARGET_ARCH_X64 | 1504 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |