@@ -105,12 +105,9 @@ namespace rubinius {
105
105
return misses () > hits ();
106
106
}
107
107
108
- bool valid_serial_p (int serial) {
109
- if (executable ()->serial ()->to_native () == serial) {
110
- return true ;
111
- } else {
112
- return false ;
113
- }
108
+ bool valid_serial_p (uint64_t class_data_raw, int serial) {
109
+ return class_data_raw == receiver_data ().raw
110
+ && executable ()->serial ()->to_native () == serial;
114
111
}
115
112
116
113
Object* execute (STATE, CallSite* call_site, Arguments& args, bool & valid_p) {
@@ -198,7 +195,7 @@ namespace rubinius {
198
195
199
196
if (call_site->lookup (state, args, dispatch, lookup_data)) {
200
197
if (Object* value = call_site->invoke (state, args, dispatch)) {
201
- call_site->cache (state, args, dispatch);
198
+ call_site->cache (state, args. recv ()-> direct_class (state) , dispatch);
202
199
203
200
return value;
204
201
}
@@ -294,11 +291,10 @@ namespace rubinius {
294
291
return true ;
295
292
}
296
293
297
- void cache (STATE, Arguments& args , Dispatch& dispatch) {
294
+ void cache (STATE, Class* klass , Dispatch& dispatch) {
298
295
// 0. Ignore method_missing for now
299
296
if (dispatch.name == G (sym_method_missing)) return ;
300
297
301
- Class* klass = args.recv ()->direct_class (state);
302
298
ClassData class_data = klass->class_data ();
303
299
304
300
// 1. Attempt to update a cache.
@@ -449,8 +445,23 @@ namespace rubinius {
449
445
}
450
446
451
447
bool valid_serial_p (STATE, Object* recv, Symbol* vis, int serial) {
448
+ Class* recv_class = recv->direct_class (state);
449
+ uint64_t class_data_raw = recv_class->data_raw ();
450
+
452
451
for (int i = 0 ; i < depth (); i++) {
453
- if (caches ()->cache [i].valid_serial_p (serial)) {
452
+ if (caches ()->cache [i].valid_serial_p (class_data_raw, serial)) {
453
+ return true ;
454
+ }
455
+ }
456
+
457
+ Dispatch dispatch (name ());
458
+ LookupData lookup_data (state->vm ()->call_frame ()->self (),
459
+ recv->lookup_begin (state), vis);
460
+
461
+ if (dispatch.resolve (state, name (), lookup_data)) {
462
+ if (dispatch.method ->serial ()->to_native () == serial) {
463
+ cache (state, recv_class, dispatch);
464
+
454
465
return true ;
455
466
}
456
467
}
0 commit comments