diff --git a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java index 289a5a41d663..0144b99658c3 100644 --- a/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java +++ b/sulong/projects/com.oracle.truffle.llvm.runtime/src/com/oracle/truffle/llvm/runtime/LLVMLanguage.java @@ -96,6 +96,7 @@ public abstract static class Loader implements LLVMCapability { } public List getLanguageContextExtension() { + verifyContextExtensionsInitialized(); return contextExtensions; } @@ -109,6 +110,7 @@ public T getContextExtension(Class type) { public T getContextExtensionOrNull(Class type) { CompilerAsserts.neverPartOfCompilation(); + verifyContextExtensionsInitialized(); for (ContextExtension ce : contextExtensions) { if (ce.extensionClass() == type) { return type.cast(ce); @@ -117,6 +119,13 @@ public T getContextExtensionOrNull(Class type) { return null; } + private void verifyContextExtensionsInitialized() { + CompilerAsserts.neverPartOfCompilation(); + if (contextExtensions == null) { + throw new IllegalStateException("LLVMContext is not yet initialized"); + } + } + /** * Do not use this on fast-path. */ @@ -167,7 +176,6 @@ protected LLVMContext createContext(Env env) { Toolchain toolchain = new ToolchainImpl(activeConfiguration.getCapability(ToolchainConfig.class), this); env.registerService(toolchain); - this.contextExtensions = activeConfiguration.createContextExtensions(env); LLVMContext context = new LLVMContext(this, env, getLanguageHome(), toolchain); return context; @@ -175,6 +183,7 @@ protected LLVMContext createContext(Env env) { @Override protected void initializeContext(LLVMContext context) { + this.contextExtensions = activeConfiguration.createContextExtensions(context.getEnv()); context.initialize(); }