Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / cpu_cache.c
blob65cc5cf9b579855ef4260a59aedb6f679e4b7e1d
1 #include <stdlib.h>
3 #include "shotgun/lib/shotgun.h"
4 #include "shotgun/lib/cpu.h"
5 #include "shotgun/lib/machine.h"
6 #include "shotgun/lib/tuple.h"
7 #include "shotgun/lib/methctx.h"
8 #include "shotgun/lib/object.h"
9 #include "shotgun/lib/bytearray.h"
10 #include "shotgun/lib/string.h"
11 #include "shotgun/lib/class.h"
12 #include "shotgun/lib/hash.h"
13 #include "shotgun/lib/symbol.h"
14 #include "shotgun/lib/selector.h"
16 void cpu_clear_cache(STATE, cpu c) {
17 struct method_cache *ent, *end;
19 ent = state->method_cache;
20 end = ent + CPU_CACHE_SIZE;
22 while(ent < end) {
23 ent++;
27 void cpu_clear_cache_for_method(STATE, cpu c, OBJECT meth, int full) {
28 struct method_cache *ent, *end;
30 selector_clear_by_name(state, meth);
32 ent = state->method_cache;
33 end = ent + CPU_CACHE_SIZE;
35 while(ent < end) {
36 if(ent->name == meth) {
37 if(full && ent->method && REFERENCE_P(ent->method)) {
38 OBJECT meth;
39 meth = ent->method;
40 if(ISA(meth, state->global->tuple)) {
41 meth = tuple_at(state, meth, 1);
43 // Don't this for now. Inline caches are disabled and we're using
44 // the serial number to detect core methods.
45 // fast_inc(meth, CMETHOD_f_SERIAL);
48 ent->name = 0;
50 ent++;
54 void cpu_clear_cache_for_class(STATE, cpu c, OBJECT klass) {
55 struct method_cache *ent, *end;
57 ent = state->method_cache;
58 end = ent + CPU_CACHE_SIZE;
60 while(ent < end) {
61 if(ent->klass == klass || ent->module == klass) {
62 ent->name = 0;
64 ent++;