* vm.c (rb_source_location): return nil if path is not found.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (rb_threadptr_error_print): renamed to
rb_ec_error_print() and it accepts `ec`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to represent execution context [Feature #14038]
* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
There are many code using `th` to represent execution context
(such as cfp, VM stack and so on). To access `ec`, they need to
use `th->ec->...` (adding one indirection) so that we need to
replace them by passing `ec` instead of `th`.
* vm_core.h (GET_EC()): introduced to access current ec. Also
remove `ruby_current_thread` global variable.
* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
rb_context_t::thread_value.
* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.
* cont.c (ec_switch): added to switch ec explicitly.
* cont.c (rb_fiber_close): added to terminate fibers explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c
to rb_execution_context_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Return value of EXEC_TAG() is saved by "int state".
Instead of "int", use "enum ruby_tag_type". First EXEC_TAG()
value should be 0, so that define TAG_NONE (= 0) and use it.
Some code used "status" instead of "state". To make them clear,
rename them to state.
We can change variable name from "state" to "tag_state", but this
ticket doesn't contain it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (rb_threadptr_error_print): print backtrace and
error message in reverse order if STDERR is unchanged and a tty.
[Feature #8661]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (append_compile_error): set Qtrue for erred state with
showing the message immediately.
* iseq.c (prepare_iseq_build): make immediate message mode if main
or top level context, not to show the failed path twice in the
first line.
* iseq.c (cleanup_iseq_build): raise default message exception if
immediate message mode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use volatile instead of optnone to avoid optimization which causes
segmentation faults.
Patch by Dimitry Andric. [ruby-core:78531] [Bug #13014]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_print, error_handle): reuse same threadptr
by passing as an argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (warn_print): optimize warn_print with a string
literal, with rb_write_error2 instead of rb_write_error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_print): use same error position format when
no backtrace too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_pos): include a clone after the position.
* eval_error.c (error_print, error_handle): do not print a colon
if the error position is unavailable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (undef_mesg_for): fix typo. Before this commit
`ArgumentError: malformed format string - %$` was raised when
`NameError#message` is called. [ruby-core:71282] [Bug #11640]
[Fix GH-1077]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (name_err_mesg_to_str): quote the name if unprintable.
* object.c (check_setter_id): use rb_check_id to convert names.
* variable.c (uninitialized_constant): use NameError::message to
keep the receiver of uninitialized constant. [Feature #10881]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
`flag' contains several categories of attributes and it makes us
confusion (at least, I had confused).
* rb_method_visibility_t (flags::visi)
* NOEX_UNDEF -> METHOD_VISI_UNDEF = 0
* NOEX_PUBLIC -> METHOD_VISI_PUBLIC = 1
* NOEX_PRIVATE -> METHOD_VISI_PRIVATE = 2
* NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
* NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
* NOEX_BASIC -> basic (flags::basic, 1 bit)
* NOEX_MODFUNC -> rb_scope_visibility_t in CREF
* NOEX_SUPER -> MISSING_SUPER (enum missing_reason)
* NOEX_VCALL -> MISSING_VCALL (enum missing_reason)
* NOEX_RESPONDS -> BOUND_RESPONDS (macro)
Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
Background:
I did not know what "NOEX" stands for.
I asked Matz (who made this name) and his answer was "Nothing".
"At first, it meant NO EXport (private), but the original
meaning was gone."
This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
scope visibility.
It has 3 method visibilities (public/private/protected)
and `module_function`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are counted by characters, not bytes. use rb_str_subseq() instead.
[Bug #10727] [ruby-core:67473]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_write_error_str): use rb_w32_write_console() on Windows
if stderr is a tty.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_print): put a newline after an anonymous
exception class name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_handle): show backtrace at SIGSEGV, to
investigate core dump in CI.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
extensions like PRIsVALUE can be used in format strings
* eval_error.c (error_print): use warn_print_str (alias for
rb_write_error_str) to print a string value instead of using
RSTRING_PTR and RSTRING_LEN manually
* eval.c (setup_exception): use PRIsVALUE instead of %s and RSTRING_PTR
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (error_print): restore errinfo for the case new
excecption raised while printing the message. [ruby-core:55365]
[Bug #8501]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
vm_trace.c (rb_suppress_tracing): use TH_PUSH_TAG() instead of
PUSH_TAG().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
nobu pointed out that rb_method_basic_definition_p() is enough
for last commit.
* error.c, eval_error.c: change for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Backtrace information contains an array consists of location
information for each frames by string.
RubyVM::Backtrace object is lightweight backtrace information,
which contains complete information to generate traditional style
backtrace (an array of strings) with faster generation.
If someone accesses to backtrace information via
Exception#backtrace, then convert a RubyVM::Backtrace object to
traditonal style backtrace.
This change causes incompatibility on marshal dumpped binary
of Exception. If you have any trouble on it, please tell us
before Ruby 2.0 release.
Note that RubyVM::Backtrace object should not expose Ruby level.
* error.c, eval.c, vm_eval.c: ditto.
* internal.h: ditto.
* eval_error.c: fix to skip "set_backtrace" method invocation in
creating an exception object if it call a normal set_backtrace
method (defined by core).
* test/ruby/test_settracefunc.rb: fix for above change.
* vm_method.c (rb_method_defined_by): added. This function
checks that the given object responds with the given method
by the given cfunc.
* benchmark/bm_vm2_raise1.rb, benchmark/bm_vm2_raise2.rb:
add to measure exception creation speed. raise1 create
exception objects from shallow stack frame. raise2 create
exception objects from deep stack frame.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NameError for undefined method.
* load.c (rb_mod_autoload_p), object.c (rb_mod_const_get),
variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c
(rb_mod_{remove,undef,alias}_method, set_method_visibility):
remove inadvertent symbol creation. based on the first patch by
Jeremy Evans at [ruby-core:38447]. [Feature #5089]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to avoid hang. [ruby-core:27608]
* test/ruby/test_beginendblock.rb (test_endblock_raise): add test for
above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"rb_thread_t *", the prefix to be rb_threadptr_ instead of
rb_thread_.
* thread.c (rb_thread_add_event_hook(), rb_thread_remove_event_hook):
change the parameter type from rb_thread_t * to VALUE.
* eval.c, eval_error.c, eval_intern.h, signal.c, vm_core.h, vm_eval.c:
ditto.
* include/ruby/intern.h: remove decl of rb_thread_signal_raise() and
rb_thread_signal_exit().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by "vm.c".
* vm_eval.c: added. Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
blockinlining.c: fix for above changes. and do some refactoring.
this changes improve rb_yield() performance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e