Граф коммитов

398 Коммитов

Автор SHA1 Сообщение Дата
nobu b4f61ad610 vm_core.h: fix symbols leak
* 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-02-06 01:31:53 +00:00
nobu 17a65c320d parse.y: eliminate empty hashes
* parse.y (assocs, assoc): eliminate splatting empty literal
  hashes.  [ruby-core:67446] [Bug #10719]
* compile.c (compile_array_): supprt splatted hash in hash type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-09 02:13:03 +00:00
nobu d5b81e6844 fix printf format conversion specifiers
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-26 05:33:01 +00:00
nobu 9da7dcc477 compile.c: add comments
* compile.c (rb_method_for_self_aref, rb_method_for_self_aset):
  add comments about inputs and outputs of func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19 11:02:10 +00:00
nobu 467830e867 compile.c: struct accessors
* compile.c (rb_method_for_self_aref, rb_method_for_self_aset):
  move from iseq.c to build from node instead of arrays.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17 03:20:58 +00:00
nobu 25d670429c compile.c: constify
* compile.c (iseq_set_local_table): constify ID table.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17 02:57:53 +00:00
ko1 6eac885ebe * compile.c (iseq_compile_each): check
iseq->compile_data->option->specialized_instruction for opt_* insn.
* test/ruby/test_iseq.rb: check no specialized_instructions option.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17 01:20:22 +00:00
normal fcf6fa8781 compile.c: skip opt_* insns for fstr args with block given
* compile.c (iseq_compile_each): only emit opt_str_freeze,
  opt_aref_with, and opt_aset_with insn when no block is given
  [Bug #10557] [ruby-core:66595]
* test/ruby/test_optimization.rb (test_block_given_aset_aref):
  new test for bug thanks to Bartosz Kopinski.
  (test_string_freeze): additional assertion for object_id

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17 00:54:13 +00:00
nobu 97628bff12 compile.c: wrap funcptr
* compile.c (iseq_build_from_ary_body): enclose funcptr with
  Integer as raw pointer cannot appear in an Array.

* iseq.c (iseq_data_to_ary): extract funcptr from Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16 05:54:32 +00:00
nobu 1d5c5ea153 iseq.c: show function name if possible
* iseq.c (rb_insn_operand_intern): show the name of the nearest
  run-time symbol if possible.

* compile.c (insn_data_to_s_detail): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16 01:14:27 +00:00
nobu 389ea73014 compile.c: check funcptr
* compile.c (iseq_build_from_ary_body): cannot load dumped funcptr.

* iseq.c (iseq_data_to_ary): cannot dump funcptr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-16 01:14:20 +00:00
nobu 5f2a4d15a7 compile.c: support for TS_FUNCPTR
* compile.c (iseq_set_sequence): support for TS_FUNCPTR.

* compile.c (insn_data_to_s_detail): ditto.

* compile.c (iseq_build_from_ary_body): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-15 19:09:25 +00:00
normal e70210cad6 compile.c (rb_iseq_build_from_ary): remove misc handling
iseq->local_size is calculated, too, along with stack_size and
param.size, meaning there is no need to blindly load values in
the misc hash passed to us.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05 21:49:42 +00:00
normal 9581954a96 mostly fix rb_iseq_load
This allows reporters commenters of [Feature #8543] to load
instruction sequences directly.  Some test cases are still failing
but documented in test/-ext-/iseq_load/test_iseq_load.rb.

* compile.c (rb_iseq_build_from_exception): entry->sp is unsigned
  (iseq_build_callinfo_from_hash): account for kw_arg
  (iseq_build_from_ary_body): update for r35459
  (CHECK_STRING, CHECK_INTEGER): remove unused checks
  (int_param): new function for checking new `params' hash
  (iseq_build_kw): new function for loading rb_iseq_param_keyword
  (rb_iseq_build_from_ary): account for `misc' entry and general
   structure changes
  [Feature #8543]
* iseq.c (CHECK_HASH): new macro (for `misc' and `param' entries)
  (iseq_load): account for `misc' and `params' hashes
  (iseq_data_to_ary): add final opt to arg_opt_labels,
   fix kw support, account for unsigned entry->sp
* ext/-test-/iseq_load/iseq_load.c: new ext for test
* ext/-test-/iseq_load/extconf.rb: ditto
* test/-ext-/iseq_load/test_iseq_load.rb: new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-03 22:16:58 +00:00
nobu ab9319d886 compile.c: set true and false directly
* compile.c (iseq_set_arguments): directly set true and false
  default values not only nil to keyword arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-02 04:55:07 +00:00
ko1 ea29080489 * compile.c (iseq_compile_each): remove duplicated line event.
[Bug #10449]
* test/ruby/test_settracefunc.rb: add and fix tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27 11:06:51 +00:00
normal b65c619058 compile.c (iseq_calc_param_size): hoist out of iseq_set_arguments
This will be reused for iseq loading.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26 22:11:54 +00:00
ko1 f0071d3b31 * compile.c (iseq_set_sequence): use "nop" insn instead of
"jump to next insn".
  https://bugs.ruby-lang.org/issues/8543#change-50085



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26 06:48:21 +00:00
nobu 606e855622 rb_id2str over rb_id2name
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:44:22 +00:00
normal cbf987c857 compile.c (iseq_build_callinfo_from_hash): hoist out
iseq_build_from_ary_body indentation was too deep for my little
terminal, so extract it so it is easier to add keyword support.

* compile.c (iseq_build_callinfo_from_hash): hoist out
  (iseq_build_from_ary_body): shorten callinfo case

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 01:46:11 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
svn 2cd4da28c6 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05 14:49:08 +00:00
ngoto da4a5ef141 * compile.c (compile_data_alloc): add padding when strict alignment
is required for memory access. Currently, the padding is enabled
  only when the CPU is 32-bit SPARC and the compiler is GCC.
  [Bug #9681] [ruby-core:61715]

* compile.c (STRICT_ALIGNMENT): defined if strict alignment is required

* compile.c (ALIGNMENT_SIZE, ALIGNMENT_SIZE_MASK, PADDING_SIZE_MAX):
  new macros for alignemnt word size, bit mask, max size of padding.

* compile.c (calc_padding): new function to calculate padding size.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05 14:49:04 +00:00
ko1 ef25be7391 * vm_core.h: change semantics of opt_num and opt_table.
`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 04:43:07 +00:00
ko1 831e33c780 * vm_core.h: change iseq parameter data structure.
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:🎏: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 23:14:21 +00:00
ko1 fbebd502f9 * rewrite method/block parameter fitting logic to optimize
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
2014-11-02 18:02:55 +00:00
normal 3fedb5128f compile.c: fix RB_GC_GUARD usage
* compile.c (iseq_build_from_ary_exception): move RB_GC_GUARD
  (iseq_build_from_ary_body): use PRIsVALUE instead of RB_GC_GUARD

Currently unused functions, but we should set good examples for
using RB_GC_GUARD (and favoring PRIsVALUE in format strings).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 06:33:58 +00:00
hsbt 2b0cc32c1a * compile.c: remove commented out code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-01 09:15:49 +00:00
nobu 7190c04417 compile.c: store IDs as Symbols
* compile.c (iseq_set_arguments): store local variable IDs in
  temporary list as Symbols.  previously these are stored as
  Fixnums to prevent from GC, but IDs of dynamic symbols can
  exceed Fixnum range and cause RangeError at inverting from
  Fixnum.  [ruby-dev:48564] [Bug #10266]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 01:23:02 +00:00
nobu e5a3c25a69 compile.c, gc.c: suppress warnings
* compile.c (iseq_compile_each): suppress implicit conversion
  warning by old apple gcc 4.2.

* gc.c (RVALUE_FLAGS_AGE, heap_page_allocate): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-14 01:56:53 +00:00
ko1 6f7eda7b30 * compile.c (rb_vm_addr2insn): rename to rb_vm_insn_addr2insn
to clear what address.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 08:53:56 +00:00
nobu 826341c718 compile.c: remove useless cast
* compile.c (rb_iseq_original_iseq): remove useless cast to fix
  compile error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 08:05:19 +00:00
normal b3a4367ce4 rb_call_info_t: shrink to 96 bytes from 104 bytes on 64-bit
This keeps ci->flag and ci->aux.index consistent across 32-bit
and 64-bit platforms.

ci->flag: VM_CALL_* flags only use 9 bits, currently
ci->aux.index: 2 billion ivars per class should be enough for anybody

This saves around 50K allocations on "valgrind ruby -e exit" on x86-64
before:
  total heap usage: 48,122 allocs, 19,253 frees, 8,099,197 bytes allocated
after:
  total heap usage: 48,069 allocs, 19,214 frees, 8,047,266 bytes allocated

* vm_core.h (rb_call_info_t): ci->flag becomes 32-bit unsigned int
  ci->index becomes a 32-bit signed int (from signed long).
  Reorder for better packing on 64-bit, giving an 8 byte reduction
  from 104 to 96 bytes for each ci.

* compile.c (new_callinfo, setup_args, iseq_compile_each,
  iseq_build_from_ary_body): adjust for type changes

* vm_insnhelper.c (vm_getivar): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 06:32:44 +00:00
normal ea4c97904e compile: translate iseq in-place
running "ruby -rpp -e 'pp GC.stat'", a reduction in
malloc usage is shown:

before:
	:malloc_increase=>118784,
	:oldmalloc_increase=>1178736,

after:
	:malloc_increase=>99832,
	:oldmalloc_increase=>1031976,

For "ruby -e exit", valgrind reports over 300K reduction in
overall allocations (and unnecessary memory copies).

before:
  total heap usage: 49,622 allocs, 20,492 frees, 8,697,493 bytes allocated
after:
  total heap usage: 48,935 allocs, 19,805 frees, 8,373,773 bytes allocated

(numbers from x86-64)

v2 changes based on ko1 recommendations [ruby-core:64883]:
- squashed in-place direct thread translation to avoid alloc+copy
- renamed rb_iseq_untranslate_threaded_code to rb_iseq_original_iseq,
  cache new iseq->iseq_original field.

* compile.c (rb_iseq_translate_threaded_code): modify in-place w/o copy
  (rb_vm_addr2insn): new function for debug
  (rb_iseq_original_iseq): ditto
  (iseq_set_sequence): assign iseq_encoded directly
  [Feature #10185]

* vm_core (rb_iseq_t): move original ->iseq to bottom

* iseq.c (iseq_free, iseq_free): adjust for new layout
  (rb_iseq_disasm): use original iseq for dump
  (iseq_data_to_ary): ditto
  (rb_iseq_line_trace_each): ditto
  (rb_iseq_build_for_ruby2cext): use iseq_encoded directly

* vm_dump.c (rb_vmdebug_debug_print_pre): use original iseq

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 06:14:07 +00:00
normal 49db57f707 compile.c: remove needless SYM2ID <-> ID2SYM conversions
Needless conversions made the code harder to follow.
[misc #10207]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08 22:08:59 +00:00
nobu a12ee80b00 compile.c: assigned in REALLOC_N
* compile.c (iseq_set_sequence): assigned in REALLOC_N, no further
  assignment.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26 23:24:52 +00:00
normal 65f7aa19a9 compile.c (iseq_set_sequence): check for multiplication overflow
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26 23:00:37 +00:00
nobu e3ba618fa1 compile.c: suppress a warning
* compile.c (compile_data_alloc): cast to suppress a warning by
  apple gcc-4.2.  it doesn't cause an error but a warning in spite
  of -Werror=shorten-64-to-32 option, for some reason.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-29 08:22:33 +00:00
nobu 61fd977798 compile.c: check size
* compile.c (compile_data_alloc): check allocation size and
  integer overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26 10:06:49 +00:00
normal 36b476cd1e struct iseq_compile_data_storage: 16 bytes (from 32) overhead
This reduces the iseq_compile_data_storage header from 32 to 16
bytes on 64-bit systems.

pos and size fields cannot exceed 32-bit sizes due to stack size
limits.  Using a flexible array for the buffer also saves us 8
bytes of pointer overhead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26 07:57:44 +00:00
normal a9c7629ece rb_iseq_t: reduce to (280 bytes from 288 bytes) on 64-bit
iseq_size and line_info_size may be 32-bit.

4GB instruction sequences should be big enough for anyone.
Other existing line info counters are 32-bit, and nobody
should need all that.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26 07:30:26 +00:00
normal 48a2b96d2b introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO use
Using calloc where possible reduces code and binary sizes.

* include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement
  (Data_Make_Struct, TypedData_Make_Struct):
  ZALLOC replaces ALLOC+memset
* compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO
* cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO
* io.c (rb_io_reopen): ditto
* iseq.c (prepare_iseq_build): ditto
* parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto
* re.c (match_alloc): ditto
* variable.c (rb_const_set): ditto
* ext/socket/raddrinfo.c (get_addrinfo): ditto
* ext/strscan/strscan.c (strscan_s_allocate): ditto
* gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 21:34:35 +00:00
nobu 97e37d6805 compile.c: make the receiver condition cleaner
* compile.c (defined_expr): make the condition if the receiver
  is explicit or implicit cleaner.  [fix GH-681]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 03:21:12 +00:00
nobu f5a43f4a9b compile.c: FCALL flag on AREF
* compile.c (iseq_compile_each): set FCALL flag on AREF call at
  private aref op_assign.  [ruby-core:63817] [Bug #10060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-19 08:07:48 +00:00
nobu bc45eed1e5 compile.c: private reader in op_assign
* compile.c (iseq_compile_each): allow to access private attribute
  reader in op_assign.  [ruby-core:63817] [Bug #10060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-19 03:40:52 +00:00
normal e91ae784bc vm_core.h (struct rb_iseq_struct): reduce to 296 bytes on 64-bit
Most iseq do not have a catch_table, so avoid needlessly adding
4-8 bytes to the struct for the common case.

Changes from v2:
- iseq_catch_table_size removed, use if (...) for (;...;)

Changes from v1:
- renamed iseq->_catch_table to iseq->catch_table
- iseq_catch_table_bytes: made a static inline function
- iseq_catch_table_size: new function replaces the
  iseq_catch_table_each iterator macro

* iseq.h (struct iseq_catch_table): new flexible array struct
         (iseq_catch_table_bytes): allocated size function
* vm_core.h (struct rb_iseq_struct): uupdate catch_table member
* compile.c (iseq_set_exception_table): update for struct changes
* iseq.c (iseq_free): ditto
* iseq.c (iseq_memsize): ditto
* iseq.c (rb_iseq_disasm): ditto
* iseq.c (iseq_data_to_ary): ditto
* iseq.c (rb_iseq_build_for_ruby2cext): ditto (untested)
* vm.c (vm_exec): ditto
* vm_core.h (struct rb_iseq_struct): ditto
* vm_insnhelper.c (vm_throw): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-14 07:06:26 +00:00
ko1 13f0b628d7 * compile.c (rb_iseq_compile_node): put start label of block after
trace (b_call).
  [Bug #9964]
* test/ruby/test_settracefunc.rb: add a test.
  added assert_consistent_call_return() method check call/return
  consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-19 22:09:23 +00:00
nobu 34b6d25640 compile.c: use enum
* compile.c (new_insn_body): use enum instead of bare int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-08 14:46:43 +00:00
nobu fd8b254705 node.h: remove NODE_PRIVATE_RECV
* compile.c (private_recv_p): check by node type, instead of a
  magic number.
* node.h (NODE_PRIVATE_RECV), parse.y (attrset_gen): remove

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 13:19:31 +00:00
nobu 199f814f32 compile.c, parse.y: private op assign
* compile.c (iseq_compile_each), parse.y (new_attr_op_assign_gen):
  allow op assign to a private attribute.
  [ruby-core:62949] [Bug #9907]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 08:07:13 +00:00