Yukihiro "Matz" Matsumoto
42a6872c2b
parse.y: adjust void_expr_error(); fix #5606
...
Allow void expression on some places e.g. right hand of `rescue`
modifier. In addition, checks added on some places, e.g. left hand of
logical operators.
2021-12-22 14:08:04 +09:00
Yukihiro "Matz" Matsumoto
4e8d376417
Merge pull request #5610 from mruby/dependabot/github_actions/github/super-linter-4.8.5
...
build(deps): bump github/super-linter from 4.8.4 to 4.8.5
2021-12-21 23:13:43 +09:00
dependabot[bot]
916fbcce2c
build(deps): bump github/super-linter from 4.8.4 to 4.8.5
...
Bumps [github/super-linter](https://github.com/github/super-linter ) from 4.8.4 to 4.8.5.
- [Release notes](https://github.com/github/super-linter/releases )
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md )
- [Commits](https://github.com/github/super-linter/compare/v4.8.4...v4.8.5 )
---
updated-dependencies:
- dependency-name: github/super-linter
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
2021-12-21 14:11:38 +00:00
Yukihiro "Matz" Matsumoto
8a5f18a1d8
codegen.c: generate OP_SETIDX; close #5608
...
Note that the current implantation only calls `[]=` method. No
performance improvement. Just 2 bytes less byte code per assignment.
2021-12-20 17:46:57 +09:00
Yukihiro "Matz" Matsumoto
a42b676ae9
vm.c: fix a half-baked implementation of OP_SETIDX; ref #5608
2021-12-20 17:45:10 +09:00
Yukihiro "Matz" Matsumoto
5774a7a38b
codedump.c: adjust the position of local variable labels.
2021-12-20 17:44:31 +09:00
Yukihiro "Matz" Matsumoto
a17955259e
Merge pull request #5602 from dearblue/no-ext-ops
...
Add `bin/mrbc --no-ext-ops` switch
2021-12-19 19:11:51 +09:00
Yukihiro "Matz" Matsumoto
d7812bd3d6
Merge pull request #5603 from dearblue/codegen_error
...
Print error before cleanup in `codegen_error()`
2021-12-18 19:42:31 +09:00
dearblue
26338fe640
Print error before cleanup in codegen_error()
...
Previously, it always pointed to the highest scope as the location of the error.
- example code `code.rb`
```ruby
huge_num = "1" + "0" * 300; eval <<CODE, nil, "test.rb", 1
class Object
module A
#{huge_num}
end
end
CODE
```
- Before this patch
```console
% bin/mruby code.rb
test.rb:1: integer too big
trace (most recent call last):
[1] code.rb:1
code.rb:1:in eval: codegen error (ScriptError)
```
- After this patch
```console
% bin/mruby code.rb
test.rb:3: integer too big
trace (most recent call last):
[1] code.rb:1
code.rb:1:in eval: codegen error (ScriptError)
```
2021-12-17 23:03:27 +09:00
dearblue
6b8582c95d
Add bin/mrbc --no-ext-ops switch
...
Print an error if `OP_EXT[123]` is needed when generating mruby binary.
This may be useful for mruby/c.
Inspired by #5590 .
2021-12-17 23:02:04 +09:00
Yukihiro "Matz" Matsumoto
9b65d0dc86
Merge pull request #5601 from mruby/dependabot/github_actions/actions/upload-artifact-2.3.1
...
build(deps): bump actions/upload-artifact from 2.2.4 to 2.3.1
2021-12-17 07:49:53 +09:00
dependabot[bot]
a7aa0b1da2
build(deps): bump actions/upload-artifact from 2.2.4 to 2.3.1
...
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact ) from 2.2.4 to 2.3.1.
- [Release notes](https://github.com/actions/upload-artifact/releases )
- [Commits](https://github.com/actions/upload-artifact/compare/v2.2.4...v2.3.1 )
---
updated-dependencies:
- dependency-name: actions/upload-artifact
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com >
2021-12-16 14:08:05 +00:00
Yukihiro "Matz" Matsumoto
57d93c4d76
string-ext.c: fix memory leak in tr_parse_pattern.
2021-12-16 11:39:35 +09:00
Yukihiro "Matz" Matsumoto
0fbdd71dcf
boxing_nan.h: remove false description in the comment [ci skip]
...
Ref #5597
2021-12-15 23:07:34 +09:00
Yukihiro "Matz" Matsumoto
a3d240c2ed
Merge pull request #5599 from dearblue/loss-digits
...
Avoid losing the upper digits for mruby binary
2021-12-15 23:07:13 +09:00
Yukihiro "Matz" Matsumoto
f5e10c5a79
proc.c: add mrb_state argument to mrb_proc_copy().
...
The function may invoke the garbage collection and it requires
`mrb_state` to run.
2021-12-14 13:35:18 +09:00
dearblue
fa33a5bb0c
Avoid losing the upper digits for mruby binary
...
- `rlen` keeps 16 bits.
- `ilen` keeps 32 bits.
Note that this change will break mruby binary format compatibility.
2021-12-13 22:58:57 +09:00
Yukihiro "Matz" Matsumoto
8a74b2a25d
string-ext/string.c: fixed memory leak from tr on exception.
...
With some refactoring.
* `ret` argument is always non-nil, so no check needed.
* move allocation check right after malloc().
* simplify conditions.
2021-12-13 10:29:16 +09:00
Yukihiro "Matz" Matsumoto
d01707d4cf
benchmark/bm_ao_render.rb: enable specifying the size of the image.
2021-12-13 10:29:16 +09:00
Yukihiro "Matz" Matsumoto
7b84fd4ce8
variable.c: resurrect size member in iv_tbl.
...
The existence of this member reduces memory and execution time.
2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto
786156d48c
class.c: increase first allocated page size.
2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto
bd4268210e
class.c: implement method cache (off by default).
2021-12-13 10:29:15 +09:00
Yukihiro "Matz" Matsumoto
523197c831
Merge pull request #5598 from dearblue/array-combinations
...
Add `Array#{repeated_combination,repeated_permutation}` methods
2021-12-13 10:28:50 +09:00
dearblue
586525f99a
Add Array#{repeated_combination,repeated_permutation} methods
...
Ruby 1.9.2 feature.
ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_combination.html
ref: https://docs.ruby-lang.org/ja/3.1.0/method/Array/i/repeated_permutation.html
2021-12-12 21:28:03 +09:00
Yukihiro "Matz" Matsumoto
7349902d5b
irep.h: c operand may require 16 bits for BSS operand type.
...
fix #5593
2021-12-09 14:28:47 +09:00
Yukihiro "Matz" Matsumoto
d2a904c884
vm.c (check_method_noarg): the value at kidx may not be a hash.
2021-12-08 16:43:02 +09:00
Yukihiro "Matz" Matsumoto
c593e3e30a
vm.c: use check_method_noarg() to reduce code duplication; ref #5584
2021-12-08 16:42:23 +09:00
Yukihiro "Matz" Matsumoto
5bad1c7429
vm.c: fix mrb_ci_kidx.
...
It used to return wrong value for 14 positional arguments.
2021-12-08 16:22:24 +09:00
Yukihiro "Matz" Matsumoto
0b6b042fe8
variable.c: fix clang integer warning.
2021-12-08 13:27:10 +09:00
Yukihiro "Matz" Matsumoto
47092ccfa5
mruby-compiler/mrbgem.rake: fix regexp pattern; close #5591
2021-12-07 23:57:32 +09:00
Yukihiro "Matz" Matsumoto
9935cf1aef
variable.c: avoid redundant iv scan in mrb_mod_cv_set().
...
Now `iv_get()` returns `pos+1` if it finds the entry, so you don't need
to call `iv_put()`. You can replace the entry value by assigning to
`t->ptr[pos-1]`.
2021-12-07 08:19:16 +09:00
Yukihiro "Matz" Matsumoto
856ae52021
bm_ao_rendar.rb: use instance variables instead of class variables.
...
Class variables are slower than instance variables of classes.
2021-12-06 21:12:23 +09:00
Yukihiro "Matz" Matsumoto
e5810db1ad
variable.c: reduce array access in iv hash table.
2021-12-04 10:43:58 +09:00
Yukihiro "Matz" Matsumoto
9d554017f0
variable.c: avoid mrb_undef_value() for delete entries.
...
Instead embed deleted flag in the key (`mrb_sym` only occupies 30bits).
2021-12-03 18:36:29 +09:00
Yukihiro "Matz" Matsumoto
4f2a153ada
variable.c: remove size member from iv_tbl to reduce memory.
...
`iv_size()` is approximated by the allocated table size.
2021-12-03 16:06:25 +09:00
Yukihiro "Matz" Matsumoto
d3ebe4894b
variable.c: first iv allocation size should be 4 instead of 1.
2021-12-03 15:38:16 +09:00
Yukihiro "Matz" Matsumoto
a20c2a08ab
variable.c: should not access NULL[0] to avoid asan warnings.
2021-12-03 15:04:14 +09:00
Yukihiro "Matz" Matsumoto
6ac26e4442
parse.y: support anonymous block argument introduced by Ruby3.1.
2021-12-02 18:24:48 +09:00
Yukihiro "Matz" Matsumoto
bd88870afb
codegen.c: ADDI/SUBI should not be prefixed by OP_EXT; fix #5590
...
As a general principles numeric instructions should not be prefixed by
`OP_EXT` instructions since they are not supported by "mruby/c".
2021-12-01 14:33:52 +09:00
Yukihiro "Matz" Matsumoto
76659a66ae
codegen.c: skip ADDI/SUBI for zero operand.
2021-12-01 14:29:44 +09:00
Yukihiro "Matz" Matsumoto
7d6b8024b5
codegen.c: fix a bug in OP_ADDI and OP_SUBI regarding negative values.
2021-12-01 14:28:27 +09:00
Yukihiro "Matz" Matsumoto
2e2f81a443
codegen.c: get_int_operand to retrieve negative values correctly.
2021-12-01 14:26:22 +09:00
Yukihiro "Matz" Matsumoto
7a31a1743a
codedump.c: print OP_EXT explicitly again for debugging purpose.
2021-12-01 13:42:40 +09:00
Yukihiro "Matz" Matsumoto
b5842dea58
variable.c: reduce memory usage of instance variable table
...
This is a fundamentally simplified reimplementation of #5317
by @shuujii
Instead of having array of `struct iv_elem`, we have sequences of keys
and values packed in single chunk of malloc'ed memory. We don't have to
worry about gaps from alignment, especially on 64 bit architecture,
where `sizeof(struct iv_elem)` probably consumes 16 bytes, but
`sizeof(mrb_sym)+sizeof(mrb_value)` is 12 bytes.
In addition, this change could improve memory access locality.
close #5317
2021-12-01 12:27:19 +09:00
Yukihiro "Matz" Matsumoto
b137eb2678
vm.c: remove duplicate code in VM.
2021-11-29 23:18:57 +09:00
Yukihiro "Matz" Matsumoto
a245c34210
Merge pull request #5589 from dearblue/argerr
...
Align "wrong number of arguments" messages
2021-11-29 10:14:59 +09:00
Yukihiro "Matz" Matsumoto
a0f38005fb
Merge pull request #5588 from dearblue/cmath+clang++
...
Fixed compile error for `mrbgems/mruby-cmath` with `clang++`
2021-11-28 19:04:57 +09:00
Yukihiro "Matz" Matsumoto
6bb2af9666
Merge pull request #5587 from dearblue/args-pass.1
...
Fix `args_unshift()` in `mrbgems/mruby-method`
2021-11-28 19:03:33 +09:00
dearblue
c4bca7cbb3
Align "wrong number of arguments" messages
...
Make "N for M" into the form "given N, expected M".
As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394 .
- Before this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
```
- After this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
```
2021-11-28 18:21:29 +09:00
dearblue
f81bc3de38
Fixed compile error for mrbgems/mruby-cmath with clang++
...
If the preprocessor check part is only `__clang__`, CI's such as `Ubuntu-2004-clang` will fail to compile.
This is why we limited the addition to FreeBSD and OpenBSD, which have `clang++` in their base systems.
DragonFly BSD and NetBSD have GCC built into their base systems, so nothing is changed.
2021-11-28 17:28:44 +09:00