summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-09-30 23:48:57 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-09-30 23:48:57 +0900
commitb72e94fa6bae6c9a35c90b4ecedc1f90cdb9a490 (patch)
tree08c13caecf740d0d4b972d75f65d6abb17d063bb /include
parentbbf24b84630eb3b3e18b04bcabd088ad22353957 (diff)
downloadmruby-b72e94fa6bae6c9a35c90b4ecedc1f90cdb9a490.tar.gz
mruby-b72e94fa6bae6c9a35c90b4ecedc1f90cdb9a490.zip
mrbconf.h option MRB_USE_ETEXT_EDATA to reduce memory.
on platforms with _etext and _edata, mruby can distinguish string literals so that it avoids memory allocation to copy them. for example, on my Linux box (x86 32bit), memory consumed by mrbtest decreased from 8,168,203 to 8,078,848 (reduced 88KB).
Diffstat (limited to 'include')
-rw-r--r--include/mrbconf.h3
-rw-r--r--include/mruby/value.h13
2 files changed, 16 insertions, 0 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 3564f6ec5..0195ae96f 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -38,6 +38,9 @@
/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
//#define MRB_IVHASH_INIT_SIZE 8
+/* if _etext and _edata available, mruby can reduce memory used by symbols */
+//#define MRB_USE_ETEXT_EDATA
+
/* turn off generational GC by default */
//#define MRB_GC_TURN_OFF_GENERATIONAL
diff --git a/include/mruby/value.h b/include/mruby/value.h
index f85cdd644..09d00302e 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -211,4 +211,17 @@ mrb_undef_value(void)
return v;
}
+#ifdef MRB_USE_ETEXT_EDATA
+extern char _etext[];
+extern char _edata[];
+
+static inline mrb_bool
+mrb_ro_data_p(const char *p)
+{
+ return _etext < p && p < _edata;
+}
+#else
+# define mrb_ro_data_p(p) FALSE
+#endif
+
#endif /* MRUBY_VALUE_H */