src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/share/classes/java/lang/invoke

src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java

Print this page
rev 11011 : 8057020: LambdaForm caches should support eviction
Reviewed-by: psandoz, ?


  29 import java.util.Arrays;
  30 import static java.lang.invoke.LambdaForm.*;
  31 import static java.lang.invoke.LambdaForm.BasicType.*;
  32 
  33 /** Working storage for an LF that is being transformed.
  34  *  Similarly to a StringBuffer, the editing can take place in multiple steps.
  35  */
  36 final class LambdaFormBuffer {
  37     private int arity, length;
  38     private Name[] names;
  39     private Name[] originalNames;  // snapshot of pre-transaction names
  40     private byte flags;
  41     private int firstChange;
  42     private Name resultName;
  43     private String debugName;
  44     private ArrayList<Name> dups;
  45 
  46     private static final int F_TRANS = 0x10, F_OWNED = 0x03;
  47 
  48     LambdaFormBuffer(LambdaForm lf) {
  49         this(lf.arity, lf.names, lf.result);





  50         debugName = lf.debugName;
  51         assert(lf.nameRefsAreLegal());
  52     }
  53 
  54     private LambdaFormBuffer(int arity, Name[] names, int result) {
  55         this.arity = arity;
  56         setNames(names);
  57         if (result == LAST_RESULT)  result = length - 1;
  58         if (result >= 0 && names[result].type != V_TYPE)
  59             resultName = names[result];
  60     }
  61 
  62     private LambdaForm lambdaForm() {
  63         assert(!inTrans());  // need endEdit call to tidy things up
  64         return new LambdaForm(debugName, arity, nameArray(), resultIndex());
  65     }
  66 
  67     Name name(int i) {
  68         assert(i < length);
  69         return names[i];
  70     }
  71 
  72     Name[] nameArray() {
  73         return Arrays.copyOf(names, length);
  74     }
  75 
  76     int resultIndex() {
  77         if (resultName == null)  return VOID_RESULT;
  78         int index = indexOf(resultName, names);
  79         assert(index >= 0);
  80         return index;
  81     }




  29 import java.util.Arrays;
  30 import static java.lang.invoke.LambdaForm.*;
  31 import static java.lang.invoke.LambdaForm.BasicType.*;
  32 
  33 /** Working storage for an LF that is being transformed.
  34  *  Similarly to a StringBuffer, the editing can take place in multiple steps.
  35  */
  36 final class LambdaFormBuffer {
  37     private int arity, length;
  38     private Name[] names;
  39     private Name[] originalNames;  // snapshot of pre-transaction names
  40     private byte flags;
  41     private int firstChange;
  42     private Name resultName;
  43     private String debugName;
  44     private ArrayList<Name> dups;
  45 
  46     private static final int F_TRANS = 0x10, F_OWNED = 0x03;
  47 
  48     LambdaFormBuffer(LambdaForm lf) {
  49         this.arity = lf.arity;
  50         setNames(lf.names);
  51         int result = lf.result;
  52         if (result == LAST_RESULT)  result = length - 1;
  53         if (result >= 0 && lf.names[result].type != V_TYPE)
  54             resultName = lf.names[result];
  55         debugName = lf.debugName;
  56         assert(lf.nameRefsAreLegal());
  57     }
  58 








  59     private LambdaForm lambdaForm() {
  60         assert(!inTrans());  // need endEdit call to tidy things up
  61         return new LambdaForm(debugName, arity, nameArray(), resultIndex());
  62     }
  63 
  64     Name name(int i) {
  65         assert(i < length);
  66         return names[i];
  67     }
  68 
  69     Name[] nameArray() {
  70         return Arrays.copyOf(names, length);
  71     }
  72 
  73     int resultIndex() {
  74         if (resultName == null)  return VOID_RESULT;
  75         int index = indexOf(resultName, names);
  76         assert(index >= 0);
  77         return index;
  78     }


src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File