Permalink
Browse files

Remove all code and references to the outdated and nonfunctional YARV…

… 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 2257c8f811fab8d675a942c86ab712922dc46c6f
View
@@ -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;
@@ -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);
}
@@ -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);
}
}
@@ -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) {
@@ -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);
}
@@ -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();
@@ -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);
@@ -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();
@@ -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();
@@ -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;
@@ -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();
}
@@ -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");
@@ -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;
}
@@ -1,60 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2007 Ola Bini <ola.bini@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-package org.jruby.ast.executable;
-
-import org.jruby.RubyArray;
-import org.jruby.RubyNumeric;
-import org.jruby.runtime.builtin.IRubyObject;
-
-/**
- * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
- */
-public class RubiniusCMethod {
- public String name;
- public String file;
- public int locals;
- public IRubyObject[] literals;
- public char[] code;
- public int required;
-
- public RubiniusCMethod(RubyArray obj) {
- code = obj.eltInternal(4).toString().toCharArray();
- name = obj.eltInternal(5).toString();
- file = obj.eltInternal(6).toString();
- locals = RubyNumeric.fix2int(obj.eltInternal(7));
- required = RubyNumeric.fix2int(obj.eltInternal(2));
- literals = toArray(obj.eltInternal(8));
- }
-
- private final IRubyObject[] toArray(IRubyObject oo) {
- if(oo.isNil()) {
- return new IRubyObject[0];
- }
- return (IRubyObject[])((RubyArray)oo).toArray(new IRubyObject[0]);
- }
-}// RubiniusCMethod
Oops, something went wrong.

0 comments on commit 2257c8f

Please sign in to comment.