Work on bug 258844: Continuation by default

This commit is contained in:
igor%mir2.org 2004-10-09 22:07:04 +00:00
Родитель 9e0265ff6d
Коммит 83a78ee629
7 изменённых файлов: 9 добавлений и 54 удалений

Просмотреть файл

@ -69,7 +69,7 @@ See <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=257128">Bugzilla 257128
<h4>Experimental support for continuations in the interpreter</h4>
<p>
The interpreter mode in Rhino contains an experimental support for continuations. It is based on the original implementation of Christopher Oliver and ideas from <a href="http://sisc.sourceforge.net/">SISC</a> project. To enable the continuation support in Java application please refer to the following <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=258844#c8">comment</a> in <a href="http://bugzilla.mozilla.org/">Bugzilla</a>. To use continuations with <a href="shell.html">Rhino shell</a> pass <tt>-continuations</tt> 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 <a href="http://sisc.sourceforge.net/">SISC</a> project. To enable the continuation support make sure that the interpreter mode is selected when you use Rhino through <a href="apidocs/org/mozilla/javascript/Context.html#setOptimizationLevel(int)">setting</a> the optimization level to -1 or if you use <a href="shell.html">shell</a> by passing <tt>-opt -1</tt> to the shell command line.
</p>
<p>
Please note that the details of implementation and Java and JavaScript API for continuations may change in future in incompatible way.

Просмотреть файл

@ -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
* <tt>Continuation</tt> object will be available to scripts.
* When used with pure interpretation mode (optimizatio level is -1)
* <tt>Continuation</tt>it allows to capture and restore continuations.
* <p> Note that currently implementation details/interfaces for
* continuation are subject to change and may not be backward compatible
* in future Rhino releases.
* <p>
* 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)

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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();