OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 988 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
989 } | 989 } |
990 | 990 |
991 | 991 |
992 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 992 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
993 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 993 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
994 } | 994 } |
995 | 995 |
996 | 996 |
997 // static | 997 // static |
998 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { | 998 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
999 // Stack Layout: | |
1000 // esp[0] : Return address | |
1001 // esp[8] : Argument n | |
1002 // esp[16] : Argument n-1 | |
1003 // ... | |
1004 // esp[8 * n] : Argument 1 | |
1005 // esp[8 * (n + 1)] : Receiver (callable to call) | |
1006 // | |
1007 // eax contains the number of arguments, n, not counting the receiver. | |
1008 // | |
1009 // 1. Make sure we have at least one argument. | |
1010 { | |
1011 Label done; | |
1012 __ test(eax, eax); | |
1013 __ j(not_zero, &done, Label::kNear); | |
1014 __ PopReturnAddressTo(ebx); | |
1015 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1016 __ PushReturnAddressFrom(ebx); | |
1017 __ inc(eax); | |
1018 __ bind(&done); | |
1019 } | |
1020 | |
1021 // 2. Get the callable to call (passed as receiver) from the stack. | |
1022 __ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize)); | |
1023 | |
1024 // 3. Shift arguments and return address one slot down on the stack | |
1025 // (overwriting the original receiver). Adjust argument count to make | |
1026 // the original first argument the new receiver. | |
1027 { | |
1028 Label loop; | |
1029 __ mov(ecx, eax); | |
1030 __ bind(&loop); | |
1031 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); | |
1032 __ mov(Operand(esp, ecx, times_pointer_size, kPointerSize), ebx); | |
1033 __ dec(ecx); | |
1034 __ j(not_sign, &loop); // While non-negative (to copy return address). | |
1035 __ pop(ebx); // Discard copy of return address. | |
1036 __ dec(eax); // One fewer argument (first argument is new receiver). | |
1037 } | |
1038 | |
1039 // 4. Call the callable. | |
1040 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | |
1041 } | |
1042 | |
1043 | |
1044 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | |
1045 // ----------- S t a t e ------------- | 999 // ----------- S t a t e ------------- |
1046 // -- eax : argc | 1000 // -- eax : argc |
1047 // -- esp[0] : return address | 1001 // -- esp[0] : return address |
1048 // -- esp[4] : argArray | 1002 // -- esp[4] : argArray |
1049 // -- esp[8] : thisArg | 1003 // -- esp[8] : thisArg |
1050 // -- esp[12] : receiver | 1004 // -- esp[12] : receiver |
1051 // ----------------------------------- | 1005 // ----------------------------------- |
1052 | 1006 |
1053 // 1. Load receiver into edi, argArray into eax (if present), remove all | 1007 // 1. Load receiver into edi, argArray into eax (if present), remove all |
1054 // arguments from the stack (including the receiver), and push thisArg (if | 1008 // arguments from the stack (including the receiver), and push thisArg (if |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1064 |
1111 // 4c. The receiver is not callable, throw an appropriate TypeError. | 1065 // 4c. The receiver is not callable, throw an appropriate TypeError. |
1112 __ bind(&receiver_not_callable); | 1066 __ bind(&receiver_not_callable); |
1113 { | 1067 { |
1114 __ mov(Operand(esp, kPointerSize), edi); | 1068 __ mov(Operand(esp, kPointerSize), edi); |
1115 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); | 1069 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); |
1116 } | 1070 } |
1117 } | 1071 } |
1118 | 1072 |
1119 | 1073 |
| 1074 // static |
| 1075 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
| 1076 // Stack Layout: |
| 1077 // esp[0] : Return address |
| 1078 // esp[8] : Argument n |
| 1079 // esp[16] : Argument n-1 |
| 1080 // ... |
| 1081 // esp[8 * n] : Argument 1 |
| 1082 // esp[8 * (n + 1)] : Receiver (callable to call) |
| 1083 // |
| 1084 // eax contains the number of arguments, n, not counting the receiver. |
| 1085 // |
| 1086 // 1. Make sure we have at least one argument. |
| 1087 { |
| 1088 Label done; |
| 1089 __ test(eax, eax); |
| 1090 __ j(not_zero, &done, Label::kNear); |
| 1091 __ PopReturnAddressTo(ebx); |
| 1092 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1093 __ PushReturnAddressFrom(ebx); |
| 1094 __ inc(eax); |
| 1095 __ bind(&done); |
| 1096 } |
| 1097 |
| 1098 // 2. Get the callable to call (passed as receiver) from the stack. |
| 1099 __ mov(edi, Operand(esp, eax, times_pointer_size, kPointerSize)); |
| 1100 |
| 1101 // 3. Shift arguments and return address one slot down on the stack |
| 1102 // (overwriting the original receiver). Adjust argument count to make |
| 1103 // the original first argument the new receiver. |
| 1104 { |
| 1105 Label loop; |
| 1106 __ mov(ecx, eax); |
| 1107 __ bind(&loop); |
| 1108 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); |
| 1109 __ mov(Operand(esp, ecx, times_pointer_size, kPointerSize), ebx); |
| 1110 __ dec(ecx); |
| 1111 __ j(not_sign, &loop); // While non-negative (to copy return address). |
| 1112 __ pop(ebx); // Discard copy of return address. |
| 1113 __ dec(eax); // One fewer argument (first argument is new receiver). |
| 1114 } |
| 1115 |
| 1116 // 4. Call the callable. |
| 1117 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1118 } |
| 1119 |
| 1120 |
1120 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { | 1121 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
1121 // ----------- S t a t e ------------- | 1122 // ----------- S t a t e ------------- |
1122 // -- eax : argc | 1123 // -- eax : argc |
1123 // -- esp[0] : return address | 1124 // -- esp[0] : return address |
1124 // -- esp[4] : argumentsList | 1125 // -- esp[4] : argumentsList |
1125 // -- esp[8] : thisArgument | 1126 // -- esp[8] : thisArgument |
1126 // -- esp[12] : target | 1127 // -- esp[12] : target |
1127 // -- esp[16] : receiver | 1128 // -- esp[16] : receiver |
1128 // ----------------------------------- | 1129 // ----------------------------------- |
1129 | 1130 |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 | 2216 |
2216 __ bind(&ok); | 2217 __ bind(&ok); |
2217 __ ret(0); | 2218 __ ret(0); |
2218 } | 2219 } |
2219 | 2220 |
2220 #undef __ | 2221 #undef __ |
2221 } // namespace internal | 2222 } // namespace internal |
2222 } // namespace v8 | 2223 } // namespace v8 |
2223 | 2224 |
2224 #endif // V8_TARGET_ARCH_IA32 | 2225 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |