for simplicity and consistency.
Now SUPPORT_JOKE needs to be prefixed with OPT_ to make the config
visible in `RubyVM::VmOptsH`, and the inconsistency was introduced.
As it has never been available for override in configure (no #ifndef
guard), it should be fine to rename the config.
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.
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct. This commit adds function prototypes
for rb_hash_foreach / st_foreach_safe. Also fixes some prototype
mismatches.
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct. This commit deletes ANYARGS from
struct vm_ifunc, but in doing so we also have to decouple the usage
of this struct in compile.c, which (I think) is an abuse of ANYARGS.
Some tooling depends on the current bytecode, and adding an operand
changes the bytecode. While tooling can be updated for new bytecode,
this support doesn't warrant such a change.
This was an intentional bug added in 1.9.
The approach taken here is to add a second operand to the
getconstant instruction for whether nil should be allowed and
treated as current scope.
Fixes [Bug #11718]
Binary dumping the iseq for `case foo in []; end` used to crash as
there was no handling for these exception classes.
Pattern matching generates these classes as operands to `putobject`.
[Bug #16088]
Closes: https://github.com/ruby/ruby/pull/2325
`(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
Previously, these hash literals were not frozen, and thus could be
modified by ObjectSpace, resulting in undesired behavior. Example:
```ruby
require 'objspace'
def a(b={0=>1,1=>4,2=>17})
b
end
p a
ObjectSpace.each_object(Hash) do |a|
a[3] = 8 if a.class == Hash && a[0] == 1 && a[1] == 4 && a[2] == 17
end
p a
```
It may be desirable to hide such hashes from ObjectSpace, since
they are internal, but I'm not sure how to do that.
From: Jeremy Evans <code@jeremyevans.net>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`code_index` doesn't need to be incremented since the mark array has
been removed. Thanks for the patch ko1!
[ruby-core:90456] [Bug #15406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (ibf_load_iseq_each): iseq_mark assumes that if
param.flags.has_kw is TRUE, then param.keyword is not NULL.
To confirm this assumption, make it FALSE before param.keyword
is initialized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: we need to restore `catch_except_p` flag at
`load_from_binary`. [Bug #15395]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (iseq_insert_nop_between_end_and_cont): insert nop so
that the end of rescue and continuing points are not same, to
get rid of infinite loop. [Bug #15385]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e