summaryrefslogtreecommitdiff
path: root/vm_args.c
AgeCommit message (Collapse)Author
2015-04-06* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-06* vm_args.c: protect value stack from calling other methodsko1
during complex parameter setting process (splat, kw, and so on). [Bug #11027] * vm_core.h: remove rb_thead_t::mark_stack_len. With this modification, we don't need to use th->mark_stack_len. * test/ruby/test_keyword.rb: add a test. * cont.c (cont_capture): catch up this fix. * vm.c (rb_thread_mark): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06* fix namespace issue on singleton class expressions. [Bug #10943]ko1
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored to rb_method_definition_t::body.iseq_body.cref. * vm_insnhelper.c: modify SVAR usage. When calling ISEQ type method, push CREF information onto method frame, SVAR located place. Before this fix, SVAR is simply nil. After this patch, CREF (or NULL == Qfalse for not iseq methods) is stored at the method invocation. When SVAR is requierd, then put NODE_IF onto SVAR location, and NDOE_IF::nd_reserved points CREF itself. * vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added. * vm_insnhelper.c (vm_push_frame): accept CREF. * method.h, vm_method.c (rb_add_method_iseq): added. This function accepts iseq and CREF. * class.c (clone_method): use rb_add_method_iseq(). * gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref. * iseq.c: remove CREF related codes. * insns.def (getinlinecache/setinlinecache): CREF should be cache key because a different CREF has a different namespace. * node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR. * proc.c: catch up changes. * struct.c: ditto. * insns.def: ditto. * vm_args.c (raise_argument_error): ditto. * vm_eval.c: ditto. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23vm_args.c: rb_exc_set_backtracenobu
* vm_args.c (raise_argument_error): call rb_exc_set_backtrace directly instead of funcall. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23error.c: predefined IDsnobu
* error.c (id_bt, id_bt_locations): use IDs predefined in id.h. * vm_args.c (raise_argument_error): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06vm_core.h: fix symbols leaknobu
* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-01vm_args.c: fix non-symbol keys hashnobu
* vm_args.c (keyword_hash_p): fix non-symbol keys hash. rb_extract_keywords() returns 0 not Qnil when no symbol keys is included. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27fix typoskazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27* vm_args.c: fix backtrace location for keyword related exceptions.ko1
For example, the following program def foo(k1: 1); end # line 1 foo(k2: 2) # line 2 causes "unknown keyword: k2 (ArgumentError)". Before this patch, the backtrace location is only line 2. However, error should be located at line 1 (over line 2 in stack trace). This patch fix this problem. * class.c (rb_keyword_error_new): separate exception creation logic from rb_keyword_error(), to use in vm_args.c. * vm_insnhelper.c (rb_arg_error_new): rename to rb_arity_error_new(). * vm_args.c (argument_arity_error): rename to argument_arity_error(). * vm_args.c (arugment_kw_error): added to fix backtrace. * test/ruby/test_keyword.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23trivial packing of rb_execarg, load_file_arg, args_infonormal
* internal.h (struct rb_execarg): 160 => 144 bytes on x86-64 * ruby.c (struct load_file_arg): 48 => 40 bytes on x86-64 * vm_args.c (struct args_info): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03* vm_core.h: change semantics of opt_num and opt_table.ko1
`opt_num' was the number of optional parameters + 1. `opt_table' has "opt_num" entries. Change them to: `opt_num' is the number of optional parameters. `opt_talbe' has "opt_num + 1" entries. This change simplify parameter fitting logics. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm_args.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03* vm_args.c: fixed build error with clanghsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02* vm_core.h: change iseq parameter data structure.ko1
https://bugs.ruby-lang.org/issues/10440#change-49694 * change terminology `arg' to `param'. * move rb_iseq_t::arg_* to rb_iseq_t::param. * move rb_iseq_t::arg_size to rb_iseq_t::param::size. * move rb_iseq_t::argc to rb_iseq_t::param::lead_num. * move rb_iseq_t::arg_opts to rb_iseq_t::param::opt_num. * move rb_iseq_t::arg_rest to rb_iseq_t::param::rest_start. * move rb_iseq_t::arg_post_num to rb_iseq_t::param::post_num. * move rb_iseq_t::arg_post_start to rb_iseq_t::param::post_start. * move rb_iseq_t::arg_block to rb_iseq_t::param::block_start. * move rb_iseq_t::arg_keyword* to rb_iseq_t::param::keyword. rb_iseq_t::param::keyword is allocated only when keyword parameters are available. * introduce rb_iseq_t::param::flags to represent parameter availability. For example, rb_iseq_t::param::flags::has_kw represents that this iseq has keyword parameters and rb_iseq_t::param::keyword is allocated. We don't need to compare with -1 to check availability. * remove rb_iseq_t::arg_simple. * compile.c: catch up this change. * iseq.c: ditto. * proc.c: ditto. * vm.c, vm_args.c, vm_dump.c, vm_insnhelper.c: ditto. * iseq.c (iseq_data_to_ary): support keyword argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02* rewrite method/block parameter fitting logic to optimizeko1
keyword arguments/parameters and a splat argument. [Feature #10440] (Details are described in this ticket) Most of complex part is moved to vm_args.c. Now, ISeq#to_a does not catch up new instruction format. * vm_core.h: change iseq data structures. * introduce rb_call_info_kw_arg_t to represent keyword arguments. * add rb_call_info_t::kw_arg. * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num. * rename rb_iseq_t::arg_keywords to arg_keyword_num. * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits. to represent keyword bitmap parameter index. This bitmap parameter shows that which keyword parameters are given or not given (0 for given). It is refered by `checkkeyword' instruction described bellow. * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest to represent keyword rest parameter index. * add rb_iseq_t::arg_keyword_default_values to represent default keyword values. * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE to represent (ci->flag & (SPLAT|BLOCKARG)) && ci->blockiseq == NULL && ci->kw_arg == NULL. * vm_insnhelper.c, vm_args.c: rewrite with refactoring. * rewrite splat argument code. * rewrite keyword arguments/parameters code. * merge method and block parameter fitting code into one code base. * vm.c, vm_eval.c: catch up these changes. * compile.c (new_callinfo): callinfo requires kw_arg parameter. * compile.c (compile_array_): check the last argument Hash object or not. If Hash object and all keys are Symbol literals, they are compiled to keyword arguments. * insns.def (checkkeyword): add new instruction. This instruction check the availability of corresponding keyword. For example, a method "def foo k1: 'v1'; end" is cimpiled to the following instructions. 0000 checkkeyword 2, 0 # check k1 is given. 0003 branchif 9 # if given, jump to address #9 0005 putstring "v1" 0007 setlocal_OP__WC__0 3 # k1 = 'v1' 0009 trace 8 0011 putnil 0012 trace 16 0014 leave * insns.def (opt_send_simple): removed and add new instruction "opt_send_without_block". * parse.y (new_args_tail_gen): reorder variables. Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)" has parameter variables "k1, kr1, k2, &b, internal_id, krest", but this patch reorders to "kr1, k1, k2, internal_id, krest, &b". (locate a block variable at last) * parse.y (vtable_pop): added. This function remove latest `n' variables from vtable. * iseq.c: catch up iseq data changes. * proc.c: ditto. * class.c (keyword_error): export as rb_keyword_error(). * common.mk: depend vm_args.c for vm.o. * hash.c (rb_hash_has_key): export. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e