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
* marshal.c (w_object, marshal_dump, r_object0, marshal_load): use
RB_GC_GUARD() (directly or indirectly) instead of volatile.
* variable.c (rb_path_to_class): prevent the arguemnt from GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
path without caching the computed path. Some classes are frozen, and
will raise an exception without this.
* probes.d (cmethod-entry, cmethod-return): separate cmethods from
regular methods to match set trace func.
* probes_helper.h: refactor macros. Fix probes to avoid calling
#inspect when profiling.
* insns.def: update for use with new macros.
* vm_eval.c: ditto
* vm_insnhelper.c: ditto
* test/dtrace/test_singleton_function.rb: fix test for new output.
* test/dtrace/test_cmethod.rb: test the cmethod probes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c (classname): tell if found name is permanent. search
tmp_classpath only if class id is set. [ruby-core:42865][Bug #6078]
* variable.c (rb_class_path): duplicate found temporary path.
* variable.c (rb_set_class_path_string, rb_set_class_path): set class
id to find classpath.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c (find_class_path): no retry when preferred is given.
* variable.c (classname): if classid is set try it to find full
qualified class path, and then try arbitrary class path. try
tmp_classpath at last even if enclosing namespace is anonymous.
fix r36574. [ruby-core:42865][Bug #6078]
* variable.c (rb_set_class_path_string, rb_set_class_path): set
tmp_classpath instead of classpath if the name is not permanent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c: store anonymous class path in tmp_classpath but not in
classpath. [ruby-core:42865][Bug #6078]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
except when the optional argument is set to false.
[ruby-dev:44034] [Bug #4971]
* variable.c (rb_mod_constants): fix typo in documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
visibility is modified. [ruby-dev:44929]
* test/ruby/test_module.rb (test_private_constants_clear_inlinecache):
add test for it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is passwd to Module#private_constant. [ruby-list:48558]
* vm_method.c (set_method_visibility): ditto for
Module#private_class_method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
changed the visibility of only the first argument. Now it changes
all of them. [ruby-list:48558]
* test/ruby/test_module.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
constant of the path is not defined but defined on toplevel.
[ruby-core:41410] [Bug #5691]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_str_new2()) before finishing autoload_data_i construction. It
caused SEGV at rb_gc_mark() at autoload_i_mark.
* variable.c (rb_autoload_load): Move RB_GC_GUARD() to proper
position based on suggestion by CHIKANAGA Tomoyuki at
http://d.hatena.ne.jp/nagachika/20110826/ruby_trunk_changes_33070_33078
* variable.c (autoload_defined_p): Fix incompatible autoload behavior
that causes Rails crash. Class deifnition instruction defined in
'defineclass' in insns.def always invokes rb_autoload_load for a
constant. It's invoked for every class definition regardless of
existence of autoload definition. rb_autoload_load checkes if a
constant is defined as autoloaded, but new thread-safe autoload
returned different value if the constant is under autoloading.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
What's the problem?
autoload is thread unsafe. When we define a constant to be
autoloaded, we expect the constant construction is invariant. But
current autoload implementation allows other threads to access the
constant while the first thread is loading a file.
What's happening inside?
The current implementation uses Qundef as a marker of autoload in
Constant table. Once the first thread find Qundef as a value at
constant lookup, it starts loading a defined feature. Generally a
loaded file overrides the Qundef in Constant table by module/class
declaration at very beginning lines of the file, so other threads
can see the new Module/Class object before feature loading is
finished. It breaks invariant construction.
How to solve?
To ensure invariant constant construction, we need to override
Qundef with defined Object after the feature loading. For keeping
Qundef in Constant table, I expanded autoload_data struct in
Module to have a slot for keeping the defined object while feature
loading. And changed Module's constant lookup/update logic a
little so that the slot is only visible from the thread which
invokes feature loading. (== the first thread which accessed the
autoload constant)
Evaluation?
All test passes (bootstrap test, test-all and RubySpec) and added
8 tests for threading behavior. Extra logics are executed only
when Qundef is found, so no perf drop should happen except
autoloading.
* variable.c (rb_autoload): Prepare new autoload_data struct.
* variable.c (rb_autoload_load): Load feature and update Constant
table after feature loading is finished.
* variable.c (rb_const_get_0): When the fetched constant is under
autoloading, it returns the object only for the thread which starts
autoloading.
* variable.c (rb_const_defined_0): Ditto.
* variable.c (rb_const_set): When the specified constant is under
autoloading, it sets the object only for the thread which starts
autoloading. Otherwise, simply overrides Qundef with constant
override warning.
* vm_insnhelper.c (vm_get_ev_const): Apply same change as
rb_const_get_0 in variable.c.
* test/ruby/test_autoload.rb: Added tests for threading behavior.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RCLASS_IV_TBL, not in a RCLASS_CONST_TBL, so take back the table
changed in r29600. And an autoload entry keeps not a
rb_const_entry_t but a NODE so remove rb_const_entry_t thing added
in r29602.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NameError for undefined method.
* load.c (rb_mod_autoload_p), object.c (rb_mod_const_get),
variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c
(rb_mod_{remove,undef,alias}_method, set_method_visibility):
remove inadvertent symbol creation. based on the first patch by
Jeremy Evans at [ruby-core:38447]. [Feature #5089]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
based on the second patch by Jeremy Evans at [ruby-core:38447]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
with the name string but not ID.
* object.c, proc.c, variable.c: more removal of inadvertent symbol
creation. [Feature #5079]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
explicitly.
* variable.c (rb_const_defined_0): should not check for
superclasses as const_get.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
the second optional argument is given for #const_get().
fix [Bug #3422] [Bug #3423]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RSTRING_PTR() for function calls since it evaluates the argument
a couple of times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
private constants. see [ruby-core:32912].
* test/ruby/test_module.rb (test_constants_with_private_constant): add
a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
visibility. see [ruby-core:32912].
* test/ruby/test_module.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e