rb_wb_protected_newobj_of(), pass the WB_PROTECTED
information explicitly.
* internal.h: use introduced functions by NEWOBJ_OF().
`flag' is immediate value, so that C compilers can
solve them at compile time.
* include/ruby/ruby.h: add a commnent about that.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at
object creation.
* vm.c (rb_source_location, rb_source_loc): retrieve source path
and line number at once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_name_err_new): new function to create NameError
exception instance. [Feature #10881]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Even if S_ISREG() is true, the file may be file on FUSE filesystem
or something. We can't assume O_NONBLOCK is safe.
Moreover, we should wait if the path is point to FIFO. That's
FIFO semantics. GVL should be transparent from ruby script.
Thus, just reopen without O_NONBLOCK for filling the requirements.
[Bug #11060][Bug #11559]
* ruby.c (loadopen_func): new for the above.
* file.c (ruby_is_fd_loadable): new. for checks loadable file type
of not.
* file.c (rb_file_load_ok): use ruby_is_fd_loadble()
* internal.h: add ruby_is_fd_loadble()
* common.mk: now, ruby.o depend on thread.h.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_success): new test.
This test successful case that loading from FIFO.
* test/ruby/test_require.rb
(TestRequire#test_loading_fifo_threading_raise): rename from
test_loading_fifo_threading. You souldn't rescue an exception
if you test raise or not.
Moreover, this case should be caught IOError because load(FIFO)
should be blocked until given any input.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_file_expand_path_internal): concatenate converted
string to the result instead of making converted string and
append it.
* string.c (rb_str_cat_conv_enc_opts): from rb_str_conv_enc_opts,
separate function to concatenate with transcoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_args.c (args_setup_block_parameter): wrap a symbol in ifunc
by a proc as a block parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c (proc_to_s): include the original symbol name in string
form.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encindex.h: separate encoding index constants from internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_s_popen): do not wait the child process during being
killed. [ruby-core:70671] [Bug #11510]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_readlink): move the declaration.
* ruby.c (dladdr_path): rb_readlink now requires the result
encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Feature #11420]
This table only manage ID->VALUE table to reduce overhead of st.
Some functions prefixed rb_id_table_* are provided.
* id_table.c: implement rb_id_table_*.
There are several algorithms to implement it.
Now, there are roughly 4 types:
* st
* array
* hash (implemented by Yura Sokolov)
* mix of array and hash
The macro ID_TABLE_IMPL can choose implementation.
You can see detailes about them at the head of id_table.c.
At the default, I choose 34 (mix of list and hash).
This is not final decision.
Please report your suitable parameters or
your data structure.
* symbol.c: introduce rb_id_serial_t and rb_id_to_serial()
to represent ID by serial number.
* internal.h: use id_table for method tables.
* class.c, gc.c, marshal.c, vm.c, vm_method.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (LIKELY, UNLIKELY): make a boolean to enforce 1 or 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (struct RClass): moved from ruby/ruby.h to hide the
internals.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h: add raw FL macros, which assume always the
argument object is not a special constant.
* internal.h (STR_EMBED_P, STR_SHARED_P): valid only for T_STRING.
* string.c: deal with taint flags directly across String instances.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
All contents of previous rb_iseq_t is in rb_iseq_t::body.
Remove rb_iseq_t::self because rb_iseq_t is an object.
RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
So RubyVM::ISeq.of(something) method returns different wrapper
objects but they point the same T_IMEMO/iseq object.
This patch is big, but most of difference is replacement of
iseq->xxx to iseq->body->xxx.
(previous) rb_iseq_t::compile_data is also located to
rb_iseq_t::compile_data.
It was moved from rb_iseq_body::compile_data.
Now rb_iseq_t has empty two pointers.
I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
[Bug #10037][ruby-core:63721].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
with one of the timer thread FDs, the internal FD is diverted.
[Bug #11336] [ruby-core:69886] [Bug #11350] [ruby-core:69961]
* process.c (dup2_with_divert): new function for the above purpose.
* thread_pthread.c (rb_divert_reserved_fd): new function for
diverting reserved FD. If the given FD is the same as one of the
reserved FDs, the reserved FD number is internally changed.
It returns -1 when error. Otherwise, returns 0. It also returns
0 if there is no need to change reserved FD number.
* thread_win32.c (rb_divert_reserved_fd): always returns 0 because
of no reserved FDs.
* internal.h (rb_divert_reserved_fd): prototype declaration.
It is Ruby internal use only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
clone iseq any more.
* class.c (clone_method): share iseq between cloned methods. All of
method dependent information are able to refer from method entry.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h, iseq.c (rb_iseq_klass): remove it because
rb_iseq_t::klass is removed.
* vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but
check callable method entry on a frame.
This fix simplify the logic to search super class.
* test/ruby/test_method.rb: support super() from Proc.
Now, [Bug #4881] and [Bug #3136] was solved.
* proc.c (rb_mod_define_method): catch up this change.
* vm.c (vm_define_method): ditto.
* vm_backtrace.c (rb_profile_frames): now, each `frame' objects
are rb_callable_method_entry_t data or iseq VALUEs.
This fix introduce minor compatibility issue that
rb_profile_frame_label() always returns
rb_profile_frame_base_label().
* test/-ext-/debug/test_profile_frames.rb: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_control_frame_t::klass.
[Bug #11278], [Bug #11279]
rb_method_entry_t data belong to modules/classes.
rb_method_entry_t::owner points defined module or class.
module M
def foo; end
end
In this case, owner is M.
rb_callable_method_entry_t data belong to only classes.
For modules, MRI creates corresponding T_ICLASS internally.
rb_callable_method_entry_t can also belong to T_ICLASS.
rb_callable_method_entry_t::defined_class points T_CLASS or
T_ICLASS.
rb_method_entry_t data for classes (not for modules) are also
rb_callable_method_entry_t data because it is completely same data.
In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
For example, there are classes C and D, and incldues M,
class C; include M; end
class D; include M; end
then, two T_ICLASS objects for C's super class and D's super class
will be created.
When C.new.foo is called, then M#foo is searcheed and
rb_callable_method_t data is used by VM to invoke M#foo.
rb_method_entry_t data is only one for M#foo.
However, rb_callable_method_entry_t data are two (and can be more).
It is proportional to the number of including (and prepending)
classes (the number of T_ICLASS which point to the module).
Now, created rb_callable_method_entry_t are collected when
the original module M was modified. We can think it is a cache.
We need to select what kind of method entry data is needed.
To operate definition, then you need to use rb_method_entry_t.
You can access them by the following functions.
* rb_method_entry(VALUE klass, ID id);
* rb_method_entry_with_refinements(VALUE klass, ID id);
* rb_method_entry_without_refinements(VALUE klass, ID id);
* rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
To invoke methods, then you need to use rb_callable_method_entry_t
which you can get by the following APIs corresponding to the
above listed functions.
* rb_callable_method_entry(VALUE klass, ID id);
* rb_callable_method_entry_with_refinements(VALUE klass, ID id);
* rb_callable_method_entry_without_refinements(VALUE klass, ID id);
* rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
returns rb_callable_method_entry_t.
You can check a super class of current method by
rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
rb_callable_method_entry_t data.
We need to consider abotu this field again because it is only
active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
rb_callable_method_t has all information.
* vm_core.h: remove several fields.
* rb_control_frame_t::klass.
* rb_block_t::klass.
And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_fstring_cstr): new function to make a fstring from
a string literal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_fstring_lit): new macro to make a fstring from a
string literal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (roomof): extract from type_roomof, and move from
bignum.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_method_entry_t::flags to make one word spare space.
Add some macros to access these flags.
* vm_method.c: use these macros.
* internal.h: define IMEMO_FL_USHIFT and IMEMO_FL_USER[0-4]
for T_IMEMO local flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_intern.h: move definition of rb_scope_visibility_t
to method.h.
* method.h: change rb_cref_t::scope_visi from VALUE to
rb_scope_visibility_t.
[Bug #11219]
* vm.c (vm_cref_new): accept rb_method_visibility_t directly.
* vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0,
but METHOD_VISI_UNDEF.
* vm_method.c (rb_scope_visibility_set): don't need to use cast.
* vm_method.c (rb_scope_module_func_set): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Special constants are all frozen since [Feature #8923] and cannot
support ivars. Remove some unused code we had for supporting them.
* variable.c (special_generic_ivar): remove flag
(givar_i, rb_mark_generic_ivar_tbl): remove functions
(rb_free_generic_ivar, rb_ivar_lookup, rb_ivar_delete,
generic_ivar_set, rb_ivar_set, rb_ivar_defined,
rb_copy_generic_ivar, rb_ivar_foreach, rb_ivar_count,
rb_obj_remove_instance_variable):
adjust for lack of ivar support in special constants
* test/ruby/test_variable.rb: test ivars for special consts
* internal.h: remove rb_mark_generic_ivar_tbl decl
* gc.c (gc_mark_roots): remove rb_mark_generic_ivar_tbl call
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`flag' contains several categories of attributes and it makes us
confusion (at least, I had confused).
* rb_method_visibility_t (flags::visi)
* NOEX_UNDEF -> METHOD_VISI_UNDEF = 0
* NOEX_PUBLIC -> METHOD_VISI_PUBLIC = 1
* NOEX_PRIVATE -> METHOD_VISI_PRIVATE = 2
* NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
* NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
* NOEX_BASIC -> basic (flags::basic, 1 bit)
* NOEX_MODFUNC -> rb_scope_visibility_t in CREF
* NOEX_SUPER -> MISSING_SUPER (enum missing_reason)
* NOEX_VCALL -> MISSING_VCALL (enum missing_reason)
* NOEX_RESPONDS -> BOUND_RESPONDS (macro)
Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
Background:
I did not know what "NOEX" stands for.
I asked Matz (who made this name) and his answer was "Nothing".
"At first, it meant NO EXport (private), but the original
meaning was gone."
This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
scope visibility.
It has 3 method visibilities (public/private/protected)
and `module_function`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Motivation and new data structure are described in [Bug #11203].
This patch also solve the following issues.
* [Bug #11200] Memory leak of method entries
* [Bug #11046] __callee__ returns incorrect method name in orphan
proc
* test/ruby/test_method.rb: add a test for [Bug #11046].
* vm_core.h: remvoe rb_control_frame_t::me. me is located at value
stack.
* vm_core.h, gc.c, vm_method.c: remove unlinked_method... codes
because method entries are simple VALUEs.
* method.h: Now, all method entries has own independent method
definititons. Strictly speaking, this change is not essential,
but for future changes.
* rb_method_entry_t::flag is move to rb_method_definition_t::flag.
* rb_method_definition_t::alias_count is now
rb_method_definition_t::alias_count_ptr, a pointer to the counter.
* vm_core.h, vm_insnhelper.c (rb_vm_frame_method_entry) added to
search the current method entry from value stack.
* vm_insnhelper.c (VM_CHECK_MODE): introduced to enable/disable
assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to internal class data structure.
* internal.h: ditto.
* hash.c (has_extra_methods): use added function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This recovers and improves performance of Marshal.dump/load on
Time objects compared to when we implemented generic ivars
entirely using st_table.
This also recovers some performance on other generic ivar objects,
but does not bring bring Marshal.dump/load performance up to
previous speeds.
benchmark results:
minimum results in each 10 measurements.
Execution time (sec)
name trunk geniv after
marshal_dump_flo 0.343 0.334 0.335
marshal_dump_load_geniv 0.487 0.527 0.495
marshal_dump_load_time 1.262 1.401 1.257
Speedup ratio: compare with the result of `trunk' (greater is better)
name geniv after
marshal_dump_flo 1.026 1.023
marshal_dump_load_geniv 0.925 0.985
marshal_dump_load_time 0.901 1.004
* include/ruby/intern.h (rb_generic_ivar_table): deprecate
* internal.h (rb_attr_delete): declare
* marshal.c (has_ivars): use rb_ivar_foreach
(w_ivar): ditto
(w_object): update for new interface
* time.c (time_mload): use rb_attr_delete
* variable.c (generic_ivar_delete): implement
(rb_ivar_delete): ditto
(rb_attr_delete): ditto
[ruby-core:69323] [Feature #11170]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (iseq_compile_each): out of range NTH_REF is always
nil.
* parse.y (parse_numvar): check overflow of NTH_REF and range.
[ruby-core:69393] [Bug #11192]
* util.c (ruby_scan_digits): make public and add length parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c: "spawn" opens files in the parent process.
(check_exec_redirect): Add an placeholder for fd in parameters
for fd_open.
(check_exec_fds_1): Delete fd_open condition.
(check_exec_fds): Don't call check_exec_fds_1 with fd_open.
(rb_execarg_parent_start): Open files specified as "spawn" options
and add "dup2" options.
(rb_execarg_parent_end): New function to close opened fds.
(run_exec_open): Removed.
(rb_execarg_run_options): Don't call run_exec_open.
(rb_spawn_internal): Call rb_execarg_parent_end.
* io.c (pipe_open): Call rb_execarg_parent_end.
* ext/pty/pty.c (establishShell): Call rb_execarg_parent_end.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (IFUNC_NEW): add argument for ID.
* vm_eval.c (rb_iterate): create ifunnc only when it is used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_any_hash): use same hash values with Float#hash so
that -0.0 and +0.0 will be identical.
[ruby-core:68541] [Bug #10979]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and related functions from node.h to internal.h.
* variable.c: remove unused include pragma.
* common.mk: remove unused dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
memo->v1 and memo->v2 is WB protected values.
So use MEMO_V1/V2_SET() macros to set these values.
memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
value), so use gc_mark_maybe() in gc.c to mark it.
Rename NEW_MEMO() to MEMO_NEW().
Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
(I'm not sure it is working correctly...)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e