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

191 Коммитов

Автор SHA1 Сообщение Дата
ko1 9eba45a72a * vm_core.h, vm_insnhelper.c, vm_eval.c (OPT_CALL_CFUNC_WITHOUT_FRAME):
add a new otpimization and its macro `OPT_CALL_CFUNC_WITHOUT_FRAME'.
  This optimization makes all cfunc method calls `frameless', which
  is fster than ordinal cfunc method call.
  If `frame' is needed (for example, it calls another method with
  `rb_funcall()'), then build a frame. In other words, this
  optimization delays frame building.
  However, to delay the frame building, we need additional overheads:
  (1) Store the last call information.
  (2) Check the delayed frame buidling before the frame is needed.
  (3) Overhead to build a delayed frame.
  rb_thread_t::passed_ci is storage of delayed cfunc call information.
  (1) is lightweight because it is only 1 assignment to `passed_ci'.
  To achieve (2), we modify GET_THREAD() to check `passed_ci' every
  time. It causes 10% overhead on my envrionment.
  This optimization only works for cfunc methods which do not need
  their `frame'.
  After evaluation on my environment, this optimization does not
  effective every time. Because of this evaluation results, this
  optimization is disabled at default.
* vm_insnhelper.c, vm.c: add VM_PROFILE* macros to measure behaviour
  of VM internals. I will extend this feature.
* vm_method.c, method.h: change parameters of the `invoker' function.
  Receive `func' pointer as the first parameter.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23 04:22:31 +00:00
ktsj f21d7d9831 * vm_core.h (rb_vm_t::trace_running): add a new field
`trace_running' to store vm global tracing status.

* vm_trace.c: fix SEGV bug. event_hook was free'd
  even when the hook is still used in another thread.
  [ruby-dev:46141] [Bug #7032]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-21 10:14:26 +00:00
ktsj 93184600c8 * vm_core.h (rb_vm_t::trace_flag): remove `trace_flag'
which is no longer used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-21 10:14:24 +00:00
ko1 f4dbc7a384 * method.h (rb_method_cfunc_t::invoker): add new field (func ptr)
`invoker'. `invoker' function invoke cfunc body
  (rb_method_cfunc_t::func).
  `invoker' is set at method definition timing.
  With this change, the big `switch' (branch) in `call_cfunc()'
  is no longer needed.
  However, the performance benefit is only a bit.
* vm_core.h (rb_call_info_t::aux::func): add a new field to store
  cfunc body function pointer.
* vm_method.c (call_cfunc_invoker_func): add a new function which
  returns a suitable invoke function.
* vm_method.c (setup_method_cfunc_struct): added.
* vm_method.c (rb_add_method): fix to set `invoker'.
* vm_eval.c (vm_call0_body): catch up above changes.
* vm_insnhelper.c (call_cfunc): removed.
* vm_insnhelper.c (vm_call_cfunc): fix to call cfunc body
  with `invoker' function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-19 10:38:30 +00:00
ko1 9a82db49eb * vm_insnhelper.c (vm_call_method_missing): make a refactoring
about method_missing process. Use `vm_call_method()' to invoke
  `method_missing' method instead of `rb_funcall2()'.
  In `vm_call_method()', set fastpath to `vm_call_method_missing()'
  if it can be cached.
* vm_core.h (rb_call_info_t): add new field
  `rb_call_info_t::aux::missing_reasion' to pass the reason to
  `vm_call_method_missing()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-17 07:12:40 +00:00
ko1 db1e99cdad * vm_insnhelper.c (vm_getivar, vm_setivar): support index inline cache
with rb_call_info_t to speedup `attr' getter and setter.
  Cached index is stored in rb_call_info_t::aux::index.
  `index' == 0 means not cached. `index' > 0 means cached and cached
  index is `index - 1'.
* insns.def ((get|set)instancevariable): use new wrapper functions
  vm_(get|set)instancevariable() defined in vm_insnhelper.c.
* vm_core.h (rb_call_info_t::aux): introduce new union data because
  opt_pc can share with index.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16 17:07:23 +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
ko1 8f08e61bad * vm_insnhelper.c: refactoring.
- move all `call' related functions to the last of file.
  - make functions for respective method types in vm_call_method().
  (all functions have same function parameters)
* vm_core.h: add `opt_pc' filed in `rb_call_info_t'
  as temporal variable.
* vm_eval.c (vm_call0_body): catch up above cahnges.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 19:58:59 +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 64f5b6aedc * vm_core.h: now VM_DEBUG_BP_CHECK should be 1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28 04:16:59 +00:00
ko1 d50483df23 * vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).
`bp' can be calculate by `sp' (stack pointer) of previous frame.
  Now, `bp_check' field is remained for debug.  You can eliminate
  this field by setting  VM_DEBUG_BP_CHECK as 0.
* vm_insnhelper.c (vm_base_ptr): add `vm_base_ptr(cfp).
  This function calculates base pointer from cfp.
