Skip to content

Commit 8ce1f68

Browse files
committedApr 25, 2016
Re-added caching at check_serial instruction.
1 parent 1dc4e0f commit 8ce1f68

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed
 

‎machine/builtin/call_site.hpp

+21-10
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,9 @@ namespace rubinius {
105105
return misses() > hits();
106106
}
107107

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;
114111
}
115112

116113
Object* execute(STATE, CallSite* call_site, Arguments& args, bool& valid_p) {
@@ -198,7 +195,7 @@ namespace rubinius {
198195

199196
if(call_site->lookup(state, args, dispatch, lookup_data)) {
200197
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);
202199

203200
return value;
204201
}
@@ -294,11 +291,10 @@ namespace rubinius {
294291
return true;
295292
}
296293

297-
void cache(STATE, Arguments& args, Dispatch& dispatch) {
294+
void cache(STATE, Class* klass, Dispatch& dispatch) {
298295
// 0. Ignore method_missing for now
299296
if(dispatch.name == G(sym_method_missing)) return;
300297

301-
Class* klass = args.recv()->direct_class(state);
302298
ClassData class_data = klass->class_data();
303299

304300
// 1. Attempt to update a cache.
@@ -449,8 +445,23 @@ namespace rubinius {
449445
}
450446

451447
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+
452451
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+
454465
return true;
455466
}
456467
}

0 commit comments

Comments
 (0)
Please sign in to comment.