< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64Call.java

Print this page




 192 
 193     public static int directCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) {
 194         if (align) {
 195             emitAlignmentForDirectCall(crb, masm);
 196         }
 197         int before = masm.position();
 198         int callPCOffset;
 199         if (scratch != null && !GeneratePIC.getValue(crb.getOptions())) {
 200             // offset might not fit a 32-bit immediate, generate an
 201             // indirect call with a 64-bit immediate
 202             masm.movq(scratch, 0L);
 203             callPCOffset = masm.position();
 204             masm.call(scratch);
 205         } else {
 206             callPCOffset = masm.position();
 207             masm.call();
 208         }
 209         int after = masm.position();
 210         crb.recordDirectCall(before, after, callTarget, info);
 211         crb.recordExceptionHandlers(after, info);
 212         masm.ensureUniquePC();
 213         return callPCOffset;
 214     }
 215 
 216     protected static void emitAlignmentForDirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
 217         // make sure that the displacement word of the call ends up word aligned
 218         int offset = masm.position();
 219         offset += crb.target.arch.getMachineCodeCallDisplacementOffset();
 220         int modulus = crb.target.wordSize;
 221         if (offset % modulus != 0) {
 222             masm.nop(modulus - offset % modulus);
 223         }
 224     }
 225 
 226     public static int directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target) {
 227         return directJmp(crb, masm, target, null);
 228     }
 229 
 230     public static int directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, Register scratch) {
 231         int before = masm.position();
 232         int callPCOffset;


 243         int after = masm.position();
 244         crb.recordDirectCall(before, after, target, null);
 245         masm.ensureUniquePC();
 246         return callPCOffset;
 247     }
 248 
 249     public static void directConditionalJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) {
 250         int before = masm.position();
 251         masm.jcc(cond, 0, true);
 252         int after = masm.position();
 253         crb.recordDirectCall(before, after, target, null);
 254         masm.ensureUniquePC();
 255     }
 256 
 257     public static int indirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) {
 258         int before = masm.position();
 259         masm.call(dst);
 260         int after = masm.position();
 261         crb.recordIndirectCall(before, after, callTarget, info);
 262         crb.recordExceptionHandlers(after, info);
 263         masm.ensureUniquePC();
 264         return before;
 265     }
 266 }


 192 
 193     public static int directCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) {
 194         if (align) {
 195             emitAlignmentForDirectCall(crb, masm);
 196         }
 197         int before = masm.position();
 198         int callPCOffset;
 199         if (scratch != null && !GeneratePIC.getValue(crb.getOptions())) {
 200             // offset might not fit a 32-bit immediate, generate an
 201             // indirect call with a 64-bit immediate
 202             masm.movq(scratch, 0L);
 203             callPCOffset = masm.position();
 204             masm.call(scratch);
 205         } else {
 206             callPCOffset = masm.position();
 207             masm.call();
 208         }
 209         int after = masm.position();
 210         crb.recordDirectCall(before, after, callTarget, info);
 211         crb.recordExceptionHandlers(after, info);
 212         masm.nop(8);
 213         return callPCOffset;
 214     }
 215 
 216     protected static void emitAlignmentForDirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
 217         // make sure that the displacement word of the call ends up word aligned
 218         int offset = masm.position();
 219         offset += crb.target.arch.getMachineCodeCallDisplacementOffset();
 220         int modulus = crb.target.wordSize;
 221         if (offset % modulus != 0) {
 222             masm.nop(modulus - offset % modulus);
 223         }
 224     }
 225 
 226     public static int directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target) {
 227         return directJmp(crb, masm, target, null);
 228     }
 229 
 230     public static int directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, Register scratch) {
 231         int before = masm.position();
 232         int callPCOffset;


 243         int after = masm.position();
 244         crb.recordDirectCall(before, after, target, null);
 245         masm.ensureUniquePC();
 246         return callPCOffset;
 247     }
 248 
 249     public static void directConditionalJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) {
 250         int before = masm.position();
 251         masm.jcc(cond, 0, true);
 252         int after = masm.position();
 253         crb.recordDirectCall(before, after, target, null);
 254         masm.ensureUniquePC();
 255     }
 256 
 257     public static int indirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) {
 258         int before = masm.position();
 259         masm.call(dst);
 260         int after = masm.position();
 261         crb.recordIndirectCall(before, after, callTarget, info);
 262         crb.recordExceptionHandlers(after, info);
 263         masm.nop(8);
 264         return before;
 265     }
 266 }
< prev index next >