comparison graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64GlobalStubEmitter.java @ 3080:46fe56f202a4

Sync with maxine changes.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Tue, 28 Jun 2011 14:17:06 +0200
parents 224412c24426
children 28071fae8577
comparison
equal deleted inserted replaced
3079:fb38d0a18ba7 3080:46fe56f202a4
96 public GlobalStub emit(CiRuntimeCall runtimeCall, RiRuntime runtime) { 96 public GlobalStub emit(CiRuntimeCall runtimeCall, RiRuntime runtime) {
97 reset(runtimeCall.resultKind, runtimeCall.arguments); 97 reset(runtimeCall.resultKind, runtimeCall.arguments);
98 emitStandardForward(null, runtimeCall); 98 emitStandardForward(null, runtimeCall);
99 String name = "stub-" + runtimeCall; 99 String name = "stub-" + runtimeCall;
100 CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true); 100 CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true);
101 Object stubObject = runtime.registerGlobalStub(targetMethod, name); 101 Object stubObject = runtime.registerCompilerStub(targetMethod, name);
102 return new GlobalStub(null, runtimeCall.resultKind, stubObject, argsSize, argOffsets, resultOffset); 102 return new GlobalStub(null, runtimeCall.resultKind, stubObject, argsSize, argOffsets, resultOffset);
103 } 103 }
104 104
105 public GlobalStub emit(GlobalStub.Id stub, RiRuntime runtime) { 105 public GlobalStub emit(GlobalStub.Id stub, RiRuntime runtime) {
106 reset(stub.resultKind, stub.arguments); 106 reset(stub.resultKind, stub.arguments);
126 break; 126 break;
127 } 127 }
128 128
129 String name = "stub-" + stub; 129 String name = "stub-" + stub;
130 CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true); 130 CiTargetMethod targetMethod = tasm.finishTargetMethod(name, runtime, registerRestoreEpilogueOffset, true);
131 Object stubObject = runtime.registerGlobalStub(targetMethod, name); 131 Object stubObject = runtime.registerCompilerStub(targetMethod, name);
132 return new GlobalStub(stub, stub.resultKind, stubObject, argsSize, argOffsets, resultOffset); 132 return new GlobalStub(stub, stub.resultKind, stubObject, argsSize, argOffsets, resultOffset);
133 } 133 }
134 134
135 private CiValue allocateParameterOperand(XirParameter param, int parameterIndex) { 135 private CiValue allocateParameterOperand(XirParameter param, int parameterIndex) {
136 return new CiAddress(param.kind, AMD64.RSP, argumentIndexToStackOffset(parameterIndex)); 136 return new CiAddress(param.kind, AMD64.RSP, argumentIndexToStackOffset(parameterIndex));
236 236
237 assert template.marks.length == 0 : "marks not supported in global stubs"; 237 assert template.marks.length == 0 : "marks not supported in global stubs";
238 assembler.emitXirInstructions(null, template.fastPath, labels, operands, null); 238 assembler.emitXirInstructions(null, template.fastPath, labels, operands, null);
239 epilogue(); 239 epilogue();
240 CiTargetMethod targetMethod = tasm.finishTargetMethod(template.name, runtime, registerRestoreEpilogueOffset, true); 240 CiTargetMethod targetMethod = tasm.finishTargetMethod(template.name, runtime, registerRestoreEpilogueOffset, true);
241 Object stubObject = runtime.registerGlobalStub(targetMethod, template.name); 241 Object stubObject = runtime.registerCompilerStub(targetMethod, template.name);
242 return new GlobalStub(null, template.resultOperand.kind, stubObject, argsSize, argOffsets, resultOffset); 242 return new GlobalStub(null, template.resultOperand.kind, stubObject, argsSize, argOffsets, resultOffset);
243 } 243 }
244 244
245 private CiKind[] getArgumentKinds(XirTemplate template) { 245 private CiKind[] getArgumentKinds(XirTemplate template) {
246 CiXirAssembler.XirParameter[] params = template.parameters; 246 CiXirAssembler.XirParameter[] params = template.parameters;
375 tasm.setFrameSize(frameSize()); 375 tasm.setFrameSize(frameSize());
376 this.savedAllRegisters = false; 376 this.savedAllRegisters = false;
377 } 377 }
378 378
379 private void completeSavePrologue() { 379 private void completeSavePrologue() {
380 CiCalleeSaveArea csa = compiler.globalStubRegisterConfig.getCalleeSaveArea(); 380 CiCalleeSaveLayout csa = compiler.globalStubRegisterConfig.getCalleeSaveLayout();
381 this.saveSize = csa.size; 381 this.saveSize = csa.size;
382 int entryCodeOffset = runtime.codeOffset(); 382 int entryCodeOffset = runtime.codeOffset();
383 if (entryCodeOffset != 0) { 383 if (entryCodeOffset != 0) {
384 // align to code size 384 // align to code size
385 asm.nop(entryCodeOffset); 385 asm.nop(entryCodeOffset);
394 private void epilogue() { 394 private void epilogue() {
395 assert registerRestoreEpilogueOffset == -1; 395 assert registerRestoreEpilogueOffset == -1;
396 registerRestoreEpilogueOffset = asm.codeBuffer.position(); 396 registerRestoreEpilogueOffset = asm.codeBuffer.position();
397 397
398 if (savedAllRegisters) { 398 if (savedAllRegisters) {
399 CiCalleeSaveArea csa = compiler.globalStubRegisterConfig.getCalleeSaveArea(); 399 CiCalleeSaveLayout csa = compiler.globalStubRegisterConfig.getCalleeSaveLayout();
400 int frameToCSA = 0; 400 int frameToCSA = 0;
401 asm.restore(csa, frameToCSA); 401 asm.restore(csa, frameToCSA);
402 } else { 402 } else {
403 // saved only select registers 403 // saved only select registers
404 for (int index = 0; index < registersSaved.length; index++) { 404 for (int index = 0; index < registersSaved.length; index++) {
417 return target.alignFrameSize(saveSize); 417 return target.alignFrameSize(saveSize);
418 } 418 }
419 419
420 private void forwardRuntimeCall(CiRuntimeCall call) { 420 private void forwardRuntimeCall(CiRuntimeCall call) {
421 // Load arguments 421 // Load arguments
422 CiCallingConvention cc = compiler.globalStubRegisterConfig.getCallingConvention(RuntimeCall, call.arguments, target); 422 CiCallingConvention cc = compiler.globalStubRegisterConfig.getCallingConvention(RuntimeCall, call.arguments, target, false);
423 for (int i = 0; i < cc.locations.length; ++i) { 423 for (int i = 0; i < cc.locations.length; ++i) {
424 CiValue location = cc.locations[i]; 424 CiValue location = cc.locations[i];
425 loadArgument(i, location.asRegister()); 425 loadArgument(i, location.asRegister());
426 } 426 }
427 427