Mercurial > hg > truffle
changeset 12501:128bf29518a0
added limited ability for one HotSpotBackendFactory to override another
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 21 Oct 2013 17:42:19 +0200 |
parents | 0806a46dced5 |
children | 28f56bf7c06a |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Oct 21 17:41:27 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Oct 21 17:42:19 2013 +0200 @@ -105,11 +105,11 @@ for (HotSpotBackendFactory factory : ServiceLoader.loadInstalled(HotSpotBackendFactory.class)) { if (factory.getArchitecture().equalsIgnoreCase(architecture)) { if (factory.getGraalRuntimeName().equals(GraalRuntime.getValue())) { - assert selected == null; + assert selected == null || checkFactoryOverriding(selected, factory); selected = factory; } if (factory.getGraalRuntimeName().equals("basic")) { - assert basic == null; + assert basic == null || checkFactoryOverriding(basic, factory); basic = factory; } else { nonBasic = factory; @@ -135,6 +135,18 @@ } /** + * Checks that a factory overriding is valid. A factory B can only override/replace a factory A + * if the B.getClass() is a subclass of A.getClass(). This models the assumption that B is + * extends the behavior of A and has therefore understood the behavior expected of A. + * + * @param baseFactory + * @param overridingFactory + */ + private static boolean checkFactoryOverriding(HotSpotBackendFactory baseFactory, HotSpotBackendFactory overridingFactory) { + return baseFactory.getClass().isAssignableFrom(overridingFactory.getClass()); + } + + /** * Gets the kind of a word value on the {@linkplain #getHostBackend() host} backend. */ public static Kind getHostWordKind() {