comparison jvmci/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java @ 22679:4688478ecb7b

Make space in frame for native callee to spill outgoing parameters
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Tue, 13 Oct 2015 17:07:59 +0200
parents 1bbd4a7c274b
children c278790fa252
comparison
equal deleted inserted replaced
22678:3088a32d27af 22679:4688478ecb7b
136 136
137 private final Register[] allocatable; 137 private final Register[] allocatable;
138 138
139 private final RegisterAttributes[] attributesMap; 139 private final RegisterAttributes[] attributesMap;
140 140
141 /**
142 * Does native code (C++ code) spill arguments in registers to the parent frame?
143 */
144 private final boolean addNativeRegisterArgumentSlots;
145
141 @Override 146 @Override
142 public Register[] getAllocatableRegisters() { 147 public Register[] getAllocatableRegisters() {
143 return allocatable.clone(); 148 return allocatable.clone();
144 } 149 }
145 150
237 242
238 return registers; 243 return registers;
239 } 244 }
240 245
241 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { 246 public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) {
242 this(target, initAllocatable(config.useCompressedOops)); 247 this(target, initAllocatable(config.useCompressedOops), config);
243 } 248 }
244 249
245 public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) { 250 public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable, HotSpotVMConfig config) {
246 this.architecture = target.arch; 251 this.architecture = target.arch;
247 this.allocatable = allocatable.clone(); 252 this.allocatable = allocatable.clone();
248 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); 253 attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
254 this.addNativeRegisterArgumentSlots = config.linuxOs;
249 } 255 }
250 256
251 @Override 257 @Override
252 public Register[] getCallerSaveRegisters() { 258 public Register[] getCallerSaveRegisters() {
253 return callerSaveRegisters; 259 return callerSaveRegisters;
351 } 357 }
352 } 358 }
353 359
354 JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); 360 JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind();
355 AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind())); 361 AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind, type).asValue(target.getLIRKind(returnKind.getStackKind()));
356 // Space where callee may spill outgoing parameters o0...o5 362
357 int lowerOutgoingSpace = Math.min(locations.length, 6) * target.wordSize; 363 int outArgSpillArea;
358 return new CallingConvention(currentStackOffset + lowerOutgoingSpace, returnLocation, locations); 364 if (type == Type.NativeCall && addNativeRegisterArgumentSlots) {
365 // Space for native callee which may spill our outgoing arguments
366 outArgSpillArea = Math.min(locations.length, generalParameterRegisters.length) * target.wordSize;
367 } else {
368 outArgSpillArea = 0;
369 }
370 return new CallingConvention(currentStackOffset + outArgSpillArea, returnLocation, locations);
359 } 371 }
360 372
361 private static int roundUp(int number, int mod) { 373 private static int roundUp(int number, int mod) {
362 return ((number + mod - 1) / mod) * mod; 374 return ((number + mod - 1) / mod) * mod;
363 } 375 }