Yukihiro "Matz" Matsumoto
5e1a6a2cc2
Make gen_assignment() to support NODE_SCALL; ref #3658
2017-05-25 12:40:49 +09:00
Clayton Smith
bf30b8e8bf
Change return back to break in the default case.
2017-05-12 14:43:12 -04:00
Yukihiro "Matz" Matsumoto
88cd807379
Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
...
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto
3b0a36d399
Alias should push() extra stack space for blocks.
2017-04-22 12:03:56 +09:00
Yukihiro "Matz" Matsumoto
f4119f518f
Changed evaluation order of yield; ref #3613
...
So that `yield expr_with_error` will cause the error from the
argument rather than `LocalJumpError` when no block is given.
2017-04-18 12:00:52 +09:00
Yukihiro "Matz" Matsumoto
3123549bcb
Fixed a bug in NODE_XSTR code generation; fix #3605
2017-04-13 00:38:47 +09:00
Yukihiro "Matz" Matsumoto
fff4a4ed34
OP_LAMBDA generation should honor VAL/NOVAL; fix #3580
2017-04-11 02:30:24 +09:00
Yukihiro "Matz" Matsumoto
77331d127b
Unify else clause style
2017-04-03 16:56:27 +09:00
Yukihiro "Matz" Matsumoto
666787beb2
Adjust exit point in loop_pop(); fix #3541
2017-04-03 12:41:27 +09:00
Yukihiro "Matz" Matsumoto
d35fcf1ea2
NODE_SPLAT to pass VAL/NOVAL; fix #3532
2017-04-03 12:02:39 +09:00
Yukihiro "Matz" Matsumoto
a14a930c80
Remove unnecessary indirection; ref #3557
2017-04-03 10:03:58 +09:00
Yukihiro "Matz" Matsumoto
8193c0b566
Check before generating special operators (e.g. OP_ADD); fix #3557
2017-04-03 10:01:44 +09:00
Yukihiro "Matz" Matsumoto
dcbfe71625
NODE_ASGN arguments may be 127 (CALL_MAXARGS) accidentally; fix #3559
2017-04-01 14:11:15 +09:00
Yukihiro "Matz" Matsumoto
e22f37a166
Argument order of __case_eqq was wrong; fix #3567
2017-04-01 13:42:44 +09:00
Yukihiro "Matz" Matsumoto
9eb0c11afd
Cast to mrb_int to silence a warning; fix #3530
2017-03-23 01:20:45 +09:00
Yukihiro "Matz" Matsumoto
3703aed7ab
Use snprintf() to stringify fixnum numbers; ref #3492
2017-03-20 11:47:15 +09:00
Yukihiro "Matz" Matsumoto
4cf38eb903
Fixed OP_RESCUE code generation bug; fix #3519
...
916b8e let code executed with mrb->exc set, and may cause a crash
like #3519 . Instead modified OP_RESCUE again. To retrieve the exception
object, we use `OP_RESCUE R(A), 0, 0` (old behavior). To compare the
exception object and the class, we use `OP_RESCUE R(A), R(B), 1`.
The reason we use OP_RESCUE for two instruction switched by operand
C is to save the instruction space.
As a result, the following code:
```ruby
begin
raise "a"
rescue TypeError
p 1
rescue RuntimeError
p 2
end
```
will be compiled as:
```
irep 0x55cd1f565cb0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: -
2 000 OP_ONERR 005
2 001 OP_LOADSELF R1
2 002 OP_STRING R2 L(0) ; "a"
2 003 OP_SEND R1 :raise 1
2 004 OP_JMP 023
2 005 OP_RESCUE R1
3 006 OP_GETCONST R2 :TypeError
3 007 OP_RESCUE R1 R2 cont
3 008 OP_JMPIF R2 010
3 009 OP_JMP 014
4 010 OP_LOADSELF R1
4 011 OP_LOADI R2 1
4 012 OP_SEND R1 :p 1
4 013 OP_JMP 024
5 014 OP_GETCONST R2 :RuntimeError
5 015 OP_RESCUE R1 R2 cont
5 016 OP_JMPIF R2 018
5 017 OP_JMP 022
6 018 OP_LOADSELF R1
6 019 OP_LOADI R2 2
6 020 OP_SEND R1 :p 1
6 021 OP_JMP 024
6 022 OP_RAISE R1
6 023 OP_POPERR 1
6 024 OP_STOP
```
2017-03-19 18:42:53 +09:00
Yukihiro "Matz" Matsumoto
916b8ed5c8
Generate new OP_RESCUE; fix #3487
...
The old OP_RESCUE took one operand A, which specifies a class
to match with the exception. The new OP_RESCUE takes tree operands:
A: the register to hold exception
B: the matching exception; the match result will be stored here.
C: the continuation; if C is zero, the exception will be stored to R(A)
otherwise, the value from R(A) is used as a exception.
Thus,
```ruby
begin
raise "a"
rescue TypeError
p 1
rescue RuntimeError
p 2
end
```
will be compiled as
```
irep 0x557a06667aa0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: /tmp/e.rb
2 000 OP_ONERR 005
2 001 OP_LOADSELF R1
2 002 OP_STRING R2 L(0) ; "a"
2 003 OP_SEND R1 :raise 1
2 004 OP_JMP 022
3 005 OP_GETCONST R2 :TypeError
3 006 OP_RESCUE R1 R2
3 007 OP_JMPIF R2 009
3 008 OP_JMP 013
4 009 OP_LOADSELF R1
4 010 OP_LOADI R2 1
4 011 OP_SEND R1 :p 1
4 012 OP_JMP 023
5 013 OP_GETCONST R2 :RuntimeError
5 014 OP_RESCUE R1 R2 cont
5 015 OP_JMPIF R2 017
5 016 OP_JMP 021
6 017 OP_LOADSELF R1
6 018 OP_LOADI R2 2
6 019 OP_SEND R1 :p 1
6 020 OP_JMP 023
6 021 OP_RAISE R1
6 022 OP_POPERR 1
6 023 OP_STOP
```
The new VM can accept old OP_RESCUE. The mruby compatible VM (namely
mruby/c) should be updated to support the new OP_RESCUE behavior.
2017-03-12 01:10:20 +09:00
Yukihiro "Matz" Matsumoto
26169f9e25
Enhance OP_RESCUE to take B operand fas matching exception; ref #3487
2017-03-12 00:50:38 +09:00
Yukihiro "Matz" Matsumoto
000c68da97
OP_RETRUN to take B as matching exception; ref #3487
2017-03-11 16:32:29 +09:00
Yukihiro "Matz" Matsumoto
1ab7e7e4dc
Fixed a bug in register size calculation; fix #3479
2017-03-02 18:14:36 +09:00
Yukihiro "Matz" Matsumoto
8b089c09f7
Keep space for safe navigation operator; fix #3475
2017-03-01 10:37:43 +09:00
Yukihiro "Matz" Matsumoto
dc56bbecc8
Ignore empty ensure clause.
2017-02-28 11:51:17 +09:00
Yukihiro "Matz" Matsumoto
fb3243e096
return (and break) should handle splat correctly; fix #3472
2017-02-28 11:34:54 +09:00
Yukihiro "Matz" Matsumoto
c52bbe1b4e
Fixed a bug in dregex option generation; fix #3471
2017-02-28 10:43:22 +09:00
Yukihiro "Matz" Matsumoto
ecb6ac8b4a
Fixed codegen error of redo in rescue; fix #3422
...
The issue (and the fix) was reported by https://hackerone.com/dgaletic
2017-02-13 19:31:06 +09:00
Yukihiro "Matz" Matsumoto
f2b18a604c
Check maximum number of formal arguments.
...
http://hkdnet.hatenablog.com/entry/2017/02/06/080000 (Japanese)
2017-02-06 09:14:49 +09:00
Yukihiro "Matz" Matsumoto
6e0ba0085d
Jump address should fit in 16 bits range; fix #3426
2017-02-04 12:37:08 +09:00
Yukihiro "Matz" Matsumoto
f0f095bc13
Fix a double free problem in codegen.c; fix #3378
...
This issue was first reported by https://hackerone.com/geeknik
The fix was proposed by @titanous
2017-01-23 16:53:31 +09:00
Yukihiro "Matz" Matsumoto
3ce82603a5
Fix memory leak; ref #3378
...
The fix was proposed by @titanous
2017-01-23 16:48:18 +09:00
Clayton Smith
2c0f8f1a23
Remove problematic optimization.
2017-01-20 18:40:18 -05:00
Yukihiro "Matz" Matsumoto
c2bbfa5b61
NODE_NEGATE cdr may not be code-node; fix #3348 ref #3324
...
Reported by Denis Kasak https://hackerone.com/dkasak
2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto
647ad29a7a
Fixed wrong condition in new_sym() that breaks symbol data.
2016-12-13 02:33:28 +09:00
Yukihiro "Matz" Matsumoto
a4ae22ae0c
Failed to realloc irep->syms in certain condition.
...
Also msym size changed to 512 from 256.
2016-12-13 01:55:08 +09:00
Yukihiro "Matz" Matsumoto
13979a4376
Merge pull request #3324 from bouk/mruby/bouk-negate
...
Don't generate code for NODE_NEGATE if the result isn't used
Reported by https://hackerone.com/haquaman
2016-12-10 15:52:41 +09:00
Bouke van der Bijl
1264219832
Fix segfault in gen_values with NOVAL and more than 127 args
2016-12-09 10:30:05 -05:00
Bouke van der Bijl
c8da3c4df4
Fix segfault when undef is called with exactly 127 arguments
...
The issue is that when there are more than 126 arguments an array needs
to be created to pass the arguments on with.
Reported by https://hackerone.com/revskills
2016-12-08 15:47:17 -05:00
Bouke van der Bijl
d56a19cbf5
Don't generate code for NODE_NEGATE if the result isn't used
...
Reported by https://hackerone.com/haquaman
2016-12-07 15:14:17 -05:00
Yukihiro "Matz" Matsumoto
a0fbc46ccd
Import locale insensitive strtod() from Ruby1.8; fix #3270
...
The function was renamed to `mrb_float_read(const char*, char**)`.
2016-12-03 18:47:04 +09:00
Yukihiro "Matz" Matsumoto
c029c6c444
codegen: avoid unnecessary OP_MOVE after CASE
2016-12-03 14:50:36 +09:00
Bouke van der Bijl
fe362c1f26
Fix segfault when using result of rest assignment
...
Reported by https://hackerone.com/haquaman
2016-12-01 15:49:36 -05:00
Yukihiro "Matz" Matsumoto
55842c5a34
resolve conflict; ref #3279
2016-11-25 09:33:20 +09:00
Yukihiro "Matz" Matsumoto
30f12ba4bc
resolve conflict; ref #3283
2016-11-25 09:27:24 +09:00
Yukihiro "Matz" Matsumoto
cc2786c84e
resolve conflict; ref #3285
2016-11-25 09:25:51 +09:00
Yukihiro "Matz" Matsumoto
0b4017fd69
resolve conflict; ref #3286
2016-11-25 09:23:47 +09:00
Francis Bogsanyi
964427f82c
Fix unsafe peephole optimization
...
Reported by https://hackerone.com/dkasak
2016-11-24 10:32:34 -05:00
Bouke van der Bijl
71641bbf73
Fix segfault caused by empty condition in ternary
...
Reported by https://hackerone.com/jpenalbae
2016-11-24 10:20:42 -05:00
Bouke van der Bijl
1253982577
Fix codegen issue causing misaligned register
...
Reported by https://hackerone.com/haquaman
2016-11-24 10:18:48 -05:00
Bouke van der Bijl
75b31d7438
Fix segfault on method call with exactly 127 arguments
...
Reported by https://hackerone.com/dkasak
2016-11-24 10:09:37 -05:00
Bouke van der Bijl
73e4f069be
Fix nested empty heredoc causing segfault
...
As reported by https://hackerone.com/jpenalbae
2016-11-24 09:54:18 -05:00