< prev index next >

src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompiledMethodInfo.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 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
   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 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                 // The mark is at the end of a group of three instructions:
 312                 // adrp; add; ldr
 313                 adjOffset += 12;
 314             } else {
 315                 // X64-specific code.
 316                 // Call instructions are aligned to 8
 317                 // bytes - 1 on x86 to patch address atomically,
 318                 adjOffset = (adjOffset & (-8)) + 7;
 319             }
 320             // Mark points before aligning nops.
 321             if ((call.pcOffset == adjOffset) && MarkId.getEnum((int) m.id) == id) {
 322                 return true;
 323             }
 324         }
 325         return false;
 326     }
 327 
 328     String asTag() {
 329         return "[" + methodInfo.getSymbolName() + "]";
 330     }
 331 
 332     HotSpotCompiledCode compiledCode() {
 333         if (code == null) {
 334             code = methodInfo.compiledCode(compilationResult);
 335         }
 336         return code;
 337     }
 338 
 339     // Free memory
< prev index next >