Skip to content

Commit fab136d

Browse files
committedMar 22, 2018
Fix regression in module_function behavior.
1 parent b4b496a commit fab136d

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed
 

Diff for: ‎core/src/main/java/org/jruby/internal/runtime/methods/MixedModeIRMethod.java

+28-14
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121
import org.jruby.util.log.LoggerFactory;
2222

2323
public class MixedModeIRMethod extends AbstractIRMethod implements Compilable<DynamicMethod> {
24-
private static final Logger LOG = LoggerFactory.getLogger(MixedModeIRMethod.class);
25-
26-
private boolean displayedCFG = false; // FIXME: Remove when we find nicer way of logging CFG
27-
2824
private volatile int callCount = 0;
29-
private volatile InterpretedIRMethod baseMethod;
25+
private final InterpretedIRMethod baseMethod;
3026
private volatile DynamicMethod jittedMethod;
3127

3228
public MixedModeIRMethod(IRScope method, Visibility visibility, RubyModule implementationClass) {
@@ -42,6 +38,15 @@ public MixedModeIRMethod(IRScope method, Visibility visibility, RubyModule imple
4238
}
4339
}
4440

41+
protected MixedModeIRMethod(MixedModeIRMethod copy) {
42+
super(copy.getIRScope(), copy.getVisibility(), copy.getImplementationClass());
43+
44+
this.serialNumber = copy.serialNumber;
45+
this.callCount = copy.callCount;
46+
this.baseMethod = copy.baseMethod;
47+
this.jittedMethod = copy.jittedMethod;
48+
}
49+
4550
public DynamicMethod getActualMethod() {
4651
return jittedMethod != null ? jittedMethod : baseMethod;
4752
}
@@ -125,19 +130,28 @@ public String getClassName(ThreadContext context) {
125130
return className;
126131
}
127132

128-
@Override
129-
public DynamicMethod dup() {
130-
MixedModeIRMethod x = (MixedModeIRMethod) super.dup();
131-
x.callCount = callCount;
132-
x.baseMethod = baseMethod;
133-
134-
return x;
135-
}
136-
137133
public void setCallCount(int callCount) {
138134
synchronized (this) {
139135
this.callCount = callCount;
140136
}
141137
}
142138

139+
@Override
140+
public DynamicMethod dup() {
141+
return new MixedModeIRMethod(this);
142+
}
143+
144+
@Override
145+
public void setImplementationClass(RubyModule implClass) {
146+
super.setImplementationClass(implClass);
147+
baseMethod.setImplementationClass(implClass);
148+
if (jittedMethod != null) jittedMethod.setImplementationClass(implClass);
149+
}
150+
151+
@Override
152+
public void setDefinedClass(RubyModule definedClass) {
153+
super.setDefinedClass(definedClass);
154+
baseMethod.setDefinedClass(definedClass);
155+
if (jittedMethod != null) jittedMethod.setDefinedClass(definedClass);
156+
}
143157
}

0 commit comments

Comments
 (0)
Please sign in to comment.