summaryrefslogtreecommitdiffhomepage
path: root/include
AgeCommit message (Collapse)Author
2021-03-19rational.c: overhaul rational operators.Yukihiro "Matz" Matsumoto
- define `MRB_TT_RATIONAL` - change object structure (`struct RRational`) - add memory management for `MRB_TT_RATIONAL` - avoid operator overloading as much as possible - implement division overloading in C - as a result, performance improved a lot
2021-03-12codegen.c: no integer overflow error in `codegen`; close #5376Yukihiro "Matz" Matsumoto
Add new pool value type `IREP_TT_BIGINT` and generate integer overflow error in the VM. In the future, `mruby` will support `Bignum` for integers bigger than `mrb_int` (probably using `mpz`).
2021-03-08ISO C99 doesn't support unnamed unions; fix #5354Yukihiro "Matz" Matsumoto
2021-03-05Merge pull request #5373 from mruby/stableYukihiro "Matz" Matsumoto
Merge mruby 3.0.0
2021-03-05Update version and release date. (mruby 3.0.0 (2021-03-05))3.0.0mimaki
2021-03-04Fix `mrb_pool_value` to keep `int64` on 32 bit platforms; fix #5366Yukihiro "Matz" Matsumoto
2021-02-19mruby/value.h: `MRB_TT_CPTR` is immediate with `MRB_NO_BOXING`.Yukihiro "Matz" Matsumoto
The issue is reported by @shuujii.
2021-02-19Fix `mrb_immediate_p()` definition for `MRB_NO_BOXING`; ref #5352Yukihiro "Matz" Matsumoto
2021-02-19Check `MRB_TT_*` before object allocation; ref #5352Yukihiro "Matz" Matsumoto
2021-02-14Add `-s` option to `mrbc` for make variable staticKOBAYASHI Shuji
2021-02-13chore: fix spellingJohn Bampton
Normally a single spell checker can't find all the mistakes or check all types of code. These mistakes were found by another spell checker inside my editor with a more manual sift / find.
2021-02-12include/mruby/array.h: `ARY_LEN()` should return `mrb_int`.Yukihiro "Matz" Matsumoto
It used to return `mrb_ssize` but its size may differ from `mrb_int`, e.g. `MRB_INT64` on `MRB_32BIT` architecture.
2021-02-08Allow the case `MRB_32BIT` and `MRB_NO_BOXING` and `MRB_USE_FLOAT32`; #4382Yukihiro "Matz" Matsumoto
2021-02-03Update version to `3.0.0RC`.3.0.0-rcmimaki
2021-02-01Allow more than 256 child `irep`; fix #5310Yukihiro "Matz" Matsumoto
We have introduced following new instructions. * `OP_LAMBDA16` * `OP_BLOCK16` * `OP_METHOD16` * `OP_EXEC16` Each instruction uses 16 bits operand for `reps` index. Since new instructions are added, `mruby/c` VM should be updated. Due to new instructions, dump format compatibility is lost, we have increased `RITE_BINARY_MAJOR_VER`. In addition, we have decreased the size of `refcnt` in `mrb_irep` from `uint32_t` to `uint16_t`, which is reasonably big enough.
2021-01-31Introduced `MRB_PRESYM_INIT_SYMBOLS()`dearblue
The `init_SYMBOLS()` function implicitly defined in `MRB_PRESYM_DEFINE_VAR_AND_INITER()` requires some familiarity when trying to find it from the caller. By introducing `MRB_PRESYM_INIT_SYMBOLS()`, it is possible to find directly from the identifier.
2021-01-27Split `presym_table` for reduced program sizeKOBAYASHI Shuji
Because a structure that is an element of `presym_table` has padding, split it into individual arrays for name and length. #### Result (64-bit CPU with full-core gembox) | | mruby | libmruby.a | |--------|------------|------------| | Before | 1,087,444B | 1,476,872B | | After | 1,079,340B | 1,469,784B |
2021-01-27Fix typos in `mruby/presym/{disable,enable}.h` [ci skip]KOBAYASHI Shuji
2021-01-27Fix "Use `MRB_SYM()` for error class retrieval"; ref 2ddfd50dfKOBAYASHI Shuji
The new macro (`MRB_E_SYM`) was not being used, so it is being used. Also `MRB_E_SYM` is confusing with `MRB_SYM_E`, so change it to `MRB_ERROR_SYM`.
2021-01-26Use `MRB_SYM()` for error class retrieval; ref #5277Yukihiro "Matz" Matsumoto
Note that `MRB_SYM()` is only available when `mruby/presym.h` is included. Use `mrb_intern_lit()` otherwise.
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-23Remove test debug lines in fallback `presym.inc`Yukihiro "Matz" Matsumoto
ref dc51d89ac22
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-21Reduce size of `mrb_callinfo` by rearranging members.Yukihiro "Matz" Matsumoto
From 48 bytes to 40 bytes on 64 bit platforms (unchanged on 32 bit).
2021-01-21Merge branch 'avoid-including-presym.inc-in-existing-header-files' of ↵Yukihiro "Matz" Matsumoto
https://github.com/shuujii/mruby into shuujii-avoid-including-presym.inc-in-existing-header-files
2021-01-20Remove CRC16 from dumped mruby binary.Yukihiro "Matz" Matsumoto
`calc_crc_16_ccitt()` consumes a lot of clock cycles in programs like `mrbtest` which loads a lot of dumped binary. Error detection for flaky channels should be done in the higher level. Note: `mruby/c` should be updated to support this change.
2021-01-12Merge branch 'reorganize-ci' of https://github.com/dearblue/mruby into ↵Yukihiro "Matz" Matsumoto
dearblue-reorganize-ci
2021-01-12Fix a signed shift bug on 32 bit platforms; ref e1c9e7eYukihiro "Matz" Matsumoto
2021-01-12Save `NOARG` information in `struct mt_elem`; fix #5257Yukihiro "Matz" Matsumoto
2021-01-12Changed packing format of inline symbols.Yukihiro "Matz" Matsumoto
To make inline symbols packed in 30 bits.
2021-01-11Remove the definition of `mrb_uint` in `numeric.h` that is no longer neededKOBAYASHI Shuji
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2021-01-10Unified `pc` and `err` of `mrb_callinfo`dearblue
This enhances self-containment. - Changed the `mrb_callinfo::pc` field to point to itself. Previously it indicated the return destination of the previous call level. `mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`. - Removed `mrb_callinfo::err` field. This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`. - The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted. - It removes the argument because `cipush()` doesn't need to save the previous `pc`.
2021-01-10Changes `stackent` to `stack` of `mrb_callinfo`dearblue
This enhances self-containment. Previously `mrb_context::stack` had the current call level stack, but now it owns it. The `mrb_context::stack` field, which is no longer needed, will be removed.
2021-01-10Unified `target_class` and `env` of `mrb_callinfo`dearblue
If there is `env`, `env->c` means `target_class`.
2021-01-10Use `uint16_t` for `argc` and `acc` of `mrb_callinfo`dearblue
This is because it is enough to express the range up to (-1..255) or (-3..255).
2021-01-09Introduce `mrb_uint` which is unsigned integer with size of `mrb_int`.Yukihiro "Matz" Matsumoto
2021-01-09Remove `khash.h` leftovers.Yukihiro "Matz" Matsumoto
2021-01-07Add scan target functions for presymKOBAYASHI Shuji
Add the following functions: - mrb_intern_cstr - mrb_define_singleton_method - mrb_define_class_under - mrb_define_module_under
2021-01-06Merge branch 'improve-source-scanning-for-presym' of ↵Yukihiro "Matz" Matsumoto
https://github.com/shuujii/mruby into shuujii-improve-source-scanning-for-presym
2020-12-31Treat tabs as 8 spaces in squiggly heredocsSeeker
2021-01-01Merge pull request #5245 from jbampton/for-mruby-for-2021Yukihiro "Matz" Matsumoto
Update copyright year for 2021
2020-12-28Fix mixed indentation and escaped tabs in squiggly heredocsSeeker
2020-12-26Add support for squiggly heredocsSeeker
2020-12-27Update copyright year for 2021John Bampton
2020-12-19🔒 Fix missing HTTPS on linksJohn Bampton
2020-12-15refactor: remove trailing whitespace from C, Header, Ruby and YAML filesJohn Bampton
Lint
2020-12-13Fix spellingJohn Bampton
2020-12-13Improve source scanning for presymKOBAYASHI Shuji
The accuracy is greatly improved by using the C preprocessor to scan C sources for presym. C preprocessor can perfectly interpret all comments and preprocessor directives, so it can detect all symbols defined, for example `mrbgems/mruby-socket/src/const.cstub`. Also, as described later, this change will greatly improve the accuracy of presym detection from Ruby sources. ## Result The number of lines in the `presym` file for all gems is as follows: ```console Previous: 999 (false positive = 89, undetected = 297) New: 1207 ``` ## Build process The new build process (with presym) is as follows: 1. Build `mrbc` without presym (more on building without presym later). 2. Compile Ruby sources to C struct format with the `mrbc` created in step 1, and create` mrblib.c` and `gem_init.c`. Note that the symbols in the created files are output as `MRB_SYM` family macros or `mrb_intern_lit` instead of IDs (details will be described later). 3. C preprocessor processes C sources including the created files of step 2 and outputs them as `.i` files. In these files, for example, `MRB_IVSYM(foo)` is converted to `<@! "@" "foo" !@>` and `mrb_define_module(mrb, "Foo")` is converted to `<@! "Foo" !@>`. 4. Scan the files created in step 3 and create `presym` and` presym.inc` files. The files created in step 2 should output all static symbols defined in Ruby sources, including local variables, so we can detect all presyms by just scanning C sources without scanning Ruby sources directly. Further, by this process, the files to be scanned becomes the same as the files to be compiled, so that there is no excess or deficiency. ## Related changes The following changes have been made in relation to realizing this feature. ### Allow build without presym It enables build without presym to achieve the "Build process: 1". This incorporates #5202, see its issue for details. Note that when presym is enabled, even adding a local variable to a Ruby source may change contents of presym and require recompilation of almost all C sources. This is inconvenient, especially during trial and error in development, but this feature is also useful because it does not cause this problem if presym is disabled. ### Automatically create build target for `mrbc` without presym The `mrbc` used in the "Build process: 1" will be built by automatically creating a build target for it. The build name is `SOURCE_BUILD_NAME/mrbc`. ### Constantize output of C struct format by `mrbc` To realizing the "Build process: 2", as mentioned above, symbol IDs are not output directly in C struct format output by `mrbc`. As a result, the output becomes constant regardless of the state of presym at the time of `mrbc` build, and it is possible to detect symbols of Ruby sources in the same way as other C sources. Note that `mrb_intern_lit` is used for symbols that do not become presym, but in this state, the corresponding element in the symbol array cannot be statically initialized, so it is initialized at run time (therefore, in this case, the `const` qualifier is not added to the symbol array). ### Specify arbitrary `mrbc` file To realizing the "Build process: 2", enabled to specify `mrbc` created by another build target or pre-built` mrbc`. Use `MRuby::Build#mrbcfile =` to specify it explicitly. You can omit the "Build process: 1" by specifying pre-built `mrbc`, and you can always use an optimized build to compile Ruby sources faster. I think changes that affect the output of `mrbc` are rare, so in many cases it helps to improve efficiency. With presym, the build will be a little slower due to more build steps, but this feature will improve it a bit. ### Create presym files for each build target This feature was proposed at #5194 and merged once, but was reverted in 5c205e6e due to problems especially with cross-compilation. It has been introduced again because this change solves the problem. The presym files will be created below. * `build/NAME/presym` * `build/NAME/include/mruby/presym.inc` ### Other changes * Because presym detection accuracy is greatly improved as mentioned above, `MRuby::Gem::Specification#cdump?` is set to true by default, and `disable_cdump` is added instead of `enable_cdump`. Also, support for gem specific presym files has been discontinued (https://github.com/mruby/mruby/issues/5151#issuecomment-730967232). * Previously, `mrbc` was automatically created for the `host` build, but it will not be created if the build target for `mrbc` mentioned above is automatically created. At this time, `mrbc` file of the `mrbc` build is copied to` bin/`. * Two types of `.d` files will be created, `.o.d` and `.i.d`. oThis is because if `.i` depends on `presym.inc`, the dependency will circulate, so the `.d` file cannot be shared. * Changed file created with `enable_cxx_exception` to `X-cxx.cxx` from `X.cxx` to use the mruby standard Rake rule. ### Note Almost all C sources will need to be recompiled if there are any changes to `persym.inc` (if not recompiled properly, it will often result in run-time error). If `gcc` toolchain is used, dependencies are resolved by the `.d` file, so it become automatically recompile target, but if not (e.g. MSVC), it is necessary to manually make it recompile target. Also, even if `gcc` toolchain is used, it may not become recompile target if external gems does not use the mruby standard Rake rule. In particular, if the standard rule is overwritten, such as https://github.com/mruby/mruby/pull/5112/files, `.d` file will not be read, so be careful.
2020-12-07Make type of `pc` arguments in `debug.c` consistent; close #5218Yukihiro "Matz" Matsumoto
They used to be `size_t`, `uint32_t` and `ptrdiff_t`. Now all of them made to be `uint32_t`.