< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/NamedLocationIdentity.java

Print this page




  43         private static final EconomicSet<String> map = EconomicSet.create(Equivalence.DEFAULT);
  44 
  45         static boolean checkUnique(String name) {
  46             if (!map.add(name)) {
  47                 throw new AssertionError("identity " + name + " already exists");
  48             }
  49             return true;
  50         }
  51     }
  52 
  53     /**
  54      * Denotes the location of a value that is guaranteed to be unchanging.
  55      */
  56     public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION");
  57 
  58     /**
  59      * Denotes the location of the length field of a Java array.
  60      */
  61     public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length");
  62 





  63     private final String name;
  64     private final boolean immutable;
  65 
  66     protected NamedLocationIdentity(String name, boolean immutable) {
  67         this.name = name;
  68         this.immutable = immutable;
  69         assert DB.checkUnique(name);
  70     }
  71 
  72     /**
  73      * Creates a named unique location identity for read and write operations against mutable
  74      * memory.
  75      *
  76      * @param name the name of the new location identity
  77      */
  78     public static NamedLocationIdentity mutable(String name) {
  79         return create(name, false);
  80     }
  81 
  82     /**
  83      * Creates a named unique location identity for read operations against immutable memory.
  84      * Immutable memory will never have a visible write in the graph, which is more restictive than
  85      * Java final.
  86      *
  87      * @param name the name of the new location identity
  88      */
  89     public static NamedLocationIdentity immutable(String name) {
  90         return create(name, true);
  91     }
  92 
  93     /**
  94      * Creates a named unique location identity for read and write operations.
  95      *
  96      * @param name the name of the new location identity
  97      * @param immutable true if the location is immutable
  98      */
  99     private static NamedLocationIdentity create(String name, boolean immutable) {
 100         return new NamedLocationIdentity(name, immutable);
 101     }
 102 
 103     @Override
 104     public boolean isImmutable() {




  43         private static final EconomicSet<String> map = EconomicSet.create(Equivalence.DEFAULT);
  44 
  45         static boolean checkUnique(String name) {
  46             if (!map.add(name)) {
  47                 throw new AssertionError("identity " + name + " already exists");
  48             }
  49             return true;
  50         }
  51     }
  52 
  53     /**
  54      * Denotes the location of a value that is guaranteed to be unchanging.
  55      */
  56     public static final LocationIdentity FINAL_LOCATION = NamedLocationIdentity.immutable("FINAL_LOCATION");
  57 
  58     /**
  59      * Denotes the location of the length field of a Java array.
  60      */
  61     public static final LocationIdentity ARRAY_LENGTH_LOCATION = NamedLocationIdentity.immutable("[].length");
  62 
  63     /**
  64      * Denotes an off-heap address.
  65      */
  66     public static final LocationIdentity OFF_HEAP_LOCATION = NamedLocationIdentity.mutable("OFF_HEAP_LOCATION");
  67 
  68     private final String name;
  69     private final boolean immutable;
  70 
  71     protected NamedLocationIdentity(String name, boolean immutable) {
  72         this.name = name;
  73         this.immutable = immutable;
  74         assert DB.checkUnique(name);
  75     }
  76 
  77     /**
  78      * Creates a named unique location identity for read and write operations against mutable
  79      * memory.
  80      *
  81      * @param name the name of the new location identity
  82      */
  83     public static NamedLocationIdentity mutable(String name) {
  84         return create(name, false);
  85     }
  86 
  87     /**
  88      * Creates a named unique location identity for read operations against immutable memory.
  89      * Immutable memory will never have a visible write in the graph, which is more restrictive than
  90      * Java final.
  91      *
  92      * @param name the name of the new location identity
  93      */
  94     public static NamedLocationIdentity immutable(String name) {
  95         return create(name, true);
  96     }
  97 
  98     /**
  99      * Creates a named unique location identity for read and write operations.
 100      *
 101      * @param name the name of the new location identity
 102      * @param immutable true if the location is immutable
 103      */
 104     private static NamedLocationIdentity create(String name, boolean immutable) {
 105         return new NamedLocationIdentity(name, immutable);
 106     }
 107 
 108     @Override
 109     public boolean isImmutable() {


< prev index next >