aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
Commit message (Collapse)AuthorAgeFilesLines
* * cont.c (rb_fiber_reset_root_local_storage): add a new function tonagachika2012-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* * vm.c (rb_iter_break_value): new function to break a block withnobu2012-01-241-4/+11
| | | | | | the value. [ruby-dev:45132] [Feature #5895] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_exec): remove workaround for LLVM because r34278 fixes it.naruse2012-01-201-3/+0
| | | | | | * vm_insnhelper.c (vm_call_cfunc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_enumerator.rb (test_nested_iteration): fix typo.nobu2012-01-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_exec): refix r34162; suppress warning and add description.naruse2012-01-101-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (ruby_mimmalloc): defined for objects need not rb_objspace,naruse2012-01-101-4/+4
| | | | | | | | | | | | | | | | | 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
* * gc.c (rb_objspace_free): global_List is allocated with xmalloc.naruse2012-01-081-2/+2
| | | | | | | | | | | | | | | | | | | 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
* * vm.c: fix comment.ktsj2012-01-021-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_exec): add guard to prevent optimization for LLVM clang.naruse2011-12-301-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_define_method): improve guard of iseq from GC. Fixngoto2011-12-181-2/+1
| | | | | | | | | 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
* * vm.c (vm_set_top_stack, vm_set_eval_stack): check for stacknobu2011-12-071-6/+3
| | | | | | | | | 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
* * bignum.c (big_rshift), compile.c (validate_label,nobu2011-12-051-4/+2
| | | | | | | | | | | | | | iseq_build_from_ary_exception), cont.c (cont_capture), dir.c (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open) (rb_io_advise), parse.y (parser_compile_string) (rb_parser_compile_file), proc.c (binding_free), process.c (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core) (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null), signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main), vm_insnhelper.c (vm_expandarray): suppress unused-but-set-variable warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (rb_thread_mark), cont.c (cont_mark): self pointer should notktsj2011-10-011-1/+0
| | | | | | | 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
* * vm.c (rb_thread_mark): rb_thread_t needs self to be marked.ktsj2011-10-011-0/+1
| | | | | | [ruby-dev:44566] [Bug #5386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (rb_vm_get_sourceline): fix indent.nobu2011-09-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * variable.c (rb_const_set): show the previous definitionnobu2011-09-031-0/+14
| | | | | | location. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (rb_vm_rewrite_dfp_in_errinfo): change return typektsj2011-08-271-1/+1
| | | | | | | | to suppress a warning. * vm_core.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.ktsj2011-08-271-16/+23
| | | | | | | | | | | | | | | [Bug #5234] [ruby-core:39125] This code will be removed after changing throw mechanism (see r33064). * vm.c (rb_vm_rewrite_dfp_in_errinfo): new function. * vm.c (vm_make_env_each): changed accordingly. * vm_core.h: ditto. * bootstraptest/test_flow.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_make_env_each): work around to solve Bug #2729.ko12011-08-241-0/+17
| | | | | | | | | | | | | | | | 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
* * vm_insnhelper.h, vm_insnhelper.c, vm.c, vm_method.c, insns.def:ko12011-08-241-2/+13
| | | | | | | | | 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
* * iseq.h, iseq.c, compile.c: Change the line number data structureko12011-08-241-12/+2
| | | | | | | | | | | | | | | | | | | | | | | 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
* * vm.c (ruby_threadptr_data_type): rename to hide.nobu2011-08-161-2/+2
| | | | | | | [ruby-core:38972] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (init_heap): allocate sigaltstack after heaps are allocated.naruse2011-08-021-2/+3
| | | | | | | | | | [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
* * vm.c (check_env): print debug messages to stderr.ktsj2011-07-311-7/+7
| | | | | | [Feature #4871] [ruby-dev:43743] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_make_env_each): don't save prev env value.ktsj2011-07-311-11/+5
| | | | | | | | It is no longer used. [Feature #4871] [ruby-dev:43743] * vm.c (check_env): changed accordingly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208]ktsj2011-07-311-0/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (th_init): preallocate alternative stack.kosaki2011-07-301-1/+4
| | | | | | | | | | | | | | 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
* * math.c: Attach documentation for Math.drbrain2011-06-291-0/+3
| | | | | | | | | | | | | | | | | | | | * object.c: Document NIL, TRUE, FALSE. * io.c: Improve grammar in ARGF comment. Document STDIN/OUT/ERR. Document ARGF global constant. * lib/rake: Hide deprecated toplevel constants from RDoc (import from rake trunk). * lib/thwait.rb: Document ThWait. * lib/mathn.rb: Hide Math redefinition from RDoc * lib/sync.rb: Add a basic comment for Sync_m, Synchronizer_m, Sync, Synchronizer. * parse.y: Document SCRIPT_LINES__. * hash.c: Document ENV class and global constant. * vm.c: Document TOPLEVEL_BINDING. * version.c: Document RUBY_* constants. * ruby.c: Document DATA and ARGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c, vm_core.h (rb_vm_stack_to_heap): remove const.kosaki2011-06-181-1/+1
| | | | | | | | It makes compilations warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c, vm_core.h (rb_vm_stack_to_heap): fix "const" place.ko12011-06-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * method.h, internal.h iseq.h: declare internal functions.akr2011-06-181-1/+0
| | | | | | | | | | | | | | | | | | * 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
* * internal.h: declare more internal functions.akr2011-06-181-2/+0
| | | | | | | | | | | | | | * iseq.h (rb_method_get_iseq): declared. * compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c, ruby.c, time.c, util.c, vm.c: don't declare internal functions. * eval.c, parse.y, thread_pthread.c: non-existing function declarations removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare internal functions here.akr2011-06-171-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * node.h: declare NODE dependent internal functions here. * iseq.h: declare rb_iseq_t dependent internal functions here. * vm_core.h: declare rb_thread_t dependent internal functions here. * bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c, enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c, iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y, proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c, thread.c, time.c, transcode.c, variable.c, vm.c, tool/compile_prelude.rb: don't declare internal functions declared in above headers. include above headers if required. Note that rb_thread_mark() was declared as void rb_thread_mark(rb_thread_t *th) in cont.c but defined as void rb_thread_mark(void *ptr) in vm.c. Now it is declared as the later in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h, vm_insnhelper.h: move decl. ofko12011-06-131-1/+19
| | | | | | | | | | | | | | 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
* * vm.c (thread_memsize): don't ignore size of th->local_storage.kosaki2011-06-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (rb_objspace_call_finalizer): use rb_typeddata_is_kind_of() fornagachika2011-06-091-0/+11
| | | | | | | | | 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
* * vm.c (Init_VM): suppress warning: "OPT_BASIC_OPERATIONS" is not defined.kazu2011-04-161-4/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (ruby_vm_destruct): run vm exit hooks after all objects arenobu2011-02-241-0/+14
| | | | | | destructed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * prevent temporary objects from GC, and should not usenobu2011-02-201-1/+1
| | | | | | | 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
* * vm.c (th_init): rename from th_init2.nobu2011-02-121-8/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * eval.c (ruby_cleanup): use rb_ary_free to free internal object.nobu2011-02-111-1/+1
| | | | | | | * gc.h (RUBY_FREE_UNLESS_NULL): get rid of double free. [ruby-core:35192] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (ruby_thread_data_type): add prefix.nobu2011-02-041-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_core.h (GetThreadPtr): use TypedData_Get_Struct() insteadkosaki2011-02-041-1/+1
| | | | | | | | | | | | 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
* * vm.c (thread_free): reset ruby_current_thread if it points theakr2011-01-121-0/+2
| | | | | | | | | | | 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.c (rb_vm_make_proc): fix indent.nobu2011-01-051-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm.c (vm_define_method): guard iseq from GC while method definition.wanabe2010-12-301-2/+3
| | | | | | [ruby-dev:42832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (setup_args), vm.c (invoke_block_from_c),nobu2010-12-201-4/+1
| | | | | | | 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
* * compile.c (setup_args), vm.c (invoke_block_from_c),nobu2010-12-181-1/+4
| | | | | | | vm_insnhelper.c (caller_setup_args): fix of r30241. lambda block shoud check argument number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (rb_objspace_free): With our "lazy-sweep" GC engine, it isshyouhei2010-12-031-3/+3
| | | | | | | | | | | | | | | 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
* * vm.c (ruby_vm_at_exit): new API. This enables extension libs toshyouhei2010-12-021-0/+10
| | | | | | | | | | | | | | | | | | | | | | | 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