< prev index next >

test/compiler/jvmci/code/amd64/AMD64TestAssembler.java

Print this page




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.jvmci.code.amd64;
  25 
  26 import jdk.vm.ci.amd64.AMD64;
  27 import jdk.vm.ci.amd64.AMD64Kind;
  28 import jdk.vm.ci.code.CodeCacheProvider;
  29 import jdk.vm.ci.code.DebugInfo;
  30 import jdk.vm.ci.code.Register;
  31 import jdk.vm.ci.code.StackSlot;
  32 import jdk.vm.ci.code.site.ConstantReference;
  33 import jdk.vm.ci.code.site.DataSectionReference;
  34 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  35 import jdk.vm.ci.hotspot.HotSpotConstant;


  36 import jdk.vm.ci.meta.JavaKind;
  37 import jdk.vm.ci.meta.LIRKind;
  38 import jdk.vm.ci.meta.VMConstant;
  39 
  40 import compiler.jvmci.code.TestAssembler;
  41 
  42 public class AMD64TestAssembler extends TestAssembler {
  43 
  44     public AMD64TestAssembler(CodeCacheProvider codeCache) {
  45         super(codeCache, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10);
  46     }
  47 
  48     private void emitFatNop() {
  49         // 5 byte NOP:
  50         // NOP DWORD ptr [EAX + EAX*1 + 00H]
  51         code.emitByte(0x0F);
  52         code.emitByte(0x1F);
  53         code.emitByte(0x44);
  54         code.emitByte(0x00);
  55         code.emitByte(0x00);
  56     }
  57 
  58     @Override
  59     public void emitPrologue() {
  60         // WARNING: Initial instruction MUST be 5 bytes or longer so that
  61         // NativeJump::patch_verified_entry will be able to patch out the entry
  62         // code safely.
  63         emitFatNop();
  64         code.emitByte(0x50 | AMD64.rbp.encoding);  // PUSH rbp
  65         emitMove(true, AMD64.rbp, AMD64.rsp);      // MOV rbp, rsp
  66         setDeoptRescueSlot(newStackSlot(LIRKind.value(AMD64Kind.QWORD)));









  67     }
  68 
  69     @Override
  70     public void emitGrowStack(int size) {
  71         // SUB rsp, size
  72         code.emitByte(0x48);
  73         code.emitByte(0x81);
  74         code.emitByte(0xEC);
  75         code.emitInt(size);
  76     }
  77 
  78     @Override
  79     public Register emitIntArg0() {
  80         return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int)[0];
  81     }
  82 
  83     @Override
  84     public Register emitIntArg1() {
  85         return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int)[1];
  86     }




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.jvmci.code.amd64;
  25 
  26 import jdk.vm.ci.amd64.AMD64;
  27 import jdk.vm.ci.amd64.AMD64Kind;
  28 import jdk.vm.ci.code.CodeCacheProvider;
  29 import jdk.vm.ci.code.DebugInfo;
  30 import jdk.vm.ci.code.Register;
  31 import jdk.vm.ci.code.StackSlot;
  32 import jdk.vm.ci.code.site.ConstantReference;
  33 import jdk.vm.ci.code.site.DataSectionReference;
  34 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
  35 import jdk.vm.ci.hotspot.HotSpotConstant;
  36 import jdk.vm.ci.hotspot.HotSpotForeignCallTarget;
  37 import jdk.vm.ci.hotspot.HotSpotVMConfig;
  38 import jdk.vm.ci.meta.JavaKind;
  39 import jdk.vm.ci.meta.LIRKind;
  40 import jdk.vm.ci.meta.VMConstant;
  41 
  42 import compiler.jvmci.code.TestAssembler;
  43 
  44 public class AMD64TestAssembler extends TestAssembler {
  45 
  46     public AMD64TestAssembler(CodeCacheProvider codeCache) {
  47         super(codeCache, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10);
  48     }
  49 
  50     private void emitFatNop() {
  51         // 5 byte NOP:
  52         // NOP DWORD ptr [EAX + EAX*1 + 00H]
  53         code.emitByte(0x0F);
  54         code.emitByte(0x1F);
  55         code.emitByte(0x44);
  56         code.emitByte(0x00);
  57         code.emitByte(0x00);
  58     }
  59 
  60     @Override
  61     public void emitPrologue() {
  62         // WARNING: Initial instruction MUST be 5 bytes or longer so that
  63         // NativeJump::patch_verified_entry will be able to patch out the entry
  64         // code safely.
  65         emitFatNop();
  66         code.emitByte(0x50 | AMD64.rbp.encoding);  // PUSH rbp
  67         emitMove(true, AMD64.rbp, AMD64.rsp);      // MOV rbp, rsp
  68         setDeoptRescueSlot(newStackSlot(LIRKind.value(AMD64Kind.QWORD)));
  69     }
  70 
  71     @Override
  72     public void emitEpilogue() {
  73         HotSpotVMConfig config = HotSpotVMConfig.config();
  74         recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
  75         recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 5, true, null);
  76         code.emitByte(0xE8); // CALL rel32
  77         code.emitInt(0xDEADDEAD);
  78     }
  79 
  80     @Override
  81     public void emitGrowStack(int size) {
  82         // SUB rsp, size
  83         code.emitByte(0x48);
  84         code.emitByte(0x81);
  85         code.emitByte(0xEC);
  86         code.emitInt(size);
  87     }
  88 
  89     @Override
  90     public Register emitIntArg0() {
  91         return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int)[0];
  92     }
  93 
  94     @Override
  95     public Register emitIntArg1() {
  96         return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int)[1];
  97     }


< prev index next >