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

239 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 70833fab7f
Suppress gcc11 clobbered warning 2021-06-14 23:24:17 +09:00
Samuel Williams 25921fe1d6 Revert "Suppress gcc11 clobbered warning"
This reverts commit f0f9e77b65.
2021-06-14 22:07:59 +12:00
Nobuyoshi Nakada 635e1c5282
Pack values to preserve 2021-06-14 14:10:21 +09:00
Nobuyoshi Nakada f0f9e77b65
Suppress gcc11 clobbered warning 2021-06-14 14:09:43 +09:00
David Rodríguez 02151dad1b `$LOAD_PATH.resolve_feature_path` should not raise
I think it's more friendly and easier to work with to return `nil` when
the feature is not found in the $LOAD_PATH.
2021-02-16 18:11:13 +09:00
Nobuyoshi Nakada b72f613210
Suppress a "clobbered" warning by gcc on macOS 2020-12-11 01:17:15 +09:00
Koichi Sasada 182fb73c40 rb_ext_ractor_safe() to declare ractor-safe ext
C extensions can violate the ractor-safety, so only ractor-safe
C extensions (C methods) can run on non-main ractors.
rb_ext_ractor_safe(true) declares that the successive
defined methods are ractor-safe. Otherwiwze, defined methods
checked they are invoked in main ractor and raise an error
if invoked at non-main ractors.

