Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: src/compiler/linkage-impl.h

Issue 1019293002: [turbofan] Use proper parameter representation for stub calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 // Add return location. 158 // Add return location.
159 AddReturnLocations(&locations); 159 AddReturnLocations(&locations);
160 types.AddReturn(kMachAnyTagged); 160 types.AddReturn(kMachAnyTagged);
161 161
162 // Add parameters in registers and on the stack. 162 // Add parameters in registers and on the stack.
163 for (int i = 0; i < js_parameter_count; i++) { 163 for (int i = 0; i < js_parameter_count; i++) {
164 if (i < register_parameter_count) { 164 if (i < register_parameter_count) {
165 // The first parameters go in registers. 165 // The first parameters go in registers.
166 Register reg = descriptor.GetEnvironmentParameterRegister(i); 166 Register reg = descriptor.GetEnvironmentParameterRegister(i);
167 Representation rep =
168 descriptor.GetEnvironmentParameterRepresentation(i);
167 locations.AddParam(regloc(reg)); 169 locations.AddParam(regloc(reg));
170 types.AddParam(reptyp(rep));
168 } else { 171 } else {
169 // The rest of the parameters go on the stack. 172 // The rest of the parameters go on the stack.
170 int stack_slot = i - register_parameter_count - stack_parameter_count; 173 int stack_slot = i - register_parameter_count - stack_parameter_count;
171 locations.AddParam(stackloc(stack_slot)); 174 locations.AddParam(stackloc(stack_slot));
175 types.AddParam(kMachAnyTagged);
172 } 176 }
173 types.AddParam(kMachAnyTagged);
174 } 177 }
175 // Add context. 178 // Add context.
176 locations.AddParam(regloc(LinkageTraits::ContextReg())); 179 locations.AddParam(regloc(LinkageTraits::ContextReg()));
177 types.AddParam(kMachAnyTagged); 180 types.AddParam(kMachAnyTagged);
178 181
179 // The target for stub calls is a code object. 182 // The target for stub calls is a code object.
180 MachineType target_type = kMachAnyTagged; 183 MachineType target_type = kMachAnyTagged;
181 LinkageLocation target_loc = LinkageLocation::AnyRegister(); 184 LinkageLocation target_loc = LinkageLocation::AnyRegister();
182 return new (zone) CallDescriptor( // -- 185 return new (zone) CallDescriptor( // --
183 CallDescriptor::kCallCodeObject, // kind 186 CallDescriptor::kCallCodeObject, // kind
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 228 }
226 229
227 static LinkageLocation regloc(Register reg) { 230 static LinkageLocation regloc(Register reg) {
228 return LinkageLocation(Register::ToAllocationIndex(reg)); 231 return LinkageLocation(Register::ToAllocationIndex(reg));
229 } 232 }
230 233
231 static LinkageLocation stackloc(int i) { 234 static LinkageLocation stackloc(int i) {
232 DCHECK_LT(i, 0); 235 DCHECK_LT(i, 0);
233 return LinkageLocation(i); 236 return LinkageLocation(i);
234 } 237 }
238
239 static MachineType reptyp(Representation representation) {
240 switch (representation.kind()) {
241 case Representation::kInteger8:
242 return kMachInt8;
243 case Representation::kUInteger8:
244 return kMachUint8;
245 case Representation::kInteger16:
246 return kMachInt16;
247 case Representation::kUInteger16:
248 return kMachUint16;
249 case Representation::kInteger32:
250 return kMachInt32;
251 case Representation::kSmi:
252 case Representation::kTagged:
253 case Representation::kHeapObject:
254 return kMachAnyTagged;
255 case Representation::kDouble:
256 return kMachFloat64;
257 case Representation::kExternal:
258 return kMachPtr;
259 case Representation::kNone:
260 case Representation::kNumRepresentations:
261 break;
262 }
263 UNREACHABLE();
264 return kMachNone;
265 }
235 }; 266 };
236 267
237 268
238 LinkageLocation Linkage::GetOsrValueLocation(int index) const { 269 LinkageLocation Linkage::GetOsrValueLocation(int index) const {
239 CHECK(incoming_->IsJSFunctionCall()); 270 CHECK(incoming_->IsJSFunctionCall());
240 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1); 271 int parameter_count = static_cast<int>(incoming_->JSParameterCount() - 1);
241 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count); 272 int first_stack_slot = OsrHelper::FirstStackSlotIndex(parameter_count);
242 273
243 if (index >= first_stack_slot) { 274 if (index >= first_stack_slot) {
244 // Local variable stored in this (callee) stack. 275 // Local variable stored in this (callee) stack.
245 int spill_index = 276 int spill_index =
246 LinkageLocation::ANY_REGISTER + 1 + index - first_stack_slot; 277 LinkageLocation::ANY_REGISTER + 1 + index - first_stack_slot;
247 // TODO(titzer): bailout instead of crashing here. 278 // TODO(titzer): bailout instead of crashing here.
248 CHECK(spill_index <= LinkageLocation::MAX_STACK_SLOT); 279 CHECK(spill_index <= LinkageLocation::MAX_STACK_SLOT);
249 return LinkageLocation(spill_index); 280 return LinkageLocation(spill_index);
250 } else { 281 } else {
251 // Parameter. Use the assigned location from the incoming call descriptor. 282 // Parameter. Use the assigned location from the incoming call descriptor.
252 int parameter_index = 1 + index; // skip index 0, which is the target. 283 int parameter_index = 1 + index; // skip index 0, which is the target.
253 return incoming_->GetInputLocation(parameter_index); 284 return incoming_->GetInputLocation(parameter_index);
254 } 285 }
255 } 286 }
256 287
257
258 } // namespace compiler 288 } // namespace compiler
259 } // namespace internal 289 } // namespace internal
260 } // namespace v8 290 } // namespace v8
261 291
262 #endif // V8_COMPILER_LINKAGE_IMPL_H_ 292 #endif // V8_COMPILER_LINKAGE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698