| 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)); |
| 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)); |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 __ pop(rbx); | 775 __ pop(rbx); |
| 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 StackArgumentsAccessor args(rsp, rax); |
| 786 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 786 __ movq(rdi, args.GetReceiverOperand()); |
| 787 __ JumpIfSmi(rdi, &non_function); | 787 __ JumpIfSmi(rdi, &non_function); |
| 788 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 788 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
| 789 __ j(not_equal, &slow); | 789 __ j(not_equal, &slow); |
| 790 | 790 |
| 791 // 3a. Patch the first argument if necessary when calling a function. | 791 // 3a. Patch the first argument if necessary when calling a function. |
| 792 Label shift_arguments; | 792 Label shift_arguments; |
| 793 __ Set(rdx, 0); // indicate regular JS_FUNCTION | 793 __ Set(rdx, 0); // indicate regular JS_FUNCTION |
| 794 { Label convert_to_object, use_global_receiver, patch_receiver; | 794 { Label convert_to_object, use_global_receiver, patch_receiver; |
| 795 // Change context eagerly in case we need the global receiver. | 795 // Change context eagerly in case we need the global receiver. |
| 796 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 796 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 797 | 797 |
| 798 // Do not transform the receiver for strict mode functions. | 798 // Do not transform the receiver for strict mode functions. |
| 799 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 799 __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
| 800 __ testb(FieldOperand(rbx, SharedFunctionInfo::kStrictModeByteOffset), | 800 __ testb(FieldOperand(rbx, SharedFunctionInfo::kStrictModeByteOffset), |
| 801 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 801 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
| 802 __ j(not_equal, &shift_arguments); | 802 __ j(not_equal, &shift_arguments); |
| 803 | 803 |
| 804 // Do not transform the receiver for natives. | 804 // Do not transform the receiver for natives. |
| 805 // SharedFunctionInfo is already loaded into rbx. | 805 // SharedFunctionInfo is already loaded into rbx. |
| 806 __ testb(FieldOperand(rbx, SharedFunctionInfo::kNativeByteOffset), | 806 __ testb(FieldOperand(rbx, SharedFunctionInfo::kNativeByteOffset), |
| 807 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); | 807 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); |
| 808 __ j(not_zero, &shift_arguments); | 808 __ j(not_zero, &shift_arguments); |
| 809 | 809 |
| 810 // Compute the receiver in non-strict mode. | 810 // Compute the receiver in non-strict mode. |
| 811 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 811 __ movq(rbx, args.GetArgumentOperand(1)); |
| 812 __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); | 812 __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); |
| 813 | 813 |
| 814 __ CompareRoot(rbx, Heap::kNullValueRootIndex); | 814 __ CompareRoot(rbx, Heap::kNullValueRootIndex); |
| 815 __ j(equal, &use_global_receiver); | 815 __ j(equal, &use_global_receiver); |
| 816 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); | 816 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); |
| 817 __ j(equal, &use_global_receiver); | 817 __ j(equal, &use_global_receiver); |
| 818 | 818 |
| 819 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); | 819 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 820 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); | 820 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); |
| 821 __ j(above_equal, &shift_arguments); | 821 __ j(above_equal, &shift_arguments); |
| 822 | 822 |
| 823 __ bind(&convert_to_object); | 823 __ bind(&convert_to_object); |
| 824 { | 824 { |
| 825 // Enter an internal frame in order to preserve argument count. | 825 // Enter an internal frame in order to preserve argument count. |
| 826 FrameScope scope(masm, StackFrame::INTERNAL); | 826 FrameScope scope(masm, StackFrame::INTERNAL); |
| 827 __ Integer32ToSmi(rax, rax); | 827 __ Integer32ToSmi(rax, rax); |
| 828 __ push(rax); | 828 __ push(rax); |
| 829 | 829 |
| 830 __ push(rbx); | 830 __ push(rbx); |
| 831 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 831 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 832 __ movq(rbx, rax); | 832 __ movq(rbx, rax); |
| 833 __ Set(rdx, 0); // indicate regular JS_FUNCTION | 833 __ Set(rdx, 0); // indicate regular JS_FUNCTION |
| 834 | 834 |
| 835 __ pop(rax); | 835 __ pop(rax); |
| 836 __ SmiToInteger32(rax, rax); | 836 __ SmiToInteger32(rax, rax); |
| 837 } | 837 } |
| 838 | 838 |
| 839 // Restore the function to rdi. | 839 // Restore the function to rdi. |
| 840 __ movq(rdi, Operand(rsp, rax, times_pointer_size, 1 * kPointerSize)); | 840 __ movq(rdi, args.GetReceiverOperand()); |
| 841 __ jmp(&patch_receiver, Label::kNear); | 841 __ jmp(&patch_receiver, Label::kNear); |
| 842 | 842 |
| 843 // Use the global receiver object from the called function as the | 843 // Use the global receiver object from the called function as the |
| 844 // receiver. | 844 // receiver. |
| 845 __ bind(&use_global_receiver); | 845 __ bind(&use_global_receiver); |
| 846 const int kGlobalIndex = | 846 const int kGlobalIndex = |
| 847 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | 847 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; |
| 848 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); | 848 __ movq(rbx, FieldOperand(rsi, kGlobalIndex)); |
| 849 __ movq(rbx, FieldOperand(rbx, GlobalObject::kNativeContextOffset)); | 849 __ movq(rbx, FieldOperand(rbx, GlobalObject::kNativeContextOffset)); |
| 850 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); | 850 __ movq(rbx, FieldOperand(rbx, kGlobalIndex)); |
| 851 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); | 851 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
| 852 | 852 |
| 853 __ bind(&patch_receiver); | 853 __ bind(&patch_receiver); |
| 854 __ movq(Operand(rsp, rax, times_pointer_size, 0), rbx); | 854 __ movq(args.GetArgumentOperand(1), rbx); |
| 855 | 855 |
| 856 __ jmp(&shift_arguments); | 856 __ jmp(&shift_arguments); |
| 857 } | 857 } |
| 858 | 858 |
| 859 // 3b. Check for function proxy. | 859 // 3b. Check for function proxy. |
| 860 __ bind(&slow); | 860 __ bind(&slow); |
| 861 __ Set(rdx, 1); // indicate function proxy | 861 __ Set(rdx, 1); // indicate function proxy |
| 862 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 862 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
| 863 __ j(equal, &shift_arguments); | 863 __ j(equal, &shift_arguments); |
| 864 __ bind(&non_function); | 864 __ bind(&non_function); |
| 865 __ Set(rdx, 2); // indicate non-function | 865 __ Set(rdx, 2); // indicate non-function |
| 866 | 866 |
| 867 // 3c. Patch the first argument when calling a non-function. The | 867 // 3c. Patch the first argument when calling a non-function. The |
| 868 // CALL_NON_FUNCTION builtin expects the non-function callee as | 868 // CALL_NON_FUNCTION builtin expects the non-function callee as |
| 869 // receiver, so overwrite the first argument which will ultimately | 869 // receiver, so overwrite the first argument which will ultimately |
| 870 // become the receiver. | 870 // become the receiver. |
| 871 __ movq(Operand(rsp, rax, times_pointer_size, 0), rdi); | 871 __ movq(args.GetArgumentOperand(1), rdi); |
| 872 | 872 |
| 873 // 4. Shift arguments and return address one slot down on the stack | 873 // 4. Shift arguments and return address one slot down on the stack |
| 874 // (overwriting the original receiver). Adjust argument count to make | 874 // (overwriting the original receiver). Adjust argument count to make |
| 875 // the original first argument the new receiver. | 875 // the original first argument the new receiver. |
| 876 __ bind(&shift_arguments); | 876 __ bind(&shift_arguments); |
| 877 { Label loop; | 877 { Label loop; |
| 878 __ movq(rcx, rax); | 878 __ movq(rcx, rax); |
| 879 __ bind(&loop); | 879 __ bind(&loop); |
| 880 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0)); | 880 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0)); |
| 881 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx); | 881 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 __ IncrementCounter(counters->string_ctor_calls(), 1); | 1171 __ IncrementCounter(counters->string_ctor_calls(), 1); |
| 1172 | 1172 |
| 1173 if (FLAG_debug_code) { | 1173 if (FLAG_debug_code) { |
| 1174 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx); | 1174 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx); |
| 1175 __ cmpq(rdi, rcx); | 1175 __ cmpq(rdi, rcx); |
| 1176 __ Assert(equal, "Unexpected String function"); | 1176 __ Assert(equal, "Unexpected String function"); |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 // Load the first argument into rax and get rid of the rest | 1179 // Load the first argument into rax and get rid of the rest |
| 1180 // (including the receiver). | 1180 // (including the receiver). |
| 1181 StackArgumentsAccessor args(rsp, rax); |
| 1181 Label no_arguments; | 1182 Label no_arguments; |
| 1182 __ testq(rax, rax); | 1183 __ testq(rax, rax); |
| 1183 __ j(zero, &no_arguments); | 1184 __ j(zero, &no_arguments); |
| 1184 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); | 1185 __ movq(rbx, args.GetArgumentOperand(1)); |
| 1185 __ pop(rcx); | 1186 __ pop(rcx); |
| 1186 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); | 1187 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); |
| 1187 __ push(rcx); | 1188 __ push(rcx); |
| 1188 __ movq(rax, rbx); | 1189 __ movq(rax, rbx); |
| 1189 | 1190 |
| 1190 // Lookup the argument in the number to string cache. | 1191 // Lookup the argument in the number to string cache. |
| 1191 Label not_cached, argument_is_string; | 1192 Label not_cached, argument_is_string; |
| 1192 NumberToStringStub::GenerateLookupNumberStringCache( | 1193 NumberToStringStub::GenerateLookupNumberStringCache( |
| 1193 masm, | 1194 masm, |
| 1194 rax, // Input. | 1195 rax, // Input. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1435 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1435 generator.Generate(); | 1436 generator.Generate(); |
| 1436 } | 1437 } |
| 1437 | 1438 |
| 1438 | 1439 |
| 1439 #undef __ | 1440 #undef __ |
| 1440 | 1441 |
| 1441 } } // namespace v8::internal | 1442 } } // namespace v8::internal |
| 1442 | 1443 |
| 1443 #endif // V8_TARGET_ARCH_X64 | 1444 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |