summaryrefslogtreecommitdiffhomepage
path: root/src/etc.c
AgeCommit message (Collapse)Author
2021-11-09etc.c: improve `mrb_obj_id` with NaN boxing and Word boxing.Yukihiro "Matz" Matsumoto
2021-10-30boxing_nan.h: allow `MRB_INT64` with `MRB_NAN_BOXING`.Yukihiro "Matz" Matsumoto
Integers out of 32 bit range will be allocated in the heap.
2021-09-25mrbconf.h: rename a configuration macro for no truncate floats.Yukihiro "Matz" Matsumoto
Rename `MRB_WORDBOX_USE_HEAP_FLOAT` to `MRB_WORDBOX_NO_FLOAT_TRUNCATE'.
2021-08-26etc.c: keep full `float32` with `MRB_64BIT` and `MRB_USE_FLOAT32`.Yukihiro "Matz" Matsumoto
2021-08-26boxing_word.h: rename configuration macro name.Yukihiro "Matz" Matsumoto
`MRB_WORDBOX_USE_HEAP_FLOAT` instead of `MRB_USE_FLOAT_FULL_PRECISION`.
2021-08-21etc.c: clear `mrb_value` if `sizeof(void*)` is bigger than `sizeof(mrb_float)`.Yukihiro "Matz" Matsumoto
2021-08-21boxing_word.h: embed `mrb_float` in `mrb_value` if possible.Yukihiro "Matz" Matsumoto
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.
2021-06-20Added `MRB_OBJ_ALLOC()` macro that does not require a castdearblue
The `MRB_OBJ_ALLOC()` macro function returns a pointer of the type corresponding to the constant literal defined in `enum mrb_vtype`.
2020-11-08Define `mrb_value` in struct for Word/NaN boxingdearblue
This is to make it possible to distinguish between `mrb_value` and `mrb_sym` in C++ "Function overloading" and C11 "Generic selection".
2020-10-28Fix `mrb_obj_id` to `Float`KOBAYASHI Shuji
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Rename `MRB_TT_FIXNUM` to `MRB_TT_INTEGER`.Yukihiro "Matz" Matsumoto
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Rename `union mrb_value` to `union mrb_value_`.Yukihiro "Matz" Matsumoto
Since some compiler complains when we `typedef` `mrb_value`.
2020-10-12Simplify `mrb_value` structure for `MRB_WORD_BOXING`.Yukihiro "Matz" Matsumoto
2020-10-12Replace entire `irep->pool`.Yukihiro "Matz" Matsumoto
Changes: - `pool format is completely replaced - supported types: `STR`, `INT32`, `INT64`, `FLOAT` - `FLOAT` may be replaced by binary representation in the future - insert `NUL` after string literals in `mrb` files - `irep->pool` no longer store values in `mrb_value` - instead it stores in `mrb_pool_value` - less allocation - `mrb_irep` can be stored in ROM
2020-07-04fix object_id of true, false, and undef all 0Rory OConnell
2020-06-15Remove unused `MRB_TT_FILE`.Yukihiro "Matz" Matsumoto
2020-04-13Fix `MRB_TT_CPTR` object with `MRB_NAN_BOXING`dearblue
Previously, if `MRB_NAN_BOXING` is defined, for example, `mrb_cptr_value()` could not keep an odd address. If it is `MRB_32BIT`, it can be embedded in `NaN` as it is. If it is `MRB_64BIT`, some operations are shared with `MRB_WORD_BOXING`. In this case, the MRB_API function `mrb_nan_boxing_cptr_value()` is defined.
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-07-02Fix and refine error message in `mrb_obj_to_sym()`KOBAYASHI Shuji
Before this patch: $ bin/mruby -e '1.respond_to?(2)' #=> nil is not a symbol After this patch (same as Ruby): $ bin/mruby -e '1.respond_to?(2)' #=> 2 is not a symbol nor a string
2019-07-01Remove unused C header file from `src/etc.c`KOBAYASHI Shuji
2019-04-24Remove unnecessary `mrb_regexp_check()` and related functions.Yukihiro "Matz" Matsumoto
2019-04-11Remove incorrect flags updating in `mrb_regexp_p()`KOBAYASHI Shuji
2019-04-10Use `mrb_immediate_p()` in `mrb_obj_freeze()` and `mrb_obj_frozen()`KOBAYASHI Shuji
2018-08-30Separate meta-programming features to `mruby-metaprog` gem.Yukihiro "Matz" Matsumoto
We assume meta-programming is less used in embedded environments. We have moved following methods: * Kernel module global_variables, local_variables, singleton_class, instance_variables, instance_variables_defined?, instance_variable_get, instance_variable_set, methods, private_methods, public_methods, protected_methods, singleton_methods, define_singleton_methods * Module class class_variables, class_variables_defined?, class_variable_get, class_variable_set, remove_class_variable, included_modules, instance_methods, remove_method, method_removed, constants * Module class methods constants, nesting Note: Following meta-programming methods are kept in the core: * Module class alias_method, undef_method, ancestors, const_defined?, const_get, const_set, remove_const, method_defined?, define_method * Toplevel object define_method `mruby-metaprog` gem is linked by default (specified in default.gembox). When it is removed, it will save 40KB (stripped:8KB) on x86-64 environment last time I measured.
2017-10-11Add MRB_WITHOUT_FLOATYAMAMOTO Masaya
2017-10-01Use `uint32_t` to avoid signed integer overflow warning; #3816Yukihiro "Matz" Matsumoto
2017-08-10Normalize float numbers before calculating a hash value.Yukihiro "Matz" Matsumoto
2016-11-17renamed "inline" to "istruct" to represent inline struct; ref #3251Yukihiro "Matz" Matsumoto
2016-11-17inline structures data type for mruby (MRB_TT_INLINE) (fix #3237)Tomasz Dąbrowski
Inline structures have no instance variables, no finalizer, and offer as much space as possible in RBASIC object. This means 24 bytes on 64-bit platforms and 12 bytes on 32-bit platforms. mruby-inline-struct gem is only provided for testing.
2016-02-04cache mrb_regexp_p(); ref #980Yukihiro "Matz" Matsumoto
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-08-11Remove non-need tmp valuego.kikuta
2015-06-02remove unnecessary mrb_immediate_p()cremno
`!mrb_array_p(ary2)` and `mrb_type(obj) != MRB_TT_DATA` are sufficient.
2014-08-21changed to call check_cv_name_str in check_cv_name_sym and adjust indentkkkkkt
2014-08-06Fix a typo in etc.cbggd
2014-08-04Merge branch 'master' of github.com:mruby/mrubyYukihiro "Matz" Matsumoto
2014-08-03MSVC: add simple (v)snprintf implementationcremno
_snprintf is not C99's snprintf! This simple implementation, unlike _snprintf, always null-terminates and returns the expected return value (in most cases). Other C99 behaviors (like format specifiers) require adding a complete snprintf implementation. Do we want or need that? The same applies to vsnprintf (aka _vsnprintf).
2014-08-04rename obsolete mrb_special_const_p to mrb_immediate_pYukihiro "Matz" Matsumoto
2014-08-04add MRB_API modifiers to mruby API functionsYukihiro "Matz" Matsumoto
2014-07-09rename word boxing functionsYukihiro "Matz" Matsumoto
2014-07-09Clean up value.h and mrb_value boxingDavid Turnbull
2014-05-15move mrb_irep_remove_lv from etc.c to mruby-bin-strip gemYukihiro "Matz" Matsumoto
2014-05-15Support `LVAR` section removing.take_cheeze
2014-04-29cast intptr_t to mrb_int to pacify compiler warning; close #2148Yukihiro "Matz" Matsumoto
2014-04-17Add mrb_regexp_p to check whether mrb_value is Regexp.take_cheeze
2014-03-15calc hash value directly for strings, symbols and numbersYukihiro "Matz" Matsumoto
2014-01-30etc.c: small cleanup (delete unused functions)cremno
mrb_data_object_alloc: unnecessary cast mrb_lastline_get: mruby doesn't support $_, weird and unused code mrb_exec_recursive: see 4e46abb86914b36e70b5f3ad0826d0b648e9b4ef mrb_block_proc: unused, doesn't really do anything (or needs to be rewritten) mrb_obj_to_sym: actually use id (and MSVC detected unreachable code)