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

393 Коммитов

Автор SHA1 Сообщение Дата
ko1 f64238e777 * vm_core.h: define USE_LAZY_LOAD if it is not defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 07:13:16 +00:00
nobu 6a105387ce suppress warnings
* compile.c (iseq_ibf_dump): check lenght overflow.

* vm_core.h (rb_iseq_check): suppress unused-value warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 14:12:11 +00:00
ko1 3dbb390180 * introduce new ISeq binary format serializer/de-serializer
and a pre-compilation/runtime loader sample.
  [Feature #11788]

* iseq.c: add new methods:
  * RubyVM::InstructionSequence#to_binary_format(extra_data = nil)
  * RubyVM::InstructionSequence.from_binary_format(binary)
  * RubyVM::InstructionSequence.from_binary_format_extra_data(binary)

* compile.c: implement body of this new feature.

* load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq):
  call RubyVM::InstructionSequence.load_iseq(fname) with
  loading script name if this method is defined.

  We can return any ISeq object as a result value.
  Otherwise loading will be continue as usual.

  This interface is not matured and is not extensible.
  So that we don't guarantee the future compatibility of this method.
  Basically, you should'nt use this method.

* iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions)
  from iseq.c.

* encoding.c (rb_data_is_encoding), internal.h: added.

* vm_core.h: add several supports for lazy load.
  * add USE_LAZY_LOAD macro to specify enable or disable of
    this feature.
  * add several fields to rb_iseq_t.
  * introduce new macro rb_iseq_check().

* insns.def: some check for lazy loading feature.

* vm_insnhelper.c: ditto.

* proc.c: ditto.

* vm.c: ditto.

* test/lib/iseq_loader_checker.rb: enabled iff suitable
  environment variables are provided.

* test/runner.rb: enable lib/iseq_loader_checker.rb.

* sample/iseq_loader.rb: add sample compiler and loader.

    $ ruby sample/iseq_loader.rb [dir]

  will compile all ruby scripts in [dir].
  With default setting, this compile creates *.rb.yarb files
  in same directory of target .rb scripts.

    $ ruby -r sample/iseq_loader.rb [app]

  will run with enable to load compiled binary data.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 13:58:50 +00:00
normal 4ebab10bf5 compile optimized case dispatch for nil/true/false
nil/true/false are special literals just like floats, integers,
literal strings, and symbols.  Optimize when statements with
them by using a jump table, too.

