OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ | 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ |
6 #define V8_COMPILER_LINKAGE_IMPL_H_ | 6 #define V8_COMPILER_LINKAGE_IMPL_H_ |
7 | 7 |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Add context. | 115 // Add context. |
116 locations.AddParam(regloc(LinkageTraits::ContextReg())); | 116 locations.AddParam(regloc(LinkageTraits::ContextReg())); |
117 types.AddParam(kMachAnyTagged); | 117 types.AddParam(kMachAnyTagged); |
118 | 118 |
119 CallDescriptor::Flags flags = Linkage::FrameStateInputCount(function_id) > 0 | 119 CallDescriptor::Flags flags = Linkage::FrameStateInputCount(function_id) > 0 |
120 ? CallDescriptor::kNeedsFrameState | 120 ? CallDescriptor::kNeedsFrameState |
121 : CallDescriptor::kNoFlags; | 121 : CallDescriptor::kNoFlags; |
122 | 122 |
123 // The target for runtime calls is a code object. | 123 // The target for runtime calls is a code object. |
124 MachineType target_type = kMachAnyTagged; | 124 MachineType target_type = kMachAnyTagged; |
125 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 125 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
126 return new (zone) CallDescriptor( // -- | 126 return new (zone) CallDescriptor( // -- |
127 CallDescriptor::kCallCodeObject, // kind | 127 CallDescriptor::kCallCodeObject, // kind |
128 target_type, // target MachineType | 128 target_type, // target MachineType |
129 target_loc, // target location | 129 target_loc, // target location |
130 types.Build(), // machine_sig | 130 types.Build(), // machine_sig |
131 locations.Build(), // location_sig | 131 locations.Build(), // location_sig |
132 js_parameter_count, // js_parameter_count | 132 js_parameter_count, // js_parameter_count |
133 properties, // properties | 133 properties, // properties |
134 kNoCalleeSaved, // callee-saved | 134 kNoCalleeSaved, // callee-saved |
135 kNoCalleeSaved, // callee-saved fp | 135 kNoCalleeSaved, // callee-saved fp |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 locations.AddParam(stackloc(stack_slot)); | 175 locations.AddParam(stackloc(stack_slot)); |
176 types.AddParam(kMachAnyTagged); | 176 types.AddParam(kMachAnyTagged); |
177 } | 177 } |
178 } | 178 } |
179 // Add context. | 179 // Add context. |
180 locations.AddParam(regloc(LinkageTraits::ContextReg())); | 180 locations.AddParam(regloc(LinkageTraits::ContextReg())); |
181 types.AddParam(kMachAnyTagged); | 181 types.AddParam(kMachAnyTagged); |
182 | 182 |
183 // The target for stub calls is a code object. | 183 // The target for stub calls is a code object. |
184 MachineType target_type = kMachAnyTagged; | 184 MachineType target_type = kMachAnyTagged; |
185 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 185 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
186 return new (zone) CallDescriptor( // -- | 186 return new (zone) CallDescriptor( // -- |
187 CallDescriptor::kCallCodeObject, // kind | 187 CallDescriptor::kCallCodeObject, // kind |
188 target_type, // target MachineType | 188 target_type, // target MachineType |
189 target_loc, // target location | 189 target_loc, // target location |
190 types.Build(), // machine_sig | 190 types.Build(), // machine_sig |
191 locations.Build(), // location_sig | 191 locations.Build(), // location_sig |
192 js_parameter_count, // js_parameter_count | 192 js_parameter_count, // js_parameter_count |
193 properties, // properties | 193 properties, // properties |
194 kNoCalleeSaved, // callee-saved registers | 194 kNoCalleeSaved, // callee-saved registers |
195 kNoCalleeSaved, // callee-saved fp | 195 kNoCalleeSaved, // callee-saved fp |
(...skipping 11 matching lines...) Expand all Loading... |
207 locations.AddParam(regloc(LinkageTraits::InterpreterBytecodeOffsetReg())); | 207 locations.AddParam(regloc(LinkageTraits::InterpreterBytecodeOffsetReg())); |
208 | 208 |
209 STATIC_ASSERT(1 == Linkage::kInterpreterBytecodeArrayParameter); | 209 STATIC_ASSERT(1 == Linkage::kInterpreterBytecodeArrayParameter); |
210 types.AddParam(kMachAnyTagged); | 210 types.AddParam(kMachAnyTagged); |
211 locations.AddParam(regloc(LinkageTraits::InterpreterBytecodeArrayReg())); | 211 locations.AddParam(regloc(LinkageTraits::InterpreterBytecodeArrayReg())); |
212 | 212 |
213 STATIC_ASSERT(2 == Linkage::kInterpreterDispatchTableParameter); | 213 STATIC_ASSERT(2 == Linkage::kInterpreterDispatchTableParameter); |
214 types.AddParam(kMachPtr); | 214 types.AddParam(kMachPtr); |
215 locations.AddParam(regloc(LinkageTraits::InterpreterDispatchTableReg())); | 215 locations.AddParam(regloc(LinkageTraits::InterpreterDispatchTableReg())); |
216 | 216 |
217 LinkageLocation target_loc = LinkageLocation::AnyRegister(); | 217 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
218 return new (zone) CallDescriptor( // -- | 218 return new (zone) CallDescriptor( // -- |
219 CallDescriptor::kInterpreterDispatch, // kind | 219 CallDescriptor::kInterpreterDispatch, // kind |
220 kMachNone, // target MachineType | 220 kMachNone, // target MachineType |
221 target_loc, // target location | 221 target_loc, // target location |
222 types.Build(), // machine_sig | 222 types.Build(), // machine_sig |
223 locations.Build(), // location_sig | 223 locations.Build(), // location_sig |
224 0, // js_parameter_count | 224 0, // js_parameter_count |
225 Operator::kNoProperties, // properties | 225 Operator::kNoProperties, // properties |
226 kNoCalleeSaved, // callee-saved registers | 226 kNoCalleeSaved, // callee-saved registers |
227 kNoCalleeSaved, // callee-saved fp regs | 227 kNoCalleeSaved, // callee-saved fp regs |
228 CallDescriptor::kSupportsTailCalls, // flags | 228 CallDescriptor::kSupportsTailCalls, // flags |
229 "interpreter-dispatch"); | 229 "interpreter-dispatch"); |
230 } | 230 } |
231 | 231 |
232 static LinkageLocation regloc(Register reg) { | 232 static LinkageLocation regloc(Register reg) { |
233 return LinkageLocation(Register::ToAllocationIndex(reg)); | 233 return LinkageLocation::ForRegister(Register::ToAllocationIndex(reg)); |
234 } | 234 } |
235 | 235 |
236 static LinkageLocation stackloc(int i) { | 236 static LinkageLocation stackloc(int i) { |
237 DCHECK_LT(i, 0); | 237 return LinkageLocation::ForCallerFrameSlot(i); |
238 return LinkageLocation(i); | |
239 } | 238 } |
240 | 239 |
241 static MachineType reptyp(Representation representation) { | 240 static MachineType reptyp(Representation representation) { |
242 switch (representation.kind()) { | 241 switch (representation.kind()) { |
243 case Representation::kInteger8: | 242 case Representation::kInteger8: |
244 return kMachInt8; | 243 return kMachInt8; |
245 case Representation::kUInteger8: | 244 case Representation::kUInteger8: |
246 return kMachUint8; | 245 return kMachUint8; |
247 case Representation::kInteger16: | 246 case Representation::kInteger16: |
248 return kMachInt16; | 247 return kMachInt16; |
(...skipping 24 matching lines...) Expand all Loading... |
273 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); | 272 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); |
274 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); | 273 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); |
275 | 274 |
276 if (index == kOsrContextSpillSlotIndex) { | 275 if (index == kOsrContextSpillSlotIndex) { |
277 // Context. Use the parameter location of the context spill slot. | 276 // Context. Use the parameter location of the context spill slot. |
278 // Parameter (arity + 1) is special for the context of the function frame. | 277 // Parameter (arity + 1) is special for the context of the function frame. |
279 int context_index = 1 + 1 + parameter_count; // target + receiver + params | 278 int context_index = 1 + 1 + parameter_count; // target + receiver + params |
280 return incoming_->GetInputLocation(context_index); | 279 return incoming_->GetInputLocation(context_index); |
281 } else if (index >= first_stack_slot) { | 280 } else if (index >= first_stack_slot) { |
282 // Local variable stored in this (callee) stack. | 281 // Local variable stored in this (callee) stack. |
283 int spill_index = | 282 int spill_index = index - first_stack_slot; |
284 LinkageLocation::ANY_REGISTER + 1 + index - first_stack_slot; | 283 return LinkageLocation::ForCalleeFrameSlot(spill_index); |
285 // TODO(titzer): bailout instead of crashing here. | |
286 CHECK(spill_index <= LinkageLocation::MAX_STACK_SLOT); | |
287 return LinkageLocation(spill_index); | |
288 } else { | 284 } else { |
289 // Parameter. Use the assigned location from the incoming call descriptor. | 285 // Parameter. Use the assigned location from the incoming call descriptor. |
290 int parameter_index = 1 + index; // skip index 0, which is the target. | 286 int parameter_index = 1 + index; // skip index 0, which is the target. |
291 return incoming_->GetInputLocation(parameter_index); | 287 return incoming_->GetInputLocation(parameter_index); |
292 } | 288 } |
293 } | 289 } |
294 | 290 |
295 } // namespace compiler | 291 } // namespace compiler |
296 } // namespace internal | 292 } // namespace internal |
297 } // namespace v8 | 293 } // namespace v8 |
298 | 294 |
299 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 295 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
OLD | NEW |