aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
Commit message (Collapse)AuthorAgeFilesLines
...
* Make sure WB executes after object is reachableAaron Patterson2019-09-111-1/+1
|
* Made a short-circuit expression w/o result into an `if`-statementNobuyoshi Nakada2019-09-111-1/+1
|
* &$$->nd_lit is uninitialized at this point卜部昌平2019-09-111-2/+2
| | | | See also https://travis-ci.org/ruby/ruby/jobs/583031687#L1874
* Macros can't be expressions, so make a functionAaron Patterson2019-09-101-0/+16
| | | | | | Macros can't be expressions, that is a GNU extension (I didn't know that). This commit converts the macro to a function so that everything will compile correctly on non-GNU compatible compilers.
* WB needs to be executed after object is reachableAaron Patterson2019-09-101-4/+4
|
* Only use `add_mark_object` in RipperAaron Patterson2019-09-091-23/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes parse.y to only use `add_mark_object` in Ripper. Previously we were seeing a bug in write barrier verification. I had changed `add_mark_object` to execute the write barrier, but the problem is that we had code like this: ``` NEW_STR(add_mark_object(p, obj), loc) ``` In this case, `add_mark_object` would execute the write barrier between the ast and `obj`, but the problem is that `obj` isn't actually reachable from the AST at the time the write barrier executed. `NEW_STR` can possibly call `malloc` which can kick a GC, and since `obj` isn't actually reachable from the AST at the time of WB execution, verification would fail. Basically the steps were like this: 1. RB_OBJ_WRITTEN via `add_mark_object` 2. Allocate node 3. *Possibly* execute GC via malloc 4. Write obj in to allocated node This patch changes the steps to: 1. Allocate node 2. *Possibly* execute GC via malloc 3. Write obj in to allocated node 4. RB_OBJ_WRITTEN
* Revert "Reverting node marking until I can fix GC problem."Aaron Patterson2019-09-091-18/+22
| | | | This reverts commit 092f31e7e23c0ee04df987f0c0f979d036971804.
* parse.y: Use the correct alias for brace flag of hash literalYusuke Endoh2019-09-081-1/+1
| | | | | nd_alen and nd_brace is the same field, but nd_brace is more suitable for this case.
* Rename some function/definition names that handles NODE_LISTYusuke Endoh2019-09-071-7/+7
| | | | | from array to list. Follow up to ac50ac03aeb210763730cdc45f230e236519223d
* Rename NODE_ARRAY to NODE_LIST to reflect its actual use casesYusuke Endoh2019-09-071-18/+18
| | | | | | | | | | and NODE_ZARRAY to NODE_ZLIST. NODE_ARRAY is used not only by an Array literal, but also the contents of Hash literals, method call arguments, dynamic string literals, etc. In addition, the structure of NODE_ARRAY is a linked list, not an array. This is very confusing, so I believe `NODE_LIST` is a better name.
* Warn local variables which conflict with new numbered parametersNobuyoshi Nakada2019-09-061-0/+4
|
* Reverting node marking until I can fix GC problem.Aaron Patterson2019-09-051-22/+18
| | | | | Looks like we're getting WB misses during stressful GC on startup. I am investigating.
* Stash tmpbuffer inside internal structsAaron Patterson2019-09-051-2/+4
| | | | | | I guess those AST node were actually used for something, so we'd better not touch them. Instead this commit just puts the tmpbuffer inside a different internal struct so that we can mark them.
* Don't change DSTR nodes to ARRAY nodesAaron Patterson2019-09-051-3/+1
| | | | | DSTR nodes are allocated in to the "markable" bucket where ARRAY nodes are not. Switching buckets can cause errors during GC.
* Create two buckets for allocating NODE structsAaron Patterson2019-09-051-1/+1
| | | | | | | | | This commit adds two buckets for allocating NODE structs, then allocates "markable" NODE objects from one bucket. The reason to do this is so when the AST mark function scans nodes for VALUE objects to mark, we only scan NODE objects that we know to reference VALUE objects. If we *did not* divide the objects, then the mark function spends too much time scanning objects that don't contain any references.
* Stash the imemo buf at the end of the ID listAaron Patterson2019-09-051-16/+8
| | | | | | | Now we can reach the ID table buffer from the id table itself, so when SCOPE nodes are marked we can keep the buffers alive. This eliminates the need for the "mark array" during normal parse / compile (IOW *not* Ripper).
* Mark some tmpbufs via node objectsAaron Patterson2019-09-051-8/+9
| | | | This way we don't need to add the tmpbufs to a Ruby array for marking
* Directly mark node objects instead of using a mark arrayAaron Patterson2019-09-051-1/+12
| | | | | | | | This patch changes the AST mark function so that it will walk through nodes in the NODE buffer marking Ruby objects rather than using a mark array to guarantee liveness. The reason I want to do this is so that when compaction happens on major GCs, node objects will have their references pinned (or possibly we can update them correctly).
* Fix code locations of array node inside hash node when multiple kw splatsJeremy Evans2019-09-051-0/+2
| | | | | | | | | | This is broken at least since 2.5 (I didn't check earlier versions). It resulted in failure in test_ast.rb when the tests were added before the parser change. Basically, in remove_duplicate_keys, if the node is modified, set the location information to the previous location information. The removal of keys should not affect the location in the code.
* Make m(**{}) mean call without keywordsJeremy Evans2019-09-051-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, **{} was removed by the parser: ``` $ ruby --dump=parse -e '{**{}}' @ NODE_SCOPE (line: 1, location: (1,0)-(1,6)) +- nd_tbl: (empty) +- nd_args: | (null node) +- nd_body: @ NODE_HASH (line: 1, location: (1,0)-(1,6))* +- nd_brace: 1 (hash literal) +- nd_head: (null node) ``` Since it was removed by the parser, the compiler did not know about it, and `m(**{})` was therefore treated as `m()`. This modifies the parser to not remove the `**{}`. A simple approach for this is fairly simple by just removing a few lines from the parser, but that would cause two hash allocations every time it was used. The approach taken here modifies both the parser and the compiler, and results in `**{}` not allocating any hashes in the usual case. The basic idea is we use a literal node in the parser containing a frozen empty hash literal. In the compiler, we recognize when that is used, and if it is the only keyword present, we just push it onto the VM stack (no creation of a new hash or merging of keywords). If it is the first keyword present, we push a new empty hash onto the VM stack, so that later keywords can merge into it. If it is not the first keyword present, we can ignore it, since the there is no reason to merge an empty hash into the existing hash. Example instructions for `m(**{})` Before (note ARGS_SIMPLE): ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE) 0000 putself ( 1)[Li] 0001 opt_send_without_block <callinfo!mid:m, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0004 leave ``` After (note putobject and KW_SPLAT): ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE) 0000 putself ( 1)[Li] 0001 putobject {} 0003 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache> 0006 leave ``` Example instructions for `m(**h, **{})` Before and After (no change): ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 putself ( 1)[Li] 0001 putspecialobject 1 0003 newhash 0 0005 putself 0006 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0009 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache> 0012 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache> 0015 leave ``` Example instructions for `m(**{}, **h)` Before: ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 putself ( 1)[Li] 0001 putspecialobject 1 0003 newhash 0 0005 putself 0006 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0009 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache> 0012 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache> 0015 leave ``` After (basically the same except for the addition of swap): ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE) 0000 putself ( 1)[Li] 0001 newhash 0 0003 putspecialobject 1 0005 swap 0006 putself 0007 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0010 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache> 0013 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache> 0016 leave ```
* Make pattern matching support **nil syntaxKazuki Tsujimoto2019-09-011-2/+19
|
* Made :nil static IDNobuyoshi Nakada2019-09-011-3/+3
|
* Add back missing warning for duplicate keys in splatted hashesJeremy Evans2019-08-301-1/+11
| | | | | | | This reverts the changes to parse.y in a5b37262524ac39d2af13eea174486370a581c23 as they are not actually needed and cause the warning for duplicate hash keys to not be emitted.
* Make ripper support **nil syntaxJeremy Evans2019-08-301-3/+9
| | | | | | | | | The on_params hook will use :nil as the keyword rest argument. There is a new on_nokw_param hook as well. This fixes a type issue in the previous code, where an ID was passed where a VALUE was the declared type. The symbol :nil is passed instead of the id.
* Support **nil syntax for specifying a method does not accept keyword argumentsJeremy Evans2019-08-301-0/+14
| | | | | | | | | This syntax means the method should be treated as a method that uses keyword arguments, but no specific keyword arguments are supported, and therefore calling the method with keyword arguments will raise an ArgumentError. It is still allowed to double splat an empty hash when calling the method, as that does not pass any keyword arguments.
* Separate keyword arguments from positional argumentsYusuke Endoh2019-08-301-11/+1
| | | | And, allow non-symbol keys as a keyword arugment
* Refined warnings against literal in flip-flopNobuyoshi Nakada2019-08-291-59/+27
|
* Revert "Add pipeline operator [Feature #15799]"Nobuyoshi Nakada2019-08-291-40/+2
| | | | | | | | | | | | | This reverts commits: * d365fd5a024254d7c105a62a015a7ea29ccf3e5d * d780c3662484d6072b3a6945b840049de72c2096 * aa7211836b769231a2a8ef6b6ec2fd0ec882ef29 * 043f010c28e82ea38978bf8ed885416f133b5b75 * bb4dd7c6af05c7821d572e2592ea3d0cc748d81f * 043f010c28e82ea38978bf8ed885416f133b5b75 * f169043d81524b5b529f2c1e9c35437ba5bc3a7a http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/94645
* Directly mark compile options from the AST objectAaron Patterson2019-08-271-2/+1
| | | | | | | `rb_ast_t` holds a reference to this object, so it should mark the object. Currently it is relying on the `mark_ary` on `node_buffer` to ensure that the object stays alive. But since the array internals can move, this could cause a segv if compaction impacts the array.
* Fix typosKazuhiro NISHIYAMA2019-08-241-8/+8
|
* Named numbered parameter indexesNobuyoshi Nakada2019-08-241-10/+14
|
* Fix parsing of mutiple assignment with rescue modifierJeremy Evans2019-08-091-0/+9
| | | | | | | | | | | | | | | | | | | Single assignment with rescue modifier applies rescue to the RHS: a = raise rescue 1 # a = (raise rescue 1) Previously, multiple assignment with rescue modifier applied rescue to the entire expression: a, b = raise rescue [1, 2] # (a, b = raise) rescue [1, 2] This makes multiple assignment with rescue modifier consistent with single assignment with rescue modifier, applying rescue to the RHS: a, b = raise rescue [1, 2] # a, b = (raise rescue [1, 2]) Implements [Feature #8239] Fixes [Bug #8279]
* Revert "Revert "Fix dangling path name from fstring""Takashi Kokubun2019-08-041-2/+2
| | | | | | | | | | | | This reverts commit 326c00b6f89e1c86e6fe29ab60da593eb6883a88. We also confirmed that test_gced_eval_location fails without the changes: https://travis-ci.org/ruby/ruby/builds/567417818 https://rubyci.org/logs/rubyci.s3.amazonaws.com/arch/ruby-master/log/20190804T000003Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu1604/ruby-master/log/20190804T003005Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/icc-x64/ruby-master/log/20190804T000007Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable10x/ruby-master/log/20190804T001806Z.fail.html.gz https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian9/ruby-master/log/20190804T003005Z.fail.html.gz
* Revert "Fix dangling path name from fstring"Takashi Kokubun2019-08-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5931857281ce45c1c277aa86d1588119ab00a955 temporarily, leaving `TestEval#test_gced_eval_location` to see the impact for missing the changes. That's because too many CIs are failing for `require` behaviors: http://rubyci.s3.amazonaws.com/freebsd11zfs/ruby-master/log/20190803T063004Z.fail.html.gz http://rubyci.s3.amazonaws.com/unstable10x/ruby-master/log/20190803T051806Z.fail.html.gz http://rubyci.s3.amazonaws.com/unstable11x/ruby-master/log/20190803T052406Z.fail.html.gz http://rubyci.s3.amazonaws.com/unstable10s/ruby-master/log/20190803T111909Z.fail.html.gz http://rubyci.s3.amazonaws.com/unstable11s/ruby-master/log/20190803T062506Z.fail.html.gz http://rubyci.s3.amazonaws.com/solaris11s-sunc/ruby-master/log/20190803T052505Z.fail.html.gz https://app.wercker.com/ruby/ruby/runs/mjit-test1/5d4512c921ca08000857936a?step=5d451305c2809c0008a3da76 https://app.wercker.com/ruby/ruby/runs/mjit-test2/5d4512c921ca080008579371?step=5d4513000421020007ca122d http://ci.rvm.jp/results/trunk_gcc4@silicon-docker/2177591 http://ci.rvm.jp/results/trunk_gcc6@silicon-docker/2177596 http://ci.rvm.jp/results/trunk_clang_60@silicon-docker/2178802 http://ci.rvm.jp/results/trunk-theap-asserts@silicon-docker/2177555 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2178747 Mostly `TestRequire#test_race_exception` failures, but in ci.rvm.jp `require` inside rubyspec hangs very often.
* Fix dangling path name from fstringNobuyoshi Nakada2019-08-031-2/+2
| | | | | | | | * parse.y (yycompile): make sure in advance that the `__FILE__` object shares a fstring, to get rid of dangling path name. Fixed up 53e9908d8afc7f03109b0aafd1698ab35f512b05. [Bug #16041] * vm_eval.c (eval_make_iseq): ditto.
* Show the location of `eval` which uses `__FILE__`/`__LINE__`Nobuyoshi Nakada2019-08-031-2/+8
|
* parse.y: make a warning for __FILE__ in eval by defaultYusuke Endoh2019-08-021-1/+1
| | | | [Bug #4352]
* Use predefined idOrNobuyoshi Nakada2019-08-011-3/+2
|
* Ripper#validate_object: check if the object is hiddenNobuyoshi Nakada2019-07-191-5/+10
|
* Moved RIPPER_DEBUG methods to Ripper from KernelNobuyoshi Nakada2019-07-191-3/+3
|
* Fixed build error with RIPPER_DEBUGNobuyoshi Nakada2019-07-191-7/+3
|
* Use Qnull instead of 0 and QundefNobuyoshi Nakada2019-07-191-4/+1
|
* Adjust indent [ci skip]Nobuyoshi Nakada2019-07-171-6/+10
|
* parse.y (here_document): remove dead codeYusuke Endoh2019-07-151-4/+1
| | | | | str is always zero when evaluating the branch. Found by Coverity Scan.
* Add a /* fall through */ commentYusuke Endoh2019-07-151-0/+1
|
* Add a /* fall through */ commentYusuke Endoh2019-07-141-0/+1
|
* Revert "parse.y: Deprecate flip-flops"Nobuyoshi Nakada2019-07-111-4/+2
| | | | | | This reverts commit bae638ad5b782c44c80efe33834cb9039279af46. [Feature #5400]
* Removed duplicate assignmentNobuyoshi Nakada2019-07-101-1/+0
| | | | | This `last_state` is set to `lex.state` just before the `switch` statement, and `token_flush` nor `nextc` never change the state.
* Check indent of `end` against `else` if presentNobuyoshi Nakada2019-07-081-7/+16
|
* Message to pipe should end with a newlineNobuyoshi Nakada2019-07-071-1/+1
|