* vm_insnhelper.c (vm_setup_method): push `recv' value on top of
  value stack (before method parameters).
  This change is for keeping consistency with normal method dispatch.
* insns.def: fix to use vm_base_ptr().
* vm.c (vm_exec): ditto.
* vm_dump.c: remove `bp' related dumps.
* cont.c (fiber_init): fix to check VM_DEBUG_BP_CHECK.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28 04:05:36 +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
nobu 68f3ece33f suppress warnings
* insns.def (checkmatch): suppress warnings.  [ruby-core:47310]
  [Bug #6930]
* vm_core.h (VM_FRAME_TYPE_FINISH_P): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-26 07:53:21 +00:00
nobu ceece4650a vm_insnhelper.c: iclass as klass in cfp
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp
  but not included modules.  [ruby-core:47241] [Bug #6891]
* vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow
  proper ancestors.  [ruby-core:47241] [Bug #6891]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20 11:36:34 +00:00
ko1 4a4a702e61 * vm_trace.c, vm_core.h: simplify tracing mechanism.
(1) add rb_hook_list_t data structure which includes
  hooks, events (flag) and `need_clean' flag.
  If the last flag is true, then clean the hooks list.
  In other words, deleted hooks are contained by `hooks'.
  Cleanup process should run before traversing the list.
  (2) Change check mechanism
  See EXEC_EVENT_HOOK() in vm_core.h.
  (3) Add `raw' hooks APIs
  Normal hooks are guarded from exception by rb_protect().
  However, this protection is overhead for too simple
  functions which never cause exceptions.  `raw' hooks
  are executed without protection and faster.
  Now, we only provide registration APIs.  All `raw'
  hooks are kicked under protection (same as normal hooks).
* include/ruby/ruby.h: remove internal data definition and
  macros.
* internal.h (ruby_suppress_tracing), vm_trace.c: rename
  ruby_suppress_tracing() to rb_suppress_tracing()
  and remove unused function parameter.
* parse.y: fix to use renamed rb_suppress_tracing().
* thread.c (thread_create_core): no need to set RUBY_VM_VM.
* vm.c (mark_event_hooks): move definition to vm_trace.c.
* vm.c (ruby_vm_event_flags): add a global variable.
  This global variable represents all of Threads and VM's
  event masks (T1#events | T2#events | ... | VM#events).
  You can check the possibility kick trace func or not
  with ruby_vm_event_flags.
  ruby_vm_event_flags is maintained by vm_trace.c.
* cont.c (fiber_switch, rb_cont_call): restore tracing status.
  [Feature #4347]
* test/ruby/test_continuation.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16 11:41: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
ko1 0d1a905edb * vm_exec.c, insns.def (leave): solve problems on
OPT_CALL_THREADED_CODE.
  Catch up finish frame structure on OPT_CALL_THREADED_CODE.
* vm_core.h: add rb_thread_t#retval for temporary space on
  OPT_CALL_THREADED_CODE.
* vm.c (th_init): clear rb_thread_t#retval as Qundef.
* vm_dump.c (rb_vmdebug_debug_print_pre): fix debug print format.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-07 11:13:57 +00:00
shugo 319088e9c7 * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: add klass to
  rb_control_frame_t to implement super correctly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:08:44 +00:00
ko1 f4a8db647a * thread.c (rb_thread_s_control_interrupt,
rb_thread_s_check_interrupt): added for
  Thread.control_intgerrupt and Thread.check_interrupt.
  See details on rdoc.
  I'll make an ticket for this feature.
* test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt.
* thread.c (rb_threadptr_raise): make a new exception object
  even if argc is 0.
* thread.c (rb_thread_kill): kill thread immediately if target thread
  is current thread.
* vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added.
  CHECK_INTS while/after blocking operation.
* vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr.
* cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS().
* eval.c (ruby_cleanup): ditto.
* insns.def: ditto.
* process.c (rb_waitpid): ditto.
* vm_eval.c (vm_call0): ditto.
* vm_insnhelper.c (vm_call_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19 14:19:40 +00:00
ko1 28144433b2 * thread.c (rb_threadptr_async_errinfo_*): manage async errors queue.
Async events such as an exception throwed by Thread#raise,
  Thread#kill and thread termination (after main thread termination)
  will be queued to th->async_errinfo_queue.
  - clear: clear the queue.
  - enque: enque err object into queue.
  - deque: deque err object from queue.
  - active_p: return 1 if the queue should be checked.
  rb_thread_t#thrown_errinfo was removed.
* vm_core.h: add declarations of rb_threadptr_async_errinfo_*.
  remove rb_thread_t#thrown_errinfo field and
  add rb_thread_t#async_errinfo_queue (queue body: Array),
  rb_thread_t#async_errinfo_queue_checked (flag),
  rb_thread_t#async_errinfo_mask_stack(Array, not used yet).
* vm.c (rb_thread_mark): fix a mark function.
* cont.c (rb_fiber_start): enque an error.
* process.c (after_fork): clear async errinfo queue.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 05:46:40 +00:00
ko1 c4bc9b5758 * iseq.c, vm_eval.c: set th->base_block properly.
th->base_block is information for (a) parsing, (b) compiling
  and (c) setting up the frame to execute the program passed by
  `eval' method.  For example, (1) parser need to know up-level
  variables to detect it is variable or method without paren.
  Befor (a), (b) and (c), VM set th->base_block by passed bindng
  (or previous frame information).  After execute (a), (b) and (c),
  VM should clear th->base_block.  However, if (a), (b) or (c)
  raises an exception, then th->base_block is not cleared.
  Problem is that the uncleared value th->balo_block is used for
  irrelevant iseq compilation.  It causes SEGV or critical error.
  I tried to solve this problem: to clear them before exception,
  but finally I found out that it is difficult to do it (Ruby
  program can be run in many places).
  Because of this background, I set th->base_block before
  compiling iseq and restore it after compiling.
  Basically, th->base_block is dirty hack (similar to global
  variable) and this patch is also dirty.
* bootstraptest/test_eval.rb: add a test for above.
* internal.h: remove unused decl.
* iseq.c (rb_iseq_compile_with_option): add base_block parameter.
  set th->base_block before compation and restore it after
  compilation.
* ruby.c (require_libraries): pass 0 as base_block instead of
  setting th->base_block
* tool/compile_prelude.rb (prelude_eval): apply above changes.
* vm.c, vm_eval.c: ditto.
* vm_core.h: add comments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 09:32:56 +00:00
ko1 745c23b2d9 * vm_core.h: remove VM_FRAME_MAGIC_FINISH (finish frame type).
Before this commit:
  `finish frame' was place holder which indicates that VM loop
  needs to return function.
  If a C method calls a Ruby methods (a method written by Ruby),
  then VM loop will be (re-)invoked.  When the Ruby method returns,
  then also VM loop should be escaped.  `finish frame' has only
  one instruction `finish', which returns VM loop function.
  VM loop function executes `finish' instruction, then VM loop
  function returns itself.
  With such mechanism, `leave' instruction (which returns one
  frame from current scope) doesn't need to check that this `leave'
  should also return from VM loop function.
  Strictly, one branch can be removed from `leave' instructon.
  Consideration:
  However, pushing the `finish frame' needs costs because
  it needs several memory accesses.  The number of pushing
  `finish frame' is greater than I had assumed.  Of course,
  pushing `finish frame' consumes additional control frame.
  Moreover, recent processors has good branch prediction,
  with which we can ignore such trivial checking.
  After this commit:
  Finally, I decide to remove `finish frame' and `finish'
  instruction.  Some parts of VM depend on `finish frame',
  so the new frame flag VM_FRAME_FLAG_FINISH is introduced.
  If this frame should escape from VM function loop, then
  the result of VM_FRAME_TYPE_FINISH_P(cfp) is true.
  `leave' instruction checks this flag every time.
  I measured performance on it.  However on my environments,
  it improves some benchmarks and slows some benchmarks down.
  Maybe it is because of C compiler optimization parameters.
  I'll re-visit here if this cause problems.
* insns.def (leave, finish): remove finish instruction.
* vm.c, vm_eval.c, vm_exec.c, vm_backtrace.c, vm_dump.c:
  apply above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-15 10:22:34 +00:00
nobu 073297789a fix r36079
* include/ruby/ruby.h: public symbols must have default visibility.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-14 03:03:48 +00:00
yugui f8601bd903 * eval.c: Add doxygen comments.
* ruby.c: ditto.

* thread_pthread.c: ditto

* version.c: ditto.

* vm_core.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-14 02:21:51 +00:00
ko1 0a71db8a74 * vm_core.h: remove lfp (local frame pointer) and rename
dfp (dynamic frame pointer) to ep (environment pointer).
  This change make VM `normal' (similar to other interpreters).
  Before this commit:
  Each frame has two env pointers lfp and dfp.  lfp points
  local environment which is method/class/toplevel frame.
  lfp[0] is block pointer.
  dfp is block local frame. dfp[0] points previous (parent)
  environment pointer.
  lfp == dfp when frame is method/class/toplevel.
  You can get lfp from dfp by traversing previous environment
  pointers.
  After this commit:
  Each frame has only `ep' to point respective enviornoment.
  If there is parent environment, then ep[0] points parent
  envioenment (as dfp).  If there are no more environment,
  then ep[0] points block pointer (as lfp).  We call such ep
  as `LEP' (local EP).  We add some macros to get LEP and to
  detect LEP or not.
  In short, we replace dfp and lfp with ep and LEP.
  rb_block_t and rb_binding_t member `lfp' and `dfp' are removed
  and member `ep' is added.
  rename rb_thread_t's member `local_lfp' and `local_svar' to
  `root_lep' and `root_svar'.
  (VM_EP_PREV_EP(ep)): get previous environment pointer.  This macro
  assume that ep is not LEP.
  (VM_EP_BLOCK_PTR(ep)): get block pointer.  This macro assume
  that ep is LEP.
  (VM_EP_LEP_P(ep)): detect ep is LEP or not.
  (VM_ENVVAL_BLOCK_PTR(ptr)): make block pointer.
  (VM_ENVVAL_BLOCK_PTR_P(v)): detect v is block pointer.
  (VM_ENVVAL_PREV_EP_PTR(ptr)): make prev environment pointer.
  (VM_ENVVAL_PREV_EP_PTR_P(v)): detect v is prev env pointer.
* vm.c: apply above changes.
  (VM_EP_LEP(ep)): get LEP.
  (VM_CF_LEP(cfp)): get LEP of cfp->ep.
  (VM_CF_PREV_EP(cfp)): utility function VM_EP_PREV_EP(cfp->ep).
  (VM_CF_BLOCK_PTR(cfp)): utility function VM_EP_BLOCK_PTR(cfp->ep).
* vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, insns.def:
  apply above changes.
* cont.c: ditto.
* eval.c, eval_intern.h: ditto.
* proc.c: ditto.
* thread.c: ditto.
* vm_dump.c: ditto.
* vm_exec.h: fix function name (on vm debug mode).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11 03:14:59 +00:00
ko1 06513cc1cf * vm_insnhelper.h: remove magical code "lfp[0] & 0x02".
Current VM doesn't use this bit.
* vm_core.h (RUBY_VM_GET_BLOCK_PTR): added.
* eval.c (rb_block_given_p): use RUBY_VM_GET_BLOCK_PTR().
* vm_eval.c (rb_f_block_given_p): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 07:24:44 +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 b57c81ae3e * common.mk: fix to build vm_backtrace.c only itself (vm_backtrace.c
is no longer included from vm.c).  I hope this separation reduce
  compile time of vm.c.
* internal.h: ditto.
* vm.c, vm_core.h, vm_dump.c, vm_eval.c: ditto.
* vm_eval.c: some functions (callee, etc) moved to vm_backtrace.c.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-02 15:59:37 +00:00
ko1 1f3142a447 * vm.c: refactoring backtrace related funcitons.
(1) unify similar functions (rb_backtrace_each() and
  backtrace_object()).  backtrace_each() is a unified function.
  variation:
  a) backtrace_object(): create backtrace object.
  b) vm_backtrace_str_ary(): create bt as an array of string.
  c) vm_backtrace_print(): print backtrace to specified file.
  d) rb_backtrace_print_as_bugreport(): print backtrace on
  bugreport style.
  (2) remove rb_backtrace_each().  Use backtrace_each() instead.
  (3) chang the type of lev parameter to size_t.
  a) lev == 0 means current frame (exception, etc use it).
  b) lev == 1 means upper frame (caller(0) use it).
