summaryrefslogtreecommitdiffhomepage
path: root/src/dump.c
AgeCommit message (Collapse)Author
2020-11-30Integrate the output of the catch handler table into iseqdearblue
Alleviates confusingness. ref #5203
2020-11-30Fixed irep size measurement by dump; ref #5203dearblue
2020-11-29Merge pull request #5203 from komainu8/fix-heap-buffer-overflowYukihiro "Matz" Matsumoto
Fix heap buffer overflow when dump irep
2020-11-29Fix heap buffer overflow when dump irepHorimoto Yasuhiro
Currently, the size of writing in heap by write_irep_record() is bigger than The size that is calculated by get_irep_record_size. Therefore, irep is dumped over the size of allocating memory when we execute dump_irep().
2020-11-29Change the catch handler address to 32 bitsdearblue
Follow commit 7150c6753933f12a2ba63769fb7b3a44cfcddd3d .
2020-11-24Fix compiler errors from `MRB_NO_FLOAT`; #5185Yukihiro "Matz" Matsumoto
Also added `no-float.rb` target in `build_config`.
2020-11-22Fix size of local variable array in struct dumped fileKOBAYASHI Shuji
2020-11-21Rename `MRB_{ENABLE,DISABLE}_` to `MRB_{USE,NO}_`; close #5163KOBAYASHI Shuji
| Previous Name | New Name | |------------------------------|-------------------------| | MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI | | MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION | | MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK | | MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING | | MRB_DISABLE_STDIO | MRB_NO_STDIO | | ENABLE_LINENOISE | MRB_USE_LINENOISE | | ENABLE_READLINE | MRB_USE_READLINE | | DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE | | DISABLE_GEMS | MRB_NO_GEMS | * `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed. * `MRB_` prefix is added to those without. * The previous names can also be used for compatibility.
2020-11-18Revert "Check if irep->reps is NULL in lv_defined_p"Yukihiro "Matz" Matsumoto
2020-11-18Check if irep->reps is NULL in lv_defined_pZhang Xiaohui
2020-10-14Add indent to `lv` in the C dump.Yukihiro "Matz" Matsumoto
2020-10-12No need to get the `irep` record size twice.Yukihiro "Matz" Matsumoto
2020-10-12Update `MRB_FLOAT_FMT` to always use double precision.Yukihiro "Matz" Matsumoto
2020-10-12Remove the length of `Float' pool from the binary dump.Yukihiro "Matz" Matsumoto
Also fixed the size calculation of `irep` dump, that could cause memory corruption.
2020-10-12Dump/load 16 bits for `ilen` and `slen` in `irep`.Yukihiro "Matz" Matsumoto
Those types are `uint16_t` in definition. Also we no longer need padding for `iseq`.
2020-10-12Should use `PRId32` to dump `.i32`; ref #5084Yukihiro "Matz" Matsumoto
The fix was proposed by @dearblue
2020-10-12Include `mruby/endian.h` only when `MRB_NO_FLOAT` is undefined.Yukihiro "Matz" Matsumoto
2020-10-12Add `U` prefix for `mrb_sym` dump.Yukihiro "Matz" Matsumoto
Since `%u` of `mrb_sym` may be its MSB turned on.
2020-10-12Don't compare `int' with `size_t` (from `sizeof()`).Yukihiro "Matz" Matsumoto
2020-10-12Change float representation in `mrb` binary files.Yukihiro "Matz" Matsumoto
From human readable (ASCII) string representation to binary dump of IEEE754 in little endian.
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-12Fix typo `_hander` -> `_handler`.Yukihiro "Matz" Matsumoto
2020-10-12Adjust PR #5060 to the latest `mruby3` branch.Yukihiro "Matz" Matsumoto
2020-10-12Extended mruby binary formatdearblue
The catch handler table is combined with iseq block. This is to prevent the structure from growing by adding a field for the catch handler table to the `mrb_irep` structure. "iseq block" and "catch handler table": [number of catch handler table (2 bytes)] [number of byte code (4 bytes)] [iseq (any bytes)] [catch handlers (multiple of 7 bytes)] catch handler: [catch type (1 byte)] [begin offset (2 bytes)] [end offset (2 bytes)] [target offset (2 bytes)] catch type: enum mrb_catch_type (0 = rescue, 1 = ensure) begin offset: Includes the specified instruction address end offset: Does not include the specified instruction address target offset: replaces pc with the specified instruction address This table is not expanded by `read_irep_record_1()`. The necessary elements are expanded one by one when used.
2020-10-12Fix the bug by the combination with `MRB_64BIT` and `MRB_INT32`.Yukihiro "Matz" Matsumoto
Which is caused by `MRB_NAN_BOXING`.
2020-10-12You don't need to keep index in local variables info in `irep`.Yukihiro "Matz" Matsumoto
2020-10-12Split `MRB_BINARY_FORMAT` to major and minor.Yukihiro "Matz" Matsumoto
The minor versions should be upper compatible. So mere opcode, section addition can be done without breaking compiled binary.
2020-10-12Add `const` qualifier to generated `Proc` structures.Yukihiro "Matz" Matsumoto
2020-10-12Use `%u` instead of `%d` to dump symbol IDs.Yukihiro "Matz" Matsumoto
2020-10-12Avoid use of designated initializer for the sake of `cxx_abi`.Yukihiro "Matz" Matsumoto
2020-10-12Add casts to silence warnings.Yukihiro "Matz" Matsumoto
2020-10-12Clarify the use of `MRB_64BIT` and `MRB_INT64` in `dump.c` and `load.c`.Yukihiro "Matz" Matsumoto
- `MRB_64BIT`: the size of a pointer is 64 bits - `MRB_INT64`: the size of `mrb_int` is 64 bits
2020-10-12Fix `dump.c` for `MRB_INT32` env.Yukihiro "Matz" Matsumoto
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-10-12Generate C source file to represent `mrb_irep` structures.Yukihiro "Matz" Matsumoto
Type `mrbc -S -B<init> -o<outfile> <rbfiles...>` to generate the C source code that holds compiled `mrb_irep`. Appending the following code to the bottom of the generated code, `mruby` executes the compiled code: ```C int main() { mrb_state *mrb = mrb_open(); struct RProc *p = mrb_proc_new(mrb, &init_irep); mrb_vm_run(mrb, p, mrb_top_self(mrb), 0); mrb_close(mrb); return 0; } ``` Eventually static compile should use this representation, instead of `uint8_t` array that holds `mrb` data, so that we can skip interpreting `mrb` data.
2020-10-12Removed alignment pragma from `-B` output from `mrbc`.Yukihiro "Matz" Matsumoto
We no longer need 4 bytes alignment after we moved to the byte oriented instructions.
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-10-12Add `irep` C struct dump from `mrbc` with `-S` option.Yukihiro "Matz" Matsumoto
But we need more work: - recursive `irep` dump (`irep->reps`) - pool values dump (`irep->pool`)
2020-10-12Constify `irep` members.Yukihiro "Matz" Matsumoto
- `pool` - `syms` - `reps`
2020-05-09Remove byteorder constants; ref 87576b8dearblue
The `FLAG_BYTEORDER_NATIVE` and `FLAG_BYTEORDER_NONATIVE` are no longer needed.
2020-05-07Remove endian information/flags from compiled binary format.Yukihiro "Matz" Matsumoto
Since `mruby 2.0`, compiled bytecode no longer depends on the endian of the machine.
2019-10-17delete extern in Cyuri
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-01-11Use `%g` instead of `%e` for float representation in dump formatKOBAYASHI Shuji
`%g` use shorter representation than `%e`.
2019-01-08Fix dump/load float leteral evaluate to infinityKOBAYASHI Shuji
Example: # example.rb p(2e308) p(-2e308) Good: $ bin/mruby example.rb inf -inf Bad: $ bin/mrbc example.rb $ bin/mruby -b example.mrb 0 -0 Cause: Float infinity representation is `inf` on dump and it is converted by corresponding `String#to_f` on load. Treatment: - Introduce new representations (`i`: +infinity, `I`: -infinity) - Allow old representations (`inf`, `-inf`, `infinity`, `-infinity`) too - Raise error for unknown representations (use corresponding `Kernel#Float`)
2018-11-15Remove `filename`&`lines` from `mrb_irep` struct.Yukihiro "Matz" Matsumoto
This patch slightly reduce memory consumption (2% for my test).
2018-11-15Small renaming refactor in `dump.c`Yukihiro "Matz" Matsumoto
2018-11-02Suppress warningtake-cheeze
2018-11-02Fix dump and load with endianesstake-cheeze
2017-10-11Add MRB_WITHOUT_FLOATYAMAMOTO Masaya