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

307 Коммитов

Автор SHA1 Сообщение Дата
nobu 506b25aabf error.c: name_err_local_variables
* error.c (name_err_local_variables): new method
  NameError#local_variables for internal use only.
  [Feature #11777]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 05:27:10 +00:00
ko1 8dce6b15cc * iseq.c (iseq_load): disable peephole optimization option
because apply it multiple times change the sequence.
  (iseq != peephole_optimize(load(iseq.to_a)))




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07 18:46:27 +00:00
ko1 6757d13ee1 * iseq.c (iseq_translate): at the end of constructing an iseq,
call RubyVM::InstructionSequence.translate(iseq) if this method
  is defined. If the return value is also an object of
  RubyVM::InstructionSequence, then use it instead of created one.

  For example, this method is useful to test iseq dumper/loader
  such as RubyVM::InstructionSequence#to_a and rb_iseq_load().

  Because this method is for such internal experimental usage,
  the interface is not matured. For example, this interface has
  no extensibility. Two or more translaters can not run
  simultaneously.

  So that we don't guarantee future compatibility of this method.
  Basically, do not use this method.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07 17:23:18 +00:00
ko1 2962b6e063 * vm_core.h, iseq.h: remove rb_iseq_t::variable_body.
Fields in rb_iseq_t::variable_body are contained by
  rb_iseq_t::body::mark_ary (hidden Array object).

  Index 0 to 2 of mark_ary are reserved by these objects.

* iseq.c: catch up this fix.

* compile.c (rb_iseq_original_iseq): trivial rewrite.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 13:58:07 +00:00
ko1 cfd1157f11 * iseq.h: introduce ISEQ_ORIGINAL_ISEQ() and
ISEQ_ORIGINAL_ISEQ_ALLOC() macro.

* compile.c: use them to access original iseq buffer.

* iseq.c: ditto.

* vm_core.h: rename iseq field to support this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 08:20:35 +00:00
ko1 417240b7fb * iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.
* compile.c: use them.

* iseq.c: ditto.

* iseq.c (rb_iseq_coverage): added.

* thread.c (update_coverage): use rb_iseq_coverage().

* vm_core.h: rename coverage field name to support this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 08:05:36 +00:00
ko1 7afefea564 * iseq.h: introduce ISEQ_COMPILE_DATA() macro.
* compile.c, iseq.c: use ISEQ_COMPILE_DATA().

* vm_core.h: rename compile_data field to support this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 07:52:12 +00:00
nobu 012368007f iseq.h: rename member
* iseq.h (rb_compile_option_struct): rename the member
  frozen_string_literal_debug as debug_frozen_string_literal.
  [Feature #11725]

* ruby.c (proc_options): do not set $DEBUG and $VERBOSE only if no
  arguments is given.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-25 08:02:29 +00:00
normal 513d8b349f iseq.c (iseq_memsize): account for rb_call_cache entries
Add some comments to clarify the allocated field used for the
allocations while we're at it.

TODO: figure out a better way of testing/maintaining this...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-01 02:13:54 +00:00
ko1 92d5da521d * iseq.c (make_compile_option_value): include frozen_string_literal*
in a made option value.

* vm_opts.h: forgot to add OPT_FROZEN_STRING_LITERAL_DEBUG
  at last commit.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 19:13:51 +00:00
ko1 54716fe7eb * ruby.c: introduce --enable-frozen-string-literal-debug option.
If this option is enabled, the modify error will be:
    can't modify frozen String (RuntimeError) =>
    can't modify frozen String, created at test.rb:3 (RuntimeError)

* iseq.h: add compile option frozen_string_literal_debug.

* compile.c: catch up this fix.

* error.c (rb_error_frozen): ditto.

* iseq.c (set_compile_option_from_hash): ditto.

* test/ruby/test_rubyoptions.rb: add a test for this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 19:02:55 +00:00
nobu 4200ddd5d0 iseq.c: list of keywords [Fix GH-1056]
* iseq.c (rb_insn_operand_intern): change kw in callinfo disasm from the
  number of keyword arguments to an ordered list of the keywords used.
  [Feature #11589]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-14 05:11:44 +00:00
ko1 a22d6f55e8 * iseq.c (rb_iseq_free): free iseq::variable_body to avoid memory
leak.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 21:55:56 +00:00
nobu 859337b17b fronzen-string-literal pragma
* compile.c (iseq_compile_each): override compile option by option
  given by pragma.
* iseq.c (rb_iseq_make_compile_option): extract a function to
  overwrite rb_compile_option_t.
* parse.y (parser_set_compile_option_flag): introduce pragma to
  override compile options.
* parse.y (magic_comments): new pragma "fronzen-string-literal".
  [Feature #8976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-27 06:44:02 +00:00
ko1 bffa617d36 * iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19 18:21:35 +00:00
ko1 d5ec9ec308 * vm_core.h: split rb_call_info_t into several structs.
* rb_call_info (ci) has compiled fixed information.
  * if ci->flag & VM_CALL_KWARG, then rb_call_info is
    also rb_call_info_with_kwarg. This technique reduce one word
    for major rb_call_info data.
  * rb_calling_info has temporary data (argc, blockptr, recv).
    for each method dispatch. This data is allocated only on
    machine stack.
  * rb_call_cache is for inline method cache.
  Before this patch, only rb_call_info_t data is passed.
  After this patch, above three structs are passed.
  This patch improves:
  * data locarity (rb_call_info is now read-only data).
  * reduce memory consumption (rb_call_info_with_kwarg,
    rb_calling_info).
* compile.c: use above data.
* insns.def: ditto.
* iseq.c: ditto.
* vm_args.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_insnhelper.h: ditto.
* iseq.h: add iseq_compile_data::ci_index and
  iseq_compile_data::ci_kw_indx.
* tool/instruction.rb: introduce TS_CALLCACHE operand type.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19 17:59:58 +00:00
ko1 22ea03bb7e * iseq.c: disable ISeq.load. It enabled accidentally at r51794.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-11 15:50:42 +00:00
ko1 eec17b718a * vm_core.h: remove rb_call_info_t::blockiseq.
* insns.def (send, invokesuper): pass blockiseq explicitly.
* compile.c: catch up this fix.
* iseq.c: ditto.
* vm_args.c: ditto.
* iseq.c (ISEQ_MINOR_VERSION): 2->3 because instruction spec was
  changed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-08 08:21:07 +00:00
ko1 970399a9ae * iseq.c (iseq_memsize): functions for wrapper object should have
iseqw_ prefix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-03 19:48:12 +00:00
ko1 7cf523c7db * vm_opts.h, iseq.c, iseq.h: add compile option to force frozen
string literals.
  [Feature #11473]
  This addition is not specification change, but to try frozen
  string literal world discussed on [Feature #11473].
  You can try frozen string literal world using this magical line:
    RubyVM::InstructionSequence.compile_option =
      {frozen_string_literal: true}
  Note that this is a global compilation option, so that you need to
  compile another script like that:
    p 'foo'.frozen? #=> false
    RubyVM::InstructionSequence.compile_option =
      {frozen_string_literal: true}
    p 'foo'.frozen? #=> false, because this line is already compiled.
    p eval("'foo'.frozen?") #=> true
  Details:
    * String literals are deduped by rb_fstring().
    * Dynamic string literals ("...#{xyz}...") is now only frozen,
      not deduped. Maybe you have other ideas.
  Now, please do not use this option on your productions :)
  Of course, current specification can be changed.
* compile.c: ditto.
* test/ruby/test_iseq.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21 20:47:53 +00:00
normal e7bb5d44e6 iseq.c (rb_iseq_mark): reduce NULL checks
iseq_location_setup always sets path, label and base_label fields,
and the only caller of iseq_location_setup (prepare_iseq_build) will
always pass non-nil `name' and `path' arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14 19:23:02 +00:00
normal 7630957eba iseq.c (iseq_memsize): reimplement for wrapper
* iseq.c (iseq_memsize): reimplement for wrapper
  (param_keyword_size): extracted from iseq_memsize
  (iseqw_mark): new mark function
  (iseqw_data_type): new data type
  (iseqw_new): wrap as iseqw_data_type
  (iseqw_check): adjust for wrapper
  (Init_ISeq): remove iseqw_iseq_key initialization
* test/objspace/test_objspace.rb: new test
  [ruby-core:70344] [Feature #11435]

v2 changes:
- added RUBY_TYPED_WB_PROTECTED and write barrier
- account for rb_call_info_kw_arg_t entries

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 12:18:51 +00:00
nobu 6e54a6df22 iseq.c: fix type
* iseq.c (rb_iseq_disasm, iseq_data_to_ary): fix loop counter type
  for array length.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25 02:18:32 +00:00
ko1 22be6d06ab * vm_core.h: size should be unsigned.
* rb_call_info_t::index
  * rb_iseq_constant_body::stack_max
  * rb_iseq_constant_body::local_size
  * rb_iseq_constant_body::param::size
  * rb_iseq_constant_body::local_table_size
  * rb_iseq_constant_body::is_size
  * rb_iseq_constant_body::callinfo_size
* iseq.h: same for iseq_catch_table::size.
* compile.c: catch up these fix.
* iseq.c: ditto.
* proc.c: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 21:44:14 +00:00
ko1 14428f09b1 * vm_core.h: constify rb_iseq_constant_body::line_info_table.
* iseq.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 21:01:09 +00:00
ko1 8fbf5dd9e5 * vm_core.h: constify rb_iseq_constant_body::catch_table.
* compile.c (iseq_set_exception_table): catch up this fix.
* iseq.c: ditto.
* vm.c (vm_exec): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 19:49:16 +00:00
ko1 eed613f4b1 * vm_core.h: constify rb_iseq_constant_body::local_table and
rb_iseq_param_keyword::table and
  rb_iseq_param_keyword::default_values.
* compile.c: catch up this fix.
* iseq.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 09:53:16 +00:00
ko1 18f6978625 * vm_core.h: constify rb_iseq_constant_body::iseq_encoded and
rb_control_frame_t::pc.
* compile.c (rb_iseq_translate_threaded_code): catch up this fix.
* iseq.c: ditto.
* vm_exec.c (vm_exec_core): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 09:34:31 +00:00
ko1 0d775f2a3c * vm_core.h: separate rb_iseq_body into rb_iseq_constant_body and
rb_iseq_variable_body (rb_iseq_t::variable_body).
  rb_iseq_variable_body can be modified after compilation.
* compile.c: use rb_iseq_t::variable_body.
* iseq.c: ditto.
* thread.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 10:55:02 +00:00
ko1 e4198a73d4 * make rb_iseq_t T_IMEMO object (type is imemo_iseq).
All contents of previous rb_iseq_t is in rb_iseq_t::body.
  Remove rb_iseq_t::self because rb_iseq_t is an object.
  RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
  So RubyVM::ISeq.of(something) method returns different wrapper
  objects but they point the same T_IMEMO/iseq object.
  This patch is big, but most of difference is replacement of
  iseq->xxx to iseq->body->xxx.
  (previous) rb_iseq_t::compile_data is also located to
  rb_iseq_t::compile_data.
  It was moved from rb_iseq_body::compile_data.
  Now rb_iseq_t has empty two pointers.
  I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
  Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
  Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
  rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
  [Bug #10037][ruby-core:63721].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 22:52:59 +00:00
ko1 331fb4a2b3 * vm_core.h: constify rb_call_info_t::kw_arg,
rb_control_frame_t::iseq and rb_control_frame_t::block_iseq.
* iseq.c (iseq_free): catch up this fix.
* vm.c: ditto.
* vm_dump.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 21:41:04 +00:00
ko1 948bd807c3 * vm_core.h: constify rb_call_info_t::blockiseq and rb_iseq_t::iseq.
* vm.c, vm_insnhelper.c: catch up this fix.
* iseq.c (iseq_data_to_ary): constify the first iseq parameter.
* vm_insnhelper.c (vm_make_proc_with_iseq): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 21:28:43 +00:00
ko1 c0c20ccb51 * compile.c: constify the first parameter (iseq).
* iseq_add_mark_object()
  * iseq_add_mark_object_compile_time()
* iseq.c, iseq.h (rb_iseq_add_mark_object): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 10:47:45 +00:00
normal 4fd2443580 avoid redundant GET_THREAD() calls
This reduces binary size slightly on my 32-bit system:

   text    data     bss     dec     hex filename
2847705   12360   30632 2890697  2c1bc9 ruby.orig
2847641   12360   30632 2890633  2c1b89 ruby

* iseq.c (rb_iseq_compile_with_option): reuse result of previous
  GET_THREAD() call
* thread.c (thread_create_core): ditto
  (rb_mutex_trylock): ditto
  (rb_mutex_lock): ditto
* process.c (rb_waitpid): avoid multiple eval from RUBY_VM_CHECK_INTS
* thread.c (rb_thread_check_ints): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16 20:42:43 +00:00
ko1 c3e8cca950 * vm_core.h: constify rb_iseq_t::parent_iseq.
rb_iseq_t::local_iseq is not constant data because
  local_iseq::flip_cnt can be modified (commentted).
* compile.c: catch up this fix.
* iseq.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16 13:13:50 +00:00
ko1 7b08338ab1 * iseq.c (rb_iseq_disasm): rename rb_iseq_t *iseqdat to iseq
and VALUE *iseq to code.
* iseq.c (rb_iseq_disasm_insn): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16 12:50:25 +00:00
normal a0908cb413 remove redundant NULL check in mark functions
gc.c (gc_mark_children)only calls mark_func if the T_DATA ptr is
non-NULL, so avoid redundantly checking for that in each
mark function.

* iseq.c (iseq_mark): remove check for data pointer
* proc.c (binding_mark): ditto
* vm.c (rb_thread_mark): ditto
* vm_trace.c (tp_mark): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15 08:29:22 +00:00
normal 011347e4d7 iseq.c (iseq_data_to_ary): dump kw_arg as symbol
Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

* iseq.c (iseq_data_to_ary): dump kw_arg as symbol
* test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip
  [ruby-core:69891] [Bug #11338]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 19:50:49 +00:00
ko1 f395c5be87 * vm_core.h: remove rb_iseq_t::orig because rb_iseq_clone()
no longer exists.
* iseq.c: don't use rb_iseq_t::orig.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 02:41:52 +00:00
ko1 16a68369d2 * iseq.c, internal.h (rb_iseq_clone): removed because we don't need to
clone iseq any more.
* class.c (clone_method): share iseq between cloned methods. All of
  method dependent information are able to refer from method entry.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 02:27:41 +00:00
ko1 5c4d7b9a9e * vm_core.h: remove rb_iseq_t::defined_method_id because it is not
needed.
* eval.c (frame_func_id): simplify. rb_callable_method_entry_t
  has enough information.
* eval.c (frame_called_id): ditto.
* iseq.c (prepare_iseq_build): catch up this fix.
* proc.c (rb_mod_define_method): ditto.
* vm.c (vm_define_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 19:08:05 +00:00
ko1 02d5868962 * vm_core.h: remove rb_iseq_t::klass to reduce dynamic data.
* internal.h, iseq.c (rb_iseq_klass): remove it because
  rb_iseq_t::klass is removed.
* vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but
  check callable method entry on a frame.
  This fix simplify the logic to search super class.
* test/ruby/test_method.rb: support super() from Proc.
  Now, [Bug #4881] and [Bug #3136] was solved.
* proc.c (rb_mod_define_method): catch up this change.
* vm.c (vm_define_method): ditto.
* vm_backtrace.c (rb_profile_frames): now, each `frame' objects
  are rb_callable_method_entry_t data or iseq VALUEs.
  This fix introduce minor compatibility issue that
  rb_profile_frame_label() always returns
  rb_profile_frame_base_label().
* test/-ext-/debug/test_profile_frames.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 18:44:54 +00:00
normal b49075cdf1 move RB_GC_GUARD responsibility to rb_add_method_iseq
This simplifies all the callers and makes code easier to use
and review.  I was confused about the need for RB_GC_GUARD
in define_{aset,aref}_method of struct.c without reading
rb_add_method_iseq.

Likewise, do the same for rb_iseq_clone, where the GC guard
only seems neccesary iff RGenGC is disabled.

* vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
* class.c (clone_method): remove RB_GC_GUARD
* struct.c (define_aref_method): ditto
  (define_aset_method): ditto
* vm.c (vm_define_method):
* iseq.c (rb_iseq_clone): add RB_GC_GUARD

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 21:07:18 +00:00
ko1 7239111ef5 * iseq.c: constify.
* iseq.h: ditto.
* method.h: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 09:01:44 +00:00
ko1 0dba10a47f * proc.c (rb_method_get_iseq): rename to rb_method_iseq.
* iseq.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 07:54:44 +00:00
ko1 08f923bdc1 * iseq.c (exception_type2symbol): show correct bug message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-20 19:11:47 +00:00
nobu b813198627 iseq.c: check srouce type
* iseq.c (rb_iseq_compile_with_option): check srouce type, must be
  an IO or a String.  [ruby-core:69219] [Bug #11159]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-19 09:54:44 +00:00
ko1 4690e62284 * iseq.c (iseq_mark): skip some marking if iseq->orig is available.
* iseq.c (rb_iseq_clone): need WB for iseq1->klass = iseq0->klass
  (done in MEMCPY).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18 20:31:50 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-17 03:20:58 +00:00