summaryrefslogtreecommitdiffhomepage
path: root/src/symbol.c
AgeCommit message (Collapse)Author
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-05Squashed commit of the following:Yukihiro "Matz" Matsumoto
commit 2d7d545c4c4bfce7fdcbcbe9baaeb437915742f0 Merge: 625a1249 b178914b Author: Yukihiro "Matz" Matsumoto <[email protected]> Date: Fri Jun 5 14:35:13 2020 +0900 Merge branch 'fix-mrb_open-with-nomem' of https://github.com/dearblue/mruby into dearblue-fix-mrb_open-with-nomem commit b178914b111dda79a8f36ec4eb3e9d37b76f982e Author: dearblue <[email protected]> Date: Sat Jan 19 22:22:44 2019 +0900 Fix invalid pointer free inside other heap's block 1. `e = mrb_obj_alloc(...)` 2. `e->stack = mrb->c->stack` (`mrb->c->stack` is anywhere in the range `stbase...stend`) 3. And raised exception by `mrb_malloc()`! 4. `mrb_free(e->stack)` by GC part (wrong free) commit 52e3d5d8585daf86af3ed12db5ab0efefbc9b956 Author: dearblue <[email protected]> Date: Sat Jan 19 21:55:36 2019 +0900 Fix memory leak for temporary symbols when out of memory commit 4c5499b88e47cc6012ad7d7379cb6bc74c6a0b60 Author: dearblue <[email protected]> Date: Sun Jan 20 11:42:07 2019 +0900 Fix uninitialized pointer dereference for debug section commit 8e993167dec62a9709d6faacd517729ddcedf4f9 Author: dearblue <[email protected]> Date: Sun Jan 20 11:41:09 2019 +0900 Fix memory leak for temporary filenames when out of memory commit 8b422577e6eae68a28121b88421d937e8707b487 Author: dearblue <[email protected]> Date: Sun Jan 20 10:57:51 2019 +0900 Fix memory leak for irep when out of memory commit 6b35ebf49a0aa3edb6bbda770ed58681e9c2e6af Author: dearblue <[email protected]> Date: Sun Jan 20 10:55:50 2019 +0900 Fix uninitialized pointer dereference when do not finished initializing irep commit 2531f2631e67e0462749618e2344c733a29238f0 Author: dearblue <[email protected]> Date: Sun Jan 20 10:48:15 2019 +0900 Fix NULL pointer dereference when do not finished initializing irep commit e2d6896ebad13694800af49c2625e106b8440ddf Author: dearblue <[email protected]> Date: Sat Jan 19 12:54:19 2019 +0900 Fix memory leak for irep when out of memory by `mrb_proc_new()` commit b6214ff8a0a1c73bc9554e39053878ac50bb683f Author: dearblue <[email protected]> Date: Sat Jan 19 12:53:07 2019 +0900 Fix memory leak for `khash_t` in `kh_init_size()` when out of memory by `kh_alloc()` commit 19162dd6c11f0093d0011e7cab83b8f9e84c2c07 Author: dearblue <[email protected]> Date: Sun Jan 20 02:15:07 2019 +0900 Fix memory leak for symbol string when out of memory in `kh_put()` commit 15e67297ff54bc14ef359d6d1e745d760a4a255a Author: dearblue <[email protected]> Date: Sun Jan 20 02:12:24 2019 +0900 Fix keep wrong symbol index when out of memory commit 3f8e2b375244f5441e8d62efa13c6e6a9afecb14 Author: dearblue <[email protected]> Date: Sun Jan 20 02:08:13 2019 +0900 Fix keep wrong symbol capacity when out of memory commit a3cfe755ab3e758046c3f4e30938ac8d567ed046 Author: dearblue <[email protected]> Date: Sat Jan 19 10:11:37 2019 +0900 Fix NULL pointer dereference `mrb->c` by `mark_context()` commit d9c7b6be6eb54630b64eea5c35be241e551676e5 Author: dearblue <[email protected]> Date: Sun Jan 20 15:25:09 2019 +0900 Fix protect exception for print error message commit 100642750e4d549f2e8050f8d6cabdf8825d4495 Author: dearblue <[email protected]> Date: Sun Jan 20 11:59:02 2019 +0900 Protect exception for mruby core initialization commit 7a0418304ec70764fa215bef3599f5f735222075 Author: dearblue <[email protected]> Date: Fri Jan 18 20:38:27 2019 +0900 Fix memory leak for string object when out of memory The `mrb_str_pool()` function has a path to call `malloc()` twice. If occurs `NoMemoryError` exception in second `malloc()`, first `malloc()` pointer is not freed. commit fef1c152ce4e52b9e4a34dc23aca5b02907ac639 Author: dearblue <[email protected]> Date: Sat Jan 19 13:05:09 2019 +0900 Fix stack overflow when out of memory As a result of this change, no backtrace information is set for NoMemoryError (`mrb->nomem_err`). Detailes: When generating a backtrace, called `mrb_intern_lit()`, `mrb_str_new_cstr()` and `mrb_obj_iv_set()` function with `exc_debug_info()` function in `src/error.c`. If a `NoMemoryError` exception occurs at this time, the `exc_debug_info()` function will be called again, and in the same way `NoMemoryError` exception raised will result in an infinite loop to occurs stack overflow (and SIGSEGV). commit da7d7f881bbbad9988a3a2b7bad8f2b72ff06bc6 Author: dearblue <[email protected]> Date: Sun Jan 20 12:00:38 2019 +0900 Fix NULL pointer dereference `mrb->nomem_err` when not initialized Add internal functions (not `static`): * `mrb_raise_nomemory()` * `mrb_core_init_abort()`
2020-01-31Remove unnecessary use of `uint16_t` in `symbol.c`.Yukihiro "Matz" Matsumoto
2019-11-23Rename `BITSIZE` to `BIT` and `BIT` to `BIT_POS` for consistencyKOBAYASHI Shuji
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT` and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
2019-11-16Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`"KOBAYASHI Shuji
This feature was reverted from Ruby 2.7.
2019-10-04Implement Ruby2.7's frozen strings from `Symbol#to_s`.Yukihiro "Matz" Matsumoto
2019-10-02Avoid `symhash()` call for inline symbol in `sym_intern()`KOBAYASHI Shuji
2019-09-27Merge pull request #4733 from ↵Yukihiro "Matz" Matsumoto
shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible Use type predicate macros instead of `mrb_type` if possible
2019-09-26Fixed `codedump` for human readable symbol format; ref #4684Yukihiro "Matz" Matsumoto
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-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-09-12Use `mrb_str_inspect` instead of `mrb_str_dup`; fix #4678Yukihiro "Matz" Matsumoto
2019-07-09Set `MRB_STR_ASCII` flag when an inline symbol is stringizedKOBAYASHI Shuji
2019-07-08Add macros for inline symbol for readabilityKOBAYASHI Shuji
2019-07-06Fix missing `#ifndef MRB_ENABLE_ALL_SYMBOLS`KOBAYASHI Shuji
2019-04-14Fix leaked function symbolsdearblue
- `free_heap()` in src/gc.c - `symhash()` in src/symbol.c - `no_optimize()` in mrbgems/mruby-compiler/core/codegen.c
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-03-28Use `mrb_sym2str` in implementation of `Symbol#to_s`KOBAYASHI Shuji
2019-03-28Fixed mistakes in 92dce05Yukihiro "Matz" Matsumoto
* rename `sym2name` to `sym2name_len`. * `MRB_API` -> `static`
2019-03-27Fix another bug related to #4342Yukihiro "Matz" Matsumoto
For short symbols with alpha numeric characters, `mrb_sym2name_len()` returns the same buffer `mrb->symbuf`. Some occasion, we forget the fact that the second call could overwrite the result of first call of the function. We have prepared the static function `sym2name()` which specifies the buffer region for inline packed symbols and use the function in `mrb_sym_to_s`.
2019-03-27Avoid using 'mrb_str_new_static` if a symbol is packed; fix #4342Yukihiro "Matz" Matsumoto
2019-03-25Remove implementation of `Symbol#===`KOBAYASHI Shuji
For reducing program size.
2019-03-25Need to check length before packing a symbol; fix #4340Yukihiro "Matz" Matsumoto
2019-02-18Parenthesize expression to suppress warning; ref #4278Yukihiro "Matz" Matsumoto
2019-02-17Merge pull request #4279 from dearblue/fix-inline-packed-symbolsYukihiro "Matz" Matsumoto
Fix destroyed "inline packed symbols" on 32 bit mode with `MRB_WORD_BOXING`
2019-02-16Use `const int` instead of `enum`dearblue
2019-02-16Fix inline packed symbols on 32 bit mode with MRB_WORD_BOXINGdearblue
2019-02-16Add length argument for `sym_inline_unpack()`KOBAYASHI Shuji
`sym_inline_unpack_with_bit()` is moved inside of `sym_inline_unpack()` because this is used only one place.
2019-02-15Extract code fragment for unpacking into method in `sym_inline_unpack()`KOBAYASHI Shuji
2019-02-15Merge pull request #4276 from ↵Yukihiro "Matz" Matsumoto
shuujii/use-assert-for-checking-sym-in-sym_inline_unpack Use `mrb_assert()` for checking `sym` in `sym_inline_unpack()`
2019-02-14Use `mrb_assert()` for checking `sym` in `sym_inline_unpack()`KOBAYASHI Shuji
2019-02-14Add `const` to `pack_table` to `src/symbol.c`KOBAYASHI Shuji
2019-02-12Disable `Symbol.all_symbols`.Yukihiro "Matz" Matsumoto
2019-02-12Implement inline packed symbols.Yukihiro "Matz" Matsumoto
Small symbols with all alphanumeric characters (<5) are packed in 32bit symbol integer a la base64. This means those small symbols are not listed in `Symbol.all_symbols`.
2019-02-06Implement symbol hash table to boost `find_symbol`.Yukihiro "Matz" Matsumoto
In 4174e02, we removed the symbol hash table from `mrb_state` but `find_symbol` was too slow with linear search. My performance estimation was wrong. So we implemented a new compact hash table for symbols.
2019-02-06Remove symbol hash table from `mrb_state` structure.Yukihiro "Matz" Matsumoto
Use linear search instead. Number of symbols is usually small (<1K), so we don't need performance boost from hash tables. In our benchmark measurement, hash tables consumes 790KB for `build/full-debug/mrbtest`.
2019-02-05Remove old comment for `mrb_sym2name_len()` [ci skip]KOBAYASHI Shuji
2018-11-02Remove reserved symbols for now.Yukihiro "Matz" Matsumoto
It should be done by planned embedded symbols.
2018-10-29Define null symboltake-cheeze
2018-10-29Reduce instruction sizetake-cheeze
2018-09-07Fix indentdearblue
2017-10-11Use division expression instead of some floating point literalsYAMAMOTO Masaya
2016-11-30Prohibit instantiation of immediate objectsYukihiro "Matz" Matsumoto
2016-01-06symname_p support `!~`ksss
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-10-20Increasing docs coverageSeba Gamboa
2015-05-28remove unnecessary including of <ctype.h>cremno
Not needed anymore since 85075bef7583edd0a48cfbdfaa632cbdacf78f2c
2014-10-02Pacify MSVC warnings for numeric.c, proc.c, and symbol.cHiroshi Mimaki
2014-09-30mrbconf.h option MRB_USE_ETEXT_EDATA to reduce memory.Yukihiro "Matz" Matsumoto
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).
2014-09-30mrb_sym2name_len() should initialize lenp even when proper symbol does not existYukihiro "Matz" Matsumoto