21
21
import org .jruby .util .log .LoggerFactory ;
22
22
23
23
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
-
28
24
private volatile int callCount = 0 ;
29
- private volatile InterpretedIRMethod baseMethod ;
25
+ private final InterpretedIRMethod baseMethod ;
30
26
private volatile DynamicMethod jittedMethod ;
31
27
32
28
public MixedModeIRMethod (IRScope method , Visibility visibility , RubyModule implementationClass ) {
@@ -42,6 +38,15 @@ public MixedModeIRMethod(IRScope method, Visibility visibility, RubyModule imple
42
38
}
43
39
}
44
40
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
+
45
50
public DynamicMethod getActualMethod () {
46
51
return jittedMethod != null ? jittedMethod : baseMethod ;
47
52
}
@@ -125,19 +130,28 @@ public String getClassName(ThreadContext context) {
125
130
return className ;
126
131
}
127
132
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
-
137
133
public void setCallCount (int callCount ) {
138
134
synchronized (this ) {
139
135
this .callCount = callCount ;
140
136
}
141
137
}
142
138
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
+ }
143
157
}
0 commit comments