`(ID)1` was assigned to NODE_ARGS#rest_arg for `{|x,| }`.
This change removes the magic number by introducing an explicit macro
variable for it: NODE_SPECIAL_EXCESSED_COMMA.
* internal.h (UNALIGNED_MEMBER_ACCESS, UNALIGNED_MEMBER_PTR):
moved from eval_intern.h.
* compile.c iseq.c, vm.c: use UNALIGNED_MEMBER_PTR for `entries`
in `struct iseq_catch_table`.
* vm_eval.c, vm_insnhelper.c: use UNALIGNED_MEMBER_PTR for `body`
in `rb_method_definition_t`.
Because hard to specify commits related to r67479 only.
So please commit again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ISeq pins references in the mark array during compile, so it manually
marks references in the mark_ary. This was causing write barrier
misses, so we need to add a write barrier when pushing on the mark
array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: add definemethod and definesmethod (singleton method)
instructions. Old YARV contains these instructions, but it is moved
to methods of FrozenCore class because remove number of instructions
can improve performance for some techniques (static stack caching
and so on). However, we don't employ these technique and it is hard
to optimize/analysis definition sequence. So I decide to introduce
them (and remove definition methods). `putiseq` insn is also removed.
* vm_method.c (rb_scope_visibility_get): renamed to
`vm_scope_visibility_get()` and make it accept `ec`.
Same for `vm_scope_module_func_check()`.
These fixes are result of refactoring `vm_define_method`.
* vm_insnhelper.c (rb_vm_get_cref): renamed to `vm_get_cref`
because of consistency with other functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NODE_HASH#nd_brace is a flag that is 1 for `foo({ k: 1 })` and 0 for
`foo(k: 1)`.
nd_alen had been abused for the flag (and the implementation is
completely the same), but an explicit name is better to read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
For unknown reason, setup_args processed the arguments from the last to
the first. This is not only difficult to read, but also inefficient in
some cases. For example, the arguments of `foo(*a1, *a2, *a3)` was
compiled like `a1.dup << (a2.dup << a3)`. The second dup (`a2.dup`) is
not needed.
This change refactors the function so that it processes the arguments
forward: `foo(*a1, *a2, *a3)` is compiled as `a1.dup << a2 << a3`, and
in my opinion, the source code is now much more readable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
compile_array function had three usages: array literal, hash literal,
and method arguments. I think the third is completely different than the
first and second. For example, method arguments and popped are
meaningless; keywords_ptr and flag parameter for array/hash literal is
also unused.
This change refactors them: a function "compile_args" is created for the
third, and removes no longer used parameters of "compile_array".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: refacetoring:
* initialize `branches` with Qfalse intead of 0.
* make compile_call* functions from `iseq_compile_each0()`
to make modifying them easy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (check_yield_place): this function check the yield location.
* show a warning if yield in `class` syntax. [Feature #15575]
* do strict check for toplevel `yield`. Without this patch,
`1.times{ yield }` in toplevel is valid-syntax (raise LocalJumpError
at runtime) although toplevel simple `yield` is not valid syntax.
This patch make them syntax error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When copying `leave` insn, TRACE also should be copied if it is
present, but this optimization is trivial and not worth the
complexity. [ruby-core:91366] [Bug #15578]
4cae5353c05afd479de6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Not only TRACE_ELEMENT but also INSN_ELEMENT may have events.
The old pc2branchindex was created using only events of TRACE_ELEMENTs.
This change uses events of INSN_ELEMENTs too for pc2branchindex table.
[Bug #15476]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e