OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 FrameScope scope(masm, StackFrame::INTERNAL); | 701 FrameScope scope(masm, StackFrame::INTERNAL); |
702 | 702 |
703 // Pass the deoptimization type to the runtime system. | 703 // Pass the deoptimization type to the runtime system. |
704 __ Push(Smi::FromInt(static_cast<int>(type))); | 704 __ Push(Smi::FromInt(static_cast<int>(type))); |
705 | 705 |
706 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); | 706 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); |
707 // Tear down internal frame. | 707 // Tear down internal frame. |
708 } | 708 } |
709 | 709 |
710 // Get the full codegen state from the stack and untag it. | 710 // Get the full codegen state from the stack and untag it. |
711 __ SmiToInteger32(r10, Operand(rsp, 1 * kPointerSize)); | 711 __ SmiToInteger32(r10, Operand(rsp, kPCOnStackSize)); |
haitao.feng
2013/07/31 00:24:50
Use kPCOnStackSize instead of kPointerSize.
| |
712 | 712 |
713 // Switch on the state. | 713 // Switch on the state. |
714 Label not_no_registers, not_tos_rax; | 714 Label not_no_registers, not_tos_rax; |
715 __ cmpq(r10, Immediate(FullCodeGenerator::NO_REGISTERS)); | 715 __ cmpq(r10, Immediate(FullCodeGenerator::NO_REGISTERS)); |
716 __ j(not_equal, ¬_no_registers, Label::kNear); | 716 __ j(not_equal, ¬_no_registers, Label::kNear); |
717 __ ret(1 * kPointerSize); // Remove state. | 717 __ ret(1 * kPointerSize); // Remove state. |
718 | 718 |
719 __ bind(¬_no_registers); | 719 __ bind(¬_no_registers); |
720 __ movq(rax, Operand(rsp, 2 * kPointerSize)); | 720 __ movq(rax, Operand(rsp, kPCOnStackSize + kPointerSize)); |
haitao.feng
2013/07/31 00:24:50
Use kPCOnStackSize instead of kPointerSize.
| |
721 __ cmpq(r10, Immediate(FullCodeGenerator::TOS_REG)); | 721 __ cmpq(r10, Immediate(FullCodeGenerator::TOS_REG)); |
722 __ j(not_equal, ¬_tos_rax, Label::kNear); | 722 __ j(not_equal, ¬_tos_rax, Label::kNear); |
723 __ ret(2 * kPointerSize); // Remove state, rax. | 723 __ ret(2 * kPointerSize); // Remove state, rax. |
724 | 724 |
725 __ bind(¬_tos_rax); | 725 __ bind(¬_tos_rax); |
726 __ Abort("no cases left"); | 726 __ Abort("no cases left"); |
727 } | 727 } |
728 | 728 |
729 | 729 |
730 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { | 730 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 __ Push(masm->isolate()->factory()->undefined_value()); | 776 __ Push(masm->isolate()->factory()->undefined_value()); |
777 __ push(rbx); | 777 __ push(rbx); |
778 __ incq(rax); | 778 __ incq(rax); |
779 __ bind(&done); | 779 __ bind(&done); |
780 } | 780 } |
781 | 781 |
782 // 2. Get the function to call (passed as receiver) from the stack, check | 782 // 2. Get the function to call (passed as receiver) from the stack, check |
783 // if it is a function. | 783 // if it is a function. |
784 Label slow, non_function; | 784 Label slow, non_function; |
785 // The function to call is at position n+1 on the stack. | 785 // The function to call is at position n+1 on the stack. |
786 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 786 __ movq(rdi, StackOperandForArgument(rax, times_pointer_size, |
787 1 * kPointerSize)); | |
787 __ JumpIfSmi(rdi, &non_function); | 788 __ JumpIfSmi(rdi, &non_function); |
788 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 789 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
789 __ j(not_equal, &slow); | 790 __ j(not_equal, &slow); |
790 | 791 |
791 // 3a. Patch the first argument if necessary when calling a function. | 792 // 3a. Patch the first argument if necessary when calling a function. |
792 Label shift_arguments; | 793 Label shift_arguments; |
793 __ Set(rdx, 0); // indicate regular JS_FUNCTION | 794 __ Set(rdx, 0); // indicate regular JS_FUNCTION |
794 { Label convert_to_object, use_global_receiver, patch_receiver; | 795 { Label convert_to_object, use_global_receiver, patch_receiver; |
795 // Change context eagerly in case we need the global receiver. | 796 // Change context eagerly in case we need the global receiver. |
796 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 797 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
797 | 798 |
798 // Do not transform the receiver for strict mode functions. | 799 // Do not transform the receiver for strict mode functions. |
799 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 800 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
800 __ testb(FieldOperand(rbx, SharedFunctionInfo::kStrictModeByteOffset), | 801 __ testb(FieldOperand(rbx, SharedFunctionInfo::kStrictModeByteOffset), |
801 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 802 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
802 __ j(not_equal, &shift_arguments); | 803 __ j(not_equal, &shift_arguments); |
803 | 804 |
804 // Do not transform the receiver for natives. | 805 // Do not transform the receiver for natives. |
805 // SharedFunctionInfo is already loaded into rbx. | 806 // SharedFunctionInfo is already loaded into rbx. |
806 __ testb(FieldOperand(rbx, SharedFunctionInfo::kNativeByteOffset), | 807 __ testb(FieldOperand(rbx, SharedFunctionInfo::kNativeByteOffset), |
807 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); | 808 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); |
808 __ j(not_zero, &shift_arguments); | 809 __ j(not_zero, &shift_arguments); |
809 | 810 |
810 // Compute the receiver in non-strict mode. | 811 // Compute the receiver in non-strict mode. |
811 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 812 __ movq(rbx, StackOperandForArgument(rax, times_pointer_size, 0)); |
812 __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); | 813 __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); |
813 | 814 |
814 __ CompareRoot(rbx, Heap::kNullValueRootIndex); | 815 __ CompareRoot(rbx, Heap::kNullValueRootIndex); |
815 __ j(equal, &use_global_receiver); | 816 __ j(equal, &use_global_receiver); |
816 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); | 817 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); |
817 __ j(equal, &use_global_receiver); | 818 __ j(equal, &use_global_receiver); |
818 | 819 |
819 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 820 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
820 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); | 821 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); |
821 __ j(above_equal, &shift_arguments); | 822 __ j(above_equal, &shift_arguments); |
822 | 823 |
823 __ bind(&convert_to_object); | 824 __ bind(&convert_to_object); |
824 { | 825 { |
825 // Enter an internal frame in order to preserve argument count. | 826 // Enter an internal frame in order to preserve argument count. |
826 FrameScope scope(masm, StackFrame::INTERNAL); | 827 FrameScope scope(masm, StackFrame::INTERNAL); |
827 __ Integer32ToSmi(rax, rax); | 828 __ Integer32ToSmi(rax, rax); |
828 __ push(rax); | 829 __ push(rax); |
829 | 830 |
830 __ push(rbx); | 831 __ push(rbx); |
831 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 832 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
832 __ movq(rbx, rax); | 833 __ movq(rbx, rax); |
833 __ Set(rdx, 0); // indicate regular JS_FUNCTION | 834 __ Set(rdx, 0); // indicate regular JS_FUNCTION |
834 | 835 |
835 __ pop(rax); | 836 __ pop(rax); |
836 __ SmiToInteger32(rax, rax); | 837 __ SmiToInteger32(rax, rax); |
837 } | 838 } |
838 | 839 |
839 // Restore the function to rdi. | 840 // Restore the function to rdi. |
840 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 841 __ movq(rdi, StackOperandForArgument(rax, times_pointer_size, |
danno
2013/07/31 07:48:37
Does this ever no use "time_pointer_size"? If so,
| |
842 1 * kPointerSize)); | |
841 __ jmp(&patch_receiver, Label::kNear); | 843 __ jmp(&patch_receiver, Label::kNear); |
842 | 844 |
843 // Use the global receiver object from the called function as the | 845 // Use the global receiver object from the called function as the |
844 // receiver. | 846 // receiver. |
845 __ bind(&use_global_receiver); | 847 __ bind(&use_global_receiver); |
846 const int kGlobalIndex = | 848 const int kGlobalIndex = |
847 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | 849 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; |
848 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); | 850 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); |
849 __ movq(rbx, FieldOperand(rbx, GlobalObject::kNativeContextOffset)); | 851 __ movq(rbx, FieldOperand(rbx, GlobalObject::kNativeContextOffset)); |
850 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); | 852 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); |
851 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); | 853 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
852 | 854 |
853 __ bind(&patch_receiver); | 855 __ bind(&patch_receiver); |
854 __ movq(Operand(rsp, rax, times_pointer_size, 0), rbx); | 856 __ movq(StackOperandForArgument(rax, times_pointer_size, 0), rbx); |
855 | 857 |
856 __ jmp(&shift_arguments); | 858 __ jmp(&shift_arguments); |
857 } | 859 } |
858 | 860 |
859 // 3b. Check for function proxy. | 861 // 3b. Check for function proxy. |
860 __ bind(&slow); | 862 __ bind(&slow); |
861 __ Set(rdx, 1); // indicate function proxy | 863 __ Set(rdx, 1); // indicate function proxy |
862 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 864 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
863 __ j(equal, &shift_arguments); | 865 __ j(equal, &shift_arguments); |
864 __ bind(&non_function); | 866 __ bind(&non_function); |
865 __ Set(rdx, 2); // indicate non-function | 867 __ Set(rdx, 2); // indicate non-function |
866 | 868 |
867 // 3c. Patch the first argument when calling a non-function. The | 869 // 3c. Patch the first argument when calling a non-function. The |
868 // CALL_NON_FUNCTION builtin expects the non-function callee as | 870 // CALL_NON_FUNCTION builtin expects the non-function callee as |
869 // receiver, so overwrite the first argument which will ultimately | 871 // receiver, so overwrite the first argument which will ultimately |
870 // become the receiver. | 872 // become the receiver. |
871 __ movq(Operand(rsp, rax, times_pointer_size, 0), rdi); | 873 __ movq(StackOperandForArgument(rax, times_pointer_size, 0), rdi); |
872 | 874 |
873 // 4. Shift arguments and return address one slot down on the stack | 875 // 4. Shift arguments and return address one slot down on the stack |
874 // (overwriting the original receiver). Adjust argument count to make | 876 // (overwriting the original receiver). Adjust argument count to make |
875 // the original first argument the new receiver. | 877 // the original first argument the new receiver. |
876 __ bind(&shift_arguments); | 878 __ bind(&shift_arguments); |
877 { Label loop; | 879 { Label loop; |
878 __ movq(rcx, rax); | 880 __ movq(rcx, rax); |
879 __ bind(&loop); | 881 __ bind(&loop); |
880 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0)); | 882 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0)); |
881 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx); | 883 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1174 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx); | 1176 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx); |
1175 __ cmpq(rdi, rcx); | 1177 __ cmpq(rdi, rcx); |
1176 __ Assert(equal, "Unexpected String function"); | 1178 __ Assert(equal, "Unexpected String function"); |
1177 } | 1179 } |
1178 | 1180 |
1179 // Load the first argument into rax and get rid of the rest | 1181 // Load the first argument into rax and get rid of the rest |
1180 // (including the receiver). | 1182 // (including the receiver). |
1181 Label no_arguments; | 1183 Label no_arguments; |
1182 __ testq(rax, rax); | 1184 __ testq(rax, rax); |
1183 __ j(zero, &no_arguments); | 1185 __ j(zero, &no_arguments); |
1184 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 1186 __ movq(rbx, StackOperandForArgument(rax, times_pointer_size, 0)); |
1185 __ pop(rcx); | 1187 __ pop(rcx); |
1186 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); | 1188 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); |
1187 __ push(rcx); | 1189 __ push(rcx); |
1188 __ movq(rax, rbx); | 1190 __ movq(rax, rbx); |
1189 | 1191 |
1190 // Lookup the argument in the number to string cache. | 1192 // Lookup the argument in the number to string cache. |
1191 Label not_cached, argument_is_string; | 1193 Label not_cached, argument_is_string; |
1192 NumberToStringStub::GenerateLookupNumberStringCache( | 1194 NumberToStringStub::GenerateLookupNumberStringCache( |
1193 masm, | 1195 masm, |
1194 rax, // Input. | 1196 rax, // Input. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1436 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1435 generator.Generate(); | 1437 generator.Generate(); |
1436 } | 1438 } |
1437 | 1439 |
1438 | 1440 |
1439 #undef __ | 1441 #undef __ |
1440 | 1442 |
1441 } } // namespace v8::internal | 1443 } } // namespace v8::internal |
1442 | 1444 |
1443 #endif // V8_TARGET_ARCH_X64 | 1445 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |