Skip to content

Commit 214e97f

Browse files
committed
Remove JSStaticFieldDefinition
Only used in a single place and there only to dispatch to CodeGenTool.genStaticField
1 parent e9d122b commit 214e97f

File tree

2 files changed

+6
-74
lines changed

2 files changed

+6
-74
lines changed

web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/long64/Long64Lowerer.java

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import org.graalvm.collections.EconomicMap;
3131

3232
import com.oracle.svm.hosted.webimage.codegen.JSCodeGenTool;
33-
import com.oracle.svm.hosted.webimage.js.JSStaticFieldDefinition;
3433
import com.oracle.svm.hosted.webimage.js.JSStaticMethodDefinition;
34+
import com.oracle.svm.util.ReflectionUtil;
3535
import com.oracle.svm.webimage.longemulation.Long64;
3636

3737
import jdk.graal.compiler.core.common.calc.FloatConvert;
@@ -61,7 +61,6 @@ public class Long64Lowerer {
6161
public static final long JS_MAX_EXACT_INT53 = 9007199254740991L;
6262
public static final long JS_MIN_EXACT_INT53 = -9007199254740991L;
6363
private static final EconomicMap<Method, JSStaticMethodDefinition> staticJSMethodCache = EconomicMap.create();
64-
private static final EconomicMap<Field, JSStaticFieldDefinition> staticJSFieldCache = EconomicMap.create();
6564

6665
public static JSStaticMethodDefinition getJSStaticMethodDefinition(Method method, JSCodeGenTool jsLTools) {
6766
if (staticJSMethodCache.containsKey(method)) {
@@ -74,45 +73,21 @@ public static JSStaticMethodDefinition getJSStaticMethodDefinition(Method method
7473
}
7574
}
7675

77-
public static JSStaticFieldDefinition getJSStaticFieldDefinition(Field field, JSCodeGenTool jsLTools) {
78-
if (staticJSFieldCache.containsKey(field)) {
79-
return staticJSFieldCache.get(field);
80-
} else {
81-
ResolvedJavaField f = jsLTools.getProviders().getMetaAccess().lookupJavaField(field);
82-
JSStaticFieldDefinition jsStaticFieldDefinition = new JSStaticFieldDefinition(f);
83-
staticJSFieldCache.put(field, jsStaticFieldDefinition);
84-
return jsStaticFieldDefinition;
85-
}
86-
}
87-
8876
public static void lowerFromConstant(Constant c, JSCodeGenTool jsLTools) {
8977
assert c instanceof PrimitiveConstant : c;
9078
long longVal = ((PrimitiveConstant) c).asLong();
9179

92-
Method m;
9380
if (longVal == 0) {
94-
try {
95-
Field f = Long64.class.getField("LongZero");
96-
JSStaticFieldDefinition constantDefinition = Long64Lowerer.getJSStaticFieldDefinition(f, jsLTools);
97-
constantDefinition.emitAccess(jsLTools);
98-
} catch (NoSuchFieldException e) {
99-
throw GraalError.shouldNotReachHere(e); // ExcludeFromJacocoGeneratedReport
100-
}
81+
Field longZeroField = ReflectionUtil.lookupField(Long64.class, "LongZero");
82+
ResolvedJavaField resolvedField = jsLTools.getProviders().getMetaAccess().lookupJavaField(longZeroField);
83+
jsLTools.genStaticField(resolvedField);
10184
} else if (Integer.MIN_VALUE <= longVal && longVal <= Integer.MAX_VALUE) {
102-
try {
103-
m = Long64.class.getMethod("fromInt", int.class);
104-
} catch (NoSuchMethodException e) {
105-
throw GraalError.shouldNotReachHere(e); // ExcludeFromJacocoGeneratedReport
106-
}
85+
Method m = ReflectionUtil.lookupMethod(Long64.class, "fromInt", int.class);
10786
getJSStaticMethodDefinition(m, jsLTools).emitCall(jsLTools, Emitter.of((int) longVal));
10887
} else {
10988
int low = (int) longVal;
11089
int high = (int) (longVal >> 32);
111-
try {
112-
m = Long64.class.getMethod("fromTwoInt", int.class, int.class);
113-
} catch (NoSuchMethodException e) {
114-
throw GraalError.shouldNotReachHere(e); // ExcludeFromJacocoGeneratedReport
115-
}
90+
Method m = ReflectionUtil.lookupMethod(Long64.class, "fromTwoInt", int.class, int.class);
11691
getJSStaticMethodDefinition(m, jsLTools).emitCall(jsLTools, Emitter.of(low), Emitter.of(high));
11792
}
11893
}

web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/js/JSStaticFieldDefinition.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)