aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/runtime/CodeInstaller.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/CodeInstaller.java')
-rw-r--r--src/jdk/nashorn/internal/runtime/CodeInstaller.java51
1 files changed, 42 insertions, 9 deletions
diff --git a/src/jdk/nashorn/internal/runtime/CodeInstaller.java b/src/jdk/nashorn/internal/runtime/CodeInstaller.java
index 579b6f3e..e2b5afe8 100644
--- a/src/jdk/nashorn/internal/runtime/CodeInstaller.java
+++ b/src/jdk/nashorn/internal/runtime/CodeInstaller.java
@@ -25,6 +25,7 @@
package jdk.nashorn.internal.runtime;
+import java.util.Collection;
import java.util.Map;
import jdk.nashorn.internal.codegen.ClassEmitter;
@@ -48,12 +49,20 @@ public interface CodeInstaller<T> {
public T getOwner();
/**
- * Install a class
+ * Install a class.
* @param className name of the class with / separation
* @param bytecode bytecode
* @return the installed class
*/
- public Class<?> install(final String className, final byte[] bytecode, final Source source, final Object[] constants);
+ public Class<?> install(final String className, final byte[] bytecode);
+
+ /**
+ * Initialize already installed classes.
+ * @param classes the class to initialize
+ * @param source the source object for the classes
+ * @param constants the runtime constants for the classes
+ */
+ public void initialize(final Collection<Class<?>> classes, final Source source, final Object[] constants);
/**
* Verify generated bytecode before emission. This is called back from the
@@ -71,17 +80,41 @@ public interface CodeInstaller<T> {
public long getUniqueScriptId();
/**
- * Get next unique eval id
- * @return unique eval id
- */
- public long getUniqueEvalId();
-
- /**
* Store a compiled script for later reuse
+ *
+ * @param cacheKey key to use in cache
* @param source the script source
* @param mainClassName the main class name
* @param classBytes map of class names to class bytes
+ * @param initializers compilation id -> FunctionInitializer map
* @param constants constants array
+ * @param compilationId compilation id
+ */
+ public void storeScript(final String cacheKey, final Source source, final String mainClassName, final Map<String, byte[]> classBytes,
+ final Map<Integer, FunctionInitializer> initializers, final Object[] constants, final int compilationId);
+
+ /**
+ * Load a previously compiled script
+ * @param source the script source
+ * @param functionKey the function id and signature
+ * @return compiled script data
+ */
+ public StoredScript loadScript(Source source, String functionKey);
+
+ /**
+ * Returns a new code installer that shares most of the functionality of this code installer, but uses a
+ * new, independent class loader.
+ * @return a new code installer with a new independent class loader.
*/
- public void storeCompiledScript(Source source, String mainClassName, Map<String, byte[]> classBytes, Object[] constants);
+ public CodeInstaller<T> withNewLoader();
+
+ /**
+ * Returns true if this code installer is compatible with the other code installer. Compatibility is expected to be
+ * an equivalence relation, and installers are supposed to be compatible with those they create using
+ * {@link #withNewLoader()}.
+ * @param other the other code installer tested for compatibility with this code installer.
+ * @return true if this code installer is compatible with the other code installer.
+ */
+ public boolean isCompatibleWith(CodeInstaller<T> other);
+
}