* encoding.c (rb_enc_associate_index): refill the terminator if it
becomes longer than before. [ruby-dev:47500] [Bug #8624]
* string.c (str_null_char, str_fill_term): get rid of out of bound
access.
* string.c (rb_str_fill_terminator): add a parameter for the length of
new terminator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* transcode.c (str_encode_associate): fill terminator after conversion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION flag.
Fix byte order and word order handling in code specialized for
wordsize % SIZEOF_BDIGITS == 0.
* internal.h (INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION): Defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(HOST_BIGENDIAN_P): New macro.
(ALIGNOF): New macro.
(CLEAR_LOWBITS): New macro.
(FILL_LOWBITS): New macro.
(swap_bdigit): New macro.
(bary_2comp): Returns an int.
* internal.h (swap16): Moved from pack.c
(swap32): Ditto.
(swap64): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(integer_unpack_num_bdigits): Extracted from
rb_integer_unpack_internal.
(bary_unpack_internal): Renamed from bary_unpack and support
INTEGER_PACK_2COMP.
(bary_unpack): New function to validate arguments and invoke
bary_unpack_internal.
(rb_integer_unpack_internal): Removed.
(rb_integer_unpack): Invoke bary_unpack_internal.
(rb_integer_unpack_2comp): Removed.
* internal.h (rb_integer_unpack_2comp): Removed.
* pack.c: Follow the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(rb_integer_unpack_internal): Extracted from rb_integer_unpack and
nlp_bits_ret argument added.
(integer_unpack_num_bdigits_small): nlp_bits_ret argument added to
return number of leading padding bits.
(integer_unpack_num_bdigits_generic): Ditto.
* internal.h (rb_integer_unpack_2comp): Declared.
* pack.c (pack_unpack): Use rb_integer_unpack_2comp and
rb_integer_unpack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_integer_unpack): Support INTEGER_PACK_FORCE_BIGNUM.
* random.c (int_pair_to_real_inclusive): Use
INTEGER_PACK_FORCE_BIGNUM to use rb_big_mul instead of rb_funcall.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Read the following test to know HOWTO.
This feature is a sample of RUBY_INTERNAL_EVENT.
* test/objspace/test_objspace.rb: add a test.
* ext/objspace/object_tracing.c: ditto.
* gc.c (rb_gc_count): add. THis function returns GC count.
* internal.h: add decl. of rb_gc_count(). Same as `GC.count'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_INTERNAL_EVENT_NEWOBJ: object created.
* RUBY_INTERNAL_EVENT_FREE: object freeed.
* RUBY_INTERNAL_EVENT_GC_START: GC started.
And rename `RUBY_EVENT_SWITCH' to `RUBY_INTERNAL_EVENT_SWITCH'.
Internal events can not invoke any Ruby program because the tracing
timing may be critical (under huge restriction).
These events can be hooked only by C-extensions.
We recommend to use rb_potponed_job_register() API to call Ruby
program safely.
This change is mostly written by Aman Gupta (tmm1).
https://bugs.ruby-lang.org/issues/8107#note-12
[Feature #8107]
* include/ruby/debug.h, vm_trace.c: added two new APIs.
* rb_tracearg_event_flag() returns rb_event_flag_t of this event.
* rb_tracearg_object() returns created/freeed object.
* ext/-test-/tracepoint/extconf.rb,
ext/-test-/tracepoint/tracepoint.c,
test/-ext-/tracepoint/test_tracepoint.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* class.c (rb_singleton_class_get): get the singleton class if exists,
or nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(SIGNED_INTEGER_MAX): Ditto.
(SIGNED_INTEGER_MIN): Ditto.
(UNSIGNED_INTEGER_MAX): Ditto.
(TIMET_MAX): Use SIGNED_INTEGER_MAX and UNSIGNED_INTEGER_MAX.
(TIMET_MIN): Use SIGNED_INTEGER_MIN.
* thread.c (TIMEVAL_SEC_MAX): Use SIGNED_INTEGER_MAX.
(TIMEVAL_SEC_MIN): Use SIGNED_INTEGER_MIN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (GCC_VERSION_SINCE): Macro moved from pack.c.
* pack.c: Include internal.h for GCC_VERSION_SINCE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (RUBY_REPLACE_TYPE): define SIGNEDNESS_OF_type same as
check_signedness of mkmf.rb.
* internal.h (TIMET_MAX, TIMET_MIN, TIMET_MAX_PLUS_ONE): use
SIGNEDNESS_OF_TIME_T.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
this fixes the build failure of mswin introduced at r39819.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (ruby_kill): helper function of kill().
* signal.c (rb_f_kill): use ruby_kill() instead of kill().
* signal.c (rb_f_kill): call rb_thread_execute_interrupts()
to ensure that make SignalException if sent a signal
to myself. [Bug #7951] [ruby-core:52864]
* vm_core.h (typedef struct rb_thread_struct): added
th->interrupt_cond.
* thread.c (rb_threadptr_interrupt_common): added to
initialization of th->interrupt_cond.
* thread.c (thread_create_core): ditto.
* test/ruby/test_signal.rb (TestSignal#test_hup_me): test for
the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (syserr_initialize): add optional function name.
* error.c (rb_sys_fail_path_in): rename and move from file.c, and pass
func_name to SystemCallError#initialize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_sys_fail_path_with_func): share same function, and path
may be nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to
get rid of conversion exception and integer overflow.
[ruby-dev:47131] [Bug #8010]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (RB_MAX_GROUPS): here.
* file.c (rb_group_member): use RB_MAX_GROUPS instead of
RUBY_GROUP_MAX. They are the same.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This makes Lazy#cycle no longer needed, so it was removed.
Make Enumerator#chunk and slice_before return lazy Enumerators.
[Bug #7715]
* internal.h: Remove ref to rb_enum_cycle_size; no longer needed
* enum.c: Make enum_cycle_size static.
* test/ruby/test_lazy_enumerator.rb: Test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c (rb_obj_clone): attach clone to its singleton class during
cloning singleton class so that singleton_method_added will be called
on it. based on the patch by shiba (satoshi shiba)[Bug #5283] in
[ruby-dev:44477]. [Bug #5283]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (compile_err_append, compile_warn_print, warn_print): use
rb_write_error_str() instead of writing to rb_stderr directly.
* io.c (rb_write_error_str): a stopgap measure not to unblock GVL.
warning from require seems to still have race condition errors.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_check_funcall_with_hook): rb_check_funcall with hook
which is called before calling method_missing or target method.
* marshal.c (w_object, r_object0): use rb_check_funcall_with_hook
instead of respond_to? and call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
sigsegv handler. enlarge value when x86 or x86_64 on Linux.
Linux has very small MINSIGSTKSZ size (2048 bytes) and
our sigsegv routine need 5KiB at least. [Bug #7141]
* internal.h: add declaration of rb_sigaltstack_size().
* vm_core.h: remove ALT_STACK_SIZE definition.
* signal.c (rb_register_sigaltstack): replace ALT_STACK_SIZE with
rb_sigaltstack_size();
* gc.c (Init_heap): ditto.
* vm.c (th_init): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (io_flush_buffer): don't hold mutex if already have.
Now recursive lock may occur when following scenario.
fptr_finalize -> finish_writeconv_sync -> finish_writeconv
-> io_fflush.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
entry with VM_METHOD_TYPE_REFINED holds only the original method
definition, so ci->me is set to a method entry allocated in the
stack, and it causes SEGV/ILL. In this commit, a method entry
with VM_METHOD_TYPE_REFINED holds the whole original method entry.
Furthermore, rb_thread_mark() is changed to mark cfp->klass to
avoid GC for iclasses created by copy_refinement_iclass().
* vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
the target module is a refinement. When a method entry with
VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
the same name is searched in refinements. If such a method is
found, the method is invoked. Otherwise, the original method in
the refined class (rb_method_definition_t::body.orig_me) is
invoked. This change is made to simplify the normal method lookup
and to improve the performance of normal method calls.
* vm_method.c (EXPR1, search_method, rb_method_entry),
vm_eval.c (rb_call0, rb_search_method_entry): do not use
refinements for method lookup.
* vm_insnhelper.c (vm_call_method): search methods in refinements if
ci->me is VM_METHOD_TYPE_REFINED. If the method is called by
super (i.e., ci->call == vm_call_super_method), skip the same
method entry as the current method to avoid infinite call of the
same method.
* class.c (include_modules_at): add a refined method entry for each
method defined in a module included in a refinement.
* class.c (rb_prepend_module): set an empty table to
RCLASS_M_TBL(klass) to add refined method entries, because
refinements should have priority over prepended modules.
* proc.c (mnew): use rb_method_entry_with_refinements() to get
a refined method.
* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
copy_refinement_iclass().
* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.
* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
the test because it should pass successfully.
* test/ruby/test_refinement.rb (test_redefine_refined_method): new
test for the case a refined method is redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
temporary async_interrupt_timing(Object => :defer)
* io.c (rb_f_p): use rb_uninterruptible.
* io.c (rb_f_p_internal): helper function for rb_f_p().
* io.c (struct rb_f_p_arg): new struct for rb_f_p_internal.
* test/ruby/test_thread.rb (test_async_interrupt_and_p): test for
the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
the target module is a refinement. When a method entry with
VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
the same name is searched in refinements. If such a method is
found, the method is invoked. Otherwise, the original method in
the refined class (rb_method_definition_t::body.orig_def) is
invoked. This change is made to simplify the normal method lookup
and to improve the performance of normal method calls.
* vm_method.c (EXPR1, search_method, rb_method_entry),
vm_eval.c (rb_call0, rb_search_method_entry): do not use
refinements for method lookup.
* vm_insnhelper.c (vm_call_method): search methods in refinements if
ci->me is VM_METHOD_TYPE_REFINED. If the method is called by
super (i.e., ci->call == vm_call_super_method), skip the same
method entry as the current method to avoid infinite call of the
same method.
* class.c (include_modules_at): add a refined method entry for each
method defined in a module included in a refinement.
* class.c (rb_prepend_module): set an empty table to
RCLASS_M_TBL(klass) to add refined method entries, because
refinements should have priority over prepended modules.
* proc.c (mnew): use rb_method_entry_with_refinements() to get
a refined method.
* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
the test because it should pass successfully.
* test/ruby/test_refinement.rb (test_redefine_refined_method): new
test for the case a refined method is redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_mutex_allow_trap): added.
* thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap.
* thread.c (mutex_sleep): remove trap check because it uses
rb_mutex_lock and rb_mutex_unlock internally.
* thread.c (rb_mutex_allow_trap): new helper function for the above.
* io.c (io_binwrite): mark fptr->write_lock as writable in trap.
* test/ruby/test_signal.rb (test_trap_puts): test for the above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_delete_same_obj): new function for WeakRef.
This deletes same objects as item argument in the array.
* internal.h (rb_ary_delete_same_obj): add a declaration.
* gc.c (wmap_final_func): remove WeakRef object reference from the
array. rb_ary_delete() is not usable because it uses rb_equal() to
compare object references.
* gc.c (wmap_finalize): remove recycled object references from weak
map hash properly. How to get object reference from object id was
wrong. st_delete() doesn't work properly if key and value arguments
are same. The key of obj2wmap is referenced object and the value of
obj2wmap is WeakRef array.
* gc.c (wmap_aset): obj2wmap should contain WeakRef array in the
definition.
* test/test_weakref.rb
(TestWeakRef#test_not_reference_different_object,
TestWeakRef#test_weakref_finalize): add tests for above.
[ruby-core:49044] [Bug #7304]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This method is similart to `caller_locations' method for
specific method.
And fix to accept `level' and `n' parameters for `Thread#backtrace'
and `Thread#backtrace_locations'.
`caller' (and `caller_locations') do not return `caller' method
frame.
However, `Thread#backtrace' (and `Thread#backtrace_locations')
return `Thread#backtrace' method frame itself
if `Thread.current.backtrace' was called.
* vm_backtrace.c: ditto.
* internal.h: ditto.
* test/ruby/test_backtrace.rb: add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.
* compile.c (rb_insns_name): allowing DTrace probes to access
instruction sequence name.
* Makefile.in: translate probes.d file to appropriate header file.
* common.mk: declare dependencies on the DTrace header.
* configure.in: add a test for existence of DTrace.
* eval.c (setup_exception): add a probe for when an exception is
raised.
* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
end.
* hash.c (empty_hash_alloc): Add a probe for hash allocation.
* insns.def: Add probes for function entry and return.
* internal.h: function declaration for compile.c change.
* load.c (rb_f_load): add probes for `load` entry and exit, require
entry and exit, and wrapping search_required for load path search.
* object.c (rb_obj_alloc): added a probe for general object creation.
* parse.y (yycompile0): added a probe around parse and compile phase.
* string.c (empty_str_alloc, str_new): DTrace probes for string
allocation.
* test/dtrace/*: tests for DTrace probes.
* vm.c (vm_invoke_proc): add probes for function return on exception
raise, hash create, and instruction sequence execution.
* vm_core.h: add probe declarations for function entry and exit.
* vm_dump.c: add probes header file.
* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
function entry and return.
* vm_exec.c: expose instruction number to instruction name function.
* vm_insnshelper.c: add function entry and exit probes for cfunc
methods.
* vm_insnhelper.h: vm usage information is always collected, so
uncomment the functions.
12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org>
* configure.in (isinf, isnan): isinf() and isnan() are macros on
DragonFly which cannot be found by AC_REPLACE_FUNCS(). This
workaround enforces the fact that they exist on DragonFly.
12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org>
* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
vm_insnhelper.c (vm_search_method): revert r37616 because it's too
slow. [ruby-dev:46477]
* test/ruby/test_refinement.rb (test_inline_method_cache): skip
the test until the bug is fixed efficiently.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_get_path_check_to_string): extract from
rb_get_path_check(). We change the spec not to call to_path of
String object.
* file.c (rb_get_path_check_convert): extract from rb_get_path_check().
* file.c (rb_get_path_check): follow the above change.
* file.c (rb_file_expand_path_fast): remove check_expand_path_args().
Instead we call it in load.c.
* file.c (rb_find_file_ext_safe): use rb_get_expanded_load_path() to
reduce expand cost.
* file.c (rb_find_file_safe): ditto.
* internal.h (rb_get_expanded_load_path): add a declaration.
* internal.h (rb_get_path_check_to_string, rb_get_path_check_convert):
add declarations.
* load.c (rb_construct_expanded_load_path): fix for compatibility.
Same checks in rb_get_path_check() are added. We don't replace
$LOAD_PATH and ensure that String object of $LOAD_PATH are frozen.
We don't freeze non String object and expand it every times. We add
arguments for expanding load path partially and checking if load path
have relative paths or non String objects.
* load.c (load_path_getcwd): get current working directory for checking
if it's changed when getting load path.
* load.c (rb_get_expanded_load_path): fix for rebuilding cache properly.
We check if current working directory is changed and rebuild expanded
load path cache. We expand paths which start with ~ (User HOME) and
non String objects every times for compatibility. We make this
accessible from other source files.
* load.c (rb_feature_provided): call rb_get_path() since we changed
rb_file_expand_path_fast() not to call it.
* load.c (Init_load): initialize vm->load_path_check_cache.
* vm.c (rb_vm_mark): mark vm->load_path_check_cache for GC.
* vm_core.h (rb_vm_struct): add vm->load_path_check_cache to store data
to check load path cache validity.
* test/ruby/test_require.rb (TestRequire): add tests for require
compatibility related to cached expanded load path.
[ruby-core:47970] [Bug #7158]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (mingw): add shlwapi to the list of dependency
libs for Windows.
* win32/Makefile.sub (EXTSOLIBS): ditto.
* internal.h: declare internal functions rb_w32_init_file,
rb_file_expand_path_internal and rb_file_expand_path_fast.
* file.c (Init_File): invoke Windows initialization rb_w32_init_file
* win32/file.c (rb_file_load_path_internal): new function.
Windows-specific implementation that replaces file_expand_path.
[Bug #6836][ruby-core:46996]
* win32/file.c (rb_w32_init_file): new function. Initialize codepage
cache for faster conversion encodings lookup.
* file.c (file_expand_path): rename to rb_file_expand_path_internal.
Conditionally exclude from Windows.
* file.c (rb_file_expand_path_fast): new function. delegates to
rb_file_expand_path_internal without performing a hit to the
filesystem.
* file.c (file_expand_path_1): use rb_file_expand_path_internal without
path expansion (used by require).
* file.c (rb_find_file_ext_safe): ditto.
* file.c (rb_find_file_safe): ditto.
* load.c (rb_get_expanded_load_path): use rb_file_expand_path_fast.
* load.c (rb_feature_provided): ditto.
* file.c (rb_file_expand_path): use rb_file_expand_path_internal with
path expansion.
* file.c (rb_file_absolute_path): ditto.
* test/ruby/test_file_exhaustive.rb: new tests to exercise
rb_file_expand_path_internal implementation and compliance with
existing behaviors.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(1) add rb_hook_list_t data structure which includes
hooks, events (flag) and `need_clean' flag.
If the last flag is true, then clean the hooks list.
In other words, deleted hooks are contained by `hooks'.
Cleanup process should run before traversing the list.
(2) Change check mechanism
See EXEC_EVENT_HOOK() in vm_core.h.
(3) Add `raw' hooks APIs
Normal hooks are guarded from exception by rb_protect().
However, this protection is overhead for too simple
functions which never cause exceptions. `raw' hooks
are executed without protection and faster.
Now, we only provide registration APIs. All `raw'
hooks are kicked under protection (same as normal hooks).
* include/ruby/ruby.h: remove internal data definition and
macros.
* internal.h (ruby_suppress_tracing), vm_trace.c: rename
ruby_suppress_tracing() to rb_suppress_tracing()
and remove unused function parameter.
* parse.y: fix to use renamed rb_suppress_tracing().
* thread.c (thread_create_core): no need to set RUBY_VM_VM.
* vm.c (mark_event_hooks): move definition to vm_trace.c.
* vm.c (ruby_vm_event_flags): add a global variable.
This global variable represents all of Threads and VM's
event masks (T1#events | T2#events | ... | VM#events).
You can check the possibility kick trace func or not
with ruby_vm_event_flags.
ruby_vm_event_flags is maintained by vm_trace.c.
* cont.c (fiber_switch, rb_cont_call): restore tracing status.
[Feature #4347]
* test/ruby/test_continuation.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* class.c (rb_special_singleton_class_of): utility function.
* vm_eval.c (eval_under): special deal for class variable scope with
instance_eval.
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow method
definition in instance_eval of special constants. [ruby-core:28324]
[Bug #2788]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
receiver for super called in instance_eval. If such a receiver is
not found, raise NoMethodError. [ruby-dev:39772] [Bug #2402]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: move mark function declarations that should be private.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (is_popen_fork): check if fork and raise NotImplementedError if
unavailable.
* io.c (rb_io_s_popen): allow environment variables hash and exec
options as flat parameters, not in an array arguments.
[Feature#6651] [EXPERIMENTAL]
* process.c (rb_execarg_extract_options): extract exec options, but no
exceptions on non-exec options and returns them as a Hash.
* process.c (rb_execarg_setenv): set environment variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fields.
* process.c (EXEC_OPTION_NEW_PGROUP): removed.
(proc_spawn_cmd): take a struct rb_execarg argument.
use the new fields.
(rb_execarg_addopt): use the new fields.
(rb_spawn_process): follow the proc_spawn_cmd change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fd_dup2_child fields.
* process.c (EXEC_OPTION_DUP2): removed.
(EXEC_OPTION_CLOSE): removed.
(EXEC_OPTION_OPEN): removed.
(EXEC_OPTION_DUP2_CHILD): removed.
(mark_exec_arg): mark the new fields.
(check_exec_redirect1): change condition for default option.
(check_exec_redirect): take a struct rb_execarg argument.
use the new fields.
(rb_execarg_addopt): follow the check_exec_redirect change.
(check_exec_fds): use the new fields.
(save_redirect_fd): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_ENV): removed.
(mark_exec_arg): mark env_modification field.
(rb_exec_fillarg): update the new field, instead of options array.
(rb_execarg_fixup): use the new field.
(save_env): ditto.
(rb_execarg_run_options): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_RLIMIT): removed.
(mark_exec_arg): mark rlimit_limits field.
(rb_execarg_addopt): update the new fields, instead of options array.
(run_exec_rlimit): use the new field.
(rb_execarg_run_options): clear sarg using MEMZERO. use the new
field.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_CHDIR): removed.
(mark_exec_arg): mark chdir_dir field.
(rb_execarg_addopt): update the new fields, instead of options array.
(rb_execarg_run_options): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
close_others_maxhint fields.
* process.c (EXEC_OPTION_CLOSE_OTHERS): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(check_exec_fds): take eargp as an argument. update the
close_others_maxhint field.
(rb_execarg_fixup): follow the argument change of check_exec_fds.
(rb_execarg_run_options): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
unsetenv_others_do fields.
* process.c (EXEC_OPTION_UNSETENV_OTHERS): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(rb_execarg_fixup): use the new fields.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (EXEC_OPTION_PGROUP): removed.
(rb_execarg_addopt): update the new fields, instead of options array.
(run_exec_pgroup): take a struct rb_execarg argument. refer the new
fields.
(rb_execarg_run_options): follow run_exec_pgroup change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
th->base_block is information for (a) parsing, (b) compiling
and (c) setting up the frame to execute the program passed by
`eval' method. For example, (1) parser need to know up-level
variables to detect it is variable or method without paren.
Befor (a), (b) and (c), VM set th->base_block by passed bindng
(or previous frame information). After execute (a), (b) and (c),
VM should clear th->base_block. However, if (a), (b) or (c)
raises an exception, then th->base_block is not cleared.
Problem is that the uncleared value th->balo_block is used for
irrelevant iseq compilation. It causes SEGV or critical error.
I tried to solve this problem: to clear them before exception,
but finally I found out that it is difficult to do it (Ruby
program can be run in many places).
Because of this background, I set th->base_block before
compiling iseq and restore it after compiling.
Basically, th->base_block is dirty hack (similar to global
variable) and this patch is also dirty.
* bootstraptest/test_eval.rb: add a test for above.
* internal.h: remove unused decl.
* iseq.c (rb_iseq_compile_with_option): add base_block parameter.
set th->base_block before compation and restore it after
compilation.
* ruby.c (require_libraries): pass 0 as base_block instead of
setting th->base_block
* tool/compile_prelude.rb (prelude_eval): apply above changes.
* vm.c, vm_eval.c: ditto.
* vm_core.h: add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ext/pty/extconf.rb: modify $INCFLAGS to include internal.h
* ext/pty/pty.c: include internal.h.
(chfunc): don't call rb_thread_atfork_before_exec. use
rb_exec_async_signal_safe instead of rb_f_exec.
(establishShell): set up earg. use rb_fork_async_signal_safe
instead of rb_fork_err.
* internal.h (rb_exec_async_signal_safe): declared.
(rb_fork_async_signal_safe): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_symname_p): new function that checks if the string
is valid as a symbol name. split from sym_inspect().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is not async-signal-safe and proc_exec_v is called in a child
process.
command_abspath field of rb_exec_arg.
(rb_exec_fillarg): call dln_find_exe_r and set command_abspath.
(rb_exec_err): Give the absolute path of the invoking command for
proc_exec_v, instead of the command name.
* internal.h: add command_abspath field for rb_exec_arg.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_exec_arg_init): don't return a value.
(rb_exec_arg_prepare): ditto.
(rb_spawn_process): don't take the prog argument. extract the
information from earg.
(rb_spawn_internal): follow rb_spawn_process change.
(rb_f_spawn): ditto.
* io.c (pipe_open): don't take the prog argument. extract the
information from eargp.
(pipe_open_v): follow pipe_open change.
(pipe_open_s): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
beginning in argv_str for try_with_sh.
* internal.h (ARGVSTR2ARGC): adjust for the above change.
(ARGVSTR2ARGV): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(ARGVSTR2ARGV): defined.
* process.c (proc_exec_v): use ARGVSTR2ARGV.
(rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.
* io.c (pipe_open): use ARGVSTR2ARGV.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is no longer included from vm.c). I hope this separation reduce
compile time of vm.c.
* internal.h: ditto.
* vm.c, vm_core.h, vm_dump.c, vm_eval.c: ditto.
* vm_eval.c: some functions (callee, etc) moved to vm_backtrace.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
nobu pointed out that rb_method_basic_definition_p() is enough
for last commit.
* error.c, eval_error.c: change for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Backtrace information contains an array consists of location
information for each frames by string.
RubyVM::Backtrace object is lightweight backtrace information,
which contains complete information to generate traditional style
backtrace (an array of strings) with faster generation.
If someone accesses to backtrace information via
Exception#backtrace, then convert a RubyVM::Backtrace object to
traditonal style backtrace.
This change causes incompatibility on marshal dumpped binary
of Exception. If you have any trouble on it, please tell us
before Ruby 2.0 release.
Note that RubyVM::Backtrace object should not expose Ruby level.
* error.c, eval.c, vm_eval.c: ditto.
* internal.h: ditto.
* eval_error.c: fix to skip "set_backtrace" method invocation in
creating an exception object if it call a normal set_backtrace
method (defined by core).
* test/ruby/test_settracefunc.rb: fix for above change.
* vm_method.c (rb_method_defined_by): added. This function
checks that the given object responds with the given method
by the given cfunc.
* benchmark/bm_vm2_raise1.rb, benchmark/bm_vm2_raise2.rb:
add to measure exception creation speed. raise1 create
exception objects from shallow stack frame. raise2 create
exception objects from deep stack frame.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_load_fail): use path as a string, not char*.
* internal.h: (rb_load_fail): moved from ruby/intern.h.
* ruby.c (load_file_internal): fname cannot be NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Bug #6048]. Isolate hash computation for proc
* internal.h: Declaration for above
* vm_method.c (rb_method_definition_hash): Computation for
hash part of a method definition
* method.h: Declaration for above
* test/ruby/test_method.rb: Test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
restore rb_thread_t::local_storage.
* cont.c (rb_obj_is_fiber): add a new function to tell finalizer to
prevent fibers from destroy.
* gc.c (rb_objspace_call_finalizer): don't sweep fibers at finalizing
objspace.
* internal.h (rb_fiber_reset_root_local_storage, rb_obj_is_fiber):
add prototypes.
* vm.c (ruby_vm_destruct): reset main thread's local_storage before
free main thread. rb_thread_t::local_storage is replaced by fiber's
local storage when forked from fiber, and it should be already freed
when the fiber was destroyed.
* test/ruby/test_fiber.rb (test_fork_from_fiber): add test for fork
from fiber.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
but should return pointer suitable for ruby_xfree;
main vm and main thread.
patched by Sokolov Yura. https://github.com/ruby/ruby/pull/79
* internal.h: ditto.
* vm.c (Init_BareVM): use ruby_mimmalloc.
* ext/dl/cfunc.c: #include <ruby/util.h>.
* ext/syslog/syslog.c: use xfree because it is allocated by
ruby_strdup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
in RBASIC()->flags. [ruby-dev:45002] [Bug #5768]
* thread.c (rb_barrier_wait): increment and decrement around
rb_mutex_lock, and use rb_barrier_waiting().
* thread.c (rb_barrier_release): use rb_barrier_waiting().
* thread.c (rb_barrier_destroy): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
share same loading barrier, so it must be kept alive while those
are waiting on it. [ruby-core:41618] [Bug #5754]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
the encoding of the format. On Windows (at least Japanese Windows),
Time#strftime("%Z") includes non ASCII in locale encoding (CP932).
So convert locale to default internal. [ruby-core:39092] [Bug #5226]
* strftime.c (rb_strftime): ditto.
* strftime.c (rb_strftime_timespec): ditto.
* internal.h (rb_strftime_timespec): follow above.
* time.c (rb_strftime_alloc): ditto.
* time.c (strftimev): ditto.
* time.c (time_strftime): ditto.
* time.c (time_to_s): the resulted string of Time#to_s is always
ascii only, so this should be US-ASCII.
* time.c (time_asctime): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (method_missing): set the length of argv array, to mark
arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
avoid inadvertent symbol creation in reflection methods. based
on a patch by Jeremy Evans at [ruby-core:38367]. [Feature #5072]
* vm_method.c (rb_mod_method_defined)
(rb_mod_{public,private,protected}_method_defined)
(obj_respond_to): ditto.
* parse.y (rb_check_id): new function returns already interned ID
or 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
make them visible as experimental C APIs. fixes Feature #4328.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fix rdoc.
* ext/objspace/objspace.c (ObjectSpace.count_tdata_objects):
Change key type if the klass of a object is zero (internal object).
Read rdoc for details.
* internal.h: export rb_objspace_data_type_name().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
In timer thread, signal handler shoul use it.
The patch is contributed by Eric Wong <normalperson@yhbt.net>.
Refs: [ruby-core:37644] and [ruby-core:37647]
* thread_pthread.c: use rb_async_bug_errno().
And replace all fprintf() to write().
* internal.h (rb_async_bug_errno): add decl. of above func.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from intern.h to internal.h. It's still experimental API and
need more discussion. [ruby-dev:43698]
* include/ruby/intern.h: ditto.
* ext/socket/rubysocket.h: include internal.h.
* ext/socket/depend: add internal.h dependency.
* ext/socket/extconf.rb: add $INCFLAGS to topdir.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
from intern.h to internal.h. It's still experimental API and
need more discussion.
* include/ruby/intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
based on the patch by Eric Wong. [ruby-core:36156]
* vm_core.h (rb_thread_call_with_gvl): don't declare here.
* thread.c: include internal.h.
(rb_thread_execute_interrupts): new function.
* internal.h (rb_thread_execute_interrupts): declared.
(rb_thread_call_with_gvl): declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
type check to get rid of a double free when main Thread has singleton
class. [ruby-core:36741] [Bug #4828]
* thread.c (rb_obj_is_mutex): add a new utility function.
* vm.c (rb_obj_is_thread): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e