aboutsummaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index fce8add6ef..781f95fdcd 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -5,8 +5,13 @@
#ifndef GLOBAL_METHOD_CACHE_SIZE
#define GLOBAL_METHOD_CACHE_SIZE 0x800
#endif
+#define LSB_ONLY(x) ((x) & ~((x) - 1))
+#define POWOR_OF_2_P(x) ((x) == LSB_ONLY(x))
+#if !POWOR_OF_2_P(GLOBAL_METHOD_CACHE_SIZE)
+# error GLOBAL_METHOD_CACHE_SIZE must be power of 2
+#endif
#ifndef GLOBAL_METHOD_CACHE_MASK
-#define GLOBAL_METHOD_CACHE_MASK 0x7ff
+#define GLOBAL_METHOD_CACHE_MASK (GLOBAL_METHOD_CACHE_SIZE-1)
#endif
#define GLOBAL_METHOD_CACHE_KEY(c,m) ((((c)>>3)^(m))&GLOBAL_METHOD_CACHE_MASK)