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

390 Коммитов

Автор SHA1 Сообщение Дата
nobu 228b29a697 load.c: loaded_features_index st_table
* load.c (rb_feature_p), vm_core.h (rb_vm_struct): turn
  loaded_features_index into st_table.  patches by tmm1 (Aman Gupta)
  in [ruby-core:53251] and [ruby-core:53274] [Bug #8048]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-22 08:38:51 +00:00
nobu 2d1c94a18d prefix global symbols
* iseq.c (rb_insn_operand_intern): prefix global symbols.

* numeric.c (ruby_num_interval_step_size): ditto.

* vm_backtrace.c (rb_vm_backtrace_str_ary),
  (rb_vm_backtrace_location_ary, rb_vm_thread_backtrace),
  (rb_vm_thread_backtrace_locations): ditto.

* vm_trace.c (rb_vm_trace_mark_event_hooks): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-06 06:30:03 +00:00
nobu f113ab552c class.c: check redefinition
* class.c (rb_prepend_module): check redefinition of built-in opimized
  methods.  [ruby-dev:47124] [Bug #7983]
* vm.c (rb_vm_check_redefinition_by_prepend): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 12:36:45 +00:00
zzak b8e24f19b5 * vm.c: Typo in overview for example of Thread#status returning false
Reported by Lee Jarvis


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 17:43:25 +00:00
eregon 20514a0893 * vm.c (Thread): fix typos in overview
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 10:54:11 +00:00
zzak 6c9fdc616a * vm.c (Thread): Typo in overview, swap setting and getting
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 04:22:08 +00:00
zzak ab0d28c1bd * vm.c (Thread): Documentation overview of Thread class
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-27 04:02:06 +00:00
ktsj 16aedfe0a0 * vm.c (ENV_IN_HEAP_P): fix off-by-one error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 11:58:33 +00:00
ko1 b4add2ac2b * vm.c (rb_thread_mark): mark a working Proc of bmethod
(a method defined by define_method) even if the method was removed.
  We could not trace working Proc object which represents the body
  of bmethod if the method was removed (alias/undef/overridden).
  Simply, it was mark miss.
  This patch by Kazuki Tsujimoto. [Bug #7825]
  NOTE: We can brush up this marking because we do not need to mark
  `me' on each living control frame. We need to mark `me's
  only if `me' was free'ed. This is future work after Ruby 2.0.0.
* test/ruby/test_method.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 07:41:55 +00:00
ktsj ca016c705f * vm.c (rb_vm_stack_to_heap): call rb_vm_get_binding_creatable_next_cfp
instead of rb_vm_get_ruby_level_next_cfp to prevent a segfault by
  calling Kernel#callcc. See r39067 for more details.
  [ruby-dev:46908] [ruby-trunk - Bug #7774]

* test/ruby/test_settracefunc.rb: add a test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 15:55:41 +00:00
ko1 88101695ab * proc.c (rb_binding_new_with_cfp): permit to create binding object
of IFUNC frame.
  When `rb_binding_new_with_cfp()' is called, VM finds out the first
  normal (has iseq) frame and create a binding object of this frame
  and create Env objects. `ep's of related frames are updated
  (`ep's point Env object managed spaces).
  However, `ep' of skipped IFUNC frame was not updated and
  old invalid `ep' was remained. It causes serious problems.
  To solve this issue, permit IFUNC to create binding.
  (Maybe there is no problem on it)
  [ruby-dev:46908] [ruby-trunk - Bug #7774]
* test/ruby/test_settracefunc.rb: add a test.
* vm.c (rb_vm_get_binding_creatable_next_cfp), vm_core.h: added.
* vm_trace.c: fix to use `rb_vm_get_binding_creatable_next_cfp()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 06:04:59 +00:00
ko1 18e01f6381 * vm_backtrace.c: fix issue of rb_debug_inspector_open().
The order of making binding should be stack (frame) top to bottom.
  [Bug #7635]
  And also fix issue of collecting klass. Collecting klass is same
  as TracePoint#defined_class.
  (previous version, it returns T_ICLASS (internal objects).
* test/-ext-/debug/test_debug.rb: add a test.
* ext/-test-/debug/extconf.rb, init.c, inspector.c: ditto.
* vm_backtrace.c: remove magic number and add enum CALLER_BINDING_*.
* vm_backtrace.c, include/ruby/debug.h: add new C api (experimental)
  rb_debug_inspector_frame_self_get().
* vm.c, vm_core.h, vm_trace.c: move decl. of
  rb_vm_control_frame_id_and_class() and constify first parameter.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29 08:25:32 +00:00
nobu 4e323c0a9d vm.c: initialize root_svar
* vm.c (th_init, ruby_thread_init): initialize root_svar with Qnil,
  since lep_svar_place() expects uninitialized svar to be nil, not 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-09 06:40:30 +00:00
nobu d00b1a7687 vm.c: suppress warning
* vm.c (check_machine_stack_size): ifdef a variable which is unused on
  non-pthread platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-28 03:03:19 +00:00
ko1 c2693f8bd6 * vm_trace.c (rb_threadptr_exec_event_hooks_and_pop_frame):
pop a frame before JUMP_TAG() if exception occurred.
  This change fix bug of Ruby 1.9.
  [ruby-core:51128] [ruby-trunk - Bug #7624]
* vm_core.h (EXEC_EVENT_HOOK_AND_POP_FRAME): add to use
  `rb_threadptr_exec_event_hooks_and_pop_frame()'.
* vm.c (vm_exec): use EXEC_EVENT_HOOK_AND_POP_FRAME() while
  exception handling. While exception hadnling, if an exception
  is raised in hooks, need to pop current frame and raise this
  raised exception by hook.
* test/ruby/test_settracefunc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25 13:24:17 +00:00
ko1 270fbd9c05 * vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): move
CHECK_STACK_OVERFLOW() to vm_core.h and rename to
  CHECK_VM_STACK_OVERFLOW().
  This change is only move and rename.
* tool/instruction.rb: catch up above changes.
* vm.c, vm_insnhelper.c: ditto.
* vm_insnhelper.c (vm_stackoverflow): add a function to unify
  raising vm stackoverflow exception.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25 09:57:07 +00:00
ko1 0f9b33c793 * thread.c: rename methods:
from Thread.async_interrupt_timing to Thread.handle_interrupt,
  from Thread.async_interrupted? to Thread.pending_interrupt?.
  Also rename option from `defer' to `never'.
  [ruby-core:51074] [ruby-trunk - Feature #6762]
* vm_core.c, thread.c: rename functions and data structure
  `async_errinfo' to `pending_interrupt'.
* thread.c: add global variables sym_immediate, sym_on_blocking and
  sym_never.
* cont.c, process.c, vm.c, signal.c: ditto.
* lib/sync.rb, lib/thread.rb: catch up this renaming.
* test/ruby/test_thread.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-23 10:18:58 +00:00
nagachika 6a35c26b2d * cont.c (rb_fiber_start): in case of jump with TAG_FATAL,
enqueue error into async_errinfo_queue, because you cannot call
  TH_TAG_JUMP() in this function. [ruby-dev:45218]  [Bug #5993]

* thread.c (rb_threadptr_execute_interrupts): now INT2FIX(TAG_FATAL)
  can be popped from async_errinfo_queue.

* vm.c (rb_vm_make_jump_tag_but_local_jump): revert r38441.
  rb_vm_make_jump_tag_but_local_jump() shouldn't return exception
  in case of state == TAG_FATAL.

* test/ruby/test_fiber.rb (test_exit_in_fiber): fix a test to illuminate
  Thread.exit should terminate current Thread.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22 06:45:28 +00:00
nobu 3ec171510e vm.c: fix format
* vm.c (get_param): fix format specifier for size_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 01:52:50 +00:00
ko1 87e1616048 * vm.c: support variable VM/Machine stack sizes.
Specified by the following environment variaables:
  - RUBY_THREAD_VM_STACK_SIZE: vm stack size used at thread creation.
  default: 128KB (32bit CPU) or 256KB (64bit CPU).
  - RUBY_THREAD_MACHINE_STACK_SIZE: machine stack size used at thread
  creation. default: 512KB or 1024KB.
  - RUBY_FIBER_VM_STACK_SIZE: vm stack size used at fiber creation.
  default: 64KB or 128KB.
  - RUBY_FIBER_MACHINE_STACK_SIZE: machine stack size used at fiber
  creation. default: 256KB or 256KB.
  This values are specified at launched timing. You can not change
  these values at running time.
  Environ variables are only *hints* because:
  - They are aligned to 4KB.
  - They have minimum values (depend on OSs).
  - Machine stack settings are ignored by some OSs.
  Default values especially fiber stack sizes are increased.
  This change affect Fiber's behavior:
  (1) You can run more complex program on a Fiber.
  (2) You can not make many (thousands) Fibers because of
  lack of address space (on 32bit CPU).
  If (2) bothers you,
  (a) Use 64bit CPU with big memory, or
  (b) Specify RUBY_FIBER_(VM|MACHINE)_STACK_SIZE correctly.
  You need to choose correct stack size carefully. These values
  are completely rely on systems (OS/compiler and so on).
* vm_core.h (rb_vm_t::default_params): add to record above settings.
* vm.c (RubyVM::DEFAULT_PARAMS): add new constant to see
  above setting.
* thread_pthread.c: support RUBY_THREAD_MACHINE_STACK_SIZE.
* cont.c: support RUBY_FIBER_(VM|MACHINE)_STACK_SIZE.
* test/ruby/test_fiber.rb: add tests for above.
* test/ruby/test_thread.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-19 22:29:18 +00:00
nagachika 26221584a9 * vm.c (rb_vm_jump_tag_but_local_jump): remove unnessesary 2nd
argument.

* load.c (rb_load_internal): ditto.

* eval_intern.h (rb_vm_jump_tag_but_local_jump): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 17:04:05 +00:00
nagachika 606b66db7d * vm.c (rb_vm_make_jump_tag_but_local_jump): take care of the case
TAG_JUMP() with TAG_FATAL (ex. rb_fatal()).

* test/ruby/test_fiber.rb (test_fatal_in_fiber): add a test for above.

* ext/-test-/fatal/extconf.rb, ext/-test-/fatal/rb_fatal.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 04:30:44 +00:00
kosaki aff9dff46d * signal.c (rb_sigaltstack_size): new. calculate stack size for
sigsegv handler. enlarge value when x86 or x86_64 on Linux.
  Linux has very small MINSIGSTKSZ size (2048 bytes) and
  our sigsegv routine need 5KiB at least. [Bug #7141]
* internal.h: add declaration of rb_sigaltstack_size().
* vm_core.h: remove ALT_STACK_SIZE definition.

* signal.c (rb_register_sigaltstack): replace ALT_STACK_SIZE with
  rb_sigaltstack_size();
* gc.c (Init_heap): ditto.
* vm.c (th_init): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 14:20:12 +00:00
nobu 63d0ea4c03 vm.c: pass exceptions while handling an exception
* vm.c (vm_exec): pass exceptions while handling an exception.
* vm_trace.c (rb_threadptr_exec_event_hooks): propagate exceptions.
  revert r38293 partially.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11 18:45:43 +00:00
nobu b949447a49 probes_helper.h: RUBY_DTRACE_HOOK
* probes_helper.h (RUBY_DTRACE_HOOK): surround with do..while.

* vm.c (vm_exec): supply semicolon.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11 03:37:19 +00:00
shugo 60d6038dda * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
  definition, so ci->me is set to a method entry allocated in the
  stack, and it causes SEGV/ILL.  In this commit, a method entry
  with VM_METHOD_TYPE_REFINED holds the whole original method entry.
  Furthermore, rb_thread_mark() is changed to mark cfp->klass to
  avoid GC for iclasses created by copy_refinement_iclass().

* vm_method.c (rb_method_entry_make): add a method entry with
  VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_me) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
  copy_refinement_iclass().

* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 13:08:41 +00:00
nobu 31e6f72c8e vm.c: save blockprocval
* vm.c (rb_vm_make_proc): save the proc made from the given block so
  that it will not get collected.  [ruby-core:50545] [Bug #7507]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-05 13:46:11 +00:00
nobu 66fd9d44d8 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01 15:25:28 +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
tenderlove 9709448474 * vm.c: add a return hook when a method raises an exception.
* probes_helper.h: look up klass and method if none are provided.

* eval.c: update macro usage.

* vm_eval.c: ditto.

* vm_insnhelper.c: ditto.

* test/dtrace/test_function_entry.rb: test for change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 17:55:54 +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
ko1 585ac7f1a2 * include/ruby/debug.h: add rb_debug_inspector_* APIs.
* vm_backtrace.c: ditto.
* common.mk: add dpendency from vm_backtrace.o to
  include/ruby/debug.h.
* proc.c (rb_binding_new_with_cfp): constify.
* vm.c (rb_vm_get_ruby_level_next_cfp): consitify.
* vm_core.h, vm_trace.c: move decls.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 07:05:27 +00:00
tenderlove 4bdd909518 * probes.d: Change function-entry probe to method-entry.
* insns.def: ditto
* probes_helper.h: ditto
* test/dtrace/test_function_entry.rb: ditto
* test/dtrace/test_singleton_function.rb: ditto
* vm.c: ditto
* vm_eval.c: ditto
* vm_insnhelper.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 20:20:50 +00:00
ko1 956cc2934d * vm.c (rb_vm_make_env_object): make Proc object if Env is possible
to point block.
  [ruby-core:41038] [ruby-trunk - Bug #5634]
* vm.c (rb_vm_make_proc): No need to make Proc object here.
* bootstraptest/test_proc.rb: add tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 11:58:10 +00:00
kosaki 4d7e8b7305 * Makefile.in: run preprocessor when making probe.h
* probes.d: define probe insn and insn__operand only when
  VM_COLLECT_USAGE_DETAILS is 1. [Bug #7370]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 08:01:49 +00:00
kosaki 82e7d00344 * vm.c: Don't define vm_collect_usage_operand() and
static void vm_collect_usage_insn() when disabling
  VM_COLLECT_USAGE_DETAILS. (refix r37796)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 07:23:40 +00:00
ko1 553931962a * vm_trace.c: add two methods:
(1) TracePoint#return_value which returns return
  value on the :return and :c_return event.
  (2) TracePoint#raised_exception which returns raised exception
  value on the :raise event.
  Eeach methods raise RuntimeError if it is called at unsupported
  event.
  Please review and give us feedback until next preview
  release (Dec/2012) of Ruby 2.0.0.
* insns.def, vm.c, vm_eval.c, vm_insnhelper.c, eval.c, thread.c:
  ditto.
* vm_trace.c, vm_core.h: move definition of rb_trace_arg_t from
  vm_trace.c to vm_core.h.
  Caller fills rb_trace_arg_t and pass the pointer of this variable.
* test/ruby/test_settracefunc.rb: fix tests to test this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 09:48:24 +00:00
ngoto 979dff3ee4 * vm_core.h, probes_helper.h (RUBY_DTRACE_FUNC_ENTRY_HOOK,
RUBY_DTRACE_FUNC_RETURN_HOOK): move from vm_core.h to new file
  probes_helper.h for narrowing dependency to probes.h.
* common.mk (VM_CORE_H_INCLUDES): remove dependency to probes.h.
* common.mk (vm.$(OBJEXT)): add dependency to probes_helper.h.
* vm.c, vm_insnhelper.c: include probes_helper.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-18 16:30:10 +00:00
nobu ed86cd0536 vm.c: gc guard
* vm.c (vm_collect_usage_operand): prevent from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16 17:02:37 +00:00
nobu b29b2962d2 adjust indent
* object.c (rb_obj_alloc): adjust indent.

* vm.c (vm_collect_usage_{insn,operand,register}): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16 17:02:35 +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
shirosaki d33b9a8a72 Fix compatibility of cached expanded load path
* file.c (rb_get_path_check_to_string): extract from
  rb_get_path_check(). We change the spec not to call to_path of
  String object.

* file.c (rb_get_path_check_convert): extract from rb_get_path_check().

* file.c (rb_get_path_check): follow the above change.

* file.c (rb_file_expand_path_fast): remove check_expand_path_args().
  Instead we call it in load.c.

* file.c (rb_find_file_ext_safe): use rb_get_expanded_load_path() to
  reduce expand cost.

* file.c (rb_find_file_safe): ditto.

* internal.h (rb_get_expanded_load_path): add a declaration.

* internal.h (rb_get_path_check_to_string, rb_get_path_check_convert):
  add declarations.

* load.c (rb_construct_expanded_load_path): fix for compatibility.
  Same checks in rb_get_path_check() are added. We don't replace
  $LOAD_PATH and ensure that String object of $LOAD_PATH are frozen.
  We don't freeze non String object and expand it every times. We add
  arguments for expanding load path partially and checking if load path
  have relative paths or non String objects.

* load.c (load_path_getcwd): get current working directory for checking
  if it's changed when getting load path.

* load.c (rb_get_expanded_load_path): fix for rebuilding cache properly.
  We check if current working directory is changed and rebuild expanded
  load path cache. We expand paths which start with ~ (User HOME) and
  non String objects every times for compatibility. We make this
  accessible from other source files.

* load.c (rb_feature_provided): call rb_get_path() since we changed
  rb_file_expand_path_fast() not to call it.

* load.c (Init_load): initialize vm->load_path_check_cache.

* vm.c (rb_vm_mark): mark vm->load_path_check_cache for GC.

* vm_core.h (rb_vm_struct): add vm->load_path_check_cache to store data
  to check load path cache validity.

* test/ruby/test_require.rb (TestRequire): add tests for require
  compatibility related to cached expanded load path.
  [ruby-core:47970] [Bug #7158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 15:27:08 +00:00
shirosaki 9823c46189 Cache the expanded load path
* load.c (rb_get_expanded_load_path): cache the expanded load
  path.  This saves 4KB of allocation and some stats for every
  element of the load path (so nearly a MB in my Rails app)
  on every require.

* load.c (rb_construct_expanded_load_path): ensure that $LOAD_PATH
  entries are frozen strings.  The user must mutate $LOAD_PATH
  itself rather than its individual entries.

* vm_core.h (rb_vm_struct): add fields.

* vm.c (rb_vm_mark): mark new fields.

* ruby.c (process_options): modify $LOAD_PATH directly rather than
  its elements.
  Patch by Greg Price.
  [ruby-core:47970] [Bug #7158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 15:27:05 +00:00
shirosaki b56a2afc14 Index $LOADED_FEATURES so that require isn't so slow
* load.c (rb_feature_p, rb_provide_feature): index $LOADED_FEATURES
  so that require isn't so slow.

* load.c (rb_provide_feature, get_loaded_features_index): ensure
  that $LOADED_FEATURES entries are frozen strings.  The user
  must mutate $LOADED_FEATURES itself rather than its individual
  entries.

* load.c (reset_loaded_features_snapshot): add a new function to reset
  vm->loaded_features_snapshot.

* load.c (get_loaded_features_index_raw): add a new function to get
  the loaded-features index.

* load.c (features_index_add_single): add a new function to add to the
  loaded-features index a single feature.

* load.c (features_index_add): add a new function to add to the
  loaded-features index all the required entries for `feature`.

* vm_core.h (rb_vm_struct): add fields.

* vm.c (rb_vm_mark): mark new fields.

* include/ruby/intern.h (rb_hash_clear): declare function.

* hash.c (rb_hash_clear): make function non-static.
  Patch by Greg Price.
  [ruby-core:47970] [Bug #7158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-05 15:27:01 +00:00
ktsj 65b746bec0 * vm.c (rb_vm_rewrite_ep_in_errinfo, vm_rewrite_ep_in_errinfo):
merge code and remove `rb_vm_rewrite_ep_in_errinfo'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 09:41:38 +00:00
ktsj 049ace5888 * vm.c, proc.c: avoid unnecessary `rb_vm_rewrite_ep_in_errinfo'
calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 09:18:58 +00:00
nobu f7894e422a vm.c: rewrite all catch points
* vm.c (rb_vm_rewrite_ep_in_errinfo): rewrite all catch points in
  errinfo, not only the topmost frame.  based on the patch by
  ktsj (Kazuki Tsujimoto) in [ruby-dev:45656]. [Bug #6460]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-02 19:14:24 +00:00
tenderlove 2285319b31 * thread.c: added Thread#thread_variable_(get|set),
Thread#thread_variable?, and Thread#thread_variables for operating
  on variables that are local to threads. [ruby-core:47790]

* vm.c: ditto

* test/ruby/test_thread.rb: tests for thread variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-29 17:22:36 +00:00
ko1 2731767b5d * vm.c (vm_define_method): remove type and frozen checking.
Checking is done in `rb_singleton_class()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 19:47:58 +00:00
ko1 180c744b3b * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:
make all Float objects frozen.
  [ruby-dev:46081] [ruby-trunk - Feature #6936]
  Most part of patch by NARUSE, Yui  <naruse@ruby-lang.org>.
* class.c (singleton_class_of): raise TypeError when
  trying to define a singleton method on Float objects.
* vm.c (vm_define_method): ditto.
* test/ruby/marshaltestlib.rb: catch up above changes.
* test/ruby/test_class.rb: ditto.
* test/test_pp.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 02:10:53 +00:00