summaryrefslogtreecommitdiff
path: root/vm.c
AgeCommit message (Collapse)Author
2012-06-02* common.mk: fix to build vm_backtrace.c only itself (vm_backtrace.cko1
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
2012-06-02* vm_backtrace.c: added. Separate backtrace related functions toko1
this file. * vm.c, common.mk: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31vm.c: UNREACHABLE to suppress warningsnobu
* vm.c (frame_info_{line_no,name,basename,filename,filepath}): add UNREACHABLE to suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-26* vm.c (backtrace_*): change type of lev and n from size_t to int.ko1
Also set type of rb_backtrace_t#backtrace_size to int. A patch from nobu. * vm_eval.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-26* vm.c (RubyVM::FrameInfo): add a class to access each frameko1
information. You don't need to parse strings from caller(). FrameInfo has the following methods: FrameInfo#name: method name, class name, etc with decorations. FrameInfo#basename: name without decorations. FrameInfo#line_no: line number. FrameInfo#filename: file name. FrameInfo#filepath: full filepath. FrameInfo#iseq: iseq if it is iseq frame (defined by ruby script) FrameInfo#to_s: return caller() method style string. RubyVM::FrameInfoFrameInfo.caller(n, lev) returns array of FrameInfo objects. The name "RubyVM::FrameInfoFrameInfo.caller" is long and ambiguous (same as caller() method), we need to change the name before Ruby 2.0 release. Good names or comments are welcome. * test/ruby/test_backtrace.rb: add a test for above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-26* vm.c (frame_info_to_str): add `break'.ko1
* vm.c (backtrace_object): remove lev and n parameter. backtrace_object always returns all of backtrace information. * vm.c (rb_backtrace_to_str_ary): fix to use backtrace_object(). This change improve performance of caller(lev, n). * benchmark/bm_vm3_backtrace.rb: added to check above improvement. FYI: measurement on my laptop, 1.9.3p229 needs 5.125 sec, and current trunk only needs 0.299sec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-26* vm.c (rb_frame_info_t): keep previous ISEQ frame info for CFUNCko1
frame info. And fix to cache a calculated line_no of ISEQ frame info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25vm.c: adjust argument typesnobu
* vm.c (backtrace_each, bt_init, oldbt_init): adjust argument types. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25* vm.c (oldbt_init, vm_backtrace_str_ary): arg->data shouldko1
be initialized before calling `backtrace_each()'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25* vm.c: refactoring backtrace related funcitons.ko1
(1) unify similar functions (rb_backtrace_each() and backtrace_object()). backtrace_each() is a unified function. variation: a) backtrace_object(): create backtrace object. b) vm_backtrace_str_ary(): create bt as an array of string. c) vm_backtrace_print(): print backtrace to specified file. d) rb_backtrace_print_as_bugreport(): print backtrace on bugreport style. (2) remove rb_backtrace_each(). Use backtrace_each() instead. (3) chang the type of lev parameter to size_t. a) lev == 0 means current frame (exception, etc use it). b) lev == 1 means upper frame (caller(0) use it). * vm_core.h, vm_dump.c, vm_eval.c: ditto. * vm.c (backtrace_object(), vm_backtrace_str_ary()): fix to return a correct size of caller(lev) array. Let n be a "caller(0).size" then ln as caller(lev).size should be (n - lev). However, the previous implementation returns a wrong size array (ln > n - lev). [ruby-dev:45673] * test/ruby/test_backtrace.rb: add tests for backtrace. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24vm.c: marshal compatibilitynobu
* vm.c (Init_VM): fix marshal compatibility of backtrace. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24vm.c: fix typonobu
* vm.c (Init_VM): fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24vm.c: rb_typeddata_is_kind_ofnobu
* vm.c (rb_backtrace_p): use rb_typeddata_is_kind_of(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24vm_eval.c: fix typesnobu
* vm_eval.c (rb_backtrace_struct, backtreace_collect): use size_t instead of int to get rid of overflow. * vm_eval.c (backtrace_object, vm_backtrace_each): ditto, use ptrdiff_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24vm.c: suppress 64-to-32 warningsnobu
* vm.c (backtrace_object): suppress 64-to-32 warnings. should adjust types. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24* vm.c: add RubyVM::Backtrace object (btobj).ko1
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
2012-05-22* vm_core.h: add a data type rb_location_t to store iseq locationko1
information. rb_location_t#filename, filepath, name and line_no was moved from rb_iseq_t. rb_location_t#basename is a new field which is similar to `name' field without any decoration. `name' field contains some decoration such as `block in foo'. `basename' only contains `foo'. rb_iseq_t contains memory object of rb_location_t. * iseq.c: setup rb_location_t for each rb_iseq_t memory objects. * compile.c, proc.c, vm.c, vm_dump.c, vm_eval.c, vm_insnhelper.c, vm_method.c: support about it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-28* parse.y (assoc, parser_yylex): add syntax to splat keyword hash.nobu
[ruby-core:44591][Feature #6353] * compile.c (compile_array_): generate keyword splat insns. * vm.c (m_core_hash_merge_kwd): merge keyword hash into intermediate hash. leftward argument is prior currently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-12* compile.c (compile_array, compile_array_):ko1
Divide big array (or hash) literals into several blocks and concatetene them. There was a problem that a big array (hash) literal causes SystemStackError exception (stack overflow) because VM push all contents of the literal onto VM stack to make an array (or hash). To solve this issue, we make several arrays (hashes) and concatenate them to make a big array (hash) object. ?? * compile.c (iseq_compile_each, setup_args): use modified compile_array. * vm.c (m_core_hash_from_ary, m_core_hash_merge_ary, m_core_hash_merge_ptr): added for above change. * id.c (Init_id), parse.y: add core method ids. * bootstraptest/test_literal.rb: add simple tests. * bootstraptest/test_eval.rb: remove rescue clause to catch SystemStackError exception. * test/ruby/test_literal.rb: add tests to check no stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15* cont.c (rb_fiber_reset_root_local_storage): add a new function tonagachika
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
2012-01-24* vm.c (rb_iter_break_value): new function to break a block withnobu
the value. [ruby-dev:45132] [Feature #5895] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-20* vm.c (vm_exec): remove workaround for LLVM because r34278 fixes it.naruse
* vm_insnhelper.c (vm_call_cfunc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10* test/ruby/test_enumerator.rb (test_nested_iteration): fix typo.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10* vm.c (vm_exec): refix r34162; suppress warning and add description.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-10* gc.c (ruby_mimmalloc): defined for objects need not rb_objspace,naruse
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
2012-01-08* gc.c (rb_objspace_free): global_List is allocated with xmalloc.naruse
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
2012-01-02* vm.c: fix comment.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-30* vm.c (vm_exec): add guard to prevent optimization for LLVM clang.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-18* vm.c (vm_define_method): improve guard of iseq from GC. Fixngoto
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
2011-12-07* vm.c (vm_set_top_stack, vm_set_eval_stack): check for stacknobu
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
2011-12-05* bignum.c (big_rshift), compile.c (validate_label,nobu
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
2011-10-01* vm.c (rb_thread_mark), cont.c (cont_mark): self pointer should notktsj
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
2011-10-01* vm.c (rb_thread_mark): rb_thread_t needs self to be marked.ktsj
[ruby-dev:44566] [Bug #5386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-15* vm.c (rb_vm_get_sourceline): fix indent.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-03* variable.c (rb_const_set): show the previous definitionnobu
location. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-27* vm.c (rb_vm_rewrite_dfp_in_errinfo): change return typektsj
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
2011-08-27* proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.ktsj
[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
2011-08-24* vm.c (vm_make_env_each): work around to solve Bug #2729.ko1
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
2011-08-24* vm_insnhelper.h, vm_insnhelper.c, vm.c, vm_method.c, insns.def:ko1
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
2011-08-24* iseq.h, iseq.c, compile.c: Change the line number data structureko1
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
2011-08-16* vm.c (ruby_threadptr_data_type): rename to hide.nobu
[ruby-core:38972] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-02* gc.c (init_heap): allocate sigaltstack after heaps are allocated.naruse
[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
2011-07-31* vm.c (check_env): print debug messages to stderr.ktsj
[Feature #4871] [ruby-dev:43743] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-31* vm.c (vm_make_env_each): don't save prev env value.ktsj
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
2011-07-31* vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208]ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30* vm.c (th_init): preallocate alternative stack.kosaki
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
2011-06-29 * math.c: Attach documentation for Math.drbrain
* 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
2011-06-18* vm.c, vm_core.h (rb_vm_stack_to_heap): remove const.kosaki
It makes compilations warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* vm.c, vm_core.h (rb_vm_stack_to_heap): fix "const" place.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18* method.h, internal.h iseq.h: declare internal functions.akr
* 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