< prev index next >

src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/JavaCallSiteRelocationSymbol.java

Print this page
rev 49736 : 8185505: AArch64: Port AOT to AArch64
Reviewed-by: duke
   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 jdk.tools.jaotc;
  25 
  26 import jdk.tools.jaotc.binformat.BinaryContainer;
  27 import jdk.tools.jaotc.binformat.Symbol;
  28 import jdk.tools.jaotc.StubInformation;
  29 
  30 import jdk.vm.ci.code.site.Call;
  31 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  32 
  33 /**
  34  * Symbol for a regular Java call. This method also creates additional relocations for {@code .plt}
  35  * to {@code .got} and {@code .got} to {@code .plt}.
  36  */
  37 final class JavaCallSiteRelocationSymbol extends CallSiteRelocationSymbol {
  38 
  39     private static final byte[] zeroSlot = new byte[8];
  40     // -1 represents Universe::non_oop_word() value
  41     private static final byte[] minusOneSlot = {-1, -1, -1, -1, -1, -1, -1, -1};












  42 
  43     JavaCallSiteRelocationSymbol(CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation, BinaryContainer binaryContainer) {
  44         super(createPltEntrySymbol(binaryContainer, mi, call, callSiteRelocation));
  45         StubInformation stub = getStub(mi, call);
  46         addRelocations(mi, stub, binaryContainer, call, callSiteRelocation);
  47     }
  48 
  49     /**
  50      * Returns a unique symbol name with the {@code suffix} appended.
  51      */
  52     private static String relocationSymbolName(String suffix, CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation) {
  53         return "M" + mi.getCodeId() + "_" + call.pcOffset + "_" + callSiteRelocation.targetSymbol + "_" + suffix;
  54     }
  55 
  56     private static Symbol createPltEntrySymbol(BinaryContainer binaryContainer, CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation) {
  57         String symbolName = relocationSymbolName("plt.entry", mi, call, callSiteRelocation);
  58         StubInformation stub = getStub(mi, call);
  59         return createCodeContainerSymbol(binaryContainer, symbolName, stub.getOffset());
  60     }
  61 


 106         String gotMoveSymbolName = relocationSymbolName("got.move", mi, call, callSiteRelocation);
 107         addExtLinkageGotContainerRelocation(binaryContainer, gotMoveSymbolName, gotMetaOffset, stub.getMovOffset());
 108 
 109         if (isVirtualCall) {
 110             // Nothing.
 111         } else {
 112             // Add relocation to GOT cell for c2i adapter jump.
 113             // The c2i jump instruction loads destination address from this GOT cell.
 114             // This GOT cell is initialized with -1 and will be updated
 115             // by JVM runtime call resolution code.
 116             String gotC2ISymbolName = relocationSymbolName("got.c2i", mi, call, callSiteRelocation);
 117             addExtLinkageGotContainerRelocation(binaryContainer, gotC2ISymbolName, gotStartOffset + 8, stub.getC2IJumpOffset());
 118         }
 119     }
 120 
 121     /**
 122      * Returns the name of the resolve method for this particular call.
 123      */
 124     private static String getResolveSymbolName(CompiledMethodInfo mi, Call call) {
 125         String resolveSymbolName;

 126         if (CallInfo.isStaticCall(call)) {
 127             assert mi.hasMark(call, MarkId.INVOKESTATIC);
 128             resolveSymbolName = BinaryContainer.getResolveStaticEntrySymbolName();
 129         } else if (CallInfo.isSpecialCall(call)) {
 130             resolveSymbolName = BinaryContainer.getResolveOptVirtualEntrySymbolName();
 131         } else if (CallInfo.isOptVirtualCall(mi, call)) {
 132             resolveSymbolName = BinaryContainer.getResolveOptVirtualEntrySymbolName();
 133         } else if (CallInfo.isVirtualCall(mi, call)) {
 134             resolveSymbolName = BinaryContainer.getResolveVirtualEntrySymbolName();
 135         } else {
 136             throw new InternalError("Unknown call type in " + mi.asTag() + " @ " + call.pcOffset + " for call" + call.target);
 137         }
 138         return resolveSymbolName;
 139     }
 140 
 141 }
   1 /*
   2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 jdk.tools.jaotc;
  25 
  26 import jdk.tools.jaotc.binformat.BinaryContainer;
  27 import jdk.tools.jaotc.binformat.Symbol;
  28 import jdk.tools.jaotc.StubInformation;
  29 
  30 import jdk.vm.ci.code.site.Call;
  31 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
  32 
  33 /**
  34  * Symbol for a regular Java call. This method also creates additional relocations for {@code .plt}
  35  * to {@code .got} and {@code .got} to {@code .plt}.
  36  */
  37 final class JavaCallSiteRelocationSymbol extends CallSiteRelocationSymbol {
  38 
  39     private static final byte[] zeroSlot = new byte[8];
  40     // -1 represents Universe::non_oop_word() value
  41     private static final byte[] minusOneSlot;
  42 
  43     static {
  44         String archStr = System.getProperty("os.arch").toLowerCase();
  45         if (archStr.equals("aarch64")) {
  46             // AArch64 is a special case: it uses 48-bit addresses.
  47             byte[] non_oop_word = {-1, -1, -1, -1, -1, -1, 0, 0};
  48             minusOneSlot = non_oop_word;
  49         } else {
  50             byte[] non_oop_word = {-1, -1, -1, -1, -1, -1, -1, -1};
  51             minusOneSlot = non_oop_word;
  52         }
  53     }
  54 
  55     JavaCallSiteRelocationSymbol(CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation, BinaryContainer binaryContainer) {
  56         super(createPltEntrySymbol(binaryContainer, mi, call, callSiteRelocation));
  57         StubInformation stub = getStub(mi, call);
  58         addRelocations(mi, stub, binaryContainer, call, callSiteRelocation);
  59     }
  60 
  61     /**
  62      * Returns a unique symbol name with the {@code suffix} appended.
  63      */
  64     private static String relocationSymbolName(String suffix, CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation) {
  65         return "M" + mi.getCodeId() + "_" + call.pcOffset + "_" + callSiteRelocation.targetSymbol + "_" + suffix;
  66     }
  67 
  68     private static Symbol createPltEntrySymbol(BinaryContainer binaryContainer, CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation) {
  69         String symbolName = relocationSymbolName("plt.entry", mi, call, callSiteRelocation);
  70         StubInformation stub = getStub(mi, call);
  71         return createCodeContainerSymbol(binaryContainer, symbolName, stub.getOffset());
  72     }
  73 


 118         String gotMoveSymbolName = relocationSymbolName("got.move", mi, call, callSiteRelocation);
 119         addExtLinkageGotContainerRelocation(binaryContainer, gotMoveSymbolName, gotMetaOffset, stub.getMovOffset());
 120 
 121         if (isVirtualCall) {
 122             // Nothing.
 123         } else {
 124             // Add relocation to GOT cell for c2i adapter jump.
 125             // The c2i jump instruction loads destination address from this GOT cell.
 126             // This GOT cell is initialized with -1 and will be updated
 127             // by JVM runtime call resolution code.
 128             String gotC2ISymbolName = relocationSymbolName("got.c2i", mi, call, callSiteRelocation);
 129             addExtLinkageGotContainerRelocation(binaryContainer, gotC2ISymbolName, gotStartOffset + 8, stub.getC2IJumpOffset());
 130         }
 131     }
 132 
 133     /**
 134      * Returns the name of the resolve method for this particular call.
 135      */
 136     private static String getResolveSymbolName(CompiledMethodInfo mi, Call call) {
 137         String resolveSymbolName;
 138         String name = call.target.toString();
 139         if (CallInfo.isStaticCall(call)) {
 140             assert mi.hasMark(call, MarkId.INVOKESTATIC);
 141             resolveSymbolName = BinaryContainer.getResolveStaticEntrySymbolName();
 142         } else if (CallInfo.isSpecialCall(call)) {
 143             resolveSymbolName = BinaryContainer.getResolveOptVirtualEntrySymbolName();
 144         } else if (CallInfo.isOptVirtualCall(mi, call)) {
 145             resolveSymbolName = BinaryContainer.getResolveOptVirtualEntrySymbolName();
 146         } else if (CallInfo.isVirtualCall(mi, call)) {
 147             resolveSymbolName = BinaryContainer.getResolveVirtualEntrySymbolName();
 148         } else {
 149             throw new InternalError("Unknown call type in " + mi.asTag() + " @ " + call.pcOffset + " for call" + call.target);
 150         }
 151         return resolveSymbolName;
 152     }
 153 
 154 }
< prev index next >