--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MarkId.java Thu Oct 17 20:27:44 2019 +0100
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MarkId.java Thu Oct 17 20:53:35 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, 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
@@ -25,6 +25,7 @@
package jdk.tools.jaotc;
+import java.util.HashMap;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
/**
@@ -56,17 +57,22 @@
INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED("CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED");
private final int value;
+ private static HashMap<Integer, MarkId> lookup = new HashMap<Integer, MarkId>();
+ static {
+ for (MarkId e : values()) {
+ lookup.put(e.value, e);
+ }
+ }
MarkId(String name) {
this.value = (int) (long) HotSpotJVMCIRuntime.runtime().getConfigStore().getConstants().get(name);
}
static MarkId getEnum(int value) {
- for (MarkId e : values()) {
- if (e.value == value) {
- return e;
- }
+ MarkId e = lookup.get(value);
+ if (e == null) {
+ throw new InternalError("Unknown enum value: " + value);
}
- throw new InternalError("Unknown enum value: " + value);
+ return e;
}
}