171 switch (declaredKind) {
172 case Object:
173 case Double:
174 case Long:
175 return false;
176 default:
177 return true;
178 }
179 }
180 assert accessKind.isPrimitive() : "Illegal access kind";
181 return declaredKind.isPrimitive() ? accessKind.getBitCount() > declaredKind.getBitCount() : true;
182 }
183
184 private boolean processUnsafeLoad(RawLoadNode load, PEReadEliminationBlockState state, GraphEffectList effects) {
185 if (load.offset().isConstant()) {
186 ResolvedJavaType type = StampTool.typeOrNull(load.object());
187 if (type != null && type.isArray()) {
188 JavaKind accessKind = load.accessKind();
189 JavaKind componentKind = type.getComponentType().getJavaKind();
190 long offset = load.offset().asJavaConstant().asLong();
191 int index = VirtualArrayNode.entryIndexForOffset(tool.getArrayOffsetProvider(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
192 ValueNode object = GraphUtil.unproxify(load.object());
193 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
194 ValueNode cachedValue = state.getReadCache(object, location, index, accessKind, this);
195 assert cachedValue == null || load.stamp(NodeView.DEFAULT).isCompatible(cachedValue.stamp(NodeView.DEFAULT)) : "The RawLoadNode's stamp is not compatible with the cached value.";
196 if (cachedValue != null) {
197 effects.replaceAtUsages(load, cachedValue, load);
198 addScalarAlias(load, cachedValue);
199 return true;
200 } else {
201 state.addReadCache(object, location, index, accessKind, isOverflowAccess(accessKind, componentKind), load, this);
202 }
203 }
204 }
205 return false;
206 }
207
208 private boolean processUnsafeStore(RawStoreNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
209 ResolvedJavaType type = StampTool.typeOrNull(store.object());
210 if (type != null && type.isArray()) {
211 JavaKind accessKind = store.accessKind();
212 JavaKind componentKind = type.getComponentType().getJavaKind();
213 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
214 if (store.offset().isConstant()) {
215 long offset = store.offset().asJavaConstant().asLong();
216 boolean overflowAccess = isOverflowAccess(accessKind, componentKind);
217 int index = overflowAccess ? -1 : VirtualArrayNode.entryIndexForOffset(tool.getArrayOffsetProvider(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
218 return processStore(store, store.object(), location, index, accessKind, overflowAccess, store.value(), state, effects);
219 } else {
220 processIdentity(state, location);
221 }
222 } else {
223 state.killReadCache();
224 }
225 return false;
226 }
227
228 private boolean processArrayLength(ArrayLengthNode length, PEReadEliminationBlockState state, GraphEffectList effects) {
229 return processLoad(length, length.array(), ARRAY_LENGTH_LOCATION, -1, JavaKind.Int, state, effects);
230 }
231
232 private boolean processStoreField(StoreFieldNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
233 if (store.isVolatile()) {
234 state.killReadCache();
235 return false;
236 }
237 JavaKind kind = store.field().getJavaKind();
|
171 switch (declaredKind) {
172 case Object:
173 case Double:
174 case Long:
175 return false;
176 default:
177 return true;
178 }
179 }
180 assert accessKind.isPrimitive() : "Illegal access kind";
181 return declaredKind.isPrimitive() ? accessKind.getBitCount() > declaredKind.getBitCount() : true;
182 }
183
184 private boolean processUnsafeLoad(RawLoadNode load, PEReadEliminationBlockState state, GraphEffectList effects) {
185 if (load.offset().isConstant()) {
186 ResolvedJavaType type = StampTool.typeOrNull(load.object());
187 if (type != null && type.isArray()) {
188 JavaKind accessKind = load.accessKind();
189 JavaKind componentKind = type.getComponentType().getJavaKind();
190 long offset = load.offset().asJavaConstant().asLong();
191 int index = VirtualArrayNode.entryIndexForOffset(tool.getMetaAccess(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
192 if (index >= 0) {
193 ValueNode object = GraphUtil.unproxify(load.object());
194 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
195 ValueNode cachedValue = state.getReadCache(object, location, index, accessKind, this);
196 assert cachedValue == null || load.stamp(NodeView.DEFAULT).isCompatible(cachedValue.stamp(NodeView.DEFAULT)) : "The RawLoadNode's stamp is not compatible with the cached value.";
197 if (cachedValue != null) {
198 effects.replaceAtUsages(load, cachedValue, load);
199 addScalarAlias(load, cachedValue);
200 return true;
201 } else {
202 state.addReadCache(object, location, index, accessKind, isOverflowAccess(accessKind, componentKind), load, this);
203 }
204 }
205 }
206 }
207 return false;
208 }
209
210 private boolean processUnsafeStore(RawStoreNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
211 ResolvedJavaType type = StampTool.typeOrNull(store.object());
212 if (type != null && type.isArray()) {
213 JavaKind accessKind = store.accessKind();
214 JavaKind componentKind = type.getComponentType().getJavaKind();
215 LocationIdentity location = NamedLocationIdentity.getArrayLocation(componentKind);
216 if (store.offset().isConstant()) {
217 long offset = store.offset().asJavaConstant().asLong();
218 boolean overflowAccess = isOverflowAccess(accessKind, componentKind);
219 int index = overflowAccess ? -1 : VirtualArrayNode.entryIndexForOffset(tool.getMetaAccess(), offset, accessKind, type.getComponentType(), Integer.MAX_VALUE);
220 return processStore(store, store.object(), location, index, accessKind, overflowAccess, store.value(), state, effects);
221 } else {
222 processIdentity(state, location);
223 }
224 } else {
225 state.killReadCache();
226 }
227 return false;
228 }
229
230 private boolean processArrayLength(ArrayLengthNode length, PEReadEliminationBlockState state, GraphEffectList effects) {
231 return processLoad(length, length.array(), ARRAY_LENGTH_LOCATION, -1, JavaKind.Int, state, effects);
232 }
233
234 private boolean processStoreField(StoreFieldNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
235 if (store.isVolatile()) {
236 state.killReadCache();
237 return false;
238 }
239 JavaKind kind = store.field().getJavaKind();
|