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

586 Коммитов

Автор SHA1 Сообщение Дата
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
nobu bb3f036336 node.h: NODE_PRIVATE_RECV
* node.h (NODE_PRIVATE_RECV): name a magic number, `self` as the
  receiver of a setter method call.

* compile.c (private_recv_p), parse.y (attr_receiver): use the
  named macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 06:05:19 +00:00
akr dd5d029db0 * compile.c (BUFSIZE): Unused macro removed.
* vm.c (BUFSIZE): Ditto.

* pack.c (INT64toNUM): Ditto.
  (UINT64toNUM): Ditto.
  (BYTEWIDTH): Ditto.

* time.c (lshift): Ditto.
  (UINT64toNUM): Ditto.
  (id_lshift): Unused variable removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-11 13:29:16 +00:00
nobu 37e432b5bf compile.c: non-destructive keyword splat
* compile.c (compile_array_): make copy a first hash not to modify
  the argument itself.  keyword splat should be non-destructive.
  [ruby-core:62161] [Bug #9776]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-26 01:55:34 +00:00
charliesome a22dd11af8 compile.c: use correct key for block when loading serialized iseqs
* compile.c (iseq_build_from_ary_body): Use :blockptr instead of :block
  as hash key when loading serialized instruction sequences from arrays.
  [Bug #9455] [ruby-core:60146]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-27 23:56:22 +00:00
nobu 27dfc398a8 compile.c: assignment result of aset_with
* compile.c (iseq_compile_each): result of assignment should be
  its rhs instead of returned value from a method.
  [ruby-core:60071] [Bug #9448]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-25 05:21:07 +00:00
nobu 7b8dc95b3a compile.c: mark fstring
* compile.c (iseq_compile_each): fstring is need marking.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-25 05:17:17 +00:00
tmm1 58f800a278 insns.def: add opt path for Hash#[] and Hash#[]= used with str literal keys
* insns.def (opt_aref_with): new instruction to optimize Hash#[],
  removing any allocation overhead when used with a string literal
  key. Patch by normalperson (Eric Wong). [ruby-core:59640] [Bug #9382]
* insns.def (opt_aset_with): new instruction to optimize Hash#[]=
* compile.c (iseq_compile_each): compiler shortcuts for new
  instructions
* hash.c (static VALUE rb_hash_compare_by_id_p): fix documentation for
  Hash#compare_by_identity to reflect frozen string sharing
* test/ruby/test_hash.rb (class TestHash): test for new behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-10 04:54:08 +00:00
nobu 31b4980ef6 compile.c: fix error by clang
* compile.c (iseq_set_arguments): get rid of error by clang,
  implicit conversion to shorter integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 14:02:18 +00:00
nobu 27682eefa4 compile.c: unnamed keyword rest check
* compile.c (iseq_set_arguments): set arg_keyword_check from
  nd_cflag, which is set by parser.  internal ID is used for
  unnamed keyword rest argument, which should be separated from no
  keyword check.
* iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is
  present.
* parse.y (new_args_tail_gen): set keywords check to nd_cflag, which
  equals to that keyword rest is not present.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 13:44:18 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
  proc.c, process.c, re.c, string.c, variable.c, vm.c,
  vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
tmm1 bd892d05ed compile.c: add opt_aset instruction for faster Hash#[]= and Array#[]=
* compile.c (iseq_specialized_instruction): emit opt_aset instruction
  to optimize Hash#[]= and Array#[]= when called with Fixnum argument.
  [Bug #9227] [ruby-core:58956]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11 06:38:42 +00:00
charliesome 7df9798126 * compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: Rename method_serial
  to global_method_state and constant_serial to global_constant_state
  after discussion with ko1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 10:51:02 +00:00
tarui 511cc1db8c * compile.c : Bugsfix for dump_disasm_list.
rb_inspect denies a hidden object. So, insert rapper that creates
	  the unhidden one.
	  adjust->label is null sometimes.
	  insn_data_line_no makes no sense at all.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 11:45:40 +00:00
tmm1 cbb56e30a4 * compile.c: Use rb_fstring() to de-duplicate string literals in code. [ruby-core:58599] [Bug #9159] [ruby-core:54405]
* iseq.c (prepare_iseq_build): De-duplicate iseq labels and source locations.
* re.c (rb_reg_initialize): Use rb_fstring() for regex string.
* string.c (rb_fstring): Handle non-string and already-fstr arguments.
* vm_eval.c (eval_string_with_cref): De-duplicate eval source filename.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26 23:30:25 +00:00
nobu aa358ac11c compile.c: tailcall on super
* compile.c (iseq_peephole_optimize): enable tail call optimization on
  super too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-17 14:34:30 +00:00
nobu 90b9996523 parse.y: remove "f" suffix [ruby-core:57966] [Feature #9042]
revert r42847 "test_string.rb: add test string encoding"

revert r42846 "parse.y: freeze in advance to reduce objects"

revert r42843 "parse.y: deduplicate frozen string literals"

revert r42780 "test_string.rb: yet another test"

revert r42779 "parse.y: valid suffix word only"

revert r42778 "test_string.rb: remove duplicated code"

revert r42775 "parse.y: force_encoding"

This reverts commit 93ea04ecec.

revert r42773 "Add frozen string literals"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-10 06:13:02 +00:00
charliesome 07ac58747f * compile.c (iseq_compile_each): emit opt_str_freeze if the #freeze
method is called on a static string literal with no arguments.

* defs/id.def (firstline): add freeze so idFreeze is available

* insns.def (opt_str_freeze): add opt_str_freeze instruction which
  pushes a frozen string literal without allocating a new object if
  String#freeze is not overriden

* string.c (Init_String): define String#freeze

* vm.c (vm_init_redefined_flag): define BOP_FREEZE on String class as
  a basic operation

* vm_insnhelper.h: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 21:17:06 +00:00
charliesome 8b0771b014 * class.c: unify names of vm state version counters to 'serial'.
This includes renaming 'vm_state_version_t' to 'rb_serial_t',
  'method_state' to 'method_serial', 'seq' to 'class_serial',
  'vmstat' to 'constant_serial', etc.

* insns.def: ditto
* internal.h: ditto
* vm.c: ditto
* vm_core.h: ditto
* vm_insnhelper.c: ditto
* vm_insnhelper.h: ditto
* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 03:34:49 +00:00
glass ce89a1c081 * compile.c (iseq_build_from_ary_exception): use RARRAY_CONST_PTR().
* compile.c (iseq_build_from_ary_body): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 02:00:35 +00:00
charliesome 7fafa8f376 * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split
ruby_vm_global_state_version into two separate counters - one for the
  global method state and one for the global constant state. This means
  changes to constants do not affect method caches, and changes to
  methods do not affect constant caches. In particular, this means
  inclusions of modules containing constants no longer globally
  invalidate the method cache.

* class.c, eval.c, include/ruby/intern.h, insns.def, vm.c, vm_method.c:
  rename rb_clear_cache_by_class to rb_clear_method_cache_by_class

* class.c, include/ruby/intern.h, variable.c, vm_method.c: add
  rb_clear_constant_cache

* compile.c, vm_core.h, vm_insnhelper.c: rename vmstat field in
  rb_call_info_struct to method_state

* vm_method.c: rename vmstat field in struct cache_entry to method_state

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 00:52:38 +00:00
nobu 0e040f8dbf compile.c, vm.c: reduce hash merge
* compile.c (compile_array_): no hash to merge if it is empty.
* vm.c (m_core_hash_merge_kwd): just check keys if only one argument
  is given, without merging.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-13 03:16:54 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
charliesome 2f522b9cc6 * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: Implement class hierarchy method cache invalidation.

  [ruby-core:55053] [Feature #8426] [GH-387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 05:25:06 +00:00
charliesome a056098cb7 * NEWS: Add note about frozen string literals
* compile.c (case_when_optimizable_literal): optimize NODE_LIT strings
  in when clauses of case statements

* ext/ripper/eventids2.c: add tSTRING_SUFFIX

* parse.y: add 'f' suffix on string literals for frozen strings

* test/ripper/test_scanner_events.rb: add scanner tests

* test/ruby/test_string.rb: add frozen string tests

[Feature #8579] [ruby-core:55699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 07:11:41 +00:00
charliesome d0d63cff8a * compile.c (NODE_MATCH3): pass CALL_INFO to opt_regexpmatch2
* insns.def (opt_regexpmatch2): use CALL_SIMPLE_METHOD to call =~ if
  the receiver is not a T_STRING [Bug #8847] [ruby-core:56916]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 06:07:21 +00:00
ko1 5a87332ef9 * compile.c (build_postexe_iseq): fix to setup the local table.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-22 07:23:44 +00:00
ko1 7e5d63f483 * compile.c (rb_iseq_compile_node): accept NODE_IFUNC to support
custom compilation.
* compile.c (NODE_POSTEXE): compile to
  "ONCE{ VMFrozenCore::core#set_postexe{...} }" with a new custom
  compiler `build_postexe_iseq()'.
* vm.c (m_core_set_postexe): remove parameters (passed by a block).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-22 06:50:42 +00:00
ko1 30b1947df2 * insns.def: fix regexp's once option behavior.
fix [ruby-trunk - Bug #6701]
* insns.def: remove `onceinlinecache' and introduce `once' instruction.
  `once' doesn't use `setinlinecache' insn any more.
* vm_core.h: `union iseq_inline_storage_entry' to store once data.
* compile.c: catch up above changes.
* iseq.c: ditto.
* vm.c, vm_insnhelper.c: ditto. fix `m_core_set_postexe()' which
  is depend on `onceinlinecache' insn.
* test/ruby/test_regexp.rb: add tests.
* iseq.c: ISEQ_MINOR_VERSION to 1 (should increment major?)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-20 17:41:13 +00:00
ko1 714428154d * compile.c (iseq_set_arguments): use RARRAY_RAWPTR() instead of
RARRAY_PTR() because there is no new reference.
* compile.c (iseq_set_exception_table): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 11:59:44 +00:00
charliesome fff3589899 * compile.c (make_name_for_block): use PRIsVALUE in format string
instead of %s and RSTRING_PTR to protect objects from being garbage
  collected too soon
* encoding.c (str_to_encindex): ditto
* hash.c (rb_hash_fetch_m): ditto
* io.c (rb_io_reopen): ditto
* parse.y (reg_fragment_check_gen): ditto
* parse.y (reg_compile_gen): ditto
* parse.y (ripper_assert_Qundef): ditto
* re.c (rb_reg_raise): ditto
* ruby.c (set_option_encoding_once): ditto
* vm_eval.c (rb_throw_obj): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 11:31:21 +00:00
ko1 4223f00713 * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:52:40 +00:00
ko1 9b47ec04a8 * include/ruby/ruby.h (struct rb_data_type_struct), gc.c: add
rb_data_type_struct::flags. Now, this flags is passed
  at T_DATA object creation. You can specify FL_WB_PROTECTED
  on this flag.
* iseq.c: making non-shady iseq objects.
* class.c, compile.c, proc.c, vm.c: add WB for iseq objects.
* vm_core.h, iseq.h: constify fields to detect WB insertion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:26:01 +00:00
ko1 f41b284fab * compile.c (rb_iseq_compile_node): fix location of a `trace'
instruction (b_return event).
  [ruby-core:55305] [ruby-trunk - Bug #8489]
  (need a backport to 2.0.0?)
* test/ruby/test_settracefunc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 09:54:58 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
nobu 4a223fb67f compile.c: not simple if keyword args
* compile.c (iseq_set_arguments): not a simple single argument if any
  keyword arguments exist.  [ruby-core:55203] [Bug #8463]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01 08:25:05 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ktsj edb98f8b91 fix typos. Patch by k_takata.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 03:10:21 +00:00
nobu e38a2399d2 compile.c: forward kwrest
* compile.c (iseq_compile_each): forward anonymous and first keyword
  rest argument one.  [ruby-core:55033] [Bug #8416].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18 07:38:55 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
tmm1 cbd8b09920 iseq: reduce array allocations for simple sequences
* compile.c (iseq_add_mark_object): Use new rb_iseq_add_mark_object().

* insns.def (setinlinecache): Ditto.

* iseq.c (rb_iseq_add_mark_object): New function to allocate
  iseq->mark_ary on demand. [Bug #8142]

* iseq.h (rb_iseq_add_mark_object): Ditto.

* iseq.c (prepare_iseq_build): Avoid allocating mark_ary until needed.

* iseq.c (rb_iseq_build_for_ruby2cext): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-17 11:20:23 +00:00
nobu f4c52b483c compile.c: append keyword hash to splat
* compile.c (iseq_compile_each): append keyword hash to argument array
  to splat if needed.  [ruby-core:54094] [Bug #8236]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 06:26:15 +00:00
nobu 0c5d73e80b compile.c: defined? with empty expression
* compile.c (iseq_compile_each): fix of defined? with empty
  expression.  [ruby-core:53999] [Bug #8220]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 10:40:03 +00:00
nobu 34a95669da required keyword arguments
* compile.c (iseq_set_arguments, iseq_compile_each): support required
  keyword arguments.   [ruby-core:51454] [Feature #7701]
* iseq.c (rb_iseq_parameters): ditto.
* parse.y (f_kw, f_block_kw): ditto.  this syntax is still
  experimental, the notation may change.
* vm_core.h (rb_iseq_struct): ditto.
* vm_insnhelper.c (vm_callee_setup_keyword_arg): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12 13:20:50 +00:00
nobu 221f2a1d8a compile.c: zsuper keyword args
* compile.c (iseq_compile_each): pass keyword arguments to zsuper,
  with current values.  [ruby-core:53114] [Bug #8008]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 05:21:40 +00:00
nobu 8a6898394c compile.c: nd_line(node)
* compile.c (iseq_compile_each): keep nd_line(node) in a local
  variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 05:17:04 +00:00
nobu fedf4c2250 compile.c: calc in int
* compile.c (iseq_compile_each): calculate argc as int, not as Fixnum.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 05:17:00 +00:00
ko1 4cf0918e8e * compile.c (iseq_compile_each): remove redundant trace(line)
instruction. for example, at the following script
  def m()
  p:xyzzy
  1
  2
  end
  compiler ignores `1' because there is no effect. However,
  `trace(line)' instruction remains in bytecode.
  This modification removes such redundant trace(line) instruction.
* test/ruby/test_iseq.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-28 14:04:53 +00:00
nobu 45dea57588 compile.c: no keyword check if kw_rest
* compile.c (iseq_set_arguments): no keyword check if any keyword rest
  argument exists, even unnamed.  [ruby-core:52744] [Bug #7922]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 22:51:45 +00:00
ko1 a5e2f3221a * compile.c (compile_array_): modify wrong optimization.
A script "[print(1)]; print(2)" should output "12".
  However, the compiler had eliminted "[print(1)]" expression
  because it is void expression (unused array).
  Of course, side-effect should be remained.
  This issue is reported by Masaya Tarui.
* bootstraptest/test_literal.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-09 18:38:41 +00:00
nobu 4ddf057b9a compile.c: adjust indent
* compile.c (iseq_compile_each): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-08 18:47:05 +00:00
nobu 69b716111f vm_core.h: flip_cnt in rb_iseq_t
* vm_core.h (rb_iseq_t): move flip_cnt from struct iseq_compile_data,
  because it has same life span as enclosing iseq.  [Bug #7671]
  [ruby-core:51296]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-08 05:41:44 +00:00
nobu be7bf5aa0c adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:04 +00:00
nobu eb56c1084d compile.c: no semicolon
* compile.c (ADD_TRACE): putting a semicolon at the last of a macro
  let do/while make no sense.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:21:58 +00:00
nobu 7ea675732a scoped constant op-assignment
* node.h (NODE_OP_CDECL), compile.c (iseq_compile_each),
  parse.y (stmt, arg): allow scoped constant op-assignment.
  [ruby-core:40154] [Bug #5449]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-24 15:59:31 +00:00
shugo ea01ffa569 * vm_core.h (rb_vm_defineclass_type_t),
compile.c (iseq_compile_each), insns.def (defineclass): change the
  meaning of the third operand of defineclass as follows:
    lower 3bits: the type of the defineclass
                   0 = class, 1 = singleton class, 2 = module
    4th bit: a flag represents whether the defineclass is scoped
               0 = not scoped (e.g., class Foo)
	       1 = scoped (e.g., class Bar::Baz)
    5th bit: a flag represents whether the superclass is specified
               0 = not specified (e.g., class Foo)
               1 = specified (e.g., class Bar < Foo)
  If the superclass is specified and is not a class, a TypeError
  should be raised.  [ruby-dev:46747] [Bug #7572]

* test/ruby/test_class.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 08:13:53 +00:00
nobu c9b4b78085 compile.c, vm_insnhelper.c: flip-flop without hidden string key
* compile.c (iseq_compile_each): count flip-flop state in local iseq
  not in each iseqs, so that the keys can be other than hidden
  strings.  [ruby-core:47253] [Bug #6899]
* vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store
  flip-flop states in an array instead of a hash.
* iseq.c (set_relation): main iseq also can has local scope.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10 06:11:16 +00:00
ko1 5c58280773 * compile.c (iseq_specialized_instruction):
change condition of using `opt_send_simple'.
  More method invocations can be simple.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03 11:33:09 +00:00
ko1 38766319e1 * compile.c (iseq_compile_each): joke shouldn't use id.h defined ids.
* id.c (Init_id): ditto.
* common.mk: fix dpendency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03 05:14:50 +00:00
shirosaki 7c407e2a33 * compile.c (ADD_CATCH_ENTRY): add a cast to fix SEGV with x64 mingw
on Windows 8. Without cast, 0 might be non zero value at higher bits
  in rb_ary_new3().
  [ruby-core:50258] [Bug #7456]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 22:29:13 +00:00
ko1 4db8340398 [EXPERIMENTAL: NEED DISCUSS]
* vm_trace.c: add events
* :thread_begin - hook at thread beggining.
* :thead_end - hook at thread ending.
* :b_call - hook at block enter.
* :b_return - hook at block leave.
  This change slow down block invocation.
  Please try and give us feedback until 2.0 code freeze.
* include/ruby/ruby.h: ditto.
* compile.c (rb_iseq_compile_node): ditto.
* insns.def: ditto.
* thread.c: ditto.
* vm.c: ditto.
* include/ruby/debug.h: add a comment.
* test/ruby/test_settracefunc.rb: add a tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 22:28:16 +00:00
naruse 4556a9ec65 * compile.c (compile_array_): refix r37991 remove assertion:
it is true only if type == COMPILE_ARRAY_TYPE_HASH.
  [ruby-dev:46658] [Bug #7466]

* vm.c (m_core_hash_from_ary): add assertion instead of above.

* vm.c (m_core_hash_merge_ary): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 17:35:29 +00:00
naruse bda0aca2af Revert r37991 "compile.c: hash must be paired"
DO BUILD BEFORE COMMIT !

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 11:09:34 +00:00
nobu 399a32dfca compile.c: hash must be paired
* compile.c (compile_array_): hash elements must be paired even for
  literal elements.  [ruby-dev:46658] [Bug #7466]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 10:15:16 +00:00
tadf c07d295204 * include/ruby/util.h: removed extra semicolon in definition of
macro.
	* compile.c: ditto.
	* cont.c: ditto.
	* math.c: ditto.
	* node.c: ditto.
	* parse.y: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 12:42:11 +00:00
ko1 1619c02dd3 * compile.c (insn_data_to_s_detail): remove debug lines.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-13 08:36:42 +00:00
tenderlove 4c740bae97 * probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.

* compile.c (rb_insns_name): allowing DTrace probes to access
  instruction sequence name.

* Makefile.in: translate probes.d file to appropriate header file.

* common.mk: declare dependencies on the DTrace header.

* configure.in: add a test for existence of DTrace.

* eval.c (setup_exception): add a probe for when an exception is
  raised.

* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
  end.

* hash.c (empty_hash_alloc): Add a probe for hash allocation.

* insns.def: Add probes for function entry and return.

* internal.h: function declaration for compile.c change.

* load.c (rb_f_load): add probes for `load` entry and exit, require
  entry and exit, and wrapping search_required for load path search.

* object.c (rb_obj_alloc): added a probe for general object creation.

* parse.y (yycompile0): added a probe around parse and compile phase.

* string.c (empty_str_alloc, str_new): DTrace probes for string
  allocation.

* test/dtrace/*: tests for DTrace probes.

* vm.c (vm_invoke_proc): add probes for function return on exception
  raise, hash create, and instruction sequence execution.

* vm_core.h: add probe declarations for function entry and exit.

* vm_dump.c: add probes header file.

* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
  function entry and return.

* vm_exec.c: expose instruction number to instruction name function.

* vm_insnshelper.c: add function entry and exit probes for cfunc
  methods.

* vm_insnhelper.h: vm usage information is always collected, so
  uncomment the functions.

12 19:14:50 2012  Akinori MUSHA  <knu@iDaemons.org>

* configure.in (isinf, isnan): isinf() and isnan() are macros on
  DragonFly which cannot be found by AC_REPLACE_FUNCS().  This
  workaround enforces the fact that they exist on DragonFly.

12 15:59:38 2012  Shugo Maeda  <shugo@ruby-lang.org>

* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
  vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 21:52:12 +00:00
shugo afdfbde4e7 * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 07:00:12 +00:00
shugo ba5ea548ce * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):
add a new field for inline method cache.

* vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements
  not to confuse inline method cache when module_eval is used with
  refinements.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-11 02:42:04 +00:00
ko1 1486b9cf0a * insns.def (opt_send_simple): introduce new instruction used
when no need to care about block and splat.
* compile.c: use the `opt_send_simple' instruction.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 08:35:19 +00:00
ko1 c992cec4a0 * compile.c (new_callinfo): set a temporary index of callinfo
(used in `iseq_set_sequence()') to rb_call_info_t::aux::index.
  rb_call_info_t::argc is initialiesed by same value of
  rb_call_info_t::orig_argc.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 05:33:31 +00:00
ko1 49371b5420 * compile.c (compile_dstr_fragments): use `putobject' instead of
`putstring' for all of strings used by NODE_DSTR because
  ruby users can not grab this string.
  For example, the string object of "baz" in "foo#{bar}baz"
  is located by `putobject' (users can not touch "baz" object
  directly). This change reduces GC pressure.
  This improvement is suggested by Aaron Patterson.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16 23:38:58 +00:00
ko1 a91e91c537 * vm_core.h (VM_CALL_*): rename VM_CALL_*_BIT
to VM_CALL_* (remove `_BIT' suffix).
  Add comments on each macros.
  Remove unused macro VM_CALL_TAILRECURSION_BIT.
* compile.c, iseq.c, insns.def, vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15 17:22:57 +00:00
nobu ca968ee45e remove garbage line
* compile.c (new_insn_send): remove garbage line.
* tool/instruction.rb (sp_increase_c_expr): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 17:20:42 +00:00
ko1 cbd597e9bc * insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
  parameters such as `op_id', 'op_argc', `blockiseq' and flag.
  These information are stored in rb_call_info_t at the compile
  time.
  This technique simplifies parameter passings at related
  function calls (~10% speedups for simple mehtod invocation at
  my machine).
  `rb_call_info_t' also has new function pointer variable `call'.
  This `call' variable enables to customize method (block)
  invocation process for each place. However, it always call
  `vm_call_general()' at this changes.
  `rb_call_info_t' also has temporary variables for method
  (block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
  VM_CALL macro.  This flag indicates that this call can skip
  caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
  parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 16:59:05 +00:00
ko1 7ea3edc409 * vm_core.h (rb_call_info_t): add new type `rb_call_inf_t'.
This data structure contains information including inline method
  cache. After that, `struct iseq_inline_cache_entry' does not
  need to contain inline cache for method invocation.
  Other information will be added to this data structure.
* vm_core.h (rb_iseq_t): add `callinfo_entries' and `callinfo_size'
  members to `rb_iseq_t'.
* insns.def, compile.c: Use CALL_INFO instead of IC.
* tool/instruction.rb: support CALL_INFO as operand type.
* vm_insnhelper.c, vm_insnhelper.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-09 05:33:54 +00:00
ko1 08c8605de9 * insns.def (getlocal, setlocal): remove old getlocal/setlocal
instructions and rename getdaynmic/setdynamic instructions
  to getlocal/setlocal.
* compile.c: ditto.
* iseq.c: remove TS_DINDEX.
* vm_exec.h (dindex_t): remove type definition of `dindex_t'.
* tool/instruction.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-04 13:52:20 +00:00
ko1 e3990633cb * insns.def (opt_checkenv): remove unused instruction `opt_checkenv'.
* compile.c (iseq_compile_each): ditto.
* node.h: remove unused node `NODE_OPTBLOCK'.
* ext/objspace/objspace.c, gc.c (gc_mark_children): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28 06:44:24 +00:00
ko1 1bebb22ce1 * insns.def: add new instruction `opt_empty_p' for optimize `empty?'
method.  Apply a patch proposed at [ruby-dev:46120]
  [ruby-trunk - Feature #6972] by Glass_saga (Masaki Matsushita).
* compile.c (iseq_specialized_instruction), vm.c, vm_insnhelper.h:
  ditto.
* id.c, template/id.h.tmpl: ditto.
* test/ruby/test_optimization.rb: test for this changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-26 09:34:46 +00:00
nobu 2314b80d4c Feature #7035
* compile.c (defined_expr), insns.def (defined): share single frozen
  strings.  [EXPERIMENTAL] [ruby-core:47558][Feature #7035]
* iseq.c (rb_iseq_defined_string): make expression strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-24 08:36:53 +00:00
ko1 dcfaf3e277 * compile.c (ADD_INSNL): make ADD_INSNSL as alias of ADD_INSN1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-08 08:12:24 +00:00
ko1 93b6f8d619 * compile.c, insns.def (checkmatch):
remove checkincludearray instruction and
  add new instruction checkmatch.
  This change is to solve
  [Bug #4438] "rescue args type check omitted".
* iseq.c: increment ISEQ_MAJOR_VERSION because removal of
  checkincludearray instruction.
* vm_core.h: add several definitions for
  the checkmatch instruction.
* vm_insnhelper.c (check_match): added.
* bootstraptest/test_exception.rb: add a test.
* test/ruby/test_exception.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-08 07:52:19 +00:00
shyouhei 9b29e5f7e1 * compile.c (iseq_set_sequence): nonstatic initializer of an
aggregate type is a C99ism.

	* compile.c (enum compile_array_type_t): comma at the end of enum
	  list is a C99ism.

	* vm_backtrace.c (enum LOCATION_TYPE): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11 02:57:02 +00:00
ko1 bac9f65f70 * vm_core.h (rb_location_t): fix type and field name.
(1) rename rb_location_t to rb_iseq_location_t.
  (2) rename field names of rb_iseq_location_t to adjust
  RubyVM::Backtrace::Location methods.
  (2-1) filename -> path
  (2-2) filepath -> absolute_path
  (2-3) basename -> base_label
  (2-4) name -> label
  (3) rename filed name rb_iseq_location_t#line_no to
  rb_iseq_location_t#first_lineno to clear purpose of this field.
  (4) The field names rb_binding_t#(filename|line_no) are also renamed
  to rb_binding_t#(path|first_lineno).
* compile.c: apply above changes.
* iseq.c: ditto.
* proc.c: ditto.
* vm*.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 02:49:37 +00:00
ko1 8bcf7fc402 * vm_core.h: add a data type rb_location_t to store iseq location
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-05-22 08:31:38 +00:00
ko1 6051f54260 * compile.c (iseq_compile_each): remove unused variable `size'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-06 09:40:47 +00:00
nobu 3380974143 * parse.y (assoc, parser_yylex): add syntax to splat keyword hash.
[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-28 21:12:05 +00:00
ko1 66d247bcb5 * compile.c: fix to output warning when the same literals
are available as a condition of same case clause.
  And remove infomation ('#n') because we can find duplicated
  condition with explicit line numbers.
  [ruby-core:38343] [Ruby 1.9 - Bug #5068]
* test/ruby/test_syntax.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 09:20:42 +00:00
ko1 ee7f8d4805 * compile.c (compile_array, compile_array_):
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-04-12 01:33:34 +00:00
ko1 6da0604df7 * compile.c (iseq_set_sequence): show a hint if there are duplicated
"when" clauses.  [ruby-core:41502] [ruby-trunk - Feature #5716]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-10 06:39:02 +00:00
nobu 0d1c2268a8 * compile.c (iseq_specialized_instruction): DRY and replace chain
of if-else with switch for special instructions.  based on a
  patch by Vasfed.  https://github.com/ruby/ruby/pull/105


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-19 06:20:55 +00:00
akr 7e78f6f526 * compile.c: typo fix by Run Paint Run Run.
[ruby-core:28368] [Bug #2824]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-18 06:28:41 +00:00
nobu 8fe3fb4c0f * compile.c (iseq_set_arguments): keyword rest arg without keyword args.
* node.c (dump_node): dump kw_rest_arg too.
* parse.y (block_param, f_arg): more kwrest patterns.
  [ruby-core:42455][Bug #5989]
* parse.y (new_args_gen): no extra kw_rest_arg if no keyword rest arg.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 13:00:17 +00:00
nobu 6a8d009709 * compile.c (iseq_compile_each): call on special object instead of
self.  since stabby lambda is a syntax, so it should not be
  affected by the context.  [ruby-core:42349][Bug #5966]
* insns.def (send): no special deal for FCALL.  self should be put
  on TOS instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-26 02:26:49 +00:00
nobu fde3c421be * insns.def (splatarray): make new array if flag is set.
* compile.c (iseq_compile_each): make new array with
  splat. [ruby-core:21901][Feature #1125]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 20:41:38 +00:00
nobu cd339692ef * compile.c (defined_expr): guard the whole expression.
[ruby-dev:45021][Bug#5786]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-11 03:04:23 +00:00
nobu 45fd88877f * compile.c (iseq_set_sequence): adjust indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-14 13:16:29 +00:00
mame d0baa0dd52 * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments), iseq.c (rb_iseq_parameters), vm_insnhelper.c (vm_callee_setup_arg_complex): support Method#parameters for keyword arguments. The provisional spec is what Benoit Daloze proposed. [ruby-core:40518]
* test/ruby/test_keyword.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:20:15 +00:00
mame a0a2c144b8 * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments, iseq_compile_each), vm_insnhelper.c (vm_callee_setup_arg_complex): implement keyword arguments. See [ruby-core:40290] The feature is promised to be included in 2.0, but the detail spec is still under discussion; this commit is a springboard for further discussion. Please try it and give us feedback. This commit includes fixes for some problems reported by Benoit Daloze <eregontp AT gmail.com> [ruby-core:40518] and Marc-Andre Lafortune <ruby-core-mailing-list AT marc-andre.ca> [ruby-core:41772].
* iseq.c (iseq_free, prepare_iseq_build): bookkeeping.

* test/ruby/test_keyword.rb: add tests for keyword arguments.

* test/ripper/dummyparser.rb (class DummyParser): temporal fix for
  ripper test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:20:09 +00:00
mame afb10c62c2 * node.h, parse.y (new_args_gen), compile.c (iseq_set_arguments): use struct rb_args_info instead of NODEs. This is a preparation for keyword argument (see [ruby-core:40290]).
* node.c (dump_node), gc.c (gc_mark_children, obj_free): bookkeeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:19:58 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
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-12-05 09:57:00 +00:00
nobu 8baffe6ef6 * class.c (rb_obj_methods), compile.c (iseq_compile_each),
iseq.c(iseq_load, rb_iseq_parameters), pack.c (pack_pack),
  regcomp.c (is_not_included, update_string_node_case_fold),
  transcode.c (rb_econv_open0, make_replacement),
  vm_eval.c (raise_method_missing): remove unused variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:50:12 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
ko1 7049d9c80d * iseq.h, iseq.c, compile.c: Change the line number data structure
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-24 06:31:15 +00:00
mame b88daae7ec * compile.c (when_vals): when a string literal is written on when
clause, skip string creation to make it faster.  [ruby-dev:44068]
  [Feature #5000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 03:11:52 +00:00
akr 7da3ea811e * method.h, internal.h iseq.h: declare internal functions.
* 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
2011-06-18 03:49:33 +00:00
akr afd7e4668f * internal.h: declare more internal functions.
* 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
2011-06-18 01:54:57 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* 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
2011-06-17 22:43:38 +00:00
naruse 021f166509 * compile.c (iseq_compile_each): fix return value of obj[a,*b]=c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 10:18:39 +00:00
nobu e7c0a6e1d7 * prevent temporary objects from GC, and should not use
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
2011-02-20 07:23:55 +00:00
nagachika 80466e3fc7 * compile.c (get_exception_sym2type): guard temporary object from GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-17 15:32:55 +00:00
mame a2ec8666cf * compile.c (NODE_CLASS, NODE_MODULE), insns.def (defineclass): raise
an exception when "class Foo::Bar" is evaluated and Foo::Bar is
  private.  To implement this, define_type of "defineclass" is added
  so that the instruction can distinguish whether the class definition
  is scoped (class Foo::Bar) or not (class Bar).

* test/ruby/test_class.rb (test_redefine_private_class),
  test/ruby/test_module.rb
  (test_define_module_under_private_constant): add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-28 17:57:34 +00:00
nobu f4db8aedc8 * compile.c (setup_args), vm.c (invoke_block_from_c),
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
2010-12-20 21:10:24 +00:00
nobu cd3f980ea2 * compile.c (setup_args), vm.c (invoke_block_from_c),
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
2010-12-18 07:02:35 +00:00
nobu 5683ad100d * compile.c (setup_args, iseq_compile_each): optimize AMPER LAMBDA
combination as block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-18 01:07:12 +00:00
nobu 31c99ce745 * compile.c (iseq_compile_each): fix for __goto__ and __label__
where were totally broken.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-12 14:45:30 +00:00
kazu fe1f0df92b remove a comma at end of enumerator list.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-10 02:42:06 +00:00
akr 15dad95dfc * compile.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-02 21:53:08 +00:00
mame 7b7210439c * compile.c (iseq_set_exception_local_table, iseq_set_local_table,
rb_iseq_build_from_ary): fix type inconsistency (which is benign
  because sizeof(ID) == sizeof(ID*), though).  Coverity Scan found
  these bugs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-15 14:44:19 +00:00
nobu f6003894b9 * compile.c (new_child_iseq): adjust argument types.
* iseq.c (prepare_iseq_build, rb_iseq_new),
  (rb_iseq_new_with_bopt_and_opt, rb_iseq_new_with_opt),
  (rb_iseq_new_with_bopt): ditto.
* compile.c (iseq_set_exception_table): suppress warnings.
* insns.def (putspecialobject, defined): ditto.
* iseq.c (iseq_load): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-31 13:11:02 +00:00
ko1 b76fd8283a * vm_core.h: some refactoring.
- move decl. of rb_compile_option_struct to iseq.h.
  - define enum iseq_type.
  - define enum vm_special_object_type.
* compile.c: some refactoring.
  - apply above changes.
  - (struct iseq_link_element): change value of type.
  - remove unused decl.
  - fix comment.
  - rename iseq_build_body and iseq_build_exception to
  iseq_build_from_ary_body and iseq_build_from_ary_exception.
* iseq.h: define enum catch_type and enum defined_type.
* insns.def: apply above changes.
* iseq.c: define ISEQ_MAJOR_VERSION and ISEQ_MINOR_VERSION.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-31 01:42:54 +00:00
nobu d410639a6d * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
  (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
  (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
  iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
  thread.c (rb_thread_local_aref),
  variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
  (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
  vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
  ext/iconv/iconv.c (map_charset): use st_data_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:47:23 +00:00
nobu 17c48bebf8 * compile.c (iseq_build_body), insns.def (getglobal, setglobal),
iseq.c (iseq_load, iseq_data_to_ary), util.c (valid_filename):
  use VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:35:40 +00:00
nobu f5bcc56bcd * compile.c (iseq_compile_each): fix truncating cast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 13:41:12 +00:00
nobu 7c73db266a * compile.c: math.h for modf.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-10 05:03:40 +00:00
wanabe 96688ecbab * compile.c (case_when_optimizable_literal): When float value can be
treated as integer, add to table hash of case that way.
  based on a patch from Ikuo KOBORI. [ruby-dev:42038]

* insnf.def (opt_case_dispatch): ditto.

* test/ruby/test_case.rb: add tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-09 13:40:14 +00:00
mame 5ffe59faf8 * compile.c (NODE_ARGSCAT, NODE_ARGSPUSH): drop unused ARGSCAT
results when poped is true.  [ruby-dev:41933], [Bug #3658]
  This is retry of r28870 and r28873 which were reverted.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-05 12:32:02 +00:00
mame fa9d53d00f * compile.c (NODE_ARGSCAT, NODE_ARGSPUSH): revert r28870 and r28873
which involuntarily changed semantics of type conversion.
  I'll re-commit a correct patch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-05 12:31:55 +00:00
nobu 600601c338 * compile.c (iseq_compile_each): to_a method should be called.
[Bug #3658]

* compile.c (iseq_compile_each): ditto for ARGSPUSH.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-05 11:30:50 +00:00
nobu 50b5049921 * compile.c (iseq_compile_each): drop unused ARGSCAT results.
fix [ruby-dev:41933], [Bug #3658]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-05 10:52:08 +00:00
naruse 7175a9073e * class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:
clean unused-value warnings.

* cont.c, process.c, vm_exec.h: clean cast warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 07:13:43 +00:00
nobu 9cce6d1071 * compile.c (rb_iseq_translate_threaded_code): removed duplicated code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-26 20:53:11 +00:00
matz 276fb7e77b * compile.c (iseq_compile_each): should consider block on stack,
if block argument is passed.  [ruby-core:30534]

* parse.c (arg_concat_gen): should append to nd_head, not to
  nd_iter for NODE_BLOCK_PASS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-02 03:05:06 +00:00
mame 59af57e257 * iseq_compile_each (NODE_DEFINED): put nil first to fix stack
consistency.  [ruby-core:30293]
  Now, lfinish[0] of defined_expr seems not to be used.  Refactoring
  may be needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-19 10:48:17 +00:00
mame 80f7f8d07e * compile.c (iseq_compile_each), vm_insnhelper.c (vm_invoke_block,
vm_throw): allow "return" and "yield" even in singleton class
  definition.  based on a patch from wanabe <s.wanabe AT gmail.com>
  for "return".  [ruby-core:21379] [ruby-dev:40975]

* insns.def (defineclass): ditto (straightforwardly push block ptr,
  instead of dfp ptr with special flag).

* vm_core.h (RUBY_VM_CLASS_SPECIAL_P): ditto (no longer needed).

* proc.c (proc_new): ditto (remove handling for special flag).

* bootstraptest/test_jump.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-09 18:21:39 +00:00
wanabe 0356eef426 * compile.c (iseq_set_sequence): fix check range of ic_index.
a patch from Tomoyuki Chikanaga.  #3236

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-05 13:33:58 +00:00
wanabe 576252ae9d * compile.c (iseq_build_body): update iseq->ic_size.
a patch from Tomoyuki Chikanaga. see #3236.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-04 14:10:09 +00:00
mame adfe4f3930 * compile.c (NODE_NEXT, NODE_REDO): add dummy putnil instruction to
fix stack consistency error.  [ruby-core:28172]

* bootstraptest/test_jump.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-20 15:28:33 +00:00
wanabe 8b261b413c * compile.c (iseq_compile_each): fix splat condition in NODE_WHEN.
[Bug #2226]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-17 00:23:28 +00:00
muraken 2eda201bc6 * compile.c (iseq_compile_each): stop hiding, and freeze unpopped string nodes to allow method redefinition. [ruby-dev:40641]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-09 05:22:53 +00:00
mame d47e0b989f * compile.c (iseq_build_body): add mark to jump table hash of case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-17 17:33:01 +00:00
mame 6ff75042db * compile.c, iseq.c, ruby.c, vm.c, vm_core.h, vm_eval.c: add absolute
path field into rb_iseq_t.  The field contains a string representing
  a path to corresponding source file. or nil when the iseq is created
  from -e, stdin, eval, etc.  This field is used for require_relative.
  [ruby-dev:40004]

* load.c (rb_f_require_relative): add C implementation of
  require_relative.

* prelude.rb (require_relative): get rid of Ruby implementation of
  require_relative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-16 17:40:00 +00:00
nobu a3d0a213dc * compile.c (insn_data_to_s_detail), iseq.c (insn_operand_intern):
fixed format specifiers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-14 00:50:10 +00:00
ko1 9da12c5850 * compile.c (defined_expr), insns.def (defined): fix to pass a Symbol
object such as :$foo for the "defined?($foo)" expression
  on defined instruction.  This patch fixes ISeq#to_a/load.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-09 19:21:37 +00:00
ko1 d3f73f45d8 * insns.def: Change the operand type of setinlinecache
(OFFSET to IC).  This IC must be same as corresponding
  getinlinecache instruction's IC operand.
  This change is for a little performance improvement
  (getting IC directly) and is for the AOT compilation development.
* compile.c, iseq.c, insns.def: Change the approach to handling inline
  cahce (IC) type operand to enable the above change.
  This change also affects ISeq#to_a method.  The inline cache operand
  will be dumped by fixnum, the index of inline cache, in other words,
  inline cache identity.
* template/insns_info.inc.tmpl, tool/instruction.rb: No need to count
  inline cache size (insn_iclen()).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-24 17:06:15 +00:00
shyouhei 0d3de66006 * common.mk (compile.$(OBJEXT)): dependencies lacking.
* vm_method.c (rb_add_method_cfunc): invalid initializer for C89

	* compile.c (iseq_insns_unification): int might be smaller than int*


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-20 07:12:16 +00:00
yugui 295bc2fe25 removes the dtrace support. reverts r26239, r26238 and r26235.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-05 05:59:23 +00:00
yugui 72b199940d * trace.h: new file. wraps tracing mechanisms.
* defs/dtrace.d: new file. defined a dtrace provider "ruby".

* include/ruby/ruby.h (LIKELY): moved from vm.c.
  (UNLIKELY): ditto.
  (OBJSETUP): probe "object-create".
  (RUBY_EVENT_RESCUE): new event.

* vm_exec.c (DEBUG_ENTER_INSN): embeded a probe insn-entry into it.
  (DEBUG_END_INSN): insn-return.

* vm.c (LIKELY): moved into ruby.h.
  (UNLIKELY): ditto.
  (Init_BareVM): embeded a probe "raise" into it.

* variable.c (rb_class2name_without_alloc): new utility function.

* tool/rbinstall.rb (install?(:ext, :arch, :'ext-arch')): installs 
  dtrace.d if necessary.

* thread_pthread.c (add_signal_thread_list): probe "raise".
  (rb_thread_create_timer_thread): ditto.

* thread.c (rb_thread_schedule_rec): probes "thread-enter" and
  "thread-leave",
  (thread_start_func_2): ditto.
  (thread_cleanup_func): probe "thread-term"

* lib/mkmf.rb: supports dtrace postprocessor on making an extension.

* iseq.c (rb_vm_insn_name): new utility function.
  (rb_vm_insn_len): ditto.

* insns.def (hook): probes "method-etnry", "method-return", "line",
  and "rescue".

* compile.c (iseq_compile_each): adds a trace op for "rescue" probe.

* gc.c (garbage_collect): probes "gc-begin" and "gc-end".
  (obj_free): probe "object-free"
  (garbage_collect_with_gvl): probe "raise"
  (negative_size_allocation_error): ditto.
  (rb_memerror): ditto.

* eval.c (rb_rescue2): probe "rescue"
  (rb_longjmp): probe "raise"

* ext/probe/probe.c: new extension for application defined probes.

* ext/probe/extconf.rb: ditto.

* configure.in (--with-tracing-model): new option to choose a tracing
  mechanism.
  (DTRACE): new substitution. name of dtrace(1).
  (RUBY_TRACING_MODEL): new substitution.
  (DTRACE_OBJ): ditto.
  (MINIDTRACE_OBJ): ditto.
  (GOLFDTRACE_OBJ): ditto.
  (LIBRUBY_DTRACE_OBJ): ditto.
  (RUBY_DTRACE_POSTPROCESS): new macro. checks whether the dtrace on 
  the system needs postprocessing.
  (RUBY_DTRACE_BSD_BROKEN): new macro. checks whether the dtrace
  supports USDT.

* Makefile.in: 
  (DTRACE): new variable. name of dtrace(1).
  (TRACING_MODEL): new variable. name of the chosen tracing mechanism.
  (DTRACE_OBJ): same as the one in configure.in.
  (MINIDTRACE_OBJ): ditto.
  (GOLFDTRACE_OBJ): ditto.
  (LIBRUBY_DTRACE_OBJ): ditto.
  (CPPOUTFILE): new substitution. necessary for generating dtrace.d
  (trace_none.h): new target for TRACING_MODEL=none
  (RUBY_H_INCLUDES): appended a header for tracing.
  (distclean-local): also removes preprocessed version of dtrace.d
  ($(LIBRUBY_A)): needs $(LIBRUBY_DTRACE_OBJ) if dtrace needs 
  postprocessing.
  ($(PROGRAM)): ditto.
  (golf): ditto.
  (miniruby): ditto.
  ($(arch_hdrdir)/ruby/dtrace.d): new target. preprocessed verson 
  of defs/dtrace.d. generated if necessary.
  ($(arch_hdrdir)/ruby/trace_dtrace.h): new target.
  definition of probes.
  ($(LIBRUBY_DTRACE_OBJ)): new target. generated if dtrace needs 
  postprocessing.
  ($(DTRACE_OBJ)): ditto.
  ($(MINIDTRACE_OBJ)): ditto.
  ($(GOLFDTRACE_OBJ)): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-03 15:36:17 +00:00
shugo 7dbfe89630 * compile.c (compile_cpath, iseq_compile_each): reverted
constant/class variable lookup in instance_eval etc. to the
  behavior of 1.8.
* eval.c (rb_mod_nesting): ditto.
* insns.def (putspecialobject, defineclass): ditto.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL): ditto.
* vm_core.h (VM_SPECIAL_OBJECT_CONST_BASE): ditto.
* vm_eval.c (yield_under, eval_under): ditto.
* vm_insnhelper.c (vm_cref_push, vm_get_const_base,
  vm_get_ev_const, vm_get_cvar_base): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-03 18:25:57 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
mame 4b62641c13 * compile.c (ADD_TRACE): fire coverage event in ensure clause.
[ruby-dev:39303]

* iseq.h, iseq.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-08 16:11:30 +00:00
nobu fe1ce93f52 * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
  vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
  tool/instruction.rb: fixed types.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 20:58:26 +00:00
nobu 8686840960 * compile.c (iseq_compile_each), parse.y (stmt, arg): arg_concat()
on op_asgn was inversed.  [ruby-core:25629] [Bug #2050]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-18 07:15:06 +00:00
nobu 31b7ae00c0 * include/ruby/st.h (st_hash_func): use st_index_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-08 13:10:04 +00:00
ko1 f825d84898 * compile.c (iseq_specialized_instruction), insns.def (opt_size):
optimize #size methods (by specialized instruction).
* id.c, id.h, vm.c, vm_insnhelper.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-06 08:39:57 +00:00
nobu c76e698fd8 * compile.c (iseq_compile_each): op_asgn to aref should return rhs.
[ruby-core:25387]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 06:21:15 +00:00
nobu 7a05e1ead3 * compile.c (FIXNUM_OR): typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 05:37:11 +00:00
nobu 47b31a44c7 * compile.c (FIXNUM_INC, FIXNUM_OR): trivial optimizations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 05:34:56 +00:00
nobu 96c50e47c5 * compile.c (iseq_compile_each): &&= and ||= should return rhs.
[ruby-dev:39163] (#1996), [ruby-core:25143]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-05 01:38:47 +00:00
mame 74dc18c953 * compile.c (NODE_RETURN): fire return event at explicit return.
[ruby-dev:38701]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-18 16:15:29 +00:00
nobu e5df8fd261 * compile.c (iseq_compile_each): used more appropriate construct.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-31 02:48:10 +00:00
mame df878f78c5 * compile.c (iseq_compile_each): fix stack consistency error.
[ruby-core:24611]

* bootstraptest/test_method.rb: add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-30 12:42:41 +00:00
mame 31c561f66a * vm_core.h (struct rb_iseq_t): add a new field line_no. This field
represents line number from which the original code of the iseq
  starts.  [ruby-dev:38698]

* iseq.c, compile.c: ditto.

* parse.y: line number hack (for Proc#source_location) is no longer
  needed.

* test/ruby/test_settracefunc.rb: line number of set_trace_func is now
  compatible with 1.8's.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-22 13:37:26 +00:00
nobu 5a392c71db * compile.c (compile_dstr_fragments): reduced needless literal.
* parse.y (xstring, regexp, dsym, literal_concat, evstr2dstr):
  literal at the top of dstr is no longer needed if it is empty,
  since concatstrings and toregexp always create new strings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-20 10:01:05 +00:00
ko1 94664d6d0c * node.h, vm_core.h, variable.c: rename global_entry to rb_global_entry.
* compile.c, insns.def, iseq.c, vm_insnhelper.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-16 00:01:06 +00:00
ko1 c330876d7c * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management.  This change affect some VM control stack structure.
* vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto.  and make some
  refactoring.
* insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto.
* vm_core.h, compile.c (iseq_specialized_instruction): remove
  VM_CALL_SEND_BIT.  use another optimization tech for Kernel#send.
* node.h: remove unused node types.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c: add mark/free functions for method entry.
* include/ruby/intern.h: remove decl of
  rb_define_notimplement_method_id().  nobody can use it
  because noex is not opend.
* iseq.c (iseq_mark): fix to check ic_method is available.
* iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 14:59:41 +00:00
ko1 20d9aefccb * vm_core.h, compile.c: declare struct iseq_inline_cache_entry.
Inline cache (IC) entries are no longer GC managed object.
  IC entries are freed when ISeq is freed.
* iseq.c: fix mark, free, memsize functions for above change.
* insns.def: remove rb_gc_write_barrier().
* vm_insnhelper.c (vm_method_search): ditto.
* tool/instruction.rb, template/insns_info.inc.tmpl (insn_iclen):
  added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-13 09:30:23 +00:00
ko1 0ac93a1a40 * insns.def, vm_insnhelper.c (getinstancevariable):
fix to use inline cache.
* compile.c: fix to skip inline cache entry (IC).  IC is added
  automatically by compiler.
* insns.def, vm_insnhelper.h: fix IC positions.
* iseq.c: increment minor_version of ISeq because of above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-13 04:44:20 +00:00
nobu 877acd03f6 * compile.c (iseq_set_arguments, iseq_compile_each): internal
arrays must be hidden.  [ruby-dev:38613]

* vm.c (Init_top_self): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-22 07:14:32 +00:00
nobu 53106bd5c3 * compile.c: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-22 07:05:50 +00:00
nobu d25ea00ac0 * compile.c: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-17 05:27:32 +00:00
nobu f91b0dc811 * compile.c (rb_parse_in_eval): returns true in true eval, not in
main.  [ruby-dev:38382]

* parse.y (program): inherits dvars in eval or main.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-17 05:23:10 +00:00
nobu 506af65de1 * compile.c (cdhash_type, iseq_set_sequence): should not call
methods of the argument of case, to keep the semantics of
  case/when.  [ruby-dev:38079]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-27 09:30:53 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
ko1 c9e4dc308f * compile.c: fix to add "ensure" codes across "while" clause
before "return" expression.  [ruby-dev:37967]
* bootstraptest/test_flow.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-16 20:54:58 +00:00
nobu ae6ba9f084 * compile.c (iseq_compile_each): just freeze xstr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-12 16:45:18 +00:00
nobu 11a4e69447 * compile.c (iseq_set_sequence, compile_dstr_fragments),
(iseq_compile_each): hides other internal objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-12 16:29:17 +00:00
nobu 5dd1a4c14e * compile.c (hide_obj): OBJ_FREEZE() is not an expression. a patch
from nagachika <nagachika00 AT gmail.com> at [ruby-dev:37977].

* compile.c (insn_set_sc_state): fixed typoe.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-12 13:51:19 +00:00
nobu e52da91987 * compile.c (compile_array_, defined_expr, iseq_compile_each): hide
and freeze internal literal objects, to prevent from modifying.
  [ruby-dev:37959]

* iseq.c (insn_operand_intern): copy internal literal objects.

* insns.def (putstring, duparray): ditto.

* string.c (rb_str_replace): exported.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-12 10:42:36 +00:00
ko1 cf23d0f0f0 * vm.c: add a prefix "rb_" to exposed functions
vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(),
  vm_stack_to_heap(), vm_make_proc(), vm_invoke_proc(),
  vm_get_sourceline(), vm_cref(), vm_localjump_error(),
  vm_make_jump_tag_but_local_jump(), vm_jump_tag_but_local_jump().
  This changes may affect only core because most of renamed functions
  require a pointer of not-exposed struct such as rb_thread_t or NODE.
  In short, they are core functions.
* cont.c, eval.c, eval_intern.h, load.c, proc.c, thread.c,
  vm_core.h, vm_dump.c, vm_eval.c, vm_exec.c, vm_insnhelper.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 02:38:11 +00:00
ko1 c4c3f238d7 * iseq.c:
rename ruby_iseq_disasm_insn() -> rb_iseq_disasm_insn().
  rename ruby_iseq_disasm() -> rb_iseq_disasm().
* compile.c:
  rename ruby_iseq_compile() -> rb_iseq_compile_node().
  rename ruby_iseq_translate_threaded_code() ->
  rb_iseq_translate_threaded_code().
  rename ruby_insns_name_array() -> rb_insns_name_array().
  rename ruby_iseq_build_from_ary() -> rb_iseq_build_from_ary().
* iseq.c, compile.c: remove ruby_insn_make_insn_table() and make
  static function insn_make_insn_table().
* iseq.h, ruby.c, vm.c, vm_core.h, vm_eval.c, vm_dump.c,
  blockinlining.c: ditto.
  Rename strange "ruby_" prefix to "rb_" prefix.
  This changes may affect only core because renamed functions
  require a pointer of rb_iseq_t which is not exposed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 01:06:56 +00:00
nobu b96f428e48 * iseq.c (rb_iseq_load): renamed from ruby_iseq_load, since it is
for C extensions or the ruby core.  [ruby-core:21407]

Index: compile.c
===================================================================
--- compile.c	(revision 21649)
+++ compile.c	(working copy)
@@ -5078,5 +5078,5 @@ iseq_build_exception(rb_iseq_t *iseq, st
 	}
 	else {
-	    eiseqval = ruby_iseq_load(ptr[1], iseq->self, Qnil);
+	    eiseqval = rb_iseq_load(ptr[1], iseq->self, Qnil);
 	}
 
@@ -5162,5 +5162,5 @@ iseq_build_body(rb_iseq_t *iseq, LINK_AN
 			    if (op != Qnil) {
 				if (TYPE(op) == T_ARRAY) {
-				    argv[j] = ruby_iseq_load(op, iseq->self, Qnil);
+				    argv[j] = rb_iseq_load(op, iseq->self, Qnil);
 				}
 				else if (CLASS_OF(op) == rb_cISeq) {
Index: iseq.c
===================================================================
--- iseq.c	(revision 21649)
+++ iseq.c	(working copy)
@@ -448,5 +448,5 @@ iseq_s_load(int argc, VALUE *argv, VALUE
 
 VALUE
-ruby_iseq_load(VALUE data, VALUE parent, VALUE opt)
+rb_iseq_load(VALUE data, VALUE parent, VALUE opt)
 {
     return iseq_load(rb_cISeq, data, parent, opt);
Index: iseq.h
===================================================================
--- iseq.h	(revision 21649)
+++ iseq.h	(working copy)
@@ -21,5 +21,5 @@ VALUE ruby_iseq_build_from_ary(rb_iseq_t
 
 /* iseq.c */
-VALUE ruby_iseq_load(VALUE data, VALUE parent, VALUE opt);
+VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
 struct st_table *ruby_insn_make_insn_table(void);
 


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-18 19:05:15 +00:00
ko1 e40928733d * ruby.c (process_options): decrement parse_in_eval to recognize
parsing main or normal eval script.
* compile.c (rb_parse_in_main): return 1 if parsing main script.
  (if parse_in_eval is negative value, it means main script)
* parse.y (yycompile0): check rb_parse_in_main() to accumulate
  script text.  Bug #848 [ruby-core:20450]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 16:14:43 +00:00
ko1 6c08b4522d * iseq.h, iseq.c (rb_iseq_new_main): add a type ISEQ_TYPE_MAIN.
[ruby-dev:37619]
* compile.c (rb_dvar_defined, ruby_iseq_compile): ditto.
* iseq.c (iseq_data_to_ary, iseq_load): ditto.
* compile.c (iseq_compile_each): fix to check ip->compile_data.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-27 05:58:23 +00:00
ko1 597220ef0c * vm.c (Init_VM): create and define TOPLEVEL_BINDING at first.
* vm.c (vm_set_main_stack, rb_iseq_eval_main): added.
* parse.y (rb_parser_compile_file): fix to check parse_in_eval flag.
* eval.c (ruby_exec_node): use rb_iseq_eval_main()
  instead of rb_iseq_eval().
* iseq.c (rb_iseq_new_main), vm_core.h: added.
  main script (specified by -e or script name) should be run
  under TOPLEVEL_BINDING using Kernel#eval.  Above changes
  simulate Kernel#eval behaviour.  [ruby-dev:37240]
* compile.c (make_name_for_block): skip iseq except block type.
  this fix is needed for [ruby-dev:37240], and also fixes
  [ruby-dev:35392].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-27 01:15:56 +00:00
ko1 155149109a * compile.c (iseq_peephole_optimize): fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-24 13:01:09 +00:00
nobu 541915b239 * compile.c (iseq_compile_each), gc.c (assign_heap_slot),
(gc_mark_children), parse.y (vtable_alloc, vtable_free, vtable_add),
  proc.c (proc_to_s), thread.c (terminate_i, rb_thread_terminate_all),
  (thread_start_func_2, blocking_region_begin, blocking_region_end),
  (rb_thread_kill), thread_pthread.c (native_thread_create),
  (ubf_pthread_cond_signal), vm.c (check_env, thread_free), vm_dump.c
  (vm_env_dump_raw, vm_stack_dump_each, vm_thread_dump_state),
  (vm_call0): use void pointer for %p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-09 04:33:55 +00:00
nobu ed19ff6bdb * compile.c (iseq_set_sequence): uses rb_compile_warning() for
warning at compilation time.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-05 03:38:50 +00:00
nobu 794eb7bc49 * compile.c (ruby_iseq_compile, ruby_iseq_translate_threaded_code),
(ruby_insns_name_array, ruby_iseq_build_from_ary): prefixed with
  ruby_.

* iseq.c (ruby_iseq_load, ruby_insn_make_insn_table): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-05 03:35:48 +00:00
mame 01cdeb8da7 * compile.c (iseq_set_sequence): fix memory leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 14:38:08 +00:00
nobu c809aaa5e1 * compile.c (iseq_compile_each): fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-12 01:18:49 +00:00
mame f2aabd1802 * compile.c (iseq_set_sequence): check duplicated when clauses.
[ruby-dev:36616]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-28 13:15:34 +00:00
ko1 2e311f6bd5 * include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
  (node.h will be changed. Extensions should not depends on
  this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
  gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
  vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 19:52:31 +00:00
ko1 7f7834abf7 * include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
  move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
  from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
  vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
  rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
  iseq structure.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 07:49:45 +00:00
matz 9839d737c2 * compile.c (defined_expr): default defined? should return
"expression" without evaluating the expression.  [ruby-dev:35967]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 14:04:09 +00:00
matz cc3cbd2965 * compile.c (defined_expr): should handle NODE_{AND,OR} as
"expression".  [ruby-dev:35951]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 10:06:12 +00:00
nobu 74cd315a50 * compile.c (iseq_build_body): suppress a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 07:01:57 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
nobu 0acca9a826 * compile.c (insn_data_to_s_detail), file.c (rb_stat_inspect),
iseq.c (ruby_iseq_disasm_insn, ruby_iseq_disasm),
  process.c (pst_message), re.c (match_inspect): use rb_str_catf.

* dir.c (dir_inspect), iseq.c (iseq_inspect, insn_operand_intern): use
  rb_sprintf.

* error.c (rb_name_error, rb_raise, rb_loaderror, rb_fatal): use
  rb_vsprintf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-22 08:53:34 +00:00
nobu 16ab763b1f * compile.c (iseq_compile_each): NODE_POSTEXE should set each end
procs only once.  [ruby-dev:35596]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-20 13:50:14 +00:00
ko1 807fbd6940 * compile.c, vm.c, insns.def: call FrozenCore.set_postexe method
instead to use "postexe" insn.
* id.c, id.h: add a prepared id for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 12:19:00 +00:00
shyouhei 3e69e83a62 * include/ruby/ruby.h (enum ruby_special_consts): ISO C forbids
comma at end of enumerator list

 	* include/ruby/ruby.h (enum ruby_value_type): ditto.

	* eval_intern.h (enum): ditto.

	* vm_core.h (enum rb_thread_status): ditto.

	* parse.y (enum lex_state_e): ditto.

	* parse.y (enum string_type): ditto.

	* process.c (enum): ditto.

	* ruby.c (enum dump_flag_bits): ditto.

	* ruby.c (enum disable_flag_bits): ditto.

	* compile.c (iseq_link_element): ditto

	* debug.c (union): ditto.

	* cont.c (enum context_type): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 08:27:58 +00:00
ko1 eb33f91cb7 * compile.c, insns.def, vm.c, vm_core.h: remove some insns
(undef, alias, definemethod).
  Call RubyVM::FrozenCore's singleton method instead.
  Add "putiseq" and "putspecialobject" instructions.
* id.c, id.h: add ids for above.
* tool/parse.rb: "VM" no longer exists.  Use RubyVM instead.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-01 03:05:58 +00:00
mame 59e103794e * compile.c (iseq_build_from_ary): initialize arg_opts, a patch from
Adam Strzelecki <ono@java.pl> in [ruby-core:17220].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-23 15:23:12 +00:00
wanabe 266a84c904 * compile.c (iseq_build_from_ary): fix expression to obtain
iseq->local_size and iseq->local_table_size.  [ruby-dev:35205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-23 15:12:29 +00:00
wanabe 62b6a462d7 * compile.c : treat []&&= in virtually the same way as []||=.
[ruby-dev:34679]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 13:49:16 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
nobu 075530a685 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
mame e0a264a9ef * compile.c (defined_expr): fix SEGV by defined?([1]).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-30 13:15:03 +00:00
mame a93136879e * compile.c (iseq_compile): set local_table for
ISEQ_TYPE_DEFINED_GUARD.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-25 08:55:09 +00:00
mame 8742de6f10 * compile.c (iseq_build_body): remove side effect from
VM::InstructionSequence.load.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-25 08:52:57 +00:00
ko1 59c061235f * eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added.  Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
  id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
  blockinlining.c: fix for above changes.  and do some refactoring.
  this changes improve rb_yield() performance.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 17:50:17 +00:00