Skip to content

Commit

Permalink
Remove all code and references to the outdated and nonfunctional YARV…
Browse files Browse the repository at this point in the history
… and RBX bytecode support. Both have evolved since, both will need a fresh look, and current interpreter is now much faster than either engine.
  • Loading branch information
headius committed Apr 10, 2009
1 parent da23e51 commit 2257c8f
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 3,645 deletions.
87 changes: 19 additions & 68 deletions src/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@
import org.jcodings.Encoding;
import org.joda.time.DateTimeZone;
import org.jruby.ast.Node;
import org.jruby.ast.executable.RubiniusRunner;
import org.jruby.ast.executable.Script;
import org.jruby.ast.executable.YARVCompiledRunner;
import org.jruby.common.RubyWarnings;
import org.jruby.common.IRubyWarnings.ID;
import org.jruby.compiler.ASTCompiler;
import org.jruby.compiler.ASTInspector;
import org.jruby.compiler.JITCompiler;
import org.jruby.compiler.NotCompilableException;
import org.jruby.compiler.impl.StandardASMCompiler;
import org.jruby.compiler.yarv.StandardYARVCompiler;
import org.jruby.compiler.NotCompilableException;
import org.jruby.exceptions.JumpException;
import org.jruby.exceptions.MainExitException;
import org.jruby.exceptions.RaiseException;
Expand Down Expand Up @@ -295,7 +292,7 @@ public IRubyObject executeScript(String script, String filename) {
int oldLine = context.getLine();
try {
context.setFileAndLine(node.getPosition());
return runNormally(node, false);
return runNormally(node);
} finally {
context.setFileAndLine(oldFile, oldLine);
}
Expand Down Expand Up @@ -348,30 +345,22 @@ public void runFromMain(InputStream inputStream, String filename) {
return;
}

if(config.isYARVEnabled()) {
if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode");
new YARVCompiledRunner(this, inputStream, filename).run();
} else if(config.isRubiniusEnabled()) {
if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode");
new RubiniusRunner(this, inputStream, filename).run();
} else {
Node scriptNode = parseFromMain(inputStream, filename);
ThreadContext context = getCurrentContext();
Node scriptNode = parseFromMain(inputStream, filename);
ThreadContext context = getCurrentContext();

String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(scriptNode.getPosition());
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(scriptNode.getPosition());

if (config.isAssumePrinting() || config.isAssumeLoop()) {
runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(),
config.isSplit(), config.isYARVCompileEnabled());
} else {
runNormally(scriptNode, config.isYARVCompileEnabled());
}
} finally {
context.setFileAndLine(oldFile, oldLine);
if (config.isAssumePrinting() || config.isAssumeLoop()) {
runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(),
config.isSplit());
} else {
runNormally(scriptNode);
}
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}

