< prev index next >

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

Print this page




  22  */
  23 
  24 package jdk.tools.jaotc;
  25 
  26 import java.util.concurrent.atomic.AtomicInteger;
  27 import java.util.HashMap;
  28 import java.util.HashSet;
  29 
  30 import jdk.tools.jaotc.binformat.BinaryContainer;
  31 import jdk.tools.jaotc.binformat.ReadOnlyDataContainer;
  32 import jdk.tools.jaotc.AOTCompiledClass.AOTKlassData;
  33 import org.graalvm.compiler.code.CompilationResult;
  34 
  35 import jdk.vm.ci.code.site.Mark;
  36 import jdk.vm.ci.code.site.Site;
  37 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
  38 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  39 
  40 final class CompiledMethodInfo {
  41 


  42     private static final int UNINITIALIZED_OFFSET = -1;
  43 
  44     private static class AOTMethodOffsets {
  45         /**
  46          * Offset in metaspace names section.
  47          */
  48         private int nameOffset;
  49 
  50         /**
  51          * Offset in the text section at which compiled code starts.
  52          */
  53         private int textSectionOffset;
  54 
  55         /**
  56          * Offset in the metadata section.
  57          */
  58         private int metadataOffset;
  59 
  60         /**
  61          * Offset to the metadata in the GOT table.


 287         assert stub != null : "missing stub for call " + call;
 288         stub.verify();
 289         return stub;
 290     }
 291 
 292     void addDependentKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
 293         AOTKlassData klassData = AOTCompiledClass.addFingerprintKlassData(binaryContainer, type);
 294         dependentKlasses.add(klassData);
 295     }
 296 
 297     AOTKlassData getDependentKlassData(HotSpotResolvedObjectType type) {
 298         AOTKlassData klassData = AOTCompiledClass.getAOTKlassData(type);
 299         if (dependentKlasses.contains(klassData)) {
 300             return klassData;
 301         }
 302         return null;
 303     }
 304 
 305     boolean hasMark(Site call, MarkId id) {
 306         for (Mark m : compilationResult.getMarks()) {







 307             // TODO: X64-specific code.
 308             // Call instructions are aligned to 8
 309             // bytes - 1 on x86 to patch address atomically,
 310             int adjOffset = (m.pcOffset & (-8)) + 7;

 311             // Mark points before aligning nops.
 312             if ((call.pcOffset == adjOffset) && MarkId.getEnum((int) m.id) == id) {
 313                 return true;
 314             }
 315         }
 316         return false;
 317     }
 318 
 319     String asTag() {
 320         return "[" + methodInfo.getSymbolName() + "]";
 321     }
 322 
 323     HotSpotCompiledCode compiledCode() {
 324         if (code == null) {
 325             code = methodInfo.compiledCode(compilationResult);
 326         }
 327         return code;
 328     }
 329 
 330     // Free memory


  22  */
  23 
  24 package jdk.tools.jaotc;
  25 
  26 import java.util.concurrent.atomic.AtomicInteger;
  27 import java.util.HashMap;
  28 import java.util.HashSet;
  29 
  30 import jdk.tools.jaotc.binformat.BinaryContainer;
  31 import jdk.tools.jaotc.binformat.ReadOnlyDataContainer;
  32 import jdk.tools.jaotc.AOTCompiledClass.AOTKlassData;
  33 import org.graalvm.compiler.code.CompilationResult;
  34 
  35 import jdk.vm.ci.code.site.Mark;
  36 import jdk.vm.ci.code.site.Site;
  37 import jdk.vm.ci.hotspot.HotSpotCompiledCode;
  38 import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
  39 
  40 final class CompiledMethodInfo {
  41 
  42     static final String archStr = System.getProperty("os.arch").toLowerCase();
  43 
  44     private static final int UNINITIALIZED_OFFSET = -1;
  45 
  46     private static class AOTMethodOffsets {
  47         /**
  48          * Offset in metaspace names section.
  49          */
  50         private int nameOffset;
  51 
  52         /**
  53          * Offset in the text section at which compiled code starts.
  54          */
  55         private int textSectionOffset;
  56 
  57         /**
  58          * Offset in the metadata section.
  59          */
  60         private int metadataOffset;
  61 
  62         /**
  63          * Offset to the metadata in the GOT table.


 289         assert stub != null : "missing stub for call " + call;
 290         stub.verify();
 291         return stub;
 292     }
 293 
 294     void addDependentKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
 295         AOTKlassData klassData = AOTCompiledClass.addFingerprintKlassData(binaryContainer, type);
 296         dependentKlasses.add(klassData);
 297     }
 298 
 299     AOTKlassData getDependentKlassData(HotSpotResolvedObjectType type) {
 300         AOTKlassData klassData = AOTCompiledClass.getAOTKlassData(type);
 301         if (dependentKlasses.contains(klassData)) {
 302             return klassData;
 303         }
 304         return null;
 305     }
 306 
 307     boolean hasMark(Site call, MarkId id) {
 308         for (Mark m : compilationResult.getMarks()) {
 309             int adjOffset = m.pcOffset;
 310             if (archStr.equals("aarch64")) {
 311                 // FIXME: This is very ugly.
 312                 // The mark is at the end of a group of three instructions:
 313                 // adrp; add; ldr
 314                 adjOffset += 12;
 315             } else {
 316                 // TODO: X64-specific code.
 317                 // Call instructions are aligned to 8
 318                 // bytes - 1 on x86 to patch address atomically,
 319                 adjOffset = (adjOffset & (-8)) + 7;
 320             }
 321             // Mark points before aligning nops.
 322             if ((call.pcOffset == adjOffset) && MarkId.getEnum((int) m.id) == id) {
 323                 return true;
 324             }
 325         }
 326         return false;
 327     }
 328 
 329     String asTag() {
 330         return "[" + methodInfo.getSymbolName() + "]";
 331     }
 332 
 333     HotSpotCompiledCode compiledCode() {
 334         if (code == null) {
 335             code = methodInfo.compiledCode(compilationResult);
 336         }
 337         return code;
 338     }
 339 
 340     // Free memory
< prev index next >