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 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 // TODO(titzer): refactor TurboFan graph to consider context a value input. | 58 // TODO(titzer): refactor TurboFan graph to consider context a value input. |
59 return new (zone) | 59 return new (zone) |
60 CallDescriptor(CallDescriptor::kCallJSFunction, // kind | 60 CallDescriptor(CallDescriptor::kCallJSFunction, // kind |
61 return_count, // return_count | 61 return_count, // return_count |
62 parameter_count, // parameter_count | 62 parameter_count, // parameter_count |
63 input_count - context_count, // input_count | 63 input_count - context_count, // input_count |
64 locations, // locations | 64 locations, // locations |
65 Operator::kNoProperties, // properties | 65 Operator::kNoProperties, // properties |
66 kNoCalleeSaved, // callee-saved registers | 66 kNoCalleeSaved, // callee-saved registers |
67 CallDescriptor::kLazyDeoptimization); // deoptimization | 67 CallDescriptor::kLazyDeoptimization); // flags |
68 } | 68 } |
69 | 69 |
70 | 70 |
71 // TODO(turbofan): cache call descriptors for runtime calls. | 71 // TODO(turbofan): cache call descriptors for runtime calls. |
72 template <typename LinkageTraits> | 72 template <typename LinkageTraits> |
73 static CallDescriptor* GetRuntimeCallDescriptor( | 73 static CallDescriptor* GetRuntimeCallDescriptor( |
74 Zone* zone, Runtime::FunctionId function_id, int parameter_count, | 74 Zone* zone, Runtime::FunctionId function_id, int parameter_count, |
75 Operator::Property properties, | 75 Operator::Property properties, CallDescriptor::Flags flags) { |
76 CallDescriptor::DeoptimizationSupport can_deoptimize) { | |
77 const int code_count = 1; | 76 const int code_count = 1; |
78 const int function_count = 1; | 77 const int function_count = 1; |
79 const int num_args_count = 1; | 78 const int num_args_count = 1; |
80 const int context_count = 1; | 79 const int context_count = 1; |
81 const int input_count = code_count + parameter_count + function_count + | 80 const int input_count = code_count + parameter_count + function_count + |
82 num_args_count + context_count; | 81 num_args_count + context_count; |
83 | 82 |
84 const Runtime::Function* function = Runtime::FunctionForId(function_id); | 83 const Runtime::Function* function = Runtime::FunctionForId(function_id); |
85 const int return_count = function->result_size; | 84 const int return_count = function->result_size; |
86 LinkageLocation* locations = | 85 LinkageLocation* locations = |
(...skipping 25 matching lines...) Expand all Loading... |
112 locations[index++] = TaggedRegisterLocation(LinkageTraits::ContextReg()); | 111 locations[index++] = TaggedRegisterLocation(LinkageTraits::ContextReg()); |
113 | 112 |
114 // TODO(titzer): refactor TurboFan graph to consider context a value input. | 113 // TODO(titzer): refactor TurboFan graph to consider context a value input. |
115 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind | 114 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind |
116 return_count, // return_count | 115 return_count, // return_count |
117 parameter_count, // parameter_count | 116 parameter_count, // parameter_count |
118 input_count, // input_count | 117 input_count, // input_count |
119 locations, // locations | 118 locations, // locations |
120 properties, // properties | 119 properties, // properties |
121 kNoCalleeSaved, // callee-saved registers | 120 kNoCalleeSaved, // callee-saved registers |
122 can_deoptimize, // deoptimization | 121 flags, // flags |
123 function->name); | 122 function->name); |
124 } | 123 } |
125 | 124 |
126 | 125 |
127 // TODO(turbofan): cache call descriptors for code stub calls. | 126 // TODO(turbofan): cache call descriptors for code stub calls. |
128 template <typename LinkageTraits> | 127 template <typename LinkageTraits> |
129 static CallDescriptor* GetStubCallDescriptor( | 128 static CallDescriptor* GetStubCallDescriptor( |
130 Zone* zone, CodeStubInterfaceDescriptor* descriptor, | 129 Zone* zone, CodeStubInterfaceDescriptor* descriptor, |
131 int stack_parameter_count, | 130 int stack_parameter_count, CallDescriptor::Flags flags) { |
132 CallDescriptor::DeoptimizationSupport can_deoptimize) { | |
133 int register_parameter_count = descriptor->GetEnvironmentParameterCount(); | 131 int register_parameter_count = descriptor->GetEnvironmentParameterCount(); |
134 int parameter_count = register_parameter_count + stack_parameter_count; | 132 int parameter_count = register_parameter_count + stack_parameter_count; |
135 const int code_count = 1; | 133 const int code_count = 1; |
136 const int context_count = 1; | 134 const int context_count = 1; |
137 int input_count = code_count + parameter_count + context_count; | 135 int input_count = code_count + parameter_count + context_count; |
138 | 136 |
139 const int return_count = 1; | 137 const int return_count = 1; |
140 LinkageLocation* locations = | 138 LinkageLocation* locations = |
141 zone->NewArray<LinkageLocation>(return_count + input_count); | 139 zone->NewArray<LinkageLocation>(return_count + input_count); |
142 | 140 |
(...skipping 16 matching lines...) Expand all Loading... |
159 | 157 |
160 // TODO(titzer): refactor TurboFan graph to consider context a value input. | 158 // TODO(titzer): refactor TurboFan graph to consider context a value input. |
161 return new (zone) | 159 return new (zone) |
162 CallDescriptor(CallDescriptor::kCallCodeObject, // kind | 160 CallDescriptor(CallDescriptor::kCallCodeObject, // kind |
163 return_count, // return_count | 161 return_count, // return_count |
164 parameter_count, // parameter_count | 162 parameter_count, // parameter_count |
165 input_count, // input_count | 163 input_count, // input_count |
166 locations, // locations | 164 locations, // locations |
167 Operator::kNoProperties, // properties | 165 Operator::kNoProperties, // properties |
168 kNoCalleeSaved, // callee-saved registers | 166 kNoCalleeSaved, // callee-saved registers |
169 can_deoptimize, // deoptimization | 167 flags, // flags |
170 CodeStub::MajorName(descriptor->MajorKey(), false)); | 168 CodeStub::MajorName(descriptor->MajorKey(), false)); |
171 } | 169 } |
172 | 170 |
173 | 171 |
174 template <typename LinkageTraits> | 172 template <typename LinkageTraits> |
175 static CallDescriptor* GetSimplifiedCDescriptor( | 173 static CallDescriptor* GetSimplifiedCDescriptor( |
176 Zone* zone, int num_params, MachineType return_type, | 174 Zone* zone, int num_params, MachineType return_type, |
177 const MachineType* param_types) { | 175 const MachineType* param_types) { |
178 LinkageLocation* locations = | 176 LinkageLocation* locations = |
179 zone->NewArray<LinkageLocation>(num_params + 2); | 177 zone->NewArray<LinkageLocation>(num_params + 2); |
180 int index = 0; | 178 int index = 0; |
181 locations[index++] = | 179 locations[index++] = |
182 TaggedRegisterLocation(LinkageTraits::ReturnValueReg()); | 180 TaggedRegisterLocation(LinkageTraits::ReturnValueReg()); |
183 locations[index++] = LinkageHelper::UnconstrainedRegister( | 181 locations[index++] = LinkageHelper::UnconstrainedRegister( |
184 MachineOperatorBuilder::pointer_rep()); | 182 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::kNoFlags); // TODO(jarin) should deoptimize! |
200 } | 198 } |
201 }; | 199 }; |
202 } | 200 |
203 } | 201 } // namespace compiler |
204 } // namespace v8::internal::compiler | 202 } // namespace internal |
| 203 } // namespace v8 |
205 | 204 |
206 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 205 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
OLD | NEW |