target 0: a (ruby 2.3.0dev (2015-12-08 trunk 52928) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"
target 1: b (ruby 2.3.0dev (2015-12-08 master 52928) [x86_64-linux]) at "/home/ew/ruby/b/ruby"

benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name	a	b
loop_whileloop2	0.102	0.103
vm2_case_lit*	1.657	0.549

Speedup ratio: compare with the result of `a' (greater is better)
name	b
loop_whileloop2	0.988
vm2_case_lit*	3.017

* benchmark/bm_vm2_case_lit.rb: new benchmark
* compile.c (case_when_optimizable_literal): add nil/true/false
* insns.def (opt_case_dispatch): ditto
* vm.c (vm_redefinition_check_flag): ditto
* vm.c (vm_init_redefined_flag): ditto
* vm_core.h: ditto
* object.c (InitVM_Object): define === explicitly for nil/true/false
* test/ruby/test_case.rb (test_deoptimize_nil): new test
* test/ruby/test_optimization.rb (test_opt_case_dispatch): update
  (test_eqq): new test
  [ruby-core:71923] [Feature #11769]
  Original patch by Aaron Patterson <tenderlove@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 01:46:45 +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 a9c0cf4ff0 * iseq.h: introduce ISEQ_FLIP_CNT_INCREMENT() macro.
* compile.c (iseq_compile_each): use it.

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




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 08:11:27 +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
normal 15476c695d fiddle: release GVL for ffi_call
Some external functions I wish to call may take a long time
and unnecessarily block other threads.  This may lead to performance
regressions for fast functions as releasing/acquiring the GVL is not
cheap, but can improve performance for long-running functions
in multi-threaded applications.

This also means we must reacquire the GVL when calling Ruby-defined
callbacks for Fiddle::Closure, meaning we must detect whether the
current thread has the GVL by exporting ruby_thread_has_gvl_p
in internal.h

* ext/fiddle/function.c (struct nogvl_ffi_call_args):
  new struct for GVL release
  (nogvl_ffi_call): new function
  (function_call): adjust for GVL release
  [ruby-core:71642] [Feature #11607]
* ext/fiddle/closure.c (struct callback_args):
  new struct for GVL acquire
  (with_gvl_callback): adjusted original callback function
  (callback): wrapper for conditional GVL acquire
* ext/fiddle/depend: add dependencies
* ext/fiddle/extconf.rb: include top_srcdir for internal.h
* internal.h (ruby_thread_has_gvl_p): expose for fiddle
* vm_core.h (ruby_thread_has_gvl_p): moved to internal.h
* test/fiddle/test_function.rb (test_nogvl_poll): new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23 21:20:56 +00:00
ko1 f363bbdf10 * insns.def (getinlinecache/setinlinecache): compare ic->ic_cref and
current cref only when cached CREF list includes singleton class.

  Singleton classes have own namespaces, so that we need to check
  cref as a key (#10943).

  However, if current CREF list does not include singleton class,
  no need to check CREF beacuse it should be same name space.

* vm_insnhelper.c (vm_get_const_key_cref): add a function returns
  CREF only when it includes singleton class.

* vm_core.h: constify iseq_inline_cache_entry::ic_cref.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 22:43:45 +00:00
nobu fd69901b26 vm_core.h: move forward declarations
* vm_core.h (rb_thread_struct): move forward declarations before
  used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:45:18 +00:00
ko1 1e0600324b * vm_core.h: define vm_call_handler.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 17:00:51 +00:00
ko1 9e1b06e17d * vm_core.h, vm_insnhelper.h: move definition of VMDEBUG
from vm_insnhelper.h to vm_core.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 16:57:58 +00:00
nobu 37ab3ed99d vm_core.h: vm_thread_with_frame
* vm_core.h (vm_thread_with_frame): skip function call in
  GET_THREAD which is empty unless OPT_CALL_CFUNC_WITHOUT_FRAME is
  enabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 07:10:25 +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
nobu 7ed700d2da vm_core.h: revert VM objspace on Windows
* vm_core.h (ENABLE_VM_OBJSPACE): disable now, as socklist and
  conlist will be freed exit_handler(), after object space
  destruction.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-16 12:14:52 +00:00
nobu c3a48736a6 vm_core.h: enable VM objspace on Windows
* vm_core.h (ENABLE_VM_OBJSPACE): enable per-VM object space on
  Windows by default, as rb_w32_sysinit() no longer depends on
  ruby_xmalloc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-16 08:18:02 +00:00
ko1 731c9288da * vm_core.h: remove rb_call_info_t::aux.opt_pc.
* vm_insnhelper.c: introduce shortcut functions for opt_pc == 0
  because opt_pc is always 0 on shortcut function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-11 18:25:54 +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
nobu 2b2c691188 vm_core.h: objspace always
* vm_core.h (rb_vm_struct): define objspace always regardless
  ENABLE_VM_OBJSPACE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-07 07:50:11 +00:00
normal f224fecc0f improve handling of timer thread shutdown
Shutting down the timer thread now always closes pipes to free FDs.
In fact, we close the write ends of the pipes is done in the main
RubyVM to signal the timer thread shutdown.

To effectively close pipes, we implement userspace locks via
atomics to force the pipe closing thread to wait on any signal
handlers which may be waking up.

While we're at it, improve robustness during resource exhaustion and
allow it to limp along non-fatally if restarting a timer thread
fails.

This reverts r51268

Note: this change is tested with VM_CHECK_MODE 1 in vm_core.h

* process.c (close_unless_reserved): add extra check
  (dup2_with_divert): remove
  (redirect_dup2): use dup2 without divert
  (before_exec_non_async_signal_safe): adjust call + comment
  (rb_f_exec): stop timer thread for all OSes
  (rb_exec_without_timer_thread): remove
* eval.c (ruby_cleanup): adjust call
* thread.c (rb_thread_stop_timer_thread): always close pipes
* thread_pthread.c (struct timer_thread_pipe): add writing field,
    mark owner_process volatile for signal handlers
  (rb_thread_wakeup_timer_thread_fd): check valid FD
  (rb_thread_wakeup_timer_thread): set writing flag to prevent close
  (rb_thread_wakeup_timer_thread_low): ditto
  (CLOSE_INVALIDATE): new macro
  (close_invalidate): new function
  (close_communication_pipe): removed
  (setup_communication_pipe_internal): make errors non-fatal
  (setup_communication_pipe): ditto
  (thread_timer): close reading ends inside timer thread
  (rb_thread_create_timer_thread): make errors non-fatal
  (native_stop_timer_thread): close write ends only, always,
   wait for signal handlers to finish
  (rb_divert_reserved_fd): remove
* thread_win32.c (native_stop_timer_thread): adjust (untested)
  (rb_divert_reserved_fd): remove
* vm_core.h: adjust prototype

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-14 09:44:10 +00:00
ko1 d22a09e189 * vm_core.h (rb_call_info_kw_arg_bytes): move the definition
to iseq.h because this function is shared with iseq.c and compile.c.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-13 08:43:32 +00:00
normal b3abb691da hoist out rb_call_info_kw_arg_bytes to inline function
* vm_core.h (rb_call_info_kw_arg_bytes): extract from compile.c
* compile.c (iseq_build_callinfo_from_hash): use above function

This will be use for implementing iseq_memsize

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 12:16:29 +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 efa31acaad * vm_core.h: constify rb_iseq_constant_body::param::opt_table and
rb_iseq_constant_body::param::keyword.
* compile.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 20:58: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 c44360f623 * vm_core.h: modify layout of rb_iseq_constant_body.
Move frequent accesssing fields to upper part.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 11:21:21 +00:00
ko1 6f8b0aeb3b * vm_core.h: remove unused declaration of
iseq_compile_data_ensure_node_stack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 10:58:33 +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
nobu 1b8ff4f799 ruby_vm_throw_flags
* vm_core.h (ruby_vm_throw_flags): constants for throw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 00:08:23 +00:00
nobu 67f5f9477c compile.c: use ruby_tag_type
* compile.c (iseq_compile_each): use enum ruby_tag_type names.
* vm_core.h (ruby_tag_type): move from eval_intern.h for compiling
  break/next/redo/return.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 13:18:12 +00:00
nobu df62161d7e RUBY_VM_CHECK_INTS: eval the argument only once
* vm_core.h (RUBY_VM_CHECK_INTS): evaluate the argument only once
  to get rid of inadvertent side effects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 07:28:53 +00:00
nobu ce7fdcf0f8 RUBY_VM_CHECK_INTS_BLOCKING: move to thread.c
* thread.c (RUBY_VM_CHECK_INTS_BLOCKING): move from vm_core.h for
  the static function rb_threadptr_pending_interrupt_empty_p.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 07:28:36 +00:00
nobu 01962439e9 EXEC_EVENT_HOOK_ORIG: eval the arguments only once
* vm_core.h (EXEC_EVENT_HOOK_ORIG): evaluate each arguments only
  once to get rid of inadvertent side effects.  fix use of `th`
  variable in the second `if` statement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 07:28:22 +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 994460c4db * vm_core.h, vm.c: remove rb_proc_t::envval because we can know it via
rb_proc_t::block::ep.
  rb_vm_proc_envval(const rb_proc_t *proc) returns an Env object which
  the Proc object use.
* proc.c: catch up this fix.
* vm_dump.c (rb_vmdebug_proc_dump_raw): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 17:59:03 +00:00
ko1 e07dad00ee * vm_core.h, vm.c: remvoe rb_env_t::prev_envval because we can know it
via env->ep.
  rb_vm_env_prev_envval(env) returns prev_envval via env->ep.
* vm_core.h (rb_vm_env_local_variables): change parameter type
  from VALUE (T_DATA/env) to `const rb_env_t *' to make same as
  rb_vm_env_prev_envval().
* proc.c: catch up these changes.
* vm_dump.c: ditto.
* vm.c: rename macros.
  * ENV_IN_HEAP_P() to VM_EP_IN_HEAP_P() because it uses ep.
  * ENV_VAL() to VM_ENV_EP_ENVVAL() because it is too short.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 17:36:36 +00:00
ko1 a82ce7c556 * vm.c: refactoring Proc/Env related code.
* vm_core.h: remove blockprocval field from rb_proc_t and rb_binding_t.
  Instead of this field, mark given block in Proc at rb_env_t::env.
* vm.c (vm_make_env_each): make an Env object with this layout.
  And also simplify parameters.
* proc.c: catch up this fix.
* vm_core.h: remove rb_env_t::local_size because it is not used.
* vm_dump.c (rb_vmdebug_env_dump_raw): catch up this fix.
* vm_core.h (rb_vm_make_env_object): remove rb_vm_make_env_object()
  because it is only refered from vm.c.
* vm_eval.c (eval_string_with_cref): catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 16:23:17 +00:00
ko1 d53e1a7937 * vm_core.h: remove rb_call_info_t::klass because
rb_callable_method_entry_t has information about defined class.
* vm_insnhelper.c (vm_search_method): don't set ci->klass because
  it is removed.
* vm_insnhelper.c (rb_equal_opt): ditto.
* vm_insnhelper.c (vm_search_superclass): removed because it is too
  simple to write code directly.
* vm_insnhelper.c (vm_defined): don't use vm_search_superclass().
  This fix avoid searching current callable `me' twice.
* vm_insnhelper.c (vm_search_super_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-09 02:10:51 +00:00
ko1 dc2eb0c653 * vm_core.h (rb_control_frame_t): fix comments (layout index).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-09 00:35:47 +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 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 ce45744254 * vm_core.h: remove a useless declaration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 18:48:10 +00:00