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).
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-09-30 23:48:57 +09:00
parent bbf24b8463
commit b72e94fa6b
4 changed files with 38 additions and 11 deletions
+13
View File
@@ -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 */