@@ -22,7 +22,15 @@ pub(super) fn init(globals: &mut Globals) {
22
22
Box :: new ( object_object_id) ,
23
23
0 ,
24
24
) ;
25
- globals. define_builtin_func_with ( OBJECT_CLASS , "respond_to?" , respond_to, 1 , 2 , false ) ;
25
+ globals. define_builtin_inline_func_with (
26
+ OBJECT_CLASS ,
27
+ "respond_to?" ,
28
+ respond_to,
29
+ Box :: new ( object_respond_to) ,
30
+ 1 ,
31
+ 2 ,
32
+ false ,
33
+ ) ;
26
34
globals. define_builtin_func ( OBJECT_CLASS , "singleton_class" , singleton_class, 0 ) ;
27
35
globals. define_builtin_func ( OBJECT_CLASS , "to_s" , to_s, 0 ) ;
28
36
globals. define_builtin_func ( OBJECT_CLASS , "inspect" , inspect, 0 ) ;
@@ -134,11 +142,11 @@ pub fn object_send(
134
142
bb. write_back_callargs_and_dst ( ir, callsite) ;
135
143
bb. writeback_acc ( ir) ;
136
144
let using_xmm = bb. get_using_xmm ( ) ;
137
- let error = bb . new_error ( ir ) ;
145
+ let error = ir . new_error ( bb ) ;
138
146
let callid = callsite. id ;
139
147
ir. inline ( move |gen, store, labels| {
140
- let error = labels[ error] ;
141
- gen. object_send_inline ( callid, store, using_xmm, error, no_splat) ;
148
+ let error = & labels[ error] ;
149
+ gen. object_send_inline ( callid, store, using_xmm, & error, no_splat) ;
142
150
} ) ;
143
151
bb. reg2acc ( ir, GP :: Rax , callsite. dst ) ;
144
152
true
@@ -273,6 +281,40 @@ fn respond_to(_vm: &mut Executor, globals: &mut Globals, lfp: Lfp) -> Result<Val
273
281
} ) )
274
282
}
275
283
284
+ fn object_respond_to (
285
+ bb : & mut BBContext ,
286
+ _: & mut AsmIr ,
287
+ ctx : & JitContext ,
288
+ store : & Store ,
289
+ callsite : & CallSiteInfo ,
290
+ recv_class : ClassId ,
291
+ ) -> bool {
292
+ if !callsite. is_simple ( ) {
293
+ return false ;
294
+ }
295
+ let CallSiteInfo {
296
+ dst, args, pos_num, ..
297
+ } = * callsite;
298
+ let dst = if let Some ( dst) = dst {
299
+ dst
300
+ } else {
301
+ return false ;
302
+ } ;
303
+ if pos_num != 1 {
304
+ return false ;
305
+ }
306
+ let method_name = if let Some ( name) = bb. is_symbol_literal ( args) {
307
+ name
308
+ } else {
309
+ return false ;
310
+ } ;
311
+ let b = store
312
+ . check_method_for_class ( recv_class, method_name, ctx. class_version ( ) )
313
+ . is_some ( ) ;
314
+ bb. def_concrete_value ( dst, Value :: bool ( b) ) ;
315
+ true
316
+ }
317
+
276
318
///
277
319
/// ### Object#inspect
278
320
///
0 commit comments