Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rebase with Ola's latest trunk YARV changes

git-svn-id: http://svn.codehaus.org/jruby/branches/enebo_block@2834 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 526a65f95031b2f03457bb09b8239b26b2c93c4b 1 parent 2190d97
@enebo enebo authored
View
2  jruby/bin/jruby
@@ -141,6 +141,8 @@ if [ "$1" = "SERVER" ]; then
shift
fi
+JAVA_OPTS="-Djruby.jit.enabled=true -Djruby.tailcall.enabled=true"
+
"$JAVA_CMD" $JAVA_OPTS $DEBUG -Xmx256m -Xss1024k -ea -classpath "$CP" \
"-Djruby.base=$JRUBY_BASE" \
"-Djruby.home=$JRUBY_HOME" \
View
6 jruby/src/org/jruby/IRuby.java
@@ -432,4 +432,10 @@ public void callTraceFunction(ThreadContext context, String event, ISourcePositi
public Profile getProfile();
public String getJRubyHome();
+
+ /** GET_VM_STATE_VERSION */
+ public long getGlobalState();
+
+ /** INC_VM_STATE_VERSION */
+ public void incGlobalState();
}
View
15 jruby/src/org/jruby/Ruby.java
@@ -139,6 +139,8 @@
private boolean globalAbortOnExceptionEnabled = false;
private boolean doNotReverseLookupEnabled = false;
private final boolean objectSpaceEnabled;
+
+ private long globalState = 1;
/**
* What encoding should we read source files in as...
@@ -1652,4 +1654,17 @@ public String getJRubyHome() {
return jrubyHome;
}
+ /** GET_VM_STATE_VERSION */
+ public long getGlobalState() {
+ synchronized(this) {
+ return globalState;
+ }
+ }
+
+ /** INC_VM_STATE_VERSION */
+ public void incGlobalState() {
+ synchronized(this) {
+ globalState = (globalState+1) & 0x8fffffff;
+ }
+ }
}
View
15 jruby/src/org/jruby/ast/executable/YARVCompiledRunner.java
@@ -172,7 +172,7 @@ public void run() {
IRubyObject first = (IRubyObject)internal.get(1);
if(instruction == YARVInstructions.GETLOCAL || instruction == YARVInstructions.SETLOCAL) {
i.l_op0 = (iseq.locals.length + 1) - RubyNumeric.fix2long(first);
- } else if(instruction == YARVInstructions.PUTOBJECT || instruction == YARVInstructions.OPT_REGEXPMATCH1) {
+ } else if(instruction == YARVInstructions.PUTOBJECT || instruction == YARVInstructions.OPT_REGEXPMATCH1 || instruction == YARVInstructions.GETINLINECACHE) {
i.o_op0 = first;
} else if(first instanceof RubyString || first instanceof RubySymbol ) {
i.s_op0 = first.toString();
@@ -188,14 +188,23 @@ public void run() {
}
if(isJump(instruction)) {
i.index = n;
- jumps.put(i, internal.get(1).toString());
+ jumps.put(i, internal.get(jumpIndex(instruction)).toString());
}
}
return i;
}
private boolean isJump(int i) {
- return i == YARVInstructions.JUMP || i == YARVInstructions.BRANCHIF || i == YARVInstructions.BRANCHUNLESS;
+ return i == YARVInstructions.JUMP || i == YARVInstructions.BRANCHIF || i == YARVInstructions.BRANCHUNLESS ||
+ i == YARVInstructions.GETINLINECACHE || i == YARVInstructions.SETINLINECACHE;
+ }
+
+ private int jumpIndex(int i) {
+ if(i == YARVInstructions.GETINLINECACHE) {
+ return 2;
+ } else {
+ return 1;
+ }
}
private Object[] getExceptionInformation(IRubyObject obj) {
View
22 jruby/src/org/jruby/ast/executable/YARVMachine.java
@@ -54,6 +54,7 @@ public static int instruction(String name) {
String s_op0;
IRubyObject o_op0;
long l_op0;
+ long l_op1;
int i_op1;
InstructionSequence iseq_op;
Instruction[] ins_op;
@@ -174,6 +175,7 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
case YARVInstructions.SETCONSTANT:
RubyModule module = (RubyModule) context.peekCRef().getValue();
module.setConstant(bytecodes[ip].s_op0,stack[stackTop--]);
+ runtime.incGlobalState();
break;
case YARVInstructions.GETGLOBAL:
System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
@@ -332,12 +334,14 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
containingClass.callMethod(context, "method_added", runtime.newSymbol(mname));
}
stack[++stackTop] = runtime.getNil();
+ runtime.incGlobalState();
break;
case YARVInstructions.ALIAS:
System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNDEF:
System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
+ runtime.incGlobalState();
break;
case YARVInstructions.DEFINED:
System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
@@ -424,14 +428,24 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
}
continue yarvloop;
case YARVInstructions.GETINLINECACHE:
- System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
+ if(bytecodes[ip].l_op1 == runtime.getGlobalState()) {
+ stack[++stackTop] = bytecodes[ip].o_op0;
+ ip = (int)bytecodes[ip].l_op0;
+ continue yarvloop;
+ }
break;
case YARVInstructions.ONCEINLINECACHE:
- System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
+ if(bytecodes[ip].l_op1 > 0) {
+ stack[++stackTop] = bytecodes[ip].o_op0;
+ ip = (int)bytecodes[ip].l_op0;
+ continue yarvloop;
+ }
break;
case YARVInstructions.SETINLINECACHE:
- System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
-break;
+ int we = (int)bytecodes[ip].l_op0;
+ bytecodes[we].o_op0 = stack[stackTop];
+ bytecodes[we].l_op1 = runtime.getGlobalState();
+ break;
case YARVInstructions.OPT_CASE_DISPATCH:
System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
View
9 jruby/test/org/jruby/test/BaseMockRuby.java
@@ -732,4 +732,13 @@ public KCode getKCode() {
public void setKCode(KCode kcode) {
return;
}
+
+ /** GET_VM_STATE_VERSION */
+ public long getGlobalState() {
+ return 0;
+ }
+
+ /** INC_VM_STATE_VERSION */
+ public void incGlobalState() {
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.