< prev index next >
src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java
Print this page
rev 12604 : 8173912: [JVMCI] fix memory overhead of JVMCI
*** 1,7 ****
/*
! * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 36,58 ****
* Represents a field in a HotSpot type.
*/
class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
private final HotSpotResolvedObjectTypeImpl holder;
- private final String name;
private JavaType type;
private final int offset;
/**
* This value contains all flags as stored in the VM including internal ones.
*/
private final int modifiers;
! HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) {
this.holder = holder;
- this.name = name;
this.type = type;
assert offset != -1;
assert offset == (int) offset : "offset larger than int";
this.offset = (int) offset;
this.modifiers = modifiers;
}
--- 36,59 ----
* Represents a field in a HotSpot type.
*/
class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField {
private final HotSpotResolvedObjectTypeImpl holder;
private JavaType type;
private final int offset;
+ private final short index;
/**
* This value contains all flags as stored in the VM including internal ones.
*/
private final int modifiers;
! HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, long offset, int modifiers, int index) {
this.holder = holder;
this.type = type;
+ this.index = (short) index;
+ assert this.index == index;
assert offset != -1;
assert offset == (int) offset : "offset larger than int";
this.offset = (int) offset;
this.modifiers = modifiers;
}
*** 65,84 ****
if (obj instanceof HotSpotResolvedJavaField) {
HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
if (that.offset != this.offset || that.isStatic() != this.isStatic()) {
return false;
} else if (this.holder.equals(that.holder)) {
- assert this.name.equals(that.name) && this.type.equals(that.type);
return true;
}
}
return false;
}
@Override
public int hashCode() {
! return name.hashCode();
}
@Override
public int getModifiers() {
return modifiers & jvmFieldModifiers();
--- 66,84 ----
if (obj instanceof HotSpotResolvedJavaField) {
HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
if (that.offset != this.offset || that.isStatic() != this.isStatic()) {
return false;
} else if (this.holder.equals(that.holder)) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
! return offset ^ modifiers;
}
@Override
public int getModifiers() {
return modifiers & jvmFieldModifiers();
*** 107,117 ****
return holder;
}
@Override
public String getName() {
! return name;
}
@Override
public JavaType getType() {
// Pull field into local variable to prevent a race causing
--- 107,117 ----
return holder;
}
@Override
public String getName() {
! return holder.createFieldInfo(index).getName();
}
@Override
public JavaType getType() {
// Pull field into local variable to prevent a race causing
*** 176,197 ****
return javaField.getAnnotation(annotationClass);
}
return null;
}
- private Field toJavaCache;
-
private Field toJava() {
- if (toJavaCache != null) {
- return toJavaCache;
- }
-
if (isInternal()) {
return null;
}
try {
! return toJavaCache = holder.mirror().getDeclaredField(name);
} catch (NoSuchFieldException | NoClassDefFoundError e) {
return null;
}
}
}
--- 176,191 ----
return javaField.getAnnotation(annotationClass);
}
return null;
}
private Field toJava() {
if (isInternal()) {
return null;
}
try {
! return holder.mirror().getDeclaredField(getName());
} catch (NoSuchFieldException | NoClassDefFoundError e) {
return null;
}
}
}
< prev index next >