[Feature #17307]
2020-12-01 15:44:18 +09:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Nobuyoshi Nakada 6944b927bd
rb_class_real never returns Qnil 2020-10-09 11:49:13 +09:00
Jeremy Evans e1bbb9ea9c Document that Kernel#load will load relative to current directory [ci skip]
Update and format the Kernel#load documentation to separate the
three cases (absolute path, explicit relative path, other), and
also document that it raises LoadError on failure.

Fixes [Bug #16988]
2020-07-09 14:47:13 -07:00
卜部昌平 6575766ea0 search_required: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 e551dfda9f rb_feature_p: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
MSP-Greg 4cb8b49d41 [DOC] relative filename `Kernel#.require` and `Kernel#.load` [ci skip] 2020-06-01 09:20:57 +09:00
Nobuyoshi Nakada e10798b3a3
[DOC] refined `Kernel#.require` and `Kernel#.load` [ci skip] 2020-05-30 22:04:49 +09:00
Nobuyoshi Nakada 0d30f42813
[DOC] mentioned "explicit relative path" [ci skip]
`Kernel#.require` and `Kernel#.load` do not search also "explicit
relative path" files, not only absolute paths, in the load path.
2020-05-30 01:09:16 +09:00
Jeremy Evans 5a9d2da76e Remove deprecated rb_require_safe 2020-04-30 10:32:27 -07:00
Nobuyoshi Nakada 7d6903dc47
Add the loaded feature after no exception raised
Retrying after rescued `require` should try to load the same
library again.  [Bug #16607]
2020-02-04 16:10:39 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Nobuyoshi Nakada 14a17063a1
Fixed stack overflow [Bug #16382]
Get rid of infinite recursion in expanding a load path to the real
path while loading a transcoder.
2019-12-03 08:51:50 +09:00
Koichi Sasada a5fe08fdd9 care about TAG_FATAL.
TAG_FATAL represents interpreter closing state and ec->errinfo
contains FIXNUM (eTerminateSignal, etc). If we need to change the
state, then errinfo is also changed because TAG_RAISE assumes that
ec->errinfo contains a Exception object.

Without this patch, TAG_FATAL is ignored and no ec->errinfo change
so that it causes critical issue.
[Bug #16177]
2019-11-19 16:56:56 +09:00
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
卜部昌平 c9ffe751d1 delete unused functions
Looking at the list of symbols inside of libruby-static.a, I found
hundreds of functions that are defined, but used from nowhere.

There can be reasons for each of them (e.g. some functions are
specific to some platform, some are useful when debugging, etc).
However it seems the functions deleted here exist for no reason.

This changeset reduces the size of ruby binary from 26,671,456
bytes to 26,592,864 bytes on my machine.
2019-11-14 20:35:48 +09:00
卜部昌平 7bcfd9189a drop-in type check for rb_define_global_function
We can check the function pointer passed to rb_define_global_function
like we do so in rb_define_method.  It turns out that almost anybody
is misunderstanding the API.
2019-08-29 18:34:09 +09:00
卜部昌平 1663d347c9 delete `$` sign from C identifiers
They lack portability. See also
https://travis-ci.org/shyouhei/ruby/jobs/577164015
2019-08-27 15:52:26 +09:00
卜部昌平 bd8dc2561d struct MEMO now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  There is only one usage of
MEMO::u3::func in load.c (where void Init_Foobar(vodi) is registered)
so why not just be explicit.
2019-08-27 15:52:26 +09:00
卜部昌平 ae2dc3f217 rb_define_hooked_variable now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit uses rb_gvar_getter_t /
rb_gvar_setter_t for rb_define_hooked_variable /
rb_define_virtual_variable which revealed lots of function prototype
inconsistencies.  Some of them were literally decades old, going back
to dda5dc00cf.
2019-08-27 15:52:26 +09:00
Nobuyoshi Nakada 74ca6b88dd
Omit a tag unless loading with a wrapper module 2019-08-18 00:34:12 +09:00
Nobuyoshi Nakada ad3f7a3667
Should require without wrapper module 2019-08-09 00:12:54 +09:00
Nobuyoshi Nakada 995c2e9536
Reduce unnecessary EXEC_TAG in require 2019-08-08 22:28:00 +09:00
Nobuyoshi Nakada 76bd0714cf
solve "duplicate :raise event" in require too [Bug #15877] 2019-08-08 21:27:39 +09:00
Nobuyoshi Nakada 3d87b774c4
Use `ec` instead of `th->ec` where the `th` came from the `ec` 2019-08-08 21:27:39 +09:00
git 29bdfeb0c6 * expand tabs. 2019-08-08 17:59:38 +09:00
Koichi Sasada b004d3e830 solve "duplicate :raise event" [Bug #15877]
Without this patch, "raise" event invoked twice when raise an
exception in "load"ed script.
This patch by  danielwaterworth (Daniel Waterworth).
[Bug #15877]
2019-08-08 17:56:04 +09:00
Nobuyoshi Nakada 8cfa3d861c
Do not expect RSTRING_PTR valid after rb_fstring 2019-08-05 10:51:52 +09:00
git 7817a6fa09 * expand tabs. 2019-08-04 22:27:17 +09:00
Nobuyoshi Nakada 76e2370f13
Fix dangling path name from fstring
* load.c (rb_require_internal): make sure in advance that the path
  to be loaded shares a fstring, to get rid of dangling path name.
  Fixed up 5931857281.  [Bug #16041]
2019-08-04 22:21:53 +09:00
Yusuke Endoh 61577fa53b Add a /* fall through */ comment 2019-07-14 17:32:53 +09:00
Benoit Daloze 4a935bc6f6 Document $LOAD_PATH.resolve_feature_path in globals.rdoc
* RDoc does not seem to support documenting singleton object methods,
  and making $LOAD_PATH a class as a workaround is too weird.
2019-07-13 15:23:49 +02:00
Nobuyoshi Nakada d77b84ca82
$LOAD_PATH.resolve_feature_path
Moved from RubyVM.  [Feature #15903]
2019-07-11 14:05:34 +09:00
Nobuyoshi Nakada 5b7cc63d11
Turned `recur` into `int` [Feature #15777] 2019-06-21 17:28:37 +09:00
Jean Boussier fb85a42860
Add an optional `inherit` argument to Module#autoload?
[Feature #15777]

Closes: https://github.com/ruby/ruby/pull/2173
2019-06-21 17:28:37 +09:00
nobu 56557ec28a [DOC] fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22 11:04:59 +00:00
svn d7c7382f7a * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 01:14:52 +00:00
nobu 58508e8b55 load.c: resolve_feature_path
* load.c (rb_resolve_feature_path): search the path for already
  loaded feature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31 01:14:51 +00:00
mame c6915042ab vm.c: Move the rdoc of RubyVM.resolve_feature_path [Bug #15482]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-30 13:21:30 +00:00
ko1 496267023c fix missed script_compiled events. [Bug #15471]
* ruby.c (process_options): script_compiled events are missed on
  command line -e or specified file. this commit fix it.
  [Bug #15471]

  This patch should be backport to Ruby 2.6 branch.

* vm_core.h (rb_exec_event_hook_script_compiled): introduce utility
  function to invoke a script_compiled event.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-27 17:39:17 +00:00
ko1 5ac990e83e `script_compiled` TracePoint event [Feature #15287]
* vm_trace.c: add `script_compiled` event. This event invoked
  after script compiling and before evaluating compiled script.
  Also the following methods are added:

  `TracePoint#compiled_instruction_sequence` method to get compiled
  `RubyVM::InstructionSequence` instance.

  `TracePoint#compiled_eval_script` method to get compiled script (String)
  by *eval methods (return nil if compiling by file).

* vm_trace.c (tracepoint_attr_raised_exception):


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 13:42:32 +00:00
mame 0cd28199e5 load.c (RubyVM.resolve_feature_path): New method. [Feature #15230]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 06:40:54 +00:00
nobu fa8b08b424 Prefer `rb_fstring_lit` over `rb_fstring_cstr`
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 09:59:22 +00:00
normal 4f53579896 load.c: use ruby_sized_xfree for calloc-ed RArray VALUE
IMHO, this increases readability, too, since it's not
immediately clear that the object is on the malloc heap
and not a regular Ruby object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-21 21:40:54 +00:00