summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler/core
AgeCommit message (Collapse)Author
2021-07-22codegen.c: `get_int_operand()` to support `OP_LOADL` (int in pool).Yukihiro "Matz" Matsumoto
2021-07-22codegen.c: add constant folding for unary numeric operators (+, -, ~).Yukihiro "Matz" Matsumoto
2021-07-22codegen.c: compare symbol names directly avoiding string conversion.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: skip `-@` call if the argument is a literal integer.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: move `gen_setxv()` after `new_sym()`.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: introduce `gen_int()` to generate integer instructions.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: add peephole optimization for `OP_LOADI32` before `OP_MOVE`.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: add peephole optimization for `OP_LOADI16` before `OP_MOVE`.Yukihiro "Matz" Matsumoto
2021-07-21codegen.c: a new function `get_int_operand`.Yukihiro "Matz" Matsumoto
2021-07-20codegen.c: negative zero equals to positive zero.Yukihiro "Matz" Matsumoto
`OP_LOADI Rn -0` should be `OP_LOADI_0`.
2021-07-20codegen.c: allow `OP_EXT` before `OP_ADDI` and `OP_SUBI`.Yukihiro "Matz" Matsumoto
This is preparation for integer constant folding.
2021-07-17codegen.c: optimize variable assignments after `OP_MOVE`.Yukihiro "Matz" Matsumoto
- `OP_SETGV` - `OP_SETIV` - `OP_SETCV` - `OP_SETCONST`
2021-07-17codegen.c: optimize `OP_SETUPVAR` after `OP_MOVE`.Yukihiro "Matz" Matsumoto
2021-07-16codegen.c: add new peephole optimization for `OP_MOVE`.Yukihiro "Matz" Matsumoto
If `OP_MOVE` comes after `OP_GETUPVAR`, you can skip move and redirect the destination register of `OP_GETUPVAR`.
2021-07-16codegen.c: add new peephole optimization for `OP_GETUPVAR`.Yukihiro "Matz" Matsumoto
When `OP_GETUPVAR` is generated right after `OP_SETUPVAR`, there is no need to read the upvar back to the register, e.g. 3 008 OP_ADDI R2 1 3 011 OP_SETUPVAR R2 1 0 4 015 OP_GETUPVAR R2 1 0 4 019 OP_LOADI_2 R3 `OP_GETUPVAR` at the address `015` is useless. We can skip it like: 3 008 OP_ADDI R2 1 3 011 OP_SETUPVAR R2 1 0 4 015 OP_LOADI_2 R3
2021-07-15codegen.c: `gen_jmpdst` always needs to generate relative address.Yukihiro "Matz" Matsumoto
2021-07-09codegen.c: avoid uninitialized local variable.Yukihiro "Matz" Matsumoto
2021-07-04codegen.c: jump address should be generated by `gen_jmpdst()`.Yukihiro "Matz" Matsumoto
2021-07-03vm.c: `OP_DEF` to push a symbol to `a` register.Yukihiro "Matz" Matsumoto
The code generator no longer need to emit `OP_LOADSYM` after `OP_DEF`. `doc/opcode.md` is also updated.
2021-06-30Revert "Remove `OP_EXT[123]` from operands."Yukihiro "Matz" Matsumoto
This reverts commit fd10c7231906ca48cb35892d2a86460004b62249. I thought it was OK to restrict index value within 1 byte, but in some cases index value could be 16 bits (2 bytes). I had several ideas to address the issue, but reverting `fd10c72` is the easiest way. The biggest reason is `mruby/c` still supports `OP_EXT[123]`, so that they don't need any additional work.
2021-06-28Merge pull request #5493 from dearblue/binding.2Yukihiro "Matz" Matsumoto
Fixed finding variables from `proc` in `binding.eval` failed
2021-06-26Fixed finding variables from `proc` in `binding.eval` faileddearblue
Previously the following code did not produce the expected results: ```ruby bx = binding block = bx.eval("a = 1; proc { a }") bx.eval("a = 2") p block.call # Expect 2 but return 1 due to a bug ``` The previous implementation of `Binding#eval` evaluated the code and then merged the top layer variables. This patch will parse and expand the variable space before making a call to `eval`. This means that the call to `Binding#eval` will do the parsing twice. In addition, the following changes will be made: - Make `mrb_parser_foreach_top_variable()`, `mrb_binding_extract_proc()` and `mrb_binding_extract_env()` functions private global functions. - Remove the `posthook` argument from `mrb_exec_irep()`. The `posthook` argument was introduced to implement the `binding` method. This patch is unnecessary because it uses a different implementation method. ref #5362 fixed #5491
2021-06-26Fixed finding variables defined in the upper proc faileddearblue
If no new variable was defined in the `eval` method, the variable was hidden from the nested `eval` method. ```ruby a = 1 p eval %(b = 2; eval %(a)) # => 1 (good) p eval %(eval %(a)) # => undefined method 'a' (NoMethodError) ``` This issue has occurred since mruby 3.0.0.
2021-06-19codegen.c: stop `uninitialized` warning.Yukihiro "Matz" Matsumoto
2021-06-11codegen.c: refactor `readint()`Yukihiro "Matz" Matsumoto
* renamed from redundant `readint_mrb_int()` * supports only base upto 16 * no base validation (already done in parser) * no negative read (negate after read) * overflow detection using `mrb_int_{mul,add}_overflow()`
2021-05-29codegen.c: just raise the exception on broken node for assignments.Yukihiro "Matz" Matsumoto
2021-05-18parse.y: allow "command" syntax in endless method definition.Yukihiro "Matz" Matsumoto
This change allows `def hello = puts "Hello"` without parentheses. This syntax has been introduced since Ruby3.1.
2021-05-18parse.y: endless singleton method definition can omit parens.Yukihiro "Matz" Matsumoto
2021-04-16feat(CI): add the GitHub Super LinterJohn Bampton
The GitHub Super Linter is a more robust and better supported tool than the current GitHub Actions we are using. Running these checks: ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_BASH: true VALIDATE_BASH_EXEC: true VALIDATE_EDITORCONFIG: true VALIDATE_MARKDOWN: true VALIDATE_SHELL_SHFMT: true VALIDATE_YAML: true https://github.com/marketplace/actions/super-linter https://github.com/github/super-linter Added the GitHub Super Linter badge to the README. Also updated the pre-commit framework and added more documentation on pre-commit. Added one more pre-commit check: check-executables-have-shebangs Added one extra check for merge conflicts to our GitHub Actions. EditorConfig and Markdown linting. Minor grammar and spelling fixes. Update linter.yml
2021-03-31codegen.c: `s->ainfo` should be zero along with `OP_ENTER(0)`.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: `yield` outside of method is now `SyntaxError`.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: remove `codegen error:` prefix from error messages.Yukihiro "Matz" Matsumoto
2021-03-31codegen.c: `ainfo` may be negative.Yukihiro "Matz" Matsumoto
When argument information is not available. So it should not happen for `yield` (error). In contrast, the error from `super` should be handled in run time (ignored).
2021-03-22codegen.c: fix integer size warnings.Yukihiro "Matz" Matsumoto
along with repeated calls of `strlen()`.
2021-03-13codegen.c: fix memory leak from `new_litbn()`.Yukihiro "Matz" Matsumoto
2021-03-12codegen.c: need to preserve `neg` info.Yukihiro "Matz" Matsumoto
2021-03-12codegen.c: avoid integer comparison of different sign.Yukihiro "Matz" Matsumoto
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-01feat: add pre-commit frameworkJohn Bampton
2021-02-24parse.y: endless_method_name should allow `==`.Yukihiro "Matz" Matsumoto
e.g. `def ==(v) = true`. The issue is reported by @shuujii
2021-02-24parse.y: upgrade endless `def` syntax.Yukihiro "Matz" Matsumoto
- prohibit defining setter method - allow endless def without parentheses
2021-02-13chore: fix missing HTTPS on linksJohn Bampton
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-13parse.y: string buffer (`tokbuf`) can overflow.Yukihiro "Matz" Matsumoto
Check if `esclen` is smaller than `len` (original string length).
2021-02-03Avoid Heap Overflow in `heredoc_remove_indent`; fix #5316Yukihiro "Matz" Matsumoto
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-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-24Prohibit `r` suffix after scientific notation (e.g. `1e10`).Yukihiro "Matz" Matsumoto
As CRuby does.
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-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