< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/CompilationResult.java

Print this page




   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 package jdk.vm.ci.code;
  24 
  25 import static java.util.Collections.*;
  26 import static jdk.vm.ci.meta.MetaUtil.*;
  27 
  28 import java.util.*;
  29 
  30 import jdk.vm.ci.meta.*;
  31 import jdk.vm.ci.meta.Assumptions.*;











  32 
  33 /**
  34  * Represents the output from compiling a method, including the compiled machine code, associated
  35  * data and references, relocation information, deoptimization information, etc.
  36  */
  37 public class CompilationResult {
  38 
  39     /**
  40      * Represents a code position with associated additional information.
  41      */
  42     public abstract static class Site {
  43 
  44         /**
  45          * The position (or offset) of this site with respect to the start of the target method.
  46          */
  47         public final int pcOffset;
  48 
  49         public Site(int pos) {
  50             this.pcOffset = pos;
  51         }


 111             }
 112             return false;
 113         }
 114     }
 115 
 116     public enum MetaSpaceAccessType {
 117         Move,
 118         Store, // store only works for compressed oops (memory <- 32bit value). Compressed oops is
 119                // not supported using AOT. TODO: Look at HotSpotStoreConstantOp
 120         Compare; // HotSpotCompareMemoryConstantOp, HotSpotCompareConstantOp
 121 
 122         private MetaSpaceAccessType() {
 123         }
 124     }
 125 
 126     /**
 127      * Represents a meta space pointer access in the code.
 128      */
 129     public static final class MetaSpaceAccess extends Infopoint {
 130 
 131         private static final long serialVersionUID = 1701958512608684706L;
 132 
 133         /**
 134          * Metaspace reference.
 135          */
 136         public final Object reference; // Object here is a HotSpotResolvedObjectType or a
 137                                        // HotSpotMetaSpaceConstant
 138 
 139         public final MetaSpaceAccessType type;
 140 
 141         /**
 142          * Instruction size.
 143          */
 144         public final int instructionSize;
 145 
 146         public MetaSpaceAccess(Object reference, int instructionSize, MetaSpaceAccessType type, int pcOffset, DebugInfo debugInfo) {
 147             super(pcOffset, debugInfo, InfopointReason.METASPACE_ACCESS);
 148             this.type = type;
 149             this.reference = reference;
 150             this.instructionSize = instructionSize;
 151         }
 152     }


 279 
 280             this.offset = offset;
 281         }
 282 
 283         @Override
 284         public int hashCode() {
 285             return offset;
 286         }
 287 
 288         @Override
 289         public boolean equals(Object obj) {
 290             if (this == obj) {
 291                 return true;
 292             }
 293             if (obj instanceof DataSectionReference) {
 294                 DataSectionReference that = (DataSectionReference) obj;
 295                 return this.offset == that.offset;
 296             }
 297             return false;
 298         }









 299     }
 300 
 301     /**
 302      * Represents a code site that references some data. The associated data can be either a
 303      * {@link DataSectionReference reference} to the data section, or it may be an inlined
 304      * {@link JavaConstant} that needs to be patched.
 305      */
 306     public static final class DataPatch extends Site {
 307 
 308         public Reference reference;
 309         public Object note;
 310 
 311         public DataPatch(int pcOffset, Reference reference) {
 312             super(pcOffset);
 313             this.reference = reference;
 314             this.note = null;
 315         }
 316 
 317         public DataPatch(int pcOffset, Reference reference, Object note) {
 318             super(pcOffset);


 511             } else {
 512                 return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
 513             }
 514         }
 515 
 516         @Override
 517         public boolean equals(Object obj) {
 518             if (this == obj) {
 519                 return true;
 520             }
 521             if (obj instanceof Mark) {
 522                 Mark that = (Mark) obj;
 523                 if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
 524                     return true;
 525                 }
 526             }
 527             return false;
 528         }
 529     }
 530 
 531     private int id = -1;
 532 
 533     /**
 534      * Specifies whether this compilation is a {@code +ImmutableCode} {@code +GeneratePIC}
 535      * compilation.
 536      */
 537     private final boolean isImmutablePIC;
 538 
 539     private int entryBCI = -1;
 540 
 541     private final DataSection dataSection = new DataSection();
 542 
 543     private final List<Infopoint> infopoints = new ArrayList<>();
 544     private final List<DataPatch> dataPatches = new ArrayList<>();
 545     private final List<ExceptionHandler> exceptionHandlers = new ArrayList<>();
 546     private final List<Mark> marks = new ArrayList<>();
 547 
 548     private int totalFrameSize = -1;
 549     private int customStackAreaOffset = -1;
 550 
 551     private final String name;
 552 


 595         throw new UnsupportedOperationException("hashCode");
 596     }
 597 
 598     @Override
 599     public String toString() {
 600         if (methods != null) {
 601             return getClass().getName() + "[" + methods[0].format("%H.%n(%p)%r") + "]";
 602         }
 603         return identityHashCodeString(this);
 604     }
 605 
 606     @Override
 607     public boolean equals(Object obj) {
 608         if (this == obj) {
 609             return true;
 610         }
 611         if (obj != null && obj.getClass() == getClass()) {
 612             CompilationResult that = (CompilationResult) obj;
 613             // @formatter:off
 614             if (this.entryBCI == that.entryBCI &&
 615                 this.id == that.id &&
 616                 this.customStackAreaOffset == that.customStackAreaOffset &&
 617                 this.totalFrameSize == that.totalFrameSize &&
 618                 this.targetCodeSize == that.targetCodeSize &&
 619                 Objects.equals(this.name, that.name) &&
 620                 Objects.equals(this.annotations, that.annotations) &&
 621                 Objects.equals(this.dataSection, that.dataSection) &&
 622                 Objects.equals(this.exceptionHandlers, that.exceptionHandlers) &&
 623                 Objects.equals(this.dataPatches, that.dataPatches) &&
 624                 Objects.equals(this.infopoints, that.infopoints) &&
 625                 Objects.equals(this.marks,  that.marks) &&
 626                 Arrays.equals(this.assumptions, that.assumptions) &&
 627                 Arrays.equals(targetCode, that.targetCode)) {
 628                 return true;
 629             }
 630             // @formatter:on
 631         }
 632         return false;
 633     }
 634 
 635     /**
 636      * @return the compile id
 637      */
 638     public int getId() {
 639         return id;
 640     }
 641 
 642     /**
 643      * @param id the compile id to set
 644      */
 645     public void setId(int id) {
 646         this.id = id;
 647     }
 648 
 649     /**
 650      * @return true is this is a {@code +ImmutableCode} {@code +GeneratePIC} compilation, false
 651      *         otherwise.
 652      */
 653     public boolean isImmutablePIC() {
 654         return isImmutablePIC;
 655     }
 656 
 657     /**
 658      * @return the entryBCI
 659      */
 660     public int getEntryBCI() {
 661         return entryBCI;
 662     }
 663 
 664     /**
 665      * @param entryBCI the entryBCI to set
 666      */
 667     public void setEntryBCI(int entryBCI) {
 668         this.entryBCI = entryBCI;
 669     }




   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 package jdk.vm.ci.code;
  24 
  25 import static java.util.Collections.emptyList;
  26 import static java.util.Collections.unmodifiableList;
  27 import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString;
  28 
  29 import java.util.ArrayList;
  30 import java.util.Arrays;
  31 import java.util.Collection;
  32 import java.util.Collections;
  33 import java.util.List;
  34 import java.util.Map;
  35 import java.util.Objects;
  36 
  37 import jdk.vm.ci.meta.Assumptions.Assumption;
  38 import jdk.vm.ci.meta.InvokeTarget;
  39 import jdk.vm.ci.meta.JavaConstant;
  40 import jdk.vm.ci.meta.MetaUtil;
  41 import jdk.vm.ci.meta.ResolvedJavaMethod;
  42 import jdk.vm.ci.meta.VMConstant;
  43 
  44 /**
  45  * Represents the output from compiling a method, including the compiled machine code, associated
  46  * data and references, relocation information, deoptimization information, etc.
  47  */
  48 public class CompilationResult {
  49 
  50     /**
  51      * Represents a code position with associated additional information.
  52      */
  53     public abstract static class Site {
  54 
  55         /**
  56          * The position (or offset) of this site with respect to the start of the target method.
  57          */
  58         public final int pcOffset;
  59 
  60         public Site(int pos) {
  61             this.pcOffset = pos;
  62         }


 122             }
 123             return false;
 124         }
 125     }
 126 
 127     public enum MetaSpaceAccessType {
 128         Move,
 129         Store,  // store only works for compressed oops (memory <- 32bit value). Compressed oops is
 130         // not supported using AOT. TODO: Look at HotSpotStoreConstantOp
 131         Compare; // HotSpotCompareMemoryConstantOp, HotSpotCompareConstantOp
 132 
 133         private MetaSpaceAccessType() {
 134         }
 135     }
 136 
 137     /**
 138      * Represents a meta space pointer access in the code.
 139      */
 140     public static final class MetaSpaceAccess extends Infopoint {
 141 


 142         /**
 143          * Metaspace reference.
 144          */
 145         public final Object reference; // Object here is a HotSpotResolvedObjectType or a
 146         // HotSpotMetaSpaceConstant
 147 
 148         public final MetaSpaceAccessType type;
 149 
 150         /**
 151          * Instruction size.
 152          */
 153         public final int instructionSize;
 154 
 155         public MetaSpaceAccess(Object reference, int instructionSize, MetaSpaceAccessType type, int pcOffset, DebugInfo debugInfo) {
 156             super(pcOffset, debugInfo, InfopointReason.METASPACE_ACCESS);
 157             this.type = type;
 158             this.reference = reference;
 159             this.instructionSize = instructionSize;
 160         }
 161     }


 288 
 289             this.offset = offset;
 290         }
 291 
 292         @Override
 293         public int hashCode() {
 294             return offset;
 295         }
 296 
 297         @Override
 298         public boolean equals(Object obj) {
 299             if (this == obj) {
 300                 return true;
 301             }
 302             if (obj instanceof DataSectionReference) {
 303                 DataSectionReference that = (DataSectionReference) obj;
 304                 return this.offset == that.offset;
 305             }
 306             return false;
 307         }
 308 
 309         @Override
 310         public String toString() {
 311             if (initialized) {
 312                 return String.format("DataSection[0x%x]", offset);
 313             } else {
 314                 return "DataSection[?]";
 315             }
 316         }
 317     }
 318 
 319     /**
 320      * Represents a code site that references some data. The associated data can be either a
 321      * {@link DataSectionReference reference} to the data section, or it may be an inlined
 322      * {@link JavaConstant} that needs to be patched.
 323      */
 324     public static final class DataPatch extends Site {
 325 
 326         public Reference reference;
 327         public Object note;
 328 
 329         public DataPatch(int pcOffset, Reference reference) {
 330             super(pcOffset);
 331             this.reference = reference;
 332             this.note = null;
 333         }
 334 
 335         public DataPatch(int pcOffset, Reference reference, Object note) {
 336             super(pcOffset);


 529             } else {
 530                 return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
 531             }
 532         }
 533 
 534         @Override
 535         public boolean equals(Object obj) {
 536             if (this == obj) {
 537                 return true;
 538             }
 539             if (obj instanceof Mark) {
 540                 Mark that = (Mark) obj;
 541                 if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
 542                     return true;
 543                 }
 544             }
 545             return false;
 546         }
 547     }
 548 


 549     /**
 550      * Specifies whether this compilation is a {@code +ImmutableCode} {@code +GeneratePIC}
 551      * compilation.
 552      */
 553     private final boolean isImmutablePIC;
 554 
 555     private int entryBCI = -1;
 556 
 557     private final DataSection dataSection = new DataSection();
 558 
 559     private final List<Infopoint> infopoints = new ArrayList<>();
 560     private final List<DataPatch> dataPatches = new ArrayList<>();
 561     private final List<ExceptionHandler> exceptionHandlers = new ArrayList<>();
 562     private final List<Mark> marks = new ArrayList<>();
 563 
 564     private int totalFrameSize = -1;
 565     private int customStackAreaOffset = -1;
 566 
 567     private final String name;
 568 


 611         throw new UnsupportedOperationException("hashCode");
 612     }
 613 
 614     @Override
 615     public String toString() {
 616         if (methods != null) {
 617             return getClass().getName() + "[" + methods[0].format("%H.%n(%p)%r") + "]";
 618         }
 619         return identityHashCodeString(this);
 620     }
 621 
 622     @Override
 623     public boolean equals(Object obj) {
 624         if (this == obj) {
 625             return true;
 626         }
 627         if (obj != null && obj.getClass() == getClass()) {
 628             CompilationResult that = (CompilationResult) obj;
 629             // @formatter:off
 630             if (this.entryBCI == that.entryBCI &&

 631                 this.customStackAreaOffset == that.customStackAreaOffset &&
 632                 this.totalFrameSize == that.totalFrameSize &&
 633                 this.targetCodeSize == that.targetCodeSize &&
 634                 Objects.equals(this.name, that.name) &&
 635                 Objects.equals(this.annotations, that.annotations) &&
 636                 Objects.equals(this.dataSection, that.dataSection) &&
 637                 Objects.equals(this.exceptionHandlers, that.exceptionHandlers) &&
 638                 Objects.equals(this.dataPatches, that.dataPatches) &&
 639                 Objects.equals(this.infopoints, that.infopoints) &&
 640                 Objects.equals(this.marks,  that.marks) &&
 641                 Arrays.equals(this.assumptions, that.assumptions) &&
 642                 Arrays.equals(targetCode, that.targetCode)) {
 643                 return true;
 644             }
 645             // @formatter:on
 646         }
 647         return false;
 648     }
 649 
 650     /**














 651      * @return true is this is a {@code +ImmutableCode} {@code +GeneratePIC} compilation, false
 652      *         otherwise.
 653      */
 654     public boolean isImmutablePIC() {
 655         return isImmutablePIC;
 656     }
 657 
 658     /**
 659      * @return the entryBCI
 660      */
 661     public int getEntryBCI() {
 662         return entryBCI;
 663     }
 664 
 665     /**
 666      * @param entryBCI the entryBCI to set
 667      */
 668     public void setEntryBCI(int entryBCI) {
 669         this.entryBCI = entryBCI;
 670     }


< prev index next >