summaryrefslogtreecommitdiffhomepage
path: root/include/mrbconf.h
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-08-20 16:57:33 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-08-21 15:25:58 +0900
commit36632f55f418bd711112b72d7fe1b6b1745058e5 (patch)
tree30a9a0e83fced5759b5da8f2354b7ba02280e2b8 /include/mrbconf.h
parent4ea80913c27264df0c7088367109c5a0678879f1 (diff)
downloadmruby-36632f55f418bd711112b72d7fe1b6b1745058e5.tar.gz
mruby-36632f55f418bd711112b72d7fe1b6b1745058e5.zip
boxing_word.h: embed `mrb_float` in `mrb_value` if possible.
Embedding reduce memory consumption, sacrificing precision. It clips least significant 2 bits from `mrb_float`, so if you need to keep float precision, define `MRB_USE_FLOAT_FULL_PRECISION`. `MRB_WORD_BOXING` and `MRB_INT64`: `mrb_float` (`double`) is embedded in `mrb_value` clipped last 2 bits. `MRB_WORD_BOXING` and `MRB_INT64` and `MRB_USE_FLOAT_FULL_PRECISION`: `mrb_float` is allocated in the heaps wrapped by `struct RFloat`. `MRB_WORD_BOXING` and `MRB_INT32` and `MRB_USE_FLOAT32`: `mrb_float` (`float`) is embedded in `mrb_value` clipped last 2 bits. In addition, to reserve bit space in the `mrb_value`, maximum inline symbol length become 4 (instead of 5) in the configuration. `MRB_WORD_BOXING` and `MRB_INT32`: Assume `MRB_USE_FLOAT_FULL_PRECISION` and allocate Float values in heap.
Diffstat (limited to 'include/mrbconf.h')
-rw-r--r--include/mrbconf.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index 5d54a1c22..7b29cb0ba 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -42,6 +42,9 @@
#error Cannot define MRB_USE_FLOAT32 and MRB_NO_FLOAT at the same time
#endif
+/* if defined mruby allocates Float objects in the heap to keep full precision if needed */
+//#define MRB_USE_FLOAT_FULL_PRECISION
+
/* add -DMRB_NO_METHOD_CACHE to disable method cache to save memory */
//#define MRB_NO_METHOD_CACHE
/* size of the method cache (need to be the power of 2) */