51 private ValueNode materializedValue; 52 private LockState locks; 53 private boolean ensureVirtualized; 54 55 private EscapeObjectState cachedState; 56 57 /** 58 * ObjectStates are duplicated lazily, if this field is true then the state needs to be copied 59 * before it is modified. 60 */ 61 boolean copyOnWrite; 62 63 public ObjectState(ValueNode[] entries, List<MonitorIdNode> locks, boolean ensureVirtualized) { 64 this(entries, (LockState) null, ensureVirtualized); 65 for (int i = locks.size() - 1; i >= 0; i--) { 66 this.locks = new LockState(locks.get(i), this.locks); 67 } 68 } 69 70 public ObjectState(ValueNode[] entries, LockState locks, boolean ensureVirtualized) { 71 this.entries = entries; 72 this.locks = locks; 73 this.ensureVirtualized = ensureVirtualized; 74 } 75 76 public ObjectState(ValueNode materializedValue, LockState locks, boolean ensureVirtualized) { 77 assert materializedValue != null; 78 this.materializedValue = materializedValue; 79 this.locks = locks; 80 this.ensureVirtualized = ensureVirtualized; 81 } 82 83 private ObjectState(ObjectState other) { 84 entries = other.entries == null ? null : other.entries.clone(); 85 materializedValue = other.materializedValue; 86 locks = other.locks; 87 cachedState = other.cachedState; 88 ensureVirtualized = other.ensureVirtualized; 89 } 90 91 public ObjectState cloneState() { 92 return new ObjectState(this); 93 } 94 95 public EscapeObjectState createEscapeObjectState(DebugContext debug, VirtualObjectNode virtual) { 96 GET_ESCAPED_OBJECT_STATE.increment(debug); 97 if (cachedState == null) { 98 CREATE_ESCAPED_OBJECT_STATE.increment(debug); 99 if (isVirtual()) { 100 /* 101 * Clear out entries that are default values anyway. 102 * 103 * TODO: this should be propagated into ObjectState.entries, but that will take some 104 * more refactoring. 105 */ 106 ValueNode[] newEntries = entries.clone(); 107 for (int i = 0; i < newEntries.length; i++) { 108 if (newEntries[i].asJavaConstant() == JavaConstant.defaultForKind(virtual.entryKind(i).getStackKind())) { 109 newEntries[i] = null; 110 } 111 } 112 cachedState = new VirtualObjectState(virtual, newEntries); | 51 private ValueNode materializedValue; 52 private LockState locks; 53 private boolean ensureVirtualized; 54 55 private EscapeObjectState cachedState; 56 57 /** 58 * ObjectStates are duplicated lazily, if this field is true then the state needs to be copied 59 * before it is modified. 60 */ 61 boolean copyOnWrite; 62 63 public ObjectState(ValueNode[] entries, List<MonitorIdNode> locks, boolean ensureVirtualized) { 64 this(entries, (LockState) null, ensureVirtualized); 65 for (int i = locks.size() - 1; i >= 0; i--) { 66 this.locks = new LockState(locks.get(i), this.locks); 67 } 68 } 69 70 public ObjectState(ValueNode[] entries, LockState locks, boolean ensureVirtualized) { 71 assert checkIllegalValues(entries); 72 this.entries = entries; 73 this.locks = locks; 74 this.ensureVirtualized = ensureVirtualized; 75 } 76 77 public ObjectState(ValueNode materializedValue, LockState locks, boolean ensureVirtualized) { 78 assert materializedValue != null; 79 this.materializedValue = materializedValue; 80 this.locks = locks; 81 this.ensureVirtualized = ensureVirtualized; 82 } 83 84 private ObjectState(ObjectState other) { 85 entries = other.entries == null ? null : other.entries.clone(); 86 materializedValue = other.materializedValue; 87 locks = other.locks; 88 cachedState = other.cachedState; 89 ensureVirtualized = other.ensureVirtualized; 90 } 91 92 public ObjectState cloneState() { 93 return new ObjectState(this); 94 } 95 96 /** 97 * Ensure that if an {@link JavaConstant#forIllegal() illegal value} is seen that the previous 98 * value is a double word value. 99 */ 100 public static boolean checkIllegalValues(ValueNode[] values) { 101 if (values != null) { 102 for (int v = 1; v < values.length; v++) { 103 checkIllegalValue(values, v); 104 } 105 } 106 return true; 107 } 108 109 /** 110 * Ensure that if an {@link JavaConstant#forIllegal() illegal value} is seen that the previous 111 * value is a double word value. 112 */ 113 public static boolean checkIllegalValue(ValueNode[] values, int v) { 114 if (v > 0 && values[v].isConstant() && values[v].asConstant().equals(JavaConstant.forIllegal())) { 115 assert values[v - 1].getStackKind().needsTwoSlots(); 116 } 117 return true; 118 } 119 120 public EscapeObjectState createEscapeObjectState(DebugContext debug, VirtualObjectNode virtual) { 121 GET_ESCAPED_OBJECT_STATE.increment(debug); 122 if (cachedState == null) { 123 CREATE_ESCAPED_OBJECT_STATE.increment(debug); 124 if (isVirtual()) { 125 /* 126 * Clear out entries that are default values anyway. 127 * 128 * TODO: this should be propagated into ObjectState.entries, but that will take some 129 * more refactoring. 130 */ 131 ValueNode[] newEntries = entries.clone(); 132 for (int i = 0; i < newEntries.length; i++) { 133 if (newEntries[i].asJavaConstant() == JavaConstant.defaultForKind(virtual.entryKind(i).getStackKind())) { 134 newEntries[i] = null; 135 } 136 } 137 cachedState = new VirtualObjectState(virtual, newEntries); |