Skip to content

Commit

Permalink
Tweaks to method definition in JIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Sep 20, 2014
1 parent 8782912 commit b941dac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 10 additions & 8 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public static IRubyObject handlePropagatedBreak(ThreadContext context, DynamicSc
}
}

public static IRubyObject defCompiledIRMethod(ThreadContext context, MethodHandle handle, String rubyName, DynamicScope currDynScope, IRubyObject self, String scopeDesc,
// Used by JIT
public static void defCompiledIRMethod(ThreadContext context, MethodHandle handle, String rubyName, DynamicScope currDynScope, IRubyObject self, String scopeDesc,
String filename, int line, String parameterDesc, boolean hasExplicitCallProtocol) {
Ruby runtime = context.runtime;
StaticScope parentScope = currDynScope.getStaticScope();
Expand All @@ -200,10 +201,11 @@ public static IRubyObject defCompiledIRMethod(ThreadContext context, MethodHandl

DynamicMethod method = new CompiledIRMethod(handle, rubyName, filename, line, scope, newVisibility, containingClass, parameterDesc, hasExplicitCallProtocol);

return Helpers.addInstanceMethod(containingClass, rubyName, method, currVisibility, context, runtime);
Helpers.addInstanceMethod(containingClass, rubyName, method, currVisibility, context, runtime);
}

public static IRubyObject defCompiledIRClassMethod(ThreadContext context, IRubyObject obj, MethodHandle handle, String rubyName, StaticScope parentScope, String scopeDesc,
// Used by JIT
public static void defCompiledIRClassMethod(ThreadContext context, IRubyObject obj, MethodHandle handle, String rubyName, StaticScope parentScope, String scopeDesc,
String filename, int line, String parameterDesc, boolean hasExplicitCallProtocol) {
Ruby runtime = context.runtime;

Expand All @@ -215,16 +217,16 @@ public static IRubyObject defCompiledIRClassMethod(ThreadContext context, IRubyO

RubyClass containingClass = obj.getSingletonClass();

Visibility currVisibility = context.getCurrentVisibility();
Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, containingClass, rubyName, currVisibility);

StaticScope scope = Helpers.decodeScope(context, parentScope, scopeDesc);

DynamicMethod method = new CompiledIRMethod(handle, rubyName, filename, line, scope, newVisibility, containingClass, parameterDesc, hasExplicitCallProtocol);
DynamicMethod method = new CompiledIRMethod(handle, rubyName, filename, line, scope, Visibility.PUBLIC, containingClass, parameterDesc, hasExplicitCallProtocol);

containingClass.addMethod(rubyName, method);

return Helpers.addInstanceMethod(containingClass, rubyName, method, currVisibility, context, runtime);
obj.callMethod(context, "singleton_method_added", runtime.fastNewSymbol(rubyName));
}

// Used by JIT
public static IRubyObject undefMethod(ThreadContext context, Object nameArg, DynamicScope currDynScope, IRubyObject self) {
RubyModule module = IRRuntimeHelpers.findInstanceMethodContainer(context, currDynScope, self);
String name = (nameArg instanceof String) ?
Expand Down
8 changes: 2 additions & 6 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,8 @@ public void DefineClassMethodInstr(DefineClassMethodInstr defineclassmethodinstr

// add method
a.invokestatic(p(IRRuntimeHelpers.class), "defCompiledIRClassMethod",
sig(IRubyObject.class, ThreadContext.class, IRubyObject.class, java.lang.invoke.MethodHandle.class, String.class,
sig(void.class, ThreadContext.class, IRubyObject.class, java.lang.invoke.MethodHandle.class, String.class,
StaticScope.class, String.class, String.class, int.class, String.class, boolean.class));

a.pop();
}

// SSS FIXME: Needs an update to reflect instr. change
Expand Down Expand Up @@ -1000,10 +998,8 @@ public void DefineInstanceMethodInstr(DefineInstanceMethodInstr defineinstanceme

// add method
a.invokestatic(p(IRRuntimeHelpers.class), "defCompiledIRMethod",
sig(IRubyObject.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, String.class,
sig(void.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, String.class,
DynamicScope.class, IRubyObject.class, String.class, String.class, int.class, String.class, boolean.class));

a.pop();
}

@Override
Expand Down

0 comments on commit b941dac

Please sign in to comment.