Class<?> getProxyClass(Member member) { Class<?> ret = proxyMap.get(member); if (ret == null) { /* the unique ID is added for unit tests that don't change the class loader */ String name = getStableProxyName(member) + PROXY_NAME_SEPARATOR + proxyNr.incrementAndGet(); Class<?> iface = getAccessorInterface(member); byte[] proxyBC = generateProxyClass(name, new Class<?>[]{iface, ReflectionProxy.class}); try { ret = (Class<?>) defineClass.invoke(imageClassLoader.getClassLoader(), name, proxyBC, 0, proxyBC.length); resolveClass.invoke(imageClassLoader.getClassLoader(), ret); proxyMap.put(member, ret); ResolvedJavaType type = metaAccess.lookupJavaType(ret); typeToMember.put(type, member); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw VMError.shouldNotReachHere(ex); } } return ret; }
/** * Make sure the runtime is initialized for threading. */ @Uninterruptible(reason = "Called from uninterruptible code. Too early for safepoints.") public static boolean ensureInitialized() { boolean result = true; if (initializationState.compareAndSet(STATE_UNINITIALIZED, STATE_INITIALIZING)) { /* * We claimed the initialization lock, so we are now responsible for doing all the * initialization. */ result = singleton().initializeOnce(); initializationState.set(STATE_INITIALIZED); } else { /* Already initialized, or some other thread claimed the initialization lock. */ while (initializationState.get() < STATE_INITIALIZED) { /* Busy wait until the other thread finishes the initialization. */ } } return result; }
public static int getSlowPathFrozen() { assert Options.GatherSafepointStatistics.getValue() : "Should have set GatherSafepointStatistics."; return slowPathFrozen.get(); }
public static int getFrozen() { assert Options.GatherSafepointStatistics.getValue() : "Should have set GatherSafepointStatistics."; return frozen.get(); }
/** Is threading being torn down? */ @Uninterruptible(reason = "Called from uninterruptible code during tear down.") public static boolean isTearingDown() { return initializationState.get() >= STATE_TEARING_DOWN; }
@Uninterruptible(reason = "Called when safepoints are requested.") public static void incSlowPathFrozen() { if (Options.GatherSafepointStatistics.getValue()) { slowPathFrozen.incrementAndGet(); } }
public static int getThawed() { assert Options.GatherSafepointStatistics.getValue() : "Should have set GatherSafepointStatistics."; return thawed.get(); }
@Uninterruptible(reason = "Called from uninterruptible code. Too early for safepoints.") public static boolean isInitialized() { return initializationState.get() >= STATE_INITIALIZED; }
@Uninterruptible(reason = "Called when safepoints are requested.") public static void incFrozen() { if (Options.GatherSafepointStatistics.getValue()) { frozen.incrementAndGet(); } }
/** Note that threading is being torn down. */ protected static void setTearingDown() { initializationState.set(STATE_TEARING_DOWN); }
@Uninterruptible(reason = "Called during safepointing.") public static void incThawed() { if (Options.GatherSafepointStatistics.getValue()) { thawed.incrementAndGet(); } }