Commit Graph

13180 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto fdfa0caa46 boxing_word.h: rename configuration macro name.
`MRB_WORDBOX_USE_HEAP_FLOAT` instead of `MRB_USE_FLOAT_FULL_PRECISION`.
2021-08-26 16:06:01 +09:00
Yukihiro "Matz" Matsumoto e9c6e52f5b value.h: reconstruct mrb_ro_data_p().
* use predefined `mrb_ro_data_p()` for user-mode Linux and macOS
* define `MRB_LINK_TIME_RO_DATA_P` if predefined one is used
* configure macro `MRB_USE_LINK_TIME_RO_DATA_P` is no longer used
* contributions for new platforms are welcome
2021-08-26 16:06:01 +09:00
Yukihiro "Matz" Matsumoto d00ae8d166 Merge pull request #5538 from jbampton/pre-commit-autoupdate
pre-commit autoupdate
2021-08-26 11:11:04 +09:00
John Bampton db884a05e8 pre-commit autoupdate
https://pre-commit.com/#pre-commit-autoupdate
2021-08-25 18:24:02 +10:00
Yukihiro "Matz" Matsumoto b8b86d1976 Merge pull request #5535 from dearblue/get-args-frozen
Checks the frozen object with `mrb_get_args()`
2021-08-24 16:33:15 +09:00
dearblue 66aa184a82 Checks the frozen object with mrb_get_args()
This now works with the `+` modifier that can be added after each specifier.

- `nil` is bypassed.
- The `s` and `z` specifiers are received in C as a `const char *`, so adding a `+` modifier will raise an exception.
- The `a` specifier is received in C as `const mrb_value *`, so adding a `+` modifier will raise an exception.
- The `|`, `*`, `&`, `?` and `:` specifiers with `+` modifier raises an exception.

If `!`/`+` exceeds one for each specifier, an exception will occur in the subsequent processing.
This is the same behavior as before.
2021-08-23 21:58:57 +09:00
dearblue 6415faabaa Integrate each element expansion process of the argument
The previously used `given` variable will be merged into the `pickarg` pointer variable, which points to the argument currently being processed for each loop.
2021-08-23 21:58:51 +09:00
Yukihiro "Matz" Matsumoto 6f46f88873 numeric.c: fix: -0.0.abs returned -0.0. 2021-08-23 10:53:23 +09:00
Yukihiro "Matz" Matsumoto 11cfe77eb1 Merge pull request #5537 from dearblue/header-files
Organize the include of header files
2021-08-23 07:34:37 +09:00
Yukihiro "Matz" Matsumoto 0f36710445 Merge pull request #5536 from dearblue/random-seed
Stirs internal state when `seed` is set in `Random`
2021-08-22 12:37:34 +09:00
dearblue 5a57602860 Organize the include of header files
- `#include <math.h>` is done in `mruby.h`.
  Eliminate the need to worry about the `MRB_NO_FLOAT` macro.

- Include mruby header files before standard header files.
  If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`.

This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-08-21 15:42:57 +09:00
dearblue 2121b6e689 Stirs internal state when seed is set in Random
This is to avoid the approximation of `Random#rand` when `seed`s are close together.

For example, the first `#rand` values after doing `Random#srand(0)` and `Random#srand(1)` are very similar.

Below is the sequence of mruby before this patch was given a `seed` of `0...20`:

```console
% bin/mruby -e 'r = Random.new; 20.times { |i| r.srand(i); puts "seed=%2d  %s" % [i, 10.times.map { "%0.3f" % r.rand }.join(" ")] }'
seed= 0  0.643 0.585 0.198 0.732 0.087 0.605 0.548 0.468 0.573 0.966
seed= 1  0.643 0.585 0.198 0.607 0.370 0.605 0.633 0.593 0.395 0.439
seed= 2  0.643 0.585 0.197 0.981 0.652 0.730 0.875 0.713 0.529 0.269
seed= 3  0.643 0.585 0.198 0.857 0.934 0.730 0.960 0.216 0.286 0.523
seed= 4  0.643 0.585 0.197 0.231 0.217 0.605 0.959 0.958 0.478 0.482
seed= 5  0.643 0.585 0.197 0.106 0.249 0.605 0.044 0.330 0.925 0.047
seed= 6  0.643 0.585 0.197 0.481 0.781 0.731 0.285 0.960 0.804 0.725
seed= 7  0.643 0.585 0.197 0.356 0.813 0.731 0.370 0.711 0.937 0.448
seed= 8  0.643 0.585 0.198 0.732 0.329 0.108 0.243 0.974 0.766 0.936
seed= 9  0.643 0.585 0.198 0.607 0.611 0.108 0.827 0.102 0.962 0.597
seed=10  0.643 0.585 0.198 0.981 0.393 0.233 0.569 0.723 0.472 0.805
seed=11  0.643 0.585 0.198 0.857 0.676 0.233 0.154 0.222 0.603 0.371
seed=12  0.643 0.585 0.198 0.231 0.458 0.108 0.654 0.979 0.928 0.577
seed=13  0.643 0.585 0.198 0.106 0.490 0.108 0.239 0.355 0.749 0.831
seed=14  0.643 0.585 0.198 0.481 0.523 0.233 0.981 0.486 0.505 0.131
seed=15  0.643 0.585 0.198 0.356 0.555 0.234 0.565 0.233 0.011 0.666
seed=16  0.643 0.585 0.197 0.730 0.573 0.611 0.904 0.512 0.971 0.153
seed=17  0.643 0.585 0.197 0.605 0.855 0.611 0.240 0.636 0.041 0.509
seed=18  0.643 0.585 0.196 0.979 0.137 0.736 0.229 0.765 0.674 0.832
seed=19  0.643 0.585 0.197 0.855 0.420 0.736 0.566 0.268 0.183 0.219
```
2021-08-21 15:37:12 +09:00
Yukihiro "Matz" Matsumoto 886055b3fb etc.c: clear mrb_value if sizeof(void*) is bigger than sizeof(mrb_float). 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 8ca40da3fe test/float.rb: avoid 1.0e16 in tests without precision specified. 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 3b4c4caddc mruby-test/driver.c: change FLOAT_TOLERANCE bigger for inline floats. 2021-08-21 15:25:59 +09:00
Yukihiro "Matz" Matsumoto 36632f55f4 boxing_word.h: embed mrb_float in mrb_value if possible.
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-08-21 15:25:58 +09:00
Yukihiro "Matz" Matsumoto 4ea80913c2 Merge pull request #5533 from dantecatalfamo/serenity-32bit-crossbuild
Add SerenityOS crossbuild
2021-08-21 15:25:46 +09:00
Dante Catalfamo 7f290bebaf Specify potential values for SERENITY_ARCH 2021-08-20 22:27:50 -04:00
Dante Catalfamo 5e030491e7 Replace 32-bit serenity config with 64-bit compatible version. 2021-08-20 14:48:49 -04:00
Dante Catalfamo 124c4d617f Add serenity-32bit crossbuild
Cross compile mruby for SerenityOS (https://github.com/SerenityOS/serenity)
2021-08-19 23:34:30 -04:00
Yukihiro "Matz" Matsumoto ca295a2c23 symbol.c: reduce memory by avoiding alignment gaps.
In additions:

* use bitmap for flags
* BER integer compression for length
2021-08-19 20:39:34 +09:00
Yukihiro "Matz" Matsumoto 7f8b30261f gc.c: remove unused structs from RVALUE. 2021-08-19 16:06:17 +09:00
Yukihiro "Matz" Matsumoto 6f305c01a2 value.h: fixed warnings on __APPLE__. 2021-08-19 13:08:39 +09:00
Yukihiro "Matz" Matsumoto 959383df75 value.h: enable mrb_ro_data_p() on __linux__ and __APPLE__.
Probably we should add conditions for FreeBSD, etc.
2021-08-19 12:52:10 +09:00
Yukihiro "Matz" Matsumoto ef66406c50 string.c: mrb_str_to_cstr() should always return a mutable string. 2021-08-18 21:40:10 +09:00
Yukihiro "Matz" Matsumoto 20635e6bdc debug.c: export integer compressing functions.
- mrb_packed_int_len()
- mrb_packed_int_encode()
- mrb_packed_int_decode()
2021-08-18 17:18:04 +09:00
Yukihiro "Matz" Matsumoto 96a8703ca8 boxing_word.h: simplifies inline symbols on MRB_64BIT. 2021-08-17 16:03:42 +09:00
Yukihiro "Matz" Matsumoto 80cf293bf6 pack.c: rename pack/unpack functions for readability. 2021-08-17 13:04:11 +09:00
Yukihiro "Matz" Matsumoto 57b347088d fixup! pack.c: reduce dispatch in pack_unpack(). 2021-08-17 13:04:06 +09:00
Yukihiro "Matz" Matsumoto 4385590d31 pack.c: reduce dispatch in pack_unpack(). 2021-08-17 12:52:56 +09:00
Yukihiro "Matz" Matsumoto bfe2bd4960 pack.c: fix M packing bug. 2021-08-16 10:56:44 +09:00
Yukihiro "Matz" Matsumoto 8d85d4ac9b AUTHORS: update. [ci skip] 2021-08-15 07:07:08 +09:00
Yukihiro "Matz" Matsumoto 40c4c5d344 random.c: use I specifier for mrb_get_args(); ref #5530 2021-08-14 15:28:38 +09:00
Yukihiro "Matz" Matsumoto 8e5e96239c pack.c: fixed a overwriting bug in pack_w and pack_M. 2021-08-14 14:58:09 +09:00
Yukihiro "Matz" Matsumoto ad194bd46b error.c: the error message may contain NUL character. 2021-08-14 13:01:47 +09:00
Yukihiro "Matz" Matsumoto 73798bff65 Merge pull request #5532 from dantecatalfamo/rhel-doxygen
Add instructions for installing doxygen on RHEL/Fedora/CentOS
2021-08-14 08:18:11 +09:00
Dante Catalfamo 89ea8fa34a Add instructions for installing doxygen on RHEL/Fedora/CentOS 2021-08-13 14:53:20 -04:00
Yukihiro "Matz" Matsumoto 32c30c35b2 Merge pull request #5530 from dearblue/mrb_get_args-I
Check the class with `I` specifier of `mrb_get_args()`
2021-08-13 18:11:26 +09:00
dearblue 01da5e1392 Check the class with I specifier of mrb_get_args()
Previously, the `I` specifier only checked if the object was `MRB_TT_ISTRUCT`.
So it was at risk of getting pointers to different C structs if multiple classes were to use the `MRB_TT_ISTRUCT` instance.

Change this behavior and change the C argument corresponding to the `I` specifier to `(void *, struct RClass)`.

This change is not compatible with the previous mruby.
Please note that if the user uses the previous specifications, `SIGSEGV` may occur or the machine stack may be destroyed.

resolve #5527
2021-08-13 15:04:19 +09:00
Yukihiro "Matz" Matsumoto 9e74aad43c codegen.c: fixed a bug in mrb_decode_insn(). 2021-08-13 12:38:10 +09:00
Yukihiro "Matz" Matsumoto 7907c184be codegen.c: add a comment that notice rewind_pc calling convention.
`rewind_pc` should not be called when `s->pc` is `0` (top).
2021-08-13 10:11:36 +09:00
Yukihiro "Matz" Matsumoto 9c3d305530 codegen.c: refactor mrb_last_insn().
Last commit made `mrb_decode_insn()` to take `NULL` as `pc`.
2021-08-13 10:10:17 +09:00
Yukihiro "Matz" Matsumoto cbdc4f2c5c codegen.c: mrb_prev_pc can return NULL at the top of iseq. 2021-08-13 10:02:01 +09:00
Yukihiro "Matz" Matsumoto 013365498d test/eval.c: add test for #5528 2021-08-12 11:57:56 +09:00
Yukihiro "Matz" Matsumoto 43f9901ec2 Revert "Drop unnecessary upper procs linked from class/module/def syntax"
Fix #5528
This reverts commit 59201b59046b9e73c309508350cd3c0fafd20e4d; #5497
2021-08-12 11:42:27 +09:00
Yukihiro "Matz" Matsumoto 80893811c0 class.c: const_missing do not have to be in the backtrace; ref #5528 2021-08-12 08:10:09 +09:00
Yukihiro "Matz" Matsumoto e1b170160b codegen.c: avoid signedness warning of int comparison. 2021-08-11 16:10:32 +09:00
Yukihiro "Matz" Matsumoto a85f2299c0 codegen.c: avoid cross initialization of mrb_insn_data. 2021-08-11 16:09:51 +09:00
Yukihiro "Matz" Matsumoto fd597d2655 codedump.c: print local variable name for `ADDI/SUBI/ instructions.
Recent peephole optimization made `ADDI/SUBI` destinations possibly
local variables.
2021-08-11 10:48:18 +09:00
Yukihiro "Matz" Matsumoto b1b9b157f8 codegen.c: more peephole optimization.
`a=10; a+=1` to generate:

```
    1 000 OP_LOADI      R1      11              ; R1:a
```

instead of:

```
    1 000 OP_LOADI      R1      10              ; R1:a
    1 003 OP_MOVE       R2      R1              ; R1:a
    1 006 OP_ADDI       R2      1
    1 009 OP_MOVE       R1      R2              ; R1:a
```
2021-08-11 10:48:18 +09:00