diff --git a/js/rhino/docs/changes.html b/js/rhino/docs/changes.html index dbc81281873d..0d58f02c36d2 100644 --- a/js/rhino/docs/changes.html +++ b/js/rhino/docs/changes.html @@ -69,7 +69,7 @@ See Bugzilla 257128

Experimental support for continuations in the interpreter

-The interpreter mode in Rhino contains an experimental support for continuations. It is based on the original implementation of Christopher Oliver and ideas from SISC project. To enable the continuation support in Java application please refer to the following comment in Bugzilla. To use continuations with Rhino shell pass -continuations flag when invoking the shell. +The interpreter mode in Rhino contains an experimental support for continuations. It is based on the original implementation of Christopher Oliver and ideas from SISC project. To enable the continuation support make sure that the interpreter mode is selected when you use Rhino through setting the optimization level to -1 or if you use shell by passing -opt -1 to the shell command line.

Please note that the details of implementation and Java and JavaScript API for continuations may change in future in incompatible way. diff --git a/js/rhino/src/org/mozilla/javascript/Context.java b/js/rhino/src/org/mozilla/javascript/Context.java index 9eff9093bf4d..c53913271c85 100644 --- a/js/rhino/src/org/mozilla/javascript/Context.java +++ b/js/rhino/src/org/mozilla/javascript/Context.java @@ -230,22 +230,6 @@ public class Context */ public static final int FEATURE_DYNAMIC_SCOPE = 7; - /** - * Control if experimental support for the continuations in the - * interpreter is enabled. - * If Rhino embedding enables this experimental features, then - * Continuation object will be available to scripts. - * When used with pure interpretation mode (optimizatio level is -1) - * Continuationit allows to capture and restore continuations. - *

Note that currently implementation details/interfaces for - * continuation are subject to change and may not be backward compatible - * in future Rhino releases. - *

- * By default {@link #hasFeature(int)} returns false. - * @since 1.6 Release 1 - */ - public static final int FEATURE_INTERPRETER_CONTINUATIONS = 8; - /** * Control if strict mode is enabled. * With strict mode enabled Rhino reports runtime errors in the following @@ -259,7 +243,7 @@ public class Context * By default {@link #hasFeature(int)} returns false. * @since 1.6 Release 1 */ - public static final int FEATURE_STRICT_MODE = 9; + public static final int FEATURE_STRICT_MODE = 8; public static final String languageVersionProperty = "language version"; public static final String errorReporterProperty = "error reporter"; @@ -1843,6 +1827,10 @@ public class Context public final void setOptimizationLevel(int optimizationLevel) { if (sealed) onSealedMutation(); + if (optimizationLevel == -2) { + // To be compatible with Cocoon fork + optimizationLevel = -1; + } checkOptimizationLevel(optimizationLevel); if (codegenClass == null) optimizationLevel = -1; @@ -2135,7 +2123,6 @@ public class Context * @see #FEATURE_PARENT_PROTO_PROPRTIES * @see #FEATURE_E4X * @see #FEATURE_DYNAMIC_SCOPE - * @see #FEATURE_INTERPRETER_CONTINUATIONS * @see #FEATURE_STRICT_MODE */ public boolean hasFeature(int featureIndex) diff --git a/js/rhino/src/org/mozilla/javascript/ContextFactory.java b/js/rhino/src/org/mozilla/javascript/ContextFactory.java index 2c2aed358e66..46ddf39f3487 100644 --- a/js/rhino/src/org/mozilla/javascript/ContextFactory.java +++ b/js/rhino/src/org/mozilla/javascript/ContextFactory.java @@ -266,9 +266,6 @@ public class ContextFactory case Context.FEATURE_DYNAMIC_SCOPE: return false; - case Context.FEATURE_INTERPRETER_CONTINUATIONS: - return false; - case Context.FEATURE_STRICT_MODE: return false; } diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index 6b0532c6d4a9..a79799121528 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -175,9 +175,7 @@ public class ScriptRuntime { new LazilyLoadedCtor(scope, topProperty, className, sealed); } - if (cx.hasFeature(Context.FEATURE_INTERPRETER_CONTINUATIONS)) { - Continuation.init(cx, scope, sealed); - } + Continuation.init(cx, scope, sealed); return scope; } diff --git a/js/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java b/js/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java index b4374b0dbeba..a7555c7545cb 100644 --- a/js/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java +++ b/js/rhino/src/org/mozilla/javascript/serialize/ScriptableOutputStream.java @@ -122,21 +122,12 @@ public class ScriptableOutputStream extends ObjectOutputStream { "Number", "Number.prototype", "Date", "Date.prototype", "RegExp", "RegExp.prototype", - "Script", "Script.prototype" + "Script", "Script.prototype", + "Continuation", "Continuation.prototype" }; for (int i=0; i < names.length; i++) { addExcludedName(names[i]); } - boolean hasContinuations = false; - Context cx = Context.getCurrentContext(); - if (cx != null) { - hasContinuations - = cx.hasFeature(Context.FEATURE_INTERPRETER_CONTINUATIONS); - } - if (hasContinuations) { - addExcludedName("Continuation"); - addExcludedName("Continuation.prototype"); - } } static Object lookupQualifiedName(Scriptable scope, diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java index f846551dab5b..bb9a3b186969 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java @@ -218,27 +218,18 @@ public class Main } if (opt == -2) { // Compatibility with Cocoon Rhino fork - shellContextFactory.setEnableContinuations(true); opt = -1; } else if (!Context.isValidOptimizationLevel(opt)) { usageError = args[i]; break goodUsage; } shellContextFactory.setOptimizationLevel(opt); - if (opt >= 0) { - shellContextFactory.setEnableContinuations(false); - } continue; } if (arg.equals("-strict")) { shellContextFactory.setStrictMode(true); continue; } - if (arg.equals("-continuations")) { - shellContextFactory.setEnableContinuations(true); - shellContextFactory.setOptimizationLevel(-1); - continue; - } if (arg.equals("-e")) { processStdin = false; if (++i == args.length) { diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/ShellContextFactory.java b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/ShellContextFactory.java index 187b666f5e85..d49b48519011 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/ShellContextFactory.java +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/ShellContextFactory.java @@ -40,7 +40,6 @@ import org.mozilla.javascript.tools.ToolErrorReporter; public class ShellContextFactory extends ContextFactory { - private boolean enableContinuations; private boolean strictMode; private int languageVersion; private int optimizationLevel; @@ -51,8 +50,6 @@ public class ShellContextFactory extends ContextFactory switch (featureIndex) { case Context.FEATURE_STRICT_MODE: return strictMode; - case Context.FEATURE_INTERPRETER_CONTINUATIONS: - return enableContinuations; } return super.hasFeature(cx, featureIndex); } @@ -67,12 +64,6 @@ public class ShellContextFactory extends ContextFactory super.onContextCreated(cx); } - public void setEnableContinuations(boolean flag) - { - checkNotSealed(); - this.enableContinuations = flag; - } - public void setStrictMode(boolean flag) { checkNotSealed();