Expand Down Expand Up @@ -405,24 +394,20 @@ public Node parseFromMain(InputStream inputStream, String filename) {
* @param processLineEnds Whether line endings should be processed by
* setting $\ to $/ and <code>chop!</code>ing every line read
* @param split Whether to split each line read using <code>String#split</code>
* @param yarvCompile Whether to compile the target script to YARV (Ruby 1.9)
* bytecode before executing.
* @return The result of executing the specified script
*/
public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean processLineEnds, boolean split, boolean yarvCompile) {
public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean processLineEnds, boolean split) {
ThreadContext context = getCurrentContext();

Script script = null;
YARVCompiledRunner runner = null;
boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI();
if (compile || !yarvCompile) {
if (compile) {
script = tryCompile(scriptNode);
if (compile && script == null) {
// terminate; tryCompile will have printed out an error and we're done
return getNil();
}
} else if (yarvCompile) {
runner = tryCompileYarv(scriptNode);
}

if (processLineEnds) {
Expand All @@ -447,8 +432,6 @@ public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean pr

if (script != null) {
runScriptBody(script);
} else if (runner != null) {
runYarv(runner);
} else {
runInterpreterBody(scriptNode);
}
Expand Down Expand Up @@ -478,19 +461,14 @@ public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean pr
* code.
*
* @param scriptNode The root node of the script to be executed
* @param yarvCompile Whether to compile the script to YARV (Ruby 1.9)
* bytecode before execution
* @return The result of executing the script
*/
public IRubyObject runNormally(Node scriptNode, boolean yarvCompile) {
public IRubyObject runNormally(Node scriptNode) {
Script script = null;
YARVCompiledRunner runner = null;
boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI();
boolean forceCompile = getInstanceConfig().getCompileMode().shouldPrecompileAll();
if (yarvCompile) {
runner = tryCompileYarv(scriptNode);
// FIXME: Once 1.9 compilation is supported this should be removed
} else if (compile) {
if (compile) {
script = tryCompile(scriptNode);
if (forceCompile && script == null) {
return getNil();
Expand All @@ -503,8 +481,6 @@ public IRubyObject runNormally(Node scriptNode, boolean yarvCompile) {
} else {
return runScript(script);
}
} else if (runner != null) {
return runYarv(runner);
} else {
if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode");
return runInterpreter(scriptNode);
Expand Down Expand Up @@ -577,23 +553,6 @@ private Script tryCompile(Node node, JRubyClassLoader classLoader) {
return script;
}

private YARVCompiledRunner tryCompileYarv(Node node) {
try {
StandardYARVCompiler compiler = new StandardYARVCompiler(this);
ASTCompiler.getYARVCompiler().compile(node, compiler);
org.jruby.lexer.yacc.ISourcePosition p = node.getPosition();
if(p == null && node instanceof org.jruby.ast.RootNode) {
p = ((org.jruby.ast.RootNode)node).getBodyNode().getPosition();
}
return new YARVCompiledRunner(this,compiler.getInstructionSequence("<main>",p.getFile(),"toplevel"));
} catch (NotCompilableException nce) {
System.err.println("Error -- Not compileable: " + nce.getMessage());
return null;
} catch (JumpException.ReturnJump rj) {
return null;
}
}

private IRubyObject runScript(Script script) {
ThreadContext context = getCurrentContext();

Expand All @@ -618,14 +577,6 @@ private IRubyObject runScriptBody(Script script) {
}
}

private IRubyObject runYarv(YARVCompiledRunner runner) {
try {
return runner.run();
} catch (JumpException.ReturnJump rj) {
return (IRubyObject) rj.getValue();
}
}

public IRubyObject runInterpreter(Node scriptNode) {
ThreadContext context = getCurrentContext();

Expand Down
26 changes: 1 addition & 25 deletions src/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ public boolean shouldPrecompileAll() {
private boolean shouldRunInterpreter = true;
private boolean shouldPrintUsage = false;
private boolean shouldPrintProperties=false;
private boolean yarv = false;
private boolean rubinius = false;
private boolean yarvCompile = false;
private KCode kcode = KCode.NONE;
private String recordSeparator = "\n";
private boolean shouldCheckSyntax = false;
Expand Down Expand Up @@ -406,10 +403,7 @@ public String getExtendedHelp() {
.append(" -O run with ObjectSpace disabled (default; improves performance)\n")
.append(" +O run with ObjectSpace enabled (reduces performance)\n")
.append(" -C disable all compilation\n")
.append(" +C force compilation of all scripts before they are run (except eval)\n")
.append(" -y read a YARV-compiled Ruby script and run that (EXPERIMENTAL)\n")
.append(" -Y compile a Ruby script into YARV bytecodes and run this (EXPERIMENTAL)\n")
.append(" -R read a Rubinius-compiled Ruby script and run that (EXPERIMENTAL)\n");
.append(" +C force compilation of all scripts before they are run (except eval)\n");

return sb.toString();
}
Expand Down Expand Up @@ -936,12 +930,6 @@ private void processArgument() {
compileMode = CompileMode.OFF;
} else if (extendedOption.equals("+C")) {
compileMode = CompileMode.FORCE;
} else if (extendedOption.equals("-y")) {
yarv = true;
} else if (extendedOption.equals("-Y")) {
yarvCompile = true;
} else if (extendedOption.equals("-R")) {
rubinius = true;
} else {
MainExitException mee =
new MainExitException(1, "jruby: invalid extended option " + extendedOption + " (-X will list valid options)\n");
Expand Down Expand Up @@ -1234,22 +1222,10 @@ public boolean isShouldCheckSyntax() {
return shouldCheckSyntax;
}

public boolean isYARVEnabled() {
return yarv;
}

public String getInputFieldSeparator() {
return inputFieldSeparator;
}

public boolean isRubiniusEnabled() {
return rubinius;
}

public boolean isYARVCompileEnabled() {
return yarvCompile;
}

public KCode getKCode() {
return kcode;
}
Expand Down
60 changes: 0 additions & 60 deletions src/org/jruby/ast/executable/RubiniusCMethod.java

This file was deleted.

0 comments on commit 2257c8f

Please sign in to comment.