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

2166 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 6f3aff3961
[Bug #19289] Retain `ruby_abi_version` function
A few extension libraries, to hide all symbols except for necessary to
load, hardcode the symbols to be exported in symbol list files for
linker without even checking by `have_func`.  As a workaround for such
libraries, retain `ruby_abi_version` symbol always even in released
versions for now.
2023-01-20 00:26:52 +09:00
Peter Zhu 0fd5a664e7 Remove macro RHASH_ITER_LEV
The function rb_hash_iter_lev doesn't exist as it was removed.
2023-01-18 11:54:34 -05:00
Benoit Daloze 6abe20e87b Remove Encoding#replicate 2023-01-11 13:41:41 +01:00
Nobuyoshi Nakada d8b55d11da
Reset ABI version [ci skip] 2022-12-26 11:25:56 +09:00
Yukihiro "Matz" Matsumoto 2a6dbf03a2
Development of 3.3.0 started. 2022-12-26 08:46:59 +09:00
Benoit Daloze 45175962a6 Never use the storage of another Fiber, that violates the whole design
* See https://bugs.ruby-lang.org/issues/19078#note-30
2022-12-20 19:32:23 +01:00
TSUYUSATO Kitsune fbedadb61f
Add `Regexp.linear_time?` (#6901) 2022-12-14 12:57:14 +09:00
Matt Valentine-House 83c12b5baa [ci skip] Fix Doxygen for ROBJECT Macro 2022-12-13 15:42:14 -05:00
Jimmy Bourassa 5738ae70d9
[DOC] Update `rb_gc_mark_locations` doc
The documentation says that the `end` pointer will be marked
but looking at the source, that is not the case.
2022-12-09 00:38:23 +09:00
卜部昌平 940b3170c1 document for commit 5bbba76489 [ci skip] 2022-12-07 15:09:12 +09:00
Lars Kanis 81e274c990 [DOC] Improve documentation to RB_ALLOCV
Although the storage of the opaque Ruby object is an array of VALUEs, the intention of RB_ALLOCV is to allocate bytes of memory.
2022-12-06 14:55:05 +09:00
Samuel Williams 4fa47eabf2
Clarify the storage argument. (#6849)
* Slightly more consistent indentation with other parts of the document.
2022-12-02 17:49:42 +13:00
Samuel Williams 0436f1e15a
Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612) 2022-12-01 23:00:33 +13:00
Koichi Sasada 67766cd55c add debug context APIs for debuggers (frame depth)
The following new debug context APIs are for implementing debugger's
`next` (step over) and similar functionality.

* `rb_debug_inspector_frame_depth(dc, index)` returns `index`-th
  frame's depth.
* `rb_debug_inspector_current_depth()` returns current frame depth.

The frame depth is not related to the frame index because debug
context API skips some special frames but proposed `_depth()` APIs
returns the count of all frames (raw depth).
2022-11-25 14:01:36 +09:00
Takashi Kokubun ab4379e086
Refactor RB_SPECIAL_CONST_P (#6759)
Since https://github.com/ruby/ruby/pull/6599, RUBY_IMMEDIATE_MASK also
overlaps RUBY_Qnil. Now RB_SPECIAL_CONST_P seems confusing since both
RB_IMMEDIATE_P and RB_TEST check for RUBY_Qnil while we only need to
check RUBY_Qnil besides RUBY_IMMEDIATE_MASK. I'd like to make this
change to make it less confusing.

I confirmed that this doesn't change the number of instructions used for
the RUBY_Qfalse check on Linux x86_64 GCC and macOS arm64 Clang.
2022-11-17 17:55:24 -08:00
Samuel Williams ea8a7287e2
Add support for `sockaddr_un` on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
Lars Kanis 7b1d23fd29
Windows: Readlink improvements (#6745)
* Windows: Use readlink emulation for File.readlink

This fixes readlink emulation for the ERROR_MORE_DATA case and general error reporting.
It now releases GVL while readlink IO operation.

The dedicated rb_readlink was introduced in commit 2ffb87995a
in order to improve encoding and buffer allocation.
However the encoding issues are solved since ruby-3.0 switched to UTF-8
and the buffer allocation will be improved in a later commit.

* Windows: Increase the default buffer size for reparse point info

So far nearly all queries of reparse points needed two attempts to get enough buffer.

* Windows: Remove declaration of rb_w32_wreadlink

It was removed in commit 2f6fdd3aeb
2022-11-17 01:57:52 -08:00
Jemma Issroff c726c48a3d Remove numiv from RObject
Since object shapes store the capacity of an object, we no longer
need the numiv field on RObjects. This gives us one extra slot which
we can use to give embedded objects one more instance variable (for a
total of 3 ivs). This commit removes the concept of numiv from RObject.
2022-11-10 10:11:34 -05:00
Jemma Issroff 5246f4027e Transition shape when object's capacity changes
This commit adds a `capacity` field to shapes, and adds shape
transitions whenever an object's capacity changes. Objects which are
allocated out of a bigger size pool will also make a transition from the
root shape to the shape with the correct capacity for their size pool
when they are allocated.

This commit will allow us to remove numiv from objects completely, and
will also mean we can guarantee that if two objects share shapes, their
IVs are in the same positions (an embedded and extended object cannot
share shapes). This will enable us to implement ivar sets in YJIT using
object shapes.

Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2022-11-10 10:11:34 -05:00
Nobuyoshi Nakada b7e8876704
[Bug #19100] Add `init_int32` function to `rb_random_interface_t`
Distinguish initialization by single word from initialization by
array.
2022-11-10 12:06:13 +09:00
Nobuyoshi Nakada 6eaed20e14
Add version to the interface of Random extensions 2022-11-10 11:59:45 +09:00
TSUYUSATO Kitsune 1dc4128e92 Reduce warnings 2022-11-09 23:21:26 +09:00
TSUYUSATO Kitsune a1c1fc558a Revert "Refactor field names"
This reverts commit 1e6673d6bbd2adbf555d82c7c0906ceb148ed6ee.
2022-11-09 23:21:26 +09:00
TSUYUSATO Kitsune 22294731a8 Refactor field names 2022-11-09 23:21:26 +09:00
TSUYUSATO Kitsune f25bb291b4 Support OP_REPEAT and OP_REPEAT_INC 2022-11-09 23:21:26 +09:00
Nobuyoshi Nakada 558137d5f3
[DOC] Fix missing type name 2022-11-09 12:04:22 +09:00
Nobuyoshi Nakada a14611cd54 Fix -Wundef warnings 2022-10-26 18:57:26 +09:00
Yusuke Endoh 1d2d25dcad Prevent potential buffer overrun in onigmo
A code pattern `p + enclen(enc, p, pend)` may lead to a buffer overrun
if incomplete bytes of a UTF-8 character is placed at the end of a
string. Because this pattern is used in several places in onigmo,
this change fixes the issue in the side of `enclen`: the function should
not return a number that is larger than `pend - p`.

Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-10-25 17:02:43 +09:00
Nick Hengeveld ee3da3784e Use CXX14 to allow constexpr with non-return statements
Co-authored-by: Daniel Colson <composerinteralia@github.com>
2022-10-24 16:47:42 -07:00
Ufuk Kayserilioglu 0378e2f4a8 Add Class#attached_object
Implements [Feature #12084]

Returns the object for which the receiver is the singleton class, or
raises TypeError if the receiver is not a singleton class.
2022-10-20 17:30:17 +02:00
Nobuyoshi Nakada 192bc72529 Define `UNDEF_P` and `NIL_OR_UNDEF_P` [EXPERIMENTAL] 2022-10-20 22:05:27 +09:00
Nobuyoshi Nakada f55212bce9 Move "special consts" so `Qundef` and `Qnil` differ just 1 bit 2022-10-20 22:05:27 +09:00
Nobuyoshi Nakada 0a43a040b4
[DOC] Fix RUBY_SYMBOL_FLAG comment [ci skip]
Upper bits than the least significant 4 bits need not be 0.
2022-10-20 11:49:55 +09:00
Nobuyoshi Nakada 412e3c7a8d Assert for RTEST that Qnil and Qfalse differ just 1 bit 2022-10-19 22:55:42 +09:00
Sergey Fedorov 567725ed30
Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975) 2022-10-19 23:49:45 +13:00
Samuel Williams fc3137ef54
Add support for anonymous shared IO buffers. (#6580) 2022-10-19 18:53:38 +13:00
Samuel Williams 7fcad1fa03
Update `Fiber::Scheduler` documentation. (#6562) 2022-10-15 21:43:45 +13:00
Samuel Williams 8a420670a2
Introduce `Fiber::Scheduler#io_select` hook for non-blocking `IO.select`. (#6559) 2022-10-15 19:59:04 +13:00
Samuel Williams ced1d17280
Improvements to IO::Buffer implementation and documentation. (#6525) 2022-10-12 12:59:05 +13:00
Jemma Issroff ad63b668e2
Revert "Revert "This commit implements the Object Shapes technique in CRuby.""
This reverts commit 9a6803c90b.
2022-10-11 08:40:56 -07:00
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