Skip to content

Commit

Permalink
Implement JVM part of ModuleVersionGuardInstr.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jan 24, 2017
1 parent e0209c9 commit b59a143
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Expand Up @@ -68,4 +68,8 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco

return context.nil; /* not used */
}

public int getIPC() {
return ipc;
}
}
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Expand Up @@ -1493,7 +1493,10 @@ public void MatchInstr(MatchInstr matchInstr) {

@Override
public void ModuleVersionGuardInstr(ModuleVersionGuardInstr moduleversionguardinstr) {
// throw new NotCompilableException("Unsupported instruction: " + moduleversionguardinstr);
visit(moduleversionguardinstr.getCandidateObject());
jvmAdapter().pushInt(moduleversionguardinstr.getExpectedVersion());
jvmAdapter().pushInt(moduleversionguardinstr.getIPC());
jvmMethod().invokeHelper("isGenerationEqual", void.class, IRubyObject.class, int.class, int.class);
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Expand Up @@ -30,6 +30,7 @@
import org.jruby.ir.Interp;
import org.jruby.ir.JIT;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.runtime.IRDeoptimization;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.javasupport.JavaClass;
import org.jruby.javasupport.JavaUtil;
Expand Down Expand Up @@ -2190,6 +2191,12 @@ public static boolean isGenerationEqual(IRubyObject object, int generation) {
return metaClass.getGeneration() == generation;
}

public static void checkGeneration(IRubyObject object, int generation, int ipc) {
if (!isGenerationEqual(object, generation)) {
throw new IRDeoptimization(ipc);
}
}

public static String[] getScopeNames(String scopeNames) {
StringTokenizer toker = new StringTokenizer(scopeNames, ";");
ArrayList list = new ArrayList(10);
Expand Down

0 comments on commit b59a143

Please sign in to comment.