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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 __ Set(rdx, 0); // indicate regular JS_FUNCTION | 837 __ Set(rdx, 0); // indicate regular JS_FUNCTION |
838 | 838 |
839 __ pop(rax); | 839 __ pop(rax); |
840 __ SmiToInteger32(rax, rax); | 840 __ SmiToInteger32(rax, rax); |
841 } | 841 } |
842 | 842 |
843 // Restore the function to rdi. | 843 // Restore the function to rdi. |
844 __ movq(rdi, args.GetReceiverOperand()); | 844 __ movq(rdi, args.GetReceiverOperand()); |
845 __ jmp(&patch_receiver, Label::kNear); | 845 __ jmp(&patch_receiver, Label::kNear); |
846 | 846 |
847 // Use the global receiver object from the called function as the | |
848 // receiver. | |
849 __ bind(&use_global_receiver); | 847 __ bind(&use_global_receiver); |
850 CallStubCompiler::FetchGlobalProxy(masm, rbx, rdi); | 848 __ movq(rbx, |
| 849 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 850 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
851 | 851 |
852 __ bind(&patch_receiver); | 852 __ bind(&patch_receiver); |
853 __ movq(args.GetArgumentOperand(1), rbx); | 853 __ movq(args.GetArgumentOperand(1), rbx); |
854 | 854 |
855 __ jmp(&shift_arguments); | 855 __ jmp(&shift_arguments); |
856 } | 856 } |
857 | 857 |
858 // 3b. Check for function proxy. | 858 // 3b. Check for function proxy. |
859 __ bind(&slow); | 859 __ bind(&slow); |
860 __ Set(rdx, 1); // indicate function proxy | 860 __ Set(rdx, 1); // indicate function proxy |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 910 } |
911 | 911 |
912 // 5b. Get the code to call from the function and check that the number of | 912 // 5b. Get the code to call from the function and check that the number of |
913 // expected arguments matches what we're providing. If so, jump | 913 // expected arguments matches what we're providing. If so, jump |
914 // (tail-call) to the code in register edx without checking arguments. | 914 // (tail-call) to the code in register edx without checking arguments. |
915 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 915 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
916 __ movsxlq(rbx, | 916 __ movsxlq(rbx, |
917 FieldOperand(rdx, | 917 FieldOperand(rdx, |
918 SharedFunctionInfo::kFormalParameterCountOffset)); | 918 SharedFunctionInfo::kFormalParameterCountOffset)); |
919 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 919 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
920 __ SetCallKind(rcx, CALL_AS_METHOD); | 920 __ SetCallKind(rcx, CALL_AS_FUNCTION); |
921 __ cmpq(rax, rbx); | 921 __ cmpq(rax, rbx); |
922 __ j(not_equal, | 922 __ j(not_equal, |
923 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 923 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
924 RelocInfo::CODE_TARGET); | 924 RelocInfo::CODE_TARGET); |
925 | 925 |
926 ParameterCount expected(0); | 926 ParameterCount expected(0); |
927 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION, | 927 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION, |
928 NullCallWrapper(), CALL_AS_METHOD); | 928 NullCallWrapper(), CALL_AS_FUNCTION); |
929 } | 929 } |
930 | 930 |
931 | 931 |
932 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 932 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
933 // Stack at entry: | 933 // Stack at entry: |
934 // rsp : return address | 934 // rsp : return address |
935 // rsp[8] : arguments | 935 // rsp[8] : arguments |
936 // rsp[16] : receiver ("this") | 936 // rsp[16] : receiver ("this") |
937 // rsp[24] : function | 937 // rsp[24] : function |
938 { | 938 { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); | 1018 __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); |
1019 __ j(above_equal, &push_receiver); | 1019 __ j(above_equal, &push_receiver); |
1020 | 1020 |
1021 // Convert the receiver to an object. | 1021 // Convert the receiver to an object. |
1022 __ bind(&call_to_object); | 1022 __ bind(&call_to_object); |
1023 __ push(rbx); | 1023 __ push(rbx); |
1024 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1024 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
1025 __ movq(rbx, rax); | 1025 __ movq(rbx, rax); |
1026 __ jmp(&push_receiver, Label::kNear); | 1026 __ jmp(&push_receiver, Label::kNear); |
1027 | 1027 |
1028 // Use the current global receiver object as the receiver. | |
1029 __ bind(&use_global_receiver); | 1028 __ bind(&use_global_receiver); |
1030 CallStubCompiler::FetchGlobalProxy(masm, rbx, rdi); | 1029 __ movq(rbx, |
| 1030 Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 1031 __ movq(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); |
| 1032 |
1031 // Push the receiver. | 1033 // Push the receiver. |
1032 __ bind(&push_receiver); | 1034 __ bind(&push_receiver); |
1033 __ push(rbx); | 1035 __ push(rbx); |
1034 | 1036 |
1035 // Copy all arguments from the array to the stack. | 1037 // Copy all arguments from the array to the stack. |
1036 Label entry, loop; | 1038 Label entry, loop; |
1037 __ movq(rax, Operand(rbp, kIndexOffset)); | 1039 __ movq(rax, Operand(rbp, kIndexOffset)); |
1038 __ jmp(&entry); | 1040 __ jmp(&entry); |
1039 __ bind(&loop); | 1041 __ bind(&loop); |
1040 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments | 1042 __ movq(rdx, Operand(rbp, kArgumentsOffset)); // load arguments |
(...skipping 12 matching lines...) Expand all Loading... |
1053 | 1055 |
1054 // Update the index on the stack and in register rax. | 1056 // Update the index on the stack and in register rax. |
1055 __ movq(rax, Operand(rbp, kIndexOffset)); | 1057 __ movq(rax, Operand(rbp, kIndexOffset)); |
1056 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); | 1058 __ SmiAddConstant(rax, rax, Smi::FromInt(1)); |
1057 __ movq(Operand(rbp, kIndexOffset), rax); | 1059 __ movq(Operand(rbp, kIndexOffset), rax); |
1058 | 1060 |
1059 __ bind(&entry); | 1061 __ bind(&entry); |
1060 __ cmpq(rax, Operand(rbp, kLimitOffset)); | 1062 __ cmpq(rax, Operand(rbp, kLimitOffset)); |
1061 __ j(not_equal, &loop); | 1063 __ j(not_equal, &loop); |
1062 | 1064 |
1063 // Invoke the function. | 1065 // Call the function. |
1064 Label call_proxy; | 1066 Label call_proxy; |
1065 ParameterCount actual(rax); | 1067 ParameterCount actual(rax); |
1066 __ SmiToInteger32(rax, rax); | 1068 __ SmiToInteger32(rax, rax); |
1067 __ movq(rdi, Operand(rbp, kFunctionOffset)); | 1069 __ movq(rdi, Operand(rbp, kFunctionOffset)); |
1068 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1070 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
1069 __ j(not_equal, &call_proxy); | 1071 __ j(not_equal, &call_proxy); |
1070 __ InvokeFunction(rdi, actual, CALL_FUNCTION, | 1072 __ InvokeFunction(rdi, actual, CALL_FUNCTION, |
1071 NullCallWrapper(), CALL_AS_METHOD); | 1073 NullCallWrapper(), CALL_AS_FUNCTION); |
1072 | 1074 |
1073 frame_scope.GenerateLeaveFrame(); | 1075 frame_scope.GenerateLeaveFrame(); |
1074 __ ret(3 * kPointerSize); // remove this, receiver, and arguments | 1076 __ ret(3 * kPointerSize); // remove this, receiver, and arguments |
1075 | 1077 |
1076 // Invoke the function proxy. | 1078 // Call the function proxy. |
1077 __ bind(&call_proxy); | 1079 __ bind(&call_proxy); |
1078 __ push(rdi); // add function proxy as last argument | 1080 __ push(rdi); // add function proxy as last argument |
1079 __ incq(rax); | 1081 __ incq(rax); |
1080 __ Set(rbx, 0); | 1082 __ Set(rbx, 0); |
1081 __ SetCallKind(rcx, CALL_AS_METHOD); | 1083 __ SetCallKind(rcx, CALL_AS_FUNCTION); |
1082 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); | 1084 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); |
1083 __ call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1085 __ call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1084 RelocInfo::CODE_TARGET); | 1086 RelocInfo::CODE_TARGET); |
1085 | 1087 |
1086 // Leave internal frame. | 1088 // Leave internal frame. |
1087 } | 1089 } |
1088 __ ret(3 * kPointerSize); // remove this, receiver, and arguments | 1090 __ ret(3 * kPointerSize); // remove this, receiver, and arguments |
1089 } | 1091 } |
1090 | 1092 |
1091 | 1093 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 __ bind(&ok); | 1451 __ bind(&ok); |
1450 __ ret(0); | 1452 __ ret(0); |
1451 } | 1453 } |
1452 | 1454 |
1453 | 1455 |
1454 #undef __ | 1456 #undef __ |
1455 | 1457 |
1456 } } // namespace v8::internal | 1458 } } // namespace v8::internal |
1457 | 1459 |
1458 #endif // V8_TARGET_ARCH_X64 | 1460 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |