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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 // Allocate the new receiver object using the runtime call. | 917 // Allocate the new receiver object using the runtime call. |
918 // a1: constructor function | 918 // a1: constructor function |
919 __ push(a1); // Argument for Runtime_NewObject. | 919 __ push(a1); // Argument for Runtime_NewObject. |
920 __ CallRuntime(Runtime::kNewObject, 1); | 920 __ CallRuntime(Runtime::kNewObject, 1); |
921 __ mov(t4, v0); | 921 __ mov(t4, v0); |
922 | 922 |
923 // Receiver for constructor call allocated. | 923 // Receiver for constructor call allocated. |
924 // t4: JSObject | 924 // t4: JSObject |
925 __ bind(&allocated); | 925 __ bind(&allocated); |
926 __ push(t4); | 926 __ push(t4); |
927 | 927 __ push(t4); |
928 // Push the function and the allocated receiver from the stack. | |
929 // sp[0]: receiver (newly allocated object) | |
930 // sp[1]: constructor function | |
931 // sp[2]: number of arguments (smi-tagged) | |
932 __ lw(a1, MemOperand(sp, kPointerSize)); | |
933 __ MultiPushReversed(a1.bit() | t4.bit()); | |
934 | 928 |
935 // Reload the number of arguments from the stack. | 929 // Reload the number of arguments from the stack. |
936 // a1: constructor function | |
937 // sp[0]: receiver | 930 // sp[0]: receiver |
938 // sp[1]: constructor function | 931 // sp[1]: receiver |
939 // sp[2]: receiver | 932 // sp[2]: constructor function |
940 // sp[3]: constructor function | 933 // sp[3]: number of arguments (smi-tagged) |
941 // sp[4]: number of arguments (smi-tagged) | 934 __ lw(a1, MemOperand(sp, 2 * kPointerSize)); |
942 __ lw(a3, MemOperand(sp, 4 * kPointerSize)); | 935 __ lw(a3, MemOperand(sp, 3 * kPointerSize)); |
943 | 936 |
944 // Set up pointer to last argument. | 937 // Set up pointer to last argument. |
945 __ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); | 938 __ Addu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
946 | 939 |
947 // Set up number of arguments for function call below. | 940 // Set up number of arguments for function call below. |
948 __ srl(a0, a3, kSmiTagSize); | 941 __ srl(a0, a3, kSmiTagSize); |
949 | 942 |
950 // Copy arguments and receiver to the expression stack. | 943 // Copy arguments and receiver to the expression stack. |
951 // a0: number of arguments | 944 // a0: number of arguments |
952 // a1: constructor function | 945 // a1: constructor function |
953 // a2: address of last argument (caller sp) | 946 // a2: address of last argument (caller sp) |
954 // a3: number of arguments (smi-tagged) | 947 // a3: number of arguments (smi-tagged) |
955 // sp[0]: receiver | 948 // sp[0]: receiver |
956 // sp[1]: constructor function | 949 // sp[1]: receiver |
957 // sp[2]: receiver | 950 // sp[2]: constructor function |
958 // sp[3]: constructor function | 951 // sp[3]: number of arguments (smi-tagged) |
959 // sp[4]: number of arguments (smi-tagged) | |
960 Label loop, entry; | 952 Label loop, entry; |
961 __ jmp(&entry); | 953 __ jmp(&entry); |
962 __ bind(&loop); | 954 __ bind(&loop); |
963 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); | 955 __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); |
964 __ Addu(t0, a2, Operand(t0)); | 956 __ Addu(t0, a2, Operand(t0)); |
965 __ lw(t1, MemOperand(t0)); | 957 __ lw(t1, MemOperand(t0)); |
966 __ push(t1); | 958 __ push(t1); |
967 __ bind(&entry); | 959 __ bind(&entry); |
968 __ Addu(a3, a3, Operand(-2)); | 960 __ Addu(a3, a3, Operand(-2)); |
969 __ Branch(&loop, greater_equal, a3, Operand(zero_reg)); | 961 __ Branch(&loop, greater_equal, a3, Operand(zero_reg)); |
970 | 962 |
971 // Call the function. | 963 // Call the function. |
972 // a0: number of arguments | 964 // a0: number of arguments |
973 // a1: constructor function | 965 // a1: constructor function |
974 if (is_api_function) { | 966 if (is_api_function) { |
975 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 967 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
976 Handle<Code> code = | 968 Handle<Code> code = |
977 masm->isolate()->builtins()->HandleApiCallConstruct(); | 969 masm->isolate()->builtins()->HandleApiCallConstruct(); |
978 ParameterCount expected(0); | 970 ParameterCount expected(0); |
979 __ InvokeCode(code, expected, expected, | 971 __ InvokeCode(code, expected, expected, |
980 RelocInfo::CODE_TARGET, CALL_FUNCTION, CALL_AS_METHOD); | 972 RelocInfo::CODE_TARGET, CALL_FUNCTION, CALL_AS_METHOD); |
981 } else { | 973 } else { |
982 ParameterCount actual(a0); | 974 ParameterCount actual(a0); |
983 __ InvokeFunction(a1, actual, CALL_FUNCTION, | 975 __ InvokeFunction(a1, actual, CALL_FUNCTION, |
984 NullCallWrapper(), CALL_AS_METHOD); | 976 NullCallWrapper(), CALL_AS_METHOD); |
985 } | 977 } |
986 | 978 |
987 // Pop the function from the stack. | |
988 // v0: result | |
989 // sp[0]: constructor function | |
990 // sp[2]: receiver | |
991 // sp[3]: constructor function | |
992 // sp[4]: number of arguments (smi-tagged) | |
993 __ Pop(); | |
994 | |
995 // Restore context from the frame. | 979 // Restore context from the frame. |
996 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 980 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
997 | 981 |
998 // If the result is an object (in the ECMA sense), we should get rid | 982 // If the result is an object (in the ECMA sense), we should get rid |
999 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 983 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
1000 // on page 74. | 984 // on page 74. |
1001 Label use_receiver, exit; | 985 Label use_receiver, exit; |
1002 | 986 |
1003 // If the result is a smi, it is *not* an object in the ECMA sense. | 987 // If the result is a smi, it is *not* an object in the ECMA sense. |
1004 // v0: result | 988 // v0: result |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 __ bind(&dont_adapt_arguments); | 1757 __ bind(&dont_adapt_arguments); |
1774 __ Jump(a3); | 1758 __ Jump(a3); |
1775 } | 1759 } |
1776 | 1760 |
1777 | 1761 |
1778 #undef __ | 1762 #undef __ |
1779 | 1763 |
1780 } } // namespace v8::internal | 1764 } } // namespace v8::internal |
1781 | 1765 |
1782 #endif // V8_TARGET_ARCH_MIPS | 1766 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |