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

2276 Коммитов

Автор SHA1 Сообщение Дата
Jean Boussier 1a7e7bb2d1 object.c: rb_eql returns int not VALUE
It works, but assumes `Qfalse == 0`, which is true today
but might not be forever.
2022-10-10 11:35:16 +02:00
Samuel Williams 844a9dff88
Try `nil` as default for 'default timeout'. (#6509) 2022-10-08 14:02:34 +13:00
Samuel Williams a081fe76de
Simplify default argument specification. (#6507) 2022-10-07 22:51:27 +13:00
Samuel Williams e4f91bbdba
Add IO#timeout attribute and use it for blocking IO operations. (#5653) 2022-10-07 21:48:38 +13:00
Aaron Patterson 9a6803c90b
Revert "This commit implements the Object Shapes technique in CRuby."
This reverts commit 68bc9e2e97d12f80df0d113e284864e225f771c2.
2022-09-30 16:01:50 -07:00
Jemma Issroff d594a5a8bd
This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-28 08:26:21 -07:00
Aaron Patterson 06abfa5be6
Revert this until we can figure out WB issues or remove shapes from GC
Revert "* expand tabs. [ci skip]"

This reverts commit 830b5b5c35.

Revert "This commit implements the Object Shapes technique in CRuby."

This reverts commit 9ddfd2ca00.
2022-09-26 16:10:11 -07:00
Jemma Issroff 9ddfd2ca00 This commit implements the Object Shapes technique in CRuby.
Object Shapes is used for accessing instance variables and representing the
"frozenness" of objects.  Object instances have a "shape" and the shape
represents some attributes of the object (currently which instance variables are
set and the "frozenness").  Shapes form a tree data structure, and when a new
instance variable is set on an object, that object "transitions" to a new shape
in the shape tree.  Each shape has an ID that is used for caching. The shape
structure is independent of class, so objects of different types can have the
same shape.

For example:

```ruby
class Foo
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

class Bar
  def initialize
    # Starts with shape id 0
    @a = 1 # transitions to shape id 1
    @b = 1 # transitions to shape id 2
  end
end

foo = Foo.new # `foo` has shape id 2
bar = Bar.new # `bar` has shape id 2
```

Both `foo` and `bar` instances have the same shape because they both set
instance variables of the same name in the same order.

This technique can help to improve inline cache hits as well as generate more
efficient machine code in JIT compilers.

This commit also adds some methods for debugging shapes on objects.  See
`RubyVM::Shape` for more details.

For more context on Object Shapes, see [Feature: #18776]

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
Co-Authored-By: Eileen M. Uchitelle <eileencodes@gmail.com>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
2022-09-26 09:21:30 -07:00
Samuel Williams 1c14e406d3 Fix `io/buffer.h` header guard. 2022-09-26 20:10:15 +13:00
Nobuyoshi Nakada 6e46bf1e54
Just a star [ci skip] 2022-09-23 08:52:15 +09:00
卜部昌平 2f8012c949 rb_define_method: dedicated overload for rb_f_notimplement
rb_f_notimplement was type-compatible with VALUE(*)(ANYARGS), but not
any longer in C23.  Provide a dedicated path for it.
2022-09-21 11:44:09 +09:00
Nobuyoshi Nakada e2ccb316b4 [Bug #5317] Use `rb_off_t` instead of `off_t`
Get rid of the conflict with system-provided small `off_t`.
2022-09-08 23:01:07 +09:00
Takashi Kokubun 83375f47e1
Avoid leaving a period alone [ci skip] 2022-08-27 14:48:15 -07:00
spaette a797ded8e2 typos 2022-08-27 14:42:55 -07:00
Jeremy Evans 6f3857f6a7 Support Encoding::Converter newline: :lf and :lf_newline options
Previously, newline: :lf was accepted but ignored.  Where it
should have been used was commented out code that didn't work,
but unlike all other invalid values, using newline: :lf did
not raise an error.

This adds support for newline: :lf and :lf_newline, for consistency
with newline: :cr and :cr_newline.  This is basically the same as
universal_newline, except that it only affects writing and not
reading due to RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK.

Add tests for the File.open :newline option while here.

Fixes [Bug #12436]
2022-08-19 20:23:36 -07:00
Nobuyoshi Nakada cd1a0b3caa Stop defining `RUBY_ABI_VERSION` if released versions
As commented in include/ruby/internal/abi.h, since teeny versions of
Ruby should guarantee ABI compatibility, `RUBY_ABI_VERSION` has no role
in released versions of Ruby.
2022-08-12 15:57:25 +09:00
Nobuyoshi Nakada a201cfd0cd Add missing `rb_enc_iscntrl` 2022-08-12 15:56:30 +09:00
Nobuyoshi Nakada 9a11d50dc7 [DOC] Use `true`/`false` for `@retval`s which are `bool` 2022-08-12 15:56:30 +09:00
Nobuyoshi Nakada 591ee9d068
[DOC] Add return values of rb_enc_mbcput 2022-08-07 13:09:46 +09:00
Nobuyoshi Nakada f42230ff22
Adjust styles [ci skip] 2022-07-27 18:42:27 +09:00
Peter Zhu efb91ff19b Rename rb_ary_tmp_new to rb_ary_hidden_new
rb_ary_tmp_new suggests that the array is temporary in some way, but
that's not true, it just creates an array that's hidden and not on the
transient heap. This commit renames it to rb_ary_hidden_new.
2022-07-26 09:12:09 -04:00
Yusuke Endoh e763b1118b Move enum definitions out of struct definition 2022-07-22 23:10:24 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Peter Zhu 4798a4fec2 Remove unused internal macros in rarray.h 2022-07-21 09:02:45 -04:00
Peter Zhu 7424ea184f Implement Objects on VWA
This commit implements Objects on Variable Width Allocation. This allows
Objects with more ivars to be embedded (i.e. contents directly follow the
object header) which improves performance through better cache locality.
2022-07-15 09:21:07 -04:00
Kevin Backhouse 8c1808151f
Fix some UBSAN false positives (#6115)
* Fix some UBSAN false positives.
* ruby tool/update-deps --fix
2022-07-12 11:48:10 -07:00
卜部昌平 7f64989e5c do not define our own version of memcpy
The (sole) use of memcpy in our public header is now replaced to
directly call ruby_nonempty_memcpy, and the previous definition of
memcpy is now internal-only.  [Bug#18893]
2022-07-07 22:10:53 +09:00
Samuel Williams d2166c09b0 Copy `IO#wait*` methods from `io-wait` gem to `io.c`. 2022-06-25 21:17:13 +12:00
Chris Seaton 31b2cd38c5 Include JIT information in crash reports
Since enabling YJIT or MJIT drastically changes what could go wrong at
runtime, it's good to be front and center about whether they are enabled
when dumping a crash report. Previously, `RUBY_DESCRIPTION` and the
description printed when crashing can be different when a JIT is on.

Introduce a new internal data global, `rb_dynamic_description`, and set
it to be the same as `RUBY_DESCRIPTION` during initialization; use it
when crashing.

 * version.c: Init_ruby_description(): Initialize and use
       `rb_dynamic_description`.
 * error.c: Change crash reports to use `rb_dynamic_description`.
 * ruby.c: Call `Init_ruby_description()` earlier. Slightly more work
       for when we exit right after printing the description but that
       was deemed acceptable.
 * include/ruby/version.h: Talk about how JIT info is not in
      `ruby_description`.
 * test/-ext-/bug_reporter/test_bug_reporter.rb: Remove handling for
       crash description being different from `RUBY_DESCRIPTION`.
 * test/ruby/test_rubyoptions.rb: ditto

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Alan Wu <alanwu@ruby-lang.org>
2022-06-20 17:18:29 -04:00
Jean Boussier b6c1e1158d GVL Instrumentation API: add STARTED and EXITED events
[Feature #18339]

After experimenting with the initial version of the API I figured there is a need
for an exit event to cleanup instrumentation data. e.g. if you record data in a
{thread_id -> data} table, you need to free associated data when a thread goes away.
2022-06-17 09:08:26 +02:00
Alan Wu 714a4942fd
Remove unused and accidentally public rb_str_shared_root_p()
This function was added to a public header in [1] probably
unintentionally since it's not used anywhere, exposes implementation
details, and isn't related to the goals of that pull request.

[1]: 56cc3e99b6
2022-06-16 07:20:20 -04:00
John Hawthorn 17d260a87f Restore rb_exec_recursive_outer
This was a public method, so we should probably keep it.
2022-06-15 16:07:29 -07:00
Matt Valentine-House 56cc3e99b6 Move String RVALUES between pools
And re-embed any strings that can now fit inside the slot they've been
moved to
2022-06-13 10:11:27 -07:00
John Hawthorn 52da90acee Make method id explicit in rb_exec_recursive_outer
Previously, because opt_aref and opt_aset don't push a frame, when they
would call rb_hash to determine the hash value of the key, the initial
level of recursion would incorrectly use the method id at the top of the
stack instead of "hash".

This commit replaces rb_exec_recursive_outer with
rb_exec_recursive_outer_mid, which takes an explicit method id, so that
we can make the hash calculation behave consistently.

rb_exec_recursive_outer was documented as being internal, so I believe
this should be okay to change.
2022-06-10 14:48:21 -07:00
Jean Boussier 9125374726 [Feature #18339] GVL Instrumentation API
Ref: https://bugs.ruby-lang.org/issues/18339

Design:

- This tries to minimize the overhead when no hook is registered.
  It should only incur an extra unsynchronized boolean check.
- The hook list is protected with a read-write lock as to cause
  contention when some hooks are registered.
- The hooks MUST be thread safe, and MUST NOT call into Ruby as they
  are executed outside the GVL.
- It's simply a noop on Windows.

API:

```
rb_internal_thread_event_hook_t * rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data);
bool rb_internal_thread_remove_event_hook(rb_internal_thread_event_hook_t * hook);
```

You can subscribe to 3 events:

  - READY: called right before attempting to acquire the GVL
  - RESUMED: called right after successfully acquiring the GVL
  - SUSPENDED: called right after releasing the GVL.

The hooks MUST be threadsafe, as they are executed outside of the GVL, they also MUST NOT call any Ruby API.
2022-06-03 15:13:33 +02:00
Jemma Issroff a04d8c9513
Remove trailing comma from FL_USER3 (#5958) 2022-05-26 15:40:34 -07:00
Jemma Issroff 33fdff3c30 Remove unused RMODULE_INCLUDED_INTO_REFINEMENT flag 2022-05-26 12:09:04 -07:00
Jemma Issroff 80ad0e751f Remove unnecessary module flag, add module assertions to other module flags 2022-05-23 11:04:34 -07:00
Daisuke Fujimura (fd0) 3d6fd162a4 Undefine RUBY_DLN_CHECK_ABI on cygwin 2022-05-19 17:15:30 +09:00
Peter Zhu a41fbc2c95 Increase SIZE_POOL_COUNT to 5
Having more size pools will allow us to allocate larger objects
through Variable Width Allocation.

I have attached some benchmark results below.

Discourse:
  On Discourse, we don't see much change in response times. We do see
  a small reduction in RSS.

  Branch RSS: 377.8 MB
  Master RSS: 396.3 MB

railsbench:
  On railsbench, we don't see a big change in RPS or p99 performance.
  We see a small increase in RSS.

  Branch RPS: 815.38
  Master RPS: 811.73

  Branch p99: 1.69 ms
  Master p99: 1.68 ms

  Branch RSS: 90.6 MB
  Master RSS: 89.4 MB

liquid:
  We don't see a significant change in liquid performance.

  Branch parse & render: 29.041 I/s
  Master parse & render: 29.211 I/s
2022-05-09 08:45:24 -04:00
Jean Boussier 4a2b5102c1 Expose `rb_hash_new_capa(long)`
[Feature #18683]

This allows parsers and similar libraries to create Hashes of
a certain capacity in advance. It's useful when the key and values
are streamed, hence `bulk_insert()` can't be used.
2022-04-26 16:12:47 +02:00
卜部昌平 dcc42d4688 [Doc] correct my understanding about nonblocking mode
I was wrong.  Nonblocking mode nowadays does not interface with
IO#read.  Document updated. [ci skip]
2022-04-21 14:59:03 +09:00
Alex Matchneer dbb227d3b6
[DOC] add missing size params in fiber scheduler.h (#5441) 2022-04-14 07:34:49 +12:00
Kevin Newton 6068da8937 Finer-grained constant cache invalidation (take 2)
This commit reintroduces finer-grained constant cache invalidation.
After 8008fb7 got merged, it was causing issues on token-threaded
builds (such as on Windows).

The issue was that when you're iterating through instruction sequences
and using the translator functions to get back the instruction structs,
you're either using `rb_vm_insn_null_translator` or
`rb_vm_insn_addr2insn2` depending if it's a direct-threading build.
`rb_vm_insn_addr2insn2` does some normalization to always return to
you the non-trace version of whatever instruction you're looking at.
`rb_vm_insn_null_translator` does not do that normalization.

This means that when you're looping through the instructions if you're
trying to do an opcode comparison, it can change depending on the type
of threading that you're using. This can be very confusing. So, this
commit creates a new translator function
`rb_vm_insn_normalizing_translator` to always return the non-trace
version so that opcode comparisons don't have to worry about different
configurations.

[Feature #18589]
2022-04-01 14:48:22 -04:00
Yusuke Endoh ffc3b37f96 re.c: Add Regexp.timeout= and Regexp.timeout
[Feature #17837]
2022-03-30 16:50:46 +09:00
Nobuyoshi Nakada 69967ee64e
Revert "Finer-grained inline constant cache invalidation"
This reverts commits for [Feature #18589]:
* 8008fb7352
  "Update formatting per feedback"
* 8f6eaca2e1
  "Delete ID from constant cache table if it becomes empty on ISEQ free"
* 629908586b
  "Finer-grained inline constant cache invalidation"

MSWin builds on AppVeyor have been crashing since the merger.
2022-03-25 20:29:09 +09:00
Kevin Newton 629908586b Finer-grained inline constant cache invalidation
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends on global counter
end

foo # populate inline cache
foo # hit inline cache

C = 1 # global counter increments, all caches are invalidated

foo # misses inline cache due to `C = 1`
```

Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends constants named "A" and "B"
end

foo # populate inline cache
foo # hit inline cache

C = 1 # caches that depend on the name "C" are invalidated

foo # hits inline cache because IC only depends on "A" and "B"
```

Examples of breaking the new cache:

```ruby
module C
  # Breaks `foo` cache because "A" constant is set and the cache in foo depends
  # on "A" and "B"
  class A; end
end

B = 1
```

We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT.
2022-03-24 09:14:38 -07:00
Peter Zhu a51f30c671 [Feature #18634] Implement Arrays on Variable Width Allocation
This commit implements arrays on Variable Width Allocation. This allows
longer arrays to be embedded (i.e. contents directly follow the object
header) which improves performance through better cache locality.
2022-03-22 09:42:39 -04:00
Nobuyoshi Nakada f91ea23324
Honor if `_Bool` is available
`AC_HEADER_STDBOOL` rejects stdbool.h in c2x, which is not
conforming to C99.
2022-03-16 17:50:13 +09:00
Peter Zhu 1289721892 Wrap ruby_abi_version in `extern "C"` for C++
Make ruby_abi_version have C linkage so that the symbol can be found
in the shared object.
2022-03-01 13:38:48 -05:00
Peter Zhu 25ad9eabc7 Only define RUBY_DLN_CHECK_ABI when supported 2022-03-01 09:44:39 -05:00
Lars Kanis eebc24218a [DOC] Fix reference in rb_enc_associate() description 2022-03-01 10:11:59 +09:00
Lars Kanis 1a20bb1c98 [DOC] Fix function name in example 2022-03-01 09:59:12 +09:00
Peter Zhu 3df16924b4 [Feature #18249] Implement ABI checking
Header file include/ruby/internal/abi.h contains RUBY_ABI_VERSION which
is the ABI version. This value should be bumped whenever an ABI
incompatible change is introduced.

When loading dynamic libraries, Ruby will compare its own
`ruby_abi_version` and the `ruby_abi_version` of the loaded library. If
these two values don't match it will raise a `LoadError`. This feature
can also be turned off by setting the environment variable
`RUBY_RUBY_ABI_CHECK=0`.

This feature will prevent cases where previously installed native gems
fail in unexpected ways due to incompatibility of changes in header
files. This will force the developer to recompile their gems to use the
same header files as the built Ruby.

In Ruby, the ABI version is exposed through
`RbConfig::CONFIG["ruby_abi_version"]`.
2022-02-22 09:55:21 -05:00
Nobuyoshi Nakada 7470780058 Check if `__assume` is supported 2022-02-19 23:32:52 +09:00
Nobuyoshi Nakada 131154f878 Define `HAVE___BUILTIN_UNREACHABLE` instead of `UNREACHABLE`
`UNREACHABLE` in ruby/internal/has/builtin.h is only used as just
a flag now, and redefined in ruby/backward/2/assume.h then.
2022-02-19 23:32:52 +09:00
Nobuyoshi Nakada 59a91f229b
Mark `rb_clear_constant_cache` as internal use only
In the past, many internal functions are declared in intern.h
under include/ruby directory, because there were no headers for
internal use.
2022-01-20 13:54:37 +09:00
Yuta Saito 528344b8de include/ruby/win32.h: explicitly define HAVE_SHUTDOWN
Configuration for mingw32 can't detect 'shutdown' due to wrong -l
option even though it's available (this has been going on for a while,
and it needs to be fixed).
In this situation, include/ruby/missing.h declares a stub shutdown
function since 7ee786388a, and another shutdown decl is came from
system header. They are incompatible at stdcall attribute, so it
causes compilation failure.
This change defines a HAVE_SHUTDOWN to guard a newly introduced stub
decl in include/ruby/missing.h
2022-01-19 17:52:19 +09:00
Yuta Saito 8c21701968 include/ruby/io.h: use 0 as POLLPRI when no support for it
0x003 is not suitable as a bit mask, and it's ok just to be 0 to avoid
setting unsupported bit.
2022-01-19 13:19:58 +09:00
Yuta Saito 50f1468bfd [wasm] include/ruby/io.h: define RB_WAITFD_PRI by ourselves for wasi
RB_WAITFD_PRI uses POLLPRI for other platforms, but wasi-libc doesn't
have POLLPRI for now.
2022-01-19 11:19:06 +09:00
Yuta Saito 420622b5a7 [wasm] add no thread variant for freestanding environment
This implementation does nothing around preemptive context switching
because there is no native thread.
2022-01-19 11:19:06 +09:00
Yuta Saito 7ee786388a [wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc 2022-01-19 11:19:06 +09:00
Jeremy Evans e7b4abf384 Don't assume __builtin_bswap32 and __builtin_bswap64 are defined on OpenBSD
At least OpenBSD/sparc64 doesn't appear to define them, and possibly
some other OpenBSD GCC platforms don't (most OpenBSD platforms have
already switched to clang).
2022-01-18 11:40:13 -08:00
Peter Zhu ffda21b7ba [Feature #18491] Drop support for HP-UX
IA64 support was dropped in ticket #15894, so we can drop support for
HP-UX.
2022-01-18 09:52:15 -05:00
Yuta Saito 6729258839
include/ruby/win32.h: define HAVE_X for the missing prototypes (#5456) 2022-01-18 19:08:07 +09:00
Nobuyoshi Nakada 9fa9cf4006 Suppress possible loss of data warnings 2022-01-14 13:46:12 +09:00
Nobuyoshi Nakada d1a55851e8
[DOC] Fix a typo in a doc 2022-01-13 11:32:35 +09:00
Peter Zhu 98fb0ab60e Enable Variable Width Allocation by default 2022-01-12 12:00:55 -05:00
Peter Zhu 2d81a718ec Make embedded string length a long for VWA
A short (2 bytes) will cause unaligned struct accesses when strings are
used as a buffer to directly store binary data.
2022-01-12 12:00:55 -05:00
Peter Zhu 33cc8816be Revert "Enable Variable Width Allocation by default"
This reverts commit c365c5921e.
2022-01-08 15:07:57 -05:00
Peter Zhu bc643bbe2e Use unsigned short for length of embedded strings 2022-01-07 15:48:06 -05:00
Peter Zhu c365c5921e Enable Variable Width Allocation by default 2022-01-07 13:27:13 -05:00
Peter Zhu aeb344e65c Revert "Enable Variable Width Allocation by default"
This reverts commit d4a95428bb.
2022-01-06 16:47:49 -05:00
Peter Zhu d4a95428bb Enable Variable Width Allocation by default 2022-01-06 14:33:35 -05:00
Nobuyoshi Nakada 8727161fcf
Flush deprecation declarations for versions older than 3.0 2021-12-30 18:52:04 +09:00
Nobuyoshi Nakada a90d188b57 Remove declarations of deprecated functions 2021-12-30 15:33:40 +09:00
U.Nakamura 4e007d705c Fix some bornheads 2021-12-27 17:15:09 +09:00
U.Nakamura 9790f54bff Call FlushInstrucitonCache() when PROT_EXEC is specified to mprotect 2021-12-27 16:38:29 +09:00
U.Nakamura 85a426dc86 Tiny mmap emulation for Windows
- prerequisite of supporting YJIT with VC++.
- note that now can specfily `--yjit` on mswin64, but not enabled
  YJIT'ed code because of YJIT requires `OPT_DIRECT_THREADED_CODE`
  or `OPT_CALL_THREADED_CODE` in `rb_yjit_compile_iseq`.
2021-12-27 15:56:23 +09:00
Nobuyoshi Nakada 7c738ce5e6
Remove deprecate rb_cData [Bug #18433]
Also enable the warning for T_DATA allocator.
2021-12-26 23:28:54 +09:00
Nobuyoshi Nakada 39bc5de833
Remove tainted and trusted features
Already these had been announced to be removed in 3.2.
2021-12-26 23:28:54 +09:00
Yukihiro "Matz" Matsumoto 81c248924d
Development of 3.1.0 started. 2021-12-26 23:22:26 +09:00
Kazuhiro NISHIYAMA 04f07713d1
Fix typos [ci skip] 2021-12-25 10:33:49 +09:00
Samuel Williams acfe2f2655
Improvements to `rb_io_wait` return value handling and internal implementation. (#5340) 2021-12-24 23:11:02 +13:00
Samuel Williams bed920f073
Add fiber scheduler hooks for `pread`/`pwrite`, and add support to `IO::Buffer`. 2021-12-23 12:20:09 +13:00
Samuel Williams e30920354f
Extended interface for IO::Buffer & documentation. 2021-12-22 10:57:34 +13:00
Samuel Williams 617687df09 Rename IMMUTABLE to READONLY. 2021-12-21 12:25:42 +13:00
Samuel Williams 9fbf94ff04 Improve interface for get/set/copy. 2021-12-21 12:25:42 +13:00
Samuel Williams c86bcd434d Mark non-private mapped files as external. 2021-12-21 12:25:42 +13:00
Samuel Williams 49166fc74a Improved exception usage/classes. 2021-12-21 12:25:42 +13:00
Samuel Williams 56811617ab Improve IO::Buffer resize and introduce ownership transfer. 2021-12-20 00:17:17 +13:00
Samuel Williams f3e30b26c5 Default size for IO::Buffer. 2021-12-19 12:25:38 +13:00
Samuel Williams 42d3231154
Introduce io_result wrapper for passing `[-errno, size]` in VALUE. 2021-12-18 18:19:30 +13:00
Yuta Saito ecb2ff6050 intern/select/posix.h: remove unused parameter from rb_fd_dup
This unused parameter seems to be accidently introduced by https://github.com/ruby/ruby/commit/9e6e39c
2021-12-11 02:23:30 +09:00
Nobuyoshi Nakada a5baf8d6bc
Revert zero-check for alloca
Something weird results in int-in-bool-context and
stringop-overflow warnings.
2021-12-10 18:39:48 +09:00
Nobuyoshi Nakada bcc2bb28b0 Fix stack buffer overflow
https://hackerone.com/reports/1306859
2021-12-10 01:04:59 +09:00
Jean Boussier c0c2b31a35 Add Class#subclasses
Implements [Feature #18273]

Returns an array containing the receiver's direct subclasses without
singleton classes.
2021-11-23 10:50:44 +01:00
卜部昌平 33533fabd5 revival of must_not_null()
Presence of RBIMPL_ATTR_NONNULL let C compilers to eliminate
must_not_null().  Because null pointers are not allowed to exist there
are no reason to call the function.  In reality null pointers are still
passed to those functions in a number of ways.  Runtime check for them
are definitely nice to have.  fix [Feature#18280]
2021-11-11 17:14:47 +09:00
卜部昌平 f5dcecf345 rb_file_size: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-11-11 11:45:19 +09:00
卜部昌平 ad84c5d1b0 rb_enc_code_to_mbclen: fix doxygen
Wrong parameter name. [ci skip]
2021-11-11 11:45:19 +09:00
卜部昌平 4b3830127f RB_ENCODING_SET_INLINED: fix doxygen
Wrong parameter name. [ci skip]
2021-11-11 11:45:19 +09:00
卜部昌平 a4a6e5cd2e ENCODING_MASK: fix doxygen link [ci skip] 2021-11-11 11:45:19 +09:00
卜部昌平 1370b0876f io/buffer.h: C linkage
Because `make install` installs this header to target systems, it must
be ready to be `#include`d form a C++ program.
2021-11-11 11:45:19 +09:00
Nobuyoshi Nakada 46e46eafd4
size_t is not for file size 2021-11-10 16:41:26 +09:00
Samuel Williams 81d0ce7e97 Mark IO::Buffer as experimental. 2021-11-10 19:21:05 +13:00
Samuel Williams 4b89034218 IO::Buffer for scheduler interface. 2021-11-10 19:21:05 +13:00
Peter Zhu 309406484b [Feature #18290] Deprecate rb_gc_force_recycle and remove invalidate_mark_stack_chunk
This commit deprecates rb_gc_force_recycle and coverts it to a no-op
function. Also removes invalidate_mark_stack_chunk since only
rb_gc_force_recycle uses it.
2021-11-08 14:05:54 -05:00
Kenta Murata 3501e0cbb5
memory_view.c: Add _memory_view_entry member in rb_memory_view_t (#5088) 2021-11-08 12:52:09 +09:00
Nobuyoshi Nakada a202408180
Fix typos 2021-11-02 19:17:37 +09:00
Jeremy Evans 717ab0bb2e
Add Class#descendants
Doesn't include receiver or singleton classes.

Implements [Feature #14394]

Co-authored-by: fatkodima <fatkodima123@gmail.com>
Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2021-10-26 12:35:21 -07:00
卜部昌平 7d4c59203f improve doc coverage [ci skip]
Just split the comment for struct's one and array's one.
2021-10-26 09:30:42 +09:00
卜部昌平 a0029ae2b6 just another evidence that @shyouhei is an idiot [ci skip]
(gdb) ptype/o struct RString
/* offset    |  size */  type = struct RString {
/*    0      |    16 */    struct RBasic {
/*    0      |     8 */        VALUE flags;
/*    8      |     8 */        const VALUE klass;

                               /* total size (bytes):   16 */
                           } basic;
/*   16      |    24 */    union {
/*                24 */        struct {
/*   16      |     8 */            long len;
/*   24      |     8 */            char *ptr;
/*   32      |     8 */            union {
/*                 8 */                long capa;
/*                 8 */                VALUE shared;

                                       /* total size (bytes):    8 */
                                   } aux;

                                   /* total size (bytes):   24 */
                               } heap;
/*                24 */        struct {
/*   16      |    24 */            char ary[24];

                                   /* total size (bytes):   24 */
                               } embed;
/* XXX  8-byte padding  */

                               /* total size (bytes):   24 */
                           } as;

                           /* total size (bytes):   40 */
                         }
(gdb)
2021-10-26 09:30:12 +09:00
Peter Zhu a5b6598192 [Feature #18239] Implement VWA for strings
This commit adds support for embedded strings with variable capacity and
uses Variable Width Allocation to allocate strings.
2021-10-25 13:26:23 -04:00
Peter Zhu 46b66eb9e8 [Feature #18239] Add struct for embedded strings 2021-10-25 13:26:23 -04:00
Shugo Maeda 6606597109
Deprecate include/prepend in refinements and add Refinement#import_methods instead
Refinement#import_methods imports methods from modules.
Unlike Module#include, it copies methods and adds them into the refinement,
so the refinement is activated in the imported methods.

[Bug #17429] [ruby-core:101639]
2021-10-21 16:31:54 +09:00
Nobuyoshi Nakada 702a58e9e5
Remove duplicate type qualifiers
`rb_encoding` is defined as `const OnigEncodingType`.
Fix lots of C4114 warnings for each files by MSVC.
2021-10-06 14:01:43 +09:00
Nobuyoshi Nakada cd182c5ee1
Adjust types to rb_enc_left_char_head
I dislike unnatural casts.
2021-10-05 17:14:29 +09:00
卜部昌平 f032c09bca rb_enc_left_char_head(): take void*
Nobu doesn't like (char*) cast.
2021-10-05 14:18:23 +09:00
卜部昌平 5112a54846 include/ruby/encoding.h: convert macros into inline functions
Less macros == huge win.
2021-10-05 14:18:23 +09:00
卜部昌平 312668cf03 split include/ruby/encoding.h
2,291 lines are too much!  include/ruby/encoding.h became the biggest
header file once it had doxygen comments.  Let us split it into smaller
parts, so that we can better organise their contents.
2021-10-05 14:18:23 +09:00
卜部昌平 2fa4715bf2 rb_ractor_shareable_p(): fix doxygen
My bad.  The document is clearly broken.  Maybe I pressed my delete key
too much. [ci skip]
2021-10-05 14:18:23 +09:00
卜部昌平 90f2ab9d62 rb_fiber_raise(): add doxygen
Must not be a bad idea to improve documents.
2021-09-30 20:55:23 +13:00
Nobuyoshi Nakada f7ffe9dbde
Introduce `RBIMPL_NONNULL_ARG` macro
Runtime assertion for the argument declared as non-null.
This macro does nothing if `RBIMPL_ATTR_NONNULL` is effective,
otherwise asserts that the argument is non-null.
2021-09-27 14:47:52 +09:00
Nobuyoshi Nakada 63297c2ca4
Align the implementation precedences with `rb_atomic_t` definition
On MinGW, where both of Win32 API and GCC built-ins are available,
the mismatch of implementations to the definition caused lots of
warnings.
2021-09-24 10:11:32 +09:00
卜部昌平 0dea31c437 RBIMPL_ATTR_NOALIAS: not until LLVM 12
I observed CI failures.
https://github.com/ruby/ruby/actions/runs/1240165911

It turns out that  RBIMPL_ATTR_NOALIAS was not mature before.  Skip
using it for old clang, and everything work as expected.
2021-09-22 16:37:13 +09:00
卜部昌平 ecaf3a391d include/ruby/atomic.h: rework
Reduce macros to do the same things in inline functions instead.  This
way assertions can be made granular.
2021-09-22 16:37:13 +09:00
Samuel Williams 88ba5fe547 Expose `rb_fiber_raise` and tidy up the internal implementation. 2021-09-20 18:30:51 +12:00
卜部昌平 63ab2fedc8 include/ruby/atomic.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-15 09:25:23 +09:00
Nobuyoshi Nakada b568e6a130
Suppress deprecated rb_iterate declaration warnings in C++
Apply commit:733ffa74cd32a5c11ff744a5490782daa00ff1ae again.
2021-09-11 17:54:11 +09:00
Nobuyoshi Nakada cd829bb078 Remove printf family from the mjit header
Linking printf family functions makes mjit objects to link
unnecessary code.
2021-09-11 08:41:32 +09:00
卜部昌平 c39dd708b5 suppress GCC's -Wmissing-attribute
I was not aware of this because I use clang these days.
2021-09-10 20:00:06 +09:00
卜部昌平 6522b51ce5 rb_ary_new_from_values: can take NULLs
Explicit check done at runtime.
2021-09-10 20:00:06 +09:00
卜部昌平 dddc618d30 suppress GCC's -Wsuggest-attribute=format
I was not aware of this because I use clang these days.
2021-09-10 20:00:06 +09:00
卜部昌平 fd12bc1896 ruby_scan_oct, ruby_scan_hex: are not pure
Silly bug, they write back consumed bytes through passed pointers.  Must
never be pure functions.

ruby_scan_oct does not refer any static variables so it can still be
__declspec(noalias), while ruby_scan_hex is not because it reads from
ruby_digit36_to_number_table.
2021-09-10 20:00:06 +09:00
卜部昌平 4f03930d04 ruby_cleanup: fix MSVC compile error
See https://ci.appveyor.com/project/ruby/ruby/builds/40686153/job/1wihxw5m5kybtohj
2021-09-10 20:00:06 +09:00
卜部昌平 676073b62e include/ruby.h: skip doxygen
Everything defined in this header file are for backwards compatibility
only.  No one practically need them any longer. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 4702b59f21 include/ruby/backward.h: skip doxygen
There is nothing interesting here. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 6420db8ab7 include/ruby/debug.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 1563526edf include/ruby/defines.h: add doxygen
The only thing that remains in this file which is still worth
documenting is the RUBY macro.  Everything else were split into many
files in
1ff4cee2b1

[ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 6e8e2b467b forgot to delete a redundant comment 2021-09-10 20:00:06 +09:00
卜部昌平 3ca688aeb0 include/ruby/encoding.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 84b96298b3 include/ruby/fiber/scheduler.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 809138fe4b include/ruby/io.h: add doxyen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 6204b0dd99 include/ruby/memory_view.h: add doxygen
I'm just applying doc/memory_view.md as a doxygen comment. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5a79439a68 include/ruby/missing.h: skip doxygen
We don't want to document e.g. M_PI, which is an ISO C thing.
2021-09-10 20:00:06 +09:00
卜部昌平 56c0475036 include/ruby/ractor.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 2c4dccad33 include/ruby/random.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 1c9106da8b include/ruby/re.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 4c14c55505 include/ruby/regex.h: skip doxygen
It seems this is a part of Onigmo's API, not Ruby's.
2021-09-10 20:00:06 +09:00
卜部昌平 e18bc14a05 include/ruby/ruby.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 4912260b70 include/ruby/subst.h: skip doxygen
Nothing worth documenting in this file. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 a50287ab03 include/ruby/thread.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 53e0d7eec7 include/ruby/thread_native.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 eb39497ecf include/ruby/util.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 99dd95806d include/ruby/version.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 072d74cc7a include/ruby/vm.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 ba814a5aa3 include/ruby/backward/2/assume.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5107a6bf12 include/ruby/backward/2/attributes.h: skip doxygen
These macros are for backwards compatibility.  No longer used in our
public header files.  People can safely forget about them.
[ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 07240056f9 include/ruby/backward/2/bool.h: skip doxygen
It's 21st century, right?  Just forget about them. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 c0b5d95cc0 include/ruby/backward/2/gcc_version_since.h: skip doxygen
It seems no public APIs depend on this macro any longer. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5868ebf46e include/ruby/backward/2/inttypes.h: skip dpxygen
These macros need not be documented methinks. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 0f9cf6d4d0 include/ruby/backward/2/limits.h: skip doxygen
For instane CHAR_BIT is an ANSI C macro which should be documented in
other places than Ruby (and the definition in this file must work
exactly identical to that of standard one). [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 7ead69068e include/ruby/backward/2/long_long.h: add doxygen
Might want to delete LONG_LONG macro but for the time being let us
describe what on earth it is. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 f05dc8b44a include/ruby/backward/2/r_cast.h: skip doxygen
Nobody practically uses this file.  Please just don't remember.
[ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 e5a1efb72a include/ruby/backward/2/rmodule.h: skip doxygen
These macros are considered archaic. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 c4693b8a5b include/ruby/backward/2/stdalign.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 8a469f1c25 include/ruby/backward/2/stdarg.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5453031fd4 include/ruby/backward/cxxanyargs.hpp: addo doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 cac1e88d75 include/ruby/backward/cxxanyargs.hpp: suppress doxygen warning
rb_cFiber is not visible from extension libraries, hence intentionally
not documented. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 9eab1e9107 include/ruby/internal/arithmetic/char.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 6e62cf46ed include/ruby/internal/arithmetic/double.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 887c1f117d include/ruby/internal/arithmetic/fixnum.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 98ab286195 include/ruby/internal/arithmetic/gid_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5e1caeb15c include/ruby/internal/arithmetic/int.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 8fa82cd272 include/ruby/internal/arithmetic/intptr_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 6706d0216f include/ruby/internal/arithmetic/long.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 abd15ac775 include/ruby/internal/arithmetic/long_long.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 e9c423ac6c include/ruby/internal/arithmetic/mode_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 92150fde85 include/ruby/internal/arithmetic/off_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5289552e53 include/ruby/internal/arithmetic/pid_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 009c6b742b include/ruby/internal/arithmetic/short.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5c3cd09715 include/ruby/internal/arithmetic/size_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 86d4fe686c include/ruby/internal/arithmetic/st_data_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 edf1964bdf include/ruby/internal/arithmetic/uid_t.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 0ea157136f postscript about rb_mutex_sleep
Asked ko1 about the design.  [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 ce54282b75 include/ruby/internal/intern/array.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 f9a00f9ef2 include/ruby/internal/intern/bignum.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 fbe1fcd82d include/ruby/internal/intern/class.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 5f478d8ac3 include/ruby/internal/intern/compar.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 0375f1fe97 include/ruby/internal/intern/complex.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 0f3ae58882 include/ruby/internal/intern/cont.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 974a9e4fba include/ruby/internal/intern/dir.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 0a7034258f include/ruby/internal/intern/enum.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 407c4850f1 include/ruby/internal/intern/enumerator.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 d5460f1cda include/ruby/internal/intern/error.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 3fa875f88b include/ruby/internal/intern/eval.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 e3b94182a0 include/ruby/internal/intern/file.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 ba42d35dd0 include/ruby/internal/intern/gc.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 990a6c789a include/ruby/internal/intern/hash.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
卜部昌平 398be8bc92 include/ruby/internal/intern/io.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00