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
patched by Sokolov Yura. https://github.com/ruby/ruby/pull/78
* dln_find.c: remove useless replacement of free.
* ext/readline/readline.c (readline_attempted_completion_function):
strings for readline must allocated with malloc.
* process.c (run_exec_dup2): use free; see also r20950.
* re.c (onig_new_with_source): use malloc for oniguruma.
* vm.c (ruby_vm_destruct): use free for VMs.
* vm.c (thread_free): use free for threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
failure or segmentation fault in test_singleton_method(TestGc)
on sparc Solaris10 compiled with Oracle Solaris Studio 12.2.
[Bug #5762] [ruby-dev:45000] [Bug #4178]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
overflow with stack_max before push new frame. [ruby-core:41520]
[Bug #5720]
* vm.c (vm_set_main_stack): no stack overflow chances after
vm_set_eval_stack().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
be marked by itself. Patch by Koichi Sasada.
[ruby-dev:44567] [Bug #5386]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fixes: Bug #2729
a patch from Kazuki Tsujimoto <kazuki@callcc.net>
This problem is caused by changing dfp (dynamic env pointer)
from saved dfp. Saved dfp is pointed env in VM stack. However,
the dfp can be moved because VM copies env from VM stack to
the heap. At this copying, dfp was also changed. To solve this
problem, I'll try to change throw mechanism (not save target dfp,
but save target cfp).
* bootstraptest/test_flow.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Manage a redefinition of special methods for each classes.
A patch from Joel Gouly <joel.gouly@gmail.com>. Thanks!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to solve an issue reported at [ruby-dev:44413] [Ruby 1.9 - Bug #5217].
Before this fix, each instruction has an information including
line number (iseq::iseq_insn_info_table). Instead of this data
structure, recording only line number changing places
(iseq::iseq_line_info_table).
The order of entries in iseq_line_info_table is ascending order of
iseq_line_info_table_entry::position. You can get a line number
by an iseq and a program counter with this data structure.
This fix reduces memory consumption of iseq (bytecode).
On my measurement, a rails application consumes 21.8MB for
iseq with this fix on the 32bit CPU. Without this fix, it
consumes 24.7MB for iseq [ruby-dev:44415].
* proc.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.
* vm.c (rb_vm_get_sourceline): change to use rb_iseq_line_no().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-dev:44315] [Bug #5139]
* vm.c (thread_free): use free because objspace is not ready.
* vm.c (th_init): use malloc because objspace is not ready.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NoMemoryError is better than rb_bug, of course.
Patch by Eric Wong. [ruby-core:38572][ruby-core:38594].
* signal.c (rb_register_sigaltstack): ditto.
* vm_core.h: moved ALT_STACK_SIZE definition from signal.c.
* vm.c (thread_free): use xfree() instead of free().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32749 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
ruby_vm_global_state_version and related macros
from vm_core.h to vm_insnhelper.h.
* vm.c (vm_clear_all_cache): added. This function is called
when ruby_vm_global_state_version overflows.
TODO: vm_clear_all_inline_method_cache() is only place holder.
We need to implement it ASAP.
* vm_method.c (vm_clear_global_method_cache): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32056 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
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
CoreDataFromValue() because we need type check. Otherwise,
type mismatch can cause segmentation fault crash.
[ruby-core:35086] [Ruby 1.9-Bug#4367]
* vm.c (thread_data_type): remove static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
thread to free.
* gc.c (slot_sweep): don't call RUBY_VM_SET_FINALIZER_INTERRUPT if
there is no current thread.
[ruby-dev:43000]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243
except for the test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
possible for an object to survive until its surrounding object
space is about to be freed. Those objects, if any, remains not
leaked for the rest of a process life. This is problematic
because for instance a T_DATA object may have its own destructor
to terminate something.
* vm.c (ruby_vm_destruct): ruby_current_vm termination should be
somewhere after rb_objspace_free for above reason.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
hook a VM termination. Right now, because the VM we have is
process global, most extensions do not deallocate resources and
leave them to Operating System's reaping userland processes. But
in a future we plan to have multiple VMs to run simultaneously in
a single process (MVM project). At that stage we can no longer
rely on OSes and have to manage every resources to be reclaimed
properly. So it is. For a forward-compatibility reason this API
is introduced now, encouraging you to be as gentle as you can for
your resources; that is, tidy up your room.
* include/ruby/vm.h: ditto.
* vm_core.h (rb_vm_struct): new field.
* vm.c (vm_init2): initialize above new field.
* eval.c (ruby_cleanup): trigger those hooks.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e