| 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 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 namespace compiler { | 10 namespace compiler { |
| 11 | 11 |
| 12 class LinkageHelper { | 12 class LinkageHelper { |
| 13 public: | 13 public: |
| 14 static LinkageLocation TaggedStackSlot(int index) { | 14 static LinkageLocation TaggedStackSlot(int index) { |
| 15 DCHECK(index < 0); | 15 DCHECK(index < 0); |
| 16 return LinkageLocation(kMachAnyTagged, index); | 16 return LinkageLocation(kMachAnyTagged, index); |
| 17 } | 17 } |
| 18 | 18 |
| 19 static LinkageLocation TaggedRegisterLocation(Register reg) { | 19 static LinkageLocation TaggedRegisterLocation(Register reg) { |
| 20 return LinkageLocation(kMachAnyTagged, Register::ToAllocationIndex(reg)); | 20 return LinkageLocation(kMachAnyTagged, Register::ToAllocationIndex(reg)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 static inline LinkageLocation WordRegisterLocation(Register reg) { | 23 static inline LinkageLocation WordRegisterLocation(Register reg) { |
| 24 return LinkageLocation(MachineOperatorBuilder::pointer_rep(), | 24 return LinkageLocation(kMachPtr, Register::ToAllocationIndex(reg)); |
| 25 Register::ToAllocationIndex(reg)); | |
| 26 } | 25 } |
| 27 | 26 |
| 28 static LinkageLocation UnconstrainedRegister(MachineType rep) { | 27 static LinkageLocation UnconstrainedRegister(MachineType rep) { |
| 29 return LinkageLocation(rep, LinkageLocation::ANY_REGISTER); | 28 return LinkageLocation(rep, LinkageLocation::ANY_REGISTER); |
| 30 } | 29 } |
| 31 | 30 |
| 32 static const RegList kNoCalleeSaved = 0; | 31 static const RegList kNoCalleeSaved = 0; |
| 33 | 32 |
| 34 // TODO(turbofan): cache call descriptors for JSFunction calls. | 33 // TODO(turbofan): cache call descriptors for JSFunction calls. |
| 35 template <typename LinkageTraits> | 34 template <typename LinkageTraits> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 172 |
| 174 template <typename LinkageTraits> | 173 template <typename LinkageTraits> |
| 175 static CallDescriptor* GetSimplifiedCDescriptor( | 174 static CallDescriptor* GetSimplifiedCDescriptor( |
| 176 Zone* zone, int num_params, MachineType return_type, | 175 Zone* zone, int num_params, MachineType return_type, |
| 177 const MachineType* param_types) { | 176 const MachineType* param_types) { |
| 178 LinkageLocation* locations = | 177 LinkageLocation* locations = |
| 179 zone->NewArray<LinkageLocation>(num_params + 2); | 178 zone->NewArray<LinkageLocation>(num_params + 2); |
| 180 int index = 0; | 179 int index = 0; |
| 181 locations[index++] = | 180 locations[index++] = |
| 182 TaggedRegisterLocation(LinkageTraits::ReturnValueReg()); | 181 TaggedRegisterLocation(LinkageTraits::ReturnValueReg()); |
| 183 locations[index++] = LinkageHelper::UnconstrainedRegister( | 182 locations[index++] = LinkageHelper::UnconstrainedRegister(kMachPtr); |
| 184 MachineOperatorBuilder::pointer_rep()); | |
| 185 // TODO(dcarney): test with lots of parameters. | 183 // TODO(dcarney): test with lots of parameters. |
| 186 int i = 0; | 184 int i = 0; |
| 187 for (; i < LinkageTraits::CRegisterParametersLength() && i < num_params; | 185 for (; i < LinkageTraits::CRegisterParametersLength() && i < num_params; |
| 188 i++) { | 186 i++) { |
| 189 locations[index++] = LinkageLocation( | 187 locations[index++] = LinkageLocation( |
| 190 param_types[i], | 188 param_types[i], |
| 191 Register::ToAllocationIndex(LinkageTraits::CRegisterParameter(i))); | 189 Register::ToAllocationIndex(LinkageTraits::CRegisterParameter(i))); |
| 192 } | 190 } |
| 193 for (; i < num_params; i++) { | 191 for (; i < num_params; i++) { |
| 194 locations[index++] = LinkageLocation(param_types[i], -1 - i); | 192 locations[index++] = LinkageLocation(param_types[i], -1 - i); |
| 195 } | 193 } |
| 196 return new (zone) CallDescriptor( | 194 return new (zone) CallDescriptor( |
| 197 CallDescriptor::kCallAddress, 1, num_params, num_params + 1, locations, | 195 CallDescriptor::kCallAddress, 1, num_params, num_params + 1, locations, |
| 198 Operator::kNoProperties, LinkageTraits::CCalleeSaveRegisters(), | 196 Operator::kNoProperties, LinkageTraits::CCalleeSaveRegisters(), |
| 199 CallDescriptor::kNoDeoptimization); // TODO(jarin) should deoptimize! | 197 CallDescriptor::kNoDeoptimization); // TODO(jarin) should deoptimize! |
| 200 } | 198 } |
| 201 }; | 199 }; |
| 202 } | 200 } |
| 203 } | 201 } |
| 204 } // namespace v8::internal::compiler | 202 } // namespace v8::internal::compiler |
| 205 | 203 |
| 206 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 204 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
| OLD | NEW |