5
5
import org .jruby .runtime .Block ;
6
6
import org .jruby .runtime .BlockBody ;
7
7
import org .jruby .runtime .CompiledIRBlockBody ;
8
- import org .jruby .runtime .Helpers ;
9
8
import org .jruby .runtime .ThreadContext ;
10
9
import org .jruby .runtime .builtin .IRubyObject ;
11
10
import org .jruby .util .cli .Options ;
11
+ import org .jruby .util .log .Logger ;
12
+ import org .jruby .util .log .LoggerFactory ;
12
13
import org .objectweb .asm .Handle ;
13
14
import org .objectweb .asm .Opcodes ;
14
15
27
28
public class YieldSite extends MutableCallSite {
28
29
private final boolean unwrap ;
29
30
31
+ private static final Logger LOG = LoggerFactory .getLogger (YieldSite .class );
32
+
30
33
public YieldSite (MethodType type , boolean unwrap ) {
31
34
super (type );
32
35
@@ -74,8 +77,16 @@ public IRubyObject yield(ThreadContext context, Block block, IRubyObject arg) th
74
77
if (block .getBody () instanceof CompiledIRBlockBody ) {
75
78
CompiledIRBlockBody compiledBody = (CompiledIRBlockBody ) block .getBody ();
76
79
80
+ if (Options .INVOKEDYNAMIC_LOG_BINDING .load ()) {
81
+ LOG .info ("yield \t bound directly as yield:" + Bootstrap .logBlock (block ));
82
+ }
83
+
77
84
target = unwrap ? compiledBody .getNormalYieldUnwrapHandle () : compiledBody .getNormalYieldHandle ();
78
85
} else {
86
+ if (Options .INVOKEDYNAMIC_LOG_BINDING .load ()) {
87
+ LOG .info ("yield \t bound indirectly as yield:" + Bootstrap .logBlock (block ));
88
+ }
89
+
79
90
target = Binder .from (type ())
80
91
.append (unwrap )
81
92
.invokeStaticQuiet (MethodHandles .lookup (), IRRuntimeHelpers .class , "yield" );
@@ -102,8 +113,16 @@ public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Thro
102
113
if (block .getBody () instanceof CompiledIRBlockBody ) {
103
114
CompiledIRBlockBody compiledBody = (CompiledIRBlockBody ) block .getBody ();
104
115
116
+ if (Options .INVOKEDYNAMIC_LOG_BINDING .load ()) {
117
+ LOG .info ("yield \t bound directly as yieldSpecific:" + Bootstrap .logBlock (block ));
118
+ }
119
+
105
120
target = compiledBody .getNormalYieldSpecificHandle ();
106
121
} else {
122
+ if (Options .INVOKEDYNAMIC_LOG_BINDING .load ()) {
123
+ LOG .info ("yield \t bound indirectly as yieldSpecific:" + Bootstrap .logBlock (block ));
124
+ }
125
+
107
126
target = Binder .from (type ())
108
127
.permute (0 , 1 )
109
128
.invokeVirtualQuiet (MethodHandles .lookup (), "yieldSpecific" );
@@ -123,6 +142,12 @@ public IRubyObject yieldSpecific(ThreadContext context, Block block) throws Thro
123
142
}
124
143
125
144
public IRubyObject yieldValues (ThreadContext context , Block block , IRubyObject [] args ) {
145
+ if (Options .INVOKEDYNAMIC_YIELD .load ()) {
146
+ if (Options .INVOKEDYNAMIC_LOG_BINDING .load ()) {
147
+ LOG .info ("yield \t bound indirectly as yieldValues:" + Bootstrap .logBlock (block ));
148
+ }
149
+ }
150
+
126
151
return block .yieldValues (context , args );
127
152
}
128
153
}
0 commit comments