summaryrefslogtreecommitdiffhomepage
path: root/src/dump.c
AgeCommit message (Collapse)Author
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
2017-09-27fix: src\dump.c(710): warning C4244: 'function': conversion from 'mrb_int' ↵Tomasz Dąbrowski
to 'uint16_t', possible loss of data
2017-09-27fix: src\dump.c(657): warning C4244: 'function': conversion from 'mrb_int' ↵Tomasz Dąbrowski
to 'uint16_t', possible loss of data
2017-08-19Reduce signed/unsigned warnings in dump.cYukihiro "Matz" Matsumoto
2017-08-12Reduce integer type mismatch warnings in VC.Yukihiro "Matz" Matsumoto
2017-04-03Unify `else` clause styleYukihiro "Matz" Matsumoto
2016-11-24Add constant export declaration for MRBC output compiled as C++Tomasz Dąbrowski
Otherwise, C++ compilers will skip this constant when producing object files.
2015-12-22fix build on VS2012Yasuhiro Matsumoto
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-11-17DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014Yukihiro "Matz" Matsumoto
changes: * rename DISABLE_STDIO -> MRB_DISABLE_STDIO * rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK * no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG). * rewrite above macro references throughout the code. * update documents
2015-08-17fix irep float dump format string for MRB_USE_FLOATcremno
IEC 60559 single format has 6 to 9 significant decimal digits precision. However the printf conversion specifier e (and E, of course) already writes 1 digit - the one before the decimal point - and precision specifies the number of digits to write after the decimal point.