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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 __ pop(ebx); // Discard copy of return address. | 997 __ pop(ebx); // Discard copy of return address. |
998 __ dec(eax); // One fewer argument (first argument is new receiver). | 998 __ dec(eax); // One fewer argument (first argument is new receiver). |
999 } | 999 } |
1000 | 1000 |
1001 // 4. Call the callable. | 1001 // 4. Call the callable. |
1002 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1002 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1003 } | 1003 } |
1004 | 1004 |
1005 | 1005 |
1006 static void Generate_PushAppliedArguments(MacroAssembler* masm, | 1006 static void Generate_PushAppliedArguments(MacroAssembler* masm, |
| 1007 const int vectorOffset, |
1007 const int argumentsOffset, | 1008 const int argumentsOffset, |
1008 const int indexOffset, | 1009 const int indexOffset, |
1009 const int limitOffset) { | 1010 const int limitOffset) { |
1010 // Copy all arguments from the array to the stack. | 1011 // Copy all arguments from the array to the stack. |
1011 Label entry, loop; | 1012 Label entry, loop; |
1012 Register receiver = LoadDescriptor::ReceiverRegister(); | 1013 Register receiver = LoadDescriptor::ReceiverRegister(); |
1013 Register key = LoadDescriptor::NameRegister(); | 1014 Register key = LoadDescriptor::NameRegister(); |
1014 Register slot = LoadDescriptor::SlotRegister(); | 1015 Register slot = LoadDescriptor::SlotRegister(); |
1015 Register vector = LoadWithVectorDescriptor::VectorRegister(); | 1016 Register vector = LoadWithVectorDescriptor::VectorRegister(); |
1016 __ mov(key, Operand(ebp, indexOffset)); | 1017 __ mov(key, Operand(ebp, indexOffset)); |
1017 __ jmp(&entry); | 1018 __ jmp(&entry); |
1018 __ bind(&loop); | 1019 __ bind(&loop); |
1019 __ mov(receiver, Operand(ebp, argumentsOffset)); // load arguments | 1020 __ mov(receiver, Operand(ebp, argumentsOffset)); // load arguments |
1020 | 1021 |
1021 // Use inline caching to speed up access to arguments. | 1022 // Use inline caching to speed up access to arguments. |
1022 Code::Kind kinds[] = {Code::KEYED_LOAD_IC}; | 1023 int slot_index = TypeFeedbackVector::PushAppliedArgumentsIndex(); |
1023 FeedbackVectorSpec spec(0, 1, kinds); | 1024 __ mov(slot, Immediate(Smi::FromInt(slot_index))); |
1024 Handle<TypeFeedbackVector> feedback_vector = | 1025 __ mov(vector, Operand(ebp, vectorOffset)); |
1025 masm->isolate()->factory()->NewTypeFeedbackVector(&spec); | |
1026 int index = feedback_vector->GetIndex(FeedbackVectorICSlot(0)); | |
1027 __ mov(slot, Immediate(Smi::FromInt(index))); | |
1028 __ mov(vector, Immediate(feedback_vector)); | |
1029 Handle<Code> ic = | 1026 Handle<Code> ic = |
1030 KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode(); | 1027 KeyedLoadICStub(masm->isolate(), LoadICState(kNoExtraICState)).GetCode(); |
1031 __ call(ic, RelocInfo::CODE_TARGET); | 1028 __ call(ic, RelocInfo::CODE_TARGET); |
1032 // It is important that we do not have a test instruction after the | 1029 // It is important that we do not have a test instruction after the |
1033 // call. A test instruction after the call is used to indicate that | 1030 // call. A test instruction after the call is used to indicate that |
1034 // we have generated an inline version of the keyed load. In this | 1031 // we have generated an inline version of the keyed load. In this |
1035 // case, we know that we are not generating a test instruction next. | 1032 // case, we know that we are not generating a test instruction next. |
1036 | 1033 |
1037 // Push the nth argument. | 1034 // Push the nth argument. |
1038 __ push(eax); | 1035 __ push(eax); |
(...skipping 27 matching lines...) Expand all Loading... |
1066 FrameScope frame_scope(masm, StackFrame::INTERNAL); | 1063 FrameScope frame_scope(masm, StackFrame::INTERNAL); |
1067 // Stack frame: | 1064 // Stack frame: |
1068 // ebp : Old base pointer | 1065 // ebp : Old base pointer |
1069 // ebp[4] : return address | 1066 // ebp[4] : return address |
1070 // ebp[8] : function arguments | 1067 // ebp[8] : function arguments |
1071 // ebp[12] : receiver | 1068 // ebp[12] : receiver |
1072 // ebp[16] : function | 1069 // ebp[16] : function |
1073 static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize; | 1070 static const int kArgumentsOffset = kFPOnStackSize + kPCOnStackSize; |
1074 static const int kReceiverOffset = kArgumentsOffset + kPointerSize; | 1071 static const int kReceiverOffset = kArgumentsOffset + kPointerSize; |
1075 static const int kFunctionOffset = kReceiverOffset + kPointerSize; | 1072 static const int kFunctionOffset = kReceiverOffset + kPointerSize; |
| 1073 static const int kVectorOffset = |
| 1074 InternalFrameConstants::kCodeOffset - 1 * kPointerSize; |
| 1075 |
| 1076 // Push the vector. |
| 1077 __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 1078 __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset)); |
| 1079 __ push(edi); |
1076 | 1080 |
1077 __ push(Operand(ebp, kFunctionOffset)); // push this | 1081 __ push(Operand(ebp, kFunctionOffset)); // push this |
1078 __ push(Operand(ebp, kArgumentsOffset)); // push arguments | 1082 __ push(Operand(ebp, kArgumentsOffset)); // push arguments |
1079 if (targetIsArgument) { | 1083 if (targetIsArgument) { |
1080 __ InvokeBuiltin(Context::REFLECT_APPLY_PREPARE_BUILTIN_INDEX, | 1084 __ InvokeBuiltin(Context::REFLECT_APPLY_PREPARE_BUILTIN_INDEX, |
1081 CALL_FUNCTION); | 1085 CALL_FUNCTION); |
1082 } else { | 1086 } else { |
1083 __ InvokeBuiltin(Context::APPLY_PREPARE_BUILTIN_INDEX, CALL_FUNCTION); | 1087 __ InvokeBuiltin(Context::APPLY_PREPARE_BUILTIN_INDEX, CALL_FUNCTION); |
1084 } | 1088 } |
1085 | 1089 |
1086 Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged); | 1090 Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged); |
1087 | 1091 |
1088 // Push current index and limit. | 1092 // Push current index and limit. |
1089 const int kLimitOffset = | 1093 const int kLimitOffset = kVectorOffset - 1 * kPointerSize; |
1090 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | |
1091 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 1094 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
1092 __ Push(eax); // limit | 1095 __ Push(eax); // limit |
1093 __ Push(Immediate(0)); // index | 1096 __ Push(Immediate(0)); // index |
1094 __ Push(Operand(ebp, kReceiverOffset)); // receiver | 1097 __ Push(Operand(ebp, kReceiverOffset)); // receiver |
1095 | 1098 |
1096 // Loop over the arguments array, pushing each value to the stack | 1099 // Loop over the arguments array, pushing each value to the stack |
1097 Generate_PushAppliedArguments(masm, kArgumentsOffset, kIndexOffset, | 1100 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
1098 kLimitOffset); | 1101 kIndexOffset, kLimitOffset); |
1099 | 1102 |
1100 // Call the callable. | 1103 // Call the callable. |
1101 // TODO(bmeurer): This should be a tail call according to ES6. | 1104 // TODO(bmeurer): This should be a tail call according to ES6. |
1102 __ mov(edi, Operand(ebp, kFunctionOffset)); | 1105 __ mov(edi, Operand(ebp, kFunctionOffset)); |
1103 __ Call(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1106 __ Call(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1104 | 1107 |
1105 // Leave internal frame. | 1108 // Leave internal frame. |
1106 } | 1109 } |
1107 __ ret(kStackSize * kPointerSize); // remove this, receiver, and arguments | 1110 __ ret(kStackSize * kPointerSize); // remove this, receiver, and arguments |
1108 } | 1111 } |
(...skipping 13 matching lines...) Expand all Loading... |
1122 FrameScope frame_scope(masm, StackFrame::INTERNAL); | 1125 FrameScope frame_scope(masm, StackFrame::INTERNAL); |
1123 // Stack frame: | 1126 // Stack frame: |
1124 // ebp : Old base pointer | 1127 // ebp : Old base pointer |
1125 // ebp[4] : return address | 1128 // ebp[4] : return address |
1126 // ebp[8] : original constructor (new.target) | 1129 // ebp[8] : original constructor (new.target) |
1127 // ebp[12] : arguments | 1130 // ebp[12] : arguments |
1128 // ebp[16] : constructor | 1131 // ebp[16] : constructor |
1129 static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize; | 1132 static const int kNewTargetOffset = kFPOnStackSize + kPCOnStackSize; |
1130 static const int kArgumentsOffset = kNewTargetOffset + kPointerSize; | 1133 static const int kArgumentsOffset = kNewTargetOffset + kPointerSize; |
1131 static const int kFunctionOffset = kArgumentsOffset + kPointerSize; | 1134 static const int kFunctionOffset = kArgumentsOffset + kPointerSize; |
| 1135 static const int kVectorOffset = |
| 1136 InternalFrameConstants::kCodeOffset - 1 * kPointerSize; |
| 1137 |
| 1138 // Push the vector. |
| 1139 __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 1140 __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFeedbackVectorOffset)); |
| 1141 __ push(edi); |
1132 | 1142 |
1133 // If newTarget is not supplied, set it to constructor | 1143 // If newTarget is not supplied, set it to constructor |
1134 Label validate_arguments; | 1144 Label validate_arguments; |
1135 __ mov(eax, Operand(ebp, kNewTargetOffset)); | 1145 __ mov(eax, Operand(ebp, kNewTargetOffset)); |
1136 __ CompareRoot(eax, Heap::kUndefinedValueRootIndex); | 1146 __ CompareRoot(eax, Heap::kUndefinedValueRootIndex); |
1137 __ j(not_equal, &validate_arguments, Label::kNear); | 1147 __ j(not_equal, &validate_arguments, Label::kNear); |
1138 __ mov(eax, Operand(ebp, kFunctionOffset)); | 1148 __ mov(eax, Operand(ebp, kFunctionOffset)); |
1139 __ mov(Operand(ebp, kNewTargetOffset), eax); | 1149 __ mov(Operand(ebp, kNewTargetOffset), eax); |
1140 | 1150 |
1141 // Validate arguments | 1151 // Validate arguments |
1142 __ bind(&validate_arguments); | 1152 __ bind(&validate_arguments); |
1143 __ push(Operand(ebp, kFunctionOffset)); | 1153 __ push(Operand(ebp, kFunctionOffset)); |
1144 __ push(Operand(ebp, kArgumentsOffset)); | 1154 __ push(Operand(ebp, kArgumentsOffset)); |
1145 __ push(Operand(ebp, kNewTargetOffset)); | 1155 __ push(Operand(ebp, kNewTargetOffset)); |
1146 __ InvokeBuiltin(Context::REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX, | 1156 __ InvokeBuiltin(Context::REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX, |
1147 CALL_FUNCTION); | 1157 CALL_FUNCTION); |
1148 | 1158 |
1149 Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged); | 1159 Generate_CheckStackOverflow(masm, kFunctionOffset, kEaxIsSmiTagged); |
1150 | 1160 |
1151 // Push current index and limit. | 1161 // Push current index and limit. |
1152 const int kLimitOffset = | 1162 const int kLimitOffset = kVectorOffset - 1 * kPointerSize; |
1153 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | |
1154 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 1163 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
1155 __ Push(eax); // limit | 1164 __ Push(eax); // limit |
1156 __ push(Immediate(0)); // index | 1165 __ push(Immediate(0)); // index |
1157 // Push the constructor function as callee. | 1166 // Push the constructor function as callee. |
1158 __ push(Operand(ebp, kFunctionOffset)); | 1167 __ push(Operand(ebp, kFunctionOffset)); |
1159 | 1168 |
1160 // Loop over the arguments array, pushing each value to the stack | 1169 // Loop over the arguments array, pushing each value to the stack |
1161 Generate_PushAppliedArguments( | 1170 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
1162 masm, kArgumentsOffset, kIndexOffset, kLimitOffset); | 1171 kIndexOffset, kLimitOffset); |
1163 | 1172 |
1164 // Use undefined feedback vector | 1173 // Use undefined feedback vector |
1165 __ LoadRoot(ebx, Heap::kUndefinedValueRootIndex); | 1174 __ LoadRoot(ebx, Heap::kUndefinedValueRootIndex); |
1166 __ mov(edi, Operand(ebp, kFunctionOffset)); | 1175 __ mov(edi, Operand(ebp, kFunctionOffset)); |
1167 __ mov(ecx, Operand(ebp, kNewTargetOffset)); | 1176 __ mov(ecx, Operand(ebp, kNewTargetOffset)); |
1168 | 1177 |
1169 // Call the function. | 1178 // Call the function. |
1170 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); | 1179 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); |
1171 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 1180 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
1172 | 1181 |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 | 1759 |
1751 __ bind(&ok); | 1760 __ bind(&ok); |
1752 __ ret(0); | 1761 __ ret(0); |
1753 } | 1762 } |
1754 | 1763 |
1755 #undef __ | 1764 #undef __ |
1756 } // namespace internal | 1765 } // namespace internal |
1757 } // namespace v8 | 1766 } // namespace v8 |
1758 | 1767 |
1759 #endif // V8_TARGET_ARCH_X87 | 1768 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |