summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 23:24:38 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 23:24:38 (GMT)
commit4e12ff9225f16dbc36e2b3edf0dd48a87b465ecf (patch)
tree97fb1bafb27b66137954117ccac2f09c83749541 /vm_method.c
parentfd61a78303ae67772abec331647a90d0c419f32b (diff)
vm_method.c: disable GMC writing if GMC is disabled
* vm_method.c (rb_method_entry_get_without_cache): disable GMC writing if GMC is disabled [ruby-core:61218] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/vm_method.c b/vm_method.c
index 1703070..203b8b8 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -2,6 +2,7 @@
* This file is included by vm.c
*/
+#if OPT_GLOBAL_METHOD_CACHE
#ifndef GLOBAL_METHOD_CACHE_SIZE
#define GLOBAL_METHOD_CACHE_SIZE 0x800
#endif
@@ -16,6 +17,9 @@
#define GLOBAL_METHOD_CACHE_KEY(c,m) ((((c)>>3)^(m))&GLOBAL_METHOD_CACHE_MASK)
#define GLOBAL_METHOD_CACHE(c,m) (global_method_cache + GLOBAL_METHOD_CACHE_KEY(c,m))
+#else
+#define GLOBAL_METHOD_CACHE(c,m) 0,rb_bug("global method cache disabled improperly")
+#endif
#include "method.h"
#define NOEX_NOREDEF 0
@@ -42,7 +46,10 @@ struct cache_entry {
VALUE defined_class;
};
+#if OPT_GLOBAL_METHOD_CACHE
static struct cache_entry global_method_cache[GLOBAL_METHOD_CACHE_SIZE];
+#endif
+
#define ruby_running (GET_VM()->running)
/* int ruby_running = 0; */
@@ -575,19 +582,24 @@ rb_method_entry_get_without_cache(VALUE klass, ID id,
defined_class = me->klass;
if (ruby_running) {
- struct cache_entry *ent;
- ent = GLOBAL_METHOD_CACHE(klass, id);
- ent->class_serial = RCLASS_SERIAL(klass);
- ent->method_state = GET_GLOBAL_METHOD_STATE();
- ent->defined_class = defined_class;
- ent->mid = id;
-
- if (UNDEFINED_METHOD_ENTRY_P(me)) {
- ent->me = 0;
- me = 0;
+ if (OPT_GLOBAL_METHOD_CACHE) {
+ struct cache_entry *ent;
+ ent = GLOBAL_METHOD_CACHE(klass, id);
+ ent->class_serial = RCLASS_SERIAL(klass);
+ ent->method_state = GET_GLOBAL_METHOD_STATE();
+ ent->defined_class = defined_class;
+ ent->mid = id;
+
+ if (UNDEFINED_METHOD_ENTRY_P(me)) {
+ ent->me = 0;
+ me = 0;
+ }
+ else {
+ ent->me = me;
+ }
}
- else {
- ent->me = me;
+ else if (UNDEFINED_METHOD_ENTRY_P(me)) {
+ me = 0;
}
}