* vm_core.h, vm_dump.c, vm_eval.c: ditto.
* vm.c (backtrace_object(), vm_backtrace_str_ary()): fix to return a
  correct size of caller(lev) array.
  Let n be a "caller(0).size" then ln as caller(lev).size should be
  (n - lev).  However, the previous implementation returns a wrong
  size array (ln > n - lev).  [ruby-dev:45673]
* test/ruby/test_backtrace.rb: add tests for backtrace.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25 04:50:10 +00:00
nobu cb61ea5ef3 remove trailing spaces
* vm_core.h (rb_iseq_struct): remove trailing spaces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-22 13:20:52 +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
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
ko1 6978b8ca67 * vm_core.h (rb_thread_t#yielding): add a field.
* thread.c (rb_thread_schedule_limits): set th#yielding while
  release GVL to yield CPU time.
* thread.c (timer_thread_function): skip timer interrupt when
  th#yielding is true.  This patch fixes r35480.
* thread.c (rb_threadptr_execute_interrupts_common): revert
  a patch of r35480.
* ChangeLog: add an extended memo of r35480.
  http://bugs.ruby-lang.org/projects/ruby-trunk/wiki/R35480_ExtendedMemo



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-28 09:59:44 +00:00
nobu e2ca7837d1 * iseq.c (rb_iseq_first_lineno): constified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 03:00:00 +00:00
marcandre 6c38e611e4 * vm_core.h: Fix comment about arg_opts of iseq and some typos
* doc/re.rdoc: Rdoc small fixes

* iseq.c: Fix comment

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-30 05:55:37 +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
nobu eb21db77c0 * vm_core.h (ruby_current_thread): probeprofiler has been removed
long ago.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-18 14:07:32 +00:00
ktsj 0971109e3d * vm.c (rb_vm_rewrite_dfp_in_errinfo): change return type
to suppress a warning.

* vm_core.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-27 11:51:02 +00:00
ktsj a09e7139a3 * proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
[Bug #5234] [ruby-core:39125]
  This code will be removed after changing throw mechanism (see r33064).

* vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

* vm.c (vm_make_env_each): changed accordingly.

* vm_core.h: ditto.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-27 09:59:48 +00:00
ko1 5d486bec61 * vm_core.h: add a decl. of rb_autoloading_value().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-26 19:03:21 +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
nobu 0dee7247a7 * vm.c (ruby_threadptr_data_type): rename to hide.
[ruby-core:38972]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-16 09:56:56 +00:00
kosaki ac397a9eee * vm_core.h (ALT_STACK_SIZE): use MINSIGSTKSZ*2 instead of SIGSTKSZ*2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 02:22:51 +00:00
kosaki 18bc6c31a1 * vm.c (th_init): preallocate alternative stack.
NoMemoryError is better than rb_bug, of course.
  Patch by Eric Wong. [ruby-core:38572][ruby-core:38594].

* signal.c (rb_register_sigaltstack): ditto.

* vm_core.h: moved ALT_STACK_SIZE definition from signal.c.
* vm.c (thread_free): use xfree() instead of free().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 01:57:06 +00:00
mame 9a27239558 * proc.c (struct METHOD), gc.c (gc_marks), vm_method.c
(rb_gc_mark_unlinked_live_method_entries): fix SEGV bug.
  rb_method_entry_t was free'd even when the method is still on the
  stack if it is BMETHOD (i.e., Method#call).  This is because
  rb_method_entry_t is embedded in struct METHOD.  This commit
  separates them and marks the live method entries.
  See [ruby-core:38449] in detail.  fix [Bug #5047] [ruby-core:38171]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-25 14:29:28 +00:00
kosaki 74b339e938 * thread_pthread.c (rb_thread_create_timer_thread): removed
rb_disable_interrupt()/rb_enable_interrupt().
* vm_core.h: ditto.
* process.c (static void before_exec): ditto.
* process.c (static void after_exec): ditto.
  [Bug #4765] [ruby-dev:43571]

* eval_intern.h: removed rb_trap_restore_mask().
* vm_eval.c (rb_throw_obj): ditto.
* eval.c (setup_exception): ditto.

* signal.c: removed trap_last_mask.
* signal.c (trap_restore_mask): removed.
* signal.c (init_sigchld): comment clarification why signal block
  is needed. and removed trap_last_mask operation.
* signal.c (trap_ensure): removed trap_last_mask operation.

* signal.c (rb_disable_interrupt, rb_enable_interrupt): made
  static and removed sigdelset(SIGVTALARM) and sigdelset(SIGSEGV).

* process.c (rb_syswait): removed implicit signal handler change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 17:04:40 +00:00
kosaki a119b9d146 * vm_core.h (typedef struct rb_vm_struct): create a new
'inhibit_thread_createion' field.
* thread.c (rb_thread_terminate_all): set inhibit_thread_creation.
* thread.c (thread_s_new): don't permit to create new thread
  if the VM is under destruction. Otherwise evil finalizer code
  can make SEGV. [Bug #4992][ruby-core:37858]

* bootstraptest/test_objectspace.rb: new test for this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 07:46:00 +00:00
kosaki 8741274529 * thread.c (thread_unlock_all_locking_mutexes): rename to
rb_threadptr_unlock_all_locking_mutexes and remove static.
* vm_core.h: add rb_threadptr_unlock_all_locking_mutexes declaration.
* thread.c (thread_start_func_2): adjust the above rename.

* eval.c (ruby_cleanup): call rb_threadptr_unlock_all_locking_mutexes
  again after finalizer. [Bug #4988] [ruby-dev:44049]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 04:40:01 +00:00