summaryrefslogtreecommitdiff
path: root/include/ruby/internal
AgeCommit message (Collapse)Author
2024-04-29suppress -Wold-style-cast warnings卜部昌平
2024-04-29workaround C++ compile error卜部昌平
We observe compiler error on FreeBSD. Their stdckdint.h does not understand C++. This shall be addressed on their side. Unti then we resport to our own version. https://rubyci.s3.amazonaws.com/freebsd14/ruby-master/log/20240427T143002Z.log.html.gz
2024-04-27use of stdckdint.h卜部昌平
C23 is going to have this header. The industry is already moving towards accepting it; OSes and compilers started to implement theirs. Why not detect its presence and if any, prefer over other ways. See also: - https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2683.pdf - https://reviews.freebsd.org/D41734 - https://reviews.llvm.org/D157331 - https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8441841a1b985d68245954af1ff023db121b0635
2024-04-18Include coderange.h in encoding.hPeter Zhu
ruby_coderange_type is defined in ruby/internal/encoding/coderange.h so we need to include it.
2024-04-16RB_OBJ_FREEZE_RAW: Set the object shapeJean Boussier
2024-04-11put empty `rb_gc_force_recycle()`Koichi Sasada
and declare it will be removed soon. ddtrace is still referes the API and build was failed. See https://github.com/DataDog/dd-trace-rb/pull/3578 Maybe threre are only few users of this C-API now so we can remove it soon.
2024-04-05Remove deprecated function rb_gc_force_recyclePeter Zhu
This function has been deprecated since Ruby 3.1, so we should remove it for Ruby 3.4.
2024-03-27[DOC] remove repetitive words in commentscrazeteam
Signed-off-by: crazeteam <lilujing@outlook.com>
2024-03-26Expose rb_str_chilled_pÉtienne Barrié
Some extensions (like stringio) may need to differentiate between chilled strings and frozen strings. They can now use rb_str_chilled_p but must check for its presence since the function will be removed when chilled strings are removed. [Bug #20389] [Feature #20205] Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-23[DOC] Small edits in rbasic.hXavier Noria
2024-03-19Implement chilled stringsÉtienne Barrié
[Feature #20205] As a path toward enabling frozen string literals by default in the future, this commit introduce "chilled strings". From a user perspective chilled strings pretend to be frozen, but on the first attempt to mutate them, they lose their frozen status and emit a warning rather than to raise a `FrozenError`. Implementation wise, `rb_compile_option_struct.frozen_string_literal` is no longer a boolean but a tri-state of `enabled/disabled/unset`. When code is compiled with frozen string literals neither explictly enabled or disabled, string literals are compiled with a new `putchilledstring` instruction. This instruction is identical to `putstring` except it marks the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags. Chilled strings have the `FL_FREEZE` flag as to minimize the need to check for chilled strings across the codebase, and to improve compatibility with C extensions. Notes: - `String#freeze`: clears the chilled flag. - `String#-@`: acts as if the string was mutable. - `String#+@`: acts as if the string was mutable. - `String#clone`: copies the chilled flag. Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-14[Feature #20265] Remove rb_newobj_of and RB_NEWOBJ_OFPeter Zhu
2024-03-14[Feature #20265] Remove rb_newobj and RB_NEWOBJPeter Zhu
2024-03-06Move FL_SINGLETON to FL_USER1Jean Boussier
This frees FL_USER0 on both T_MODULE and T_CLASS. Note: prior to this, FL_SINGLETON was never set on T_MODULE, so checking for `FL_SINGLETON` without first checking that `FL_TYPE` was `T_CLASS` was valid. That's no longer the case.
2024-03-05[DOC] fix some commentscui fliter
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-01Clarify C API documentation about pinned classesJean Boussier
They are not only pinned, but also immortal. Even if the constant referencing them is removed, they will remain alive. It's a precision worth noting.
2024-02-11Win32: Fix pre-defined macros for platformsNobuyoshi Nakada
Use `_WIN64` for word-size, `_M_AMD64` for CPU-specific feature.
2024-02-04Do not define ABI version in statically linked objectsNobuyoshi Nakada
It is for dynamically loading, useless for statically linked objects.
2024-02-01Suppress unused-local-typedef warningsNobuyoshi Nakada
2024-01-19Pass down "stack start" variables from closer to the top of the stackKJ Tsanaktsidis
This commit changes how stack extents are calculated for both the main thread and other threads. Ruby uses the address of a local variable as part of the calculation for machine stack extents: * pthreads uses it as a lower-bound on the start of the stack, because glibc (and maybe other libcs) can store its own data on the stack before calling into user code on thread creation. * win32 uses it as an argument to VirtualQuery, which gets the extent of the memory mapping which contains the variable However, the local being used for this is actually too low (too close to the leaf function call) in both the main thread case and the new thread case. In the main thread case, we have the `INIT_STACK` macro, which is used for pthreads to set the `native_main_thread->stack_start` value. This value is correctly captured at the very top level of the program (in main.c). However, this is _not_ what's used to set the execution context machine stack (`th->ec->machine_stack.stack_start`); that gets set as part of a call to `ruby_thread_init_stack` in `Init_BareVM`, using the address of a local variable allocated _inside_ `Init_BareVM`. This is too low; we need to use a local allocated closer to the top of the program. In the new thread case, the lolcal is allocated inside `native_thread_init_stack`, which is, again, too low. In both cases, this means that we might have VALUEs lying outside the bounds of `th->ec->machine.stack_{start,end}`, which won't be marked correctly by the GC machinery. To fix this, * In the main thread case: We already have `INIT_STACK` at the right level, so just pass that local var to `ruby_thread_init_stack`. * In the new thread case: Allocate the local one level above the call to `native_thread_init_stack` in `call_thread_start_func2`. [Bug #20001] fix
2024-01-12Revert "Pass down "stack start" variables from closer to the top of the stack"KJ Tsanaktsidis
This reverts commit 4ba8f0dc993953d3ddda6328e3ef17a2fc2cbde5.
2024-01-12Pass down "stack start" variables from closer to the top of the stackKJ Tsanaktsidis
The implementation of `native_thread_init_stack` for the various threading models can use the address of a local variable as part of the calculation of the machine stack extents: * pthreads uses it as a lower-bound on the start of the stack, because glibc (and maybe other libcs) can store its own data on the stack before calling into user code on thread creation. * win32 uses it as an argument to VirtualQuery, which gets the extent of the memory mapping which contains the variable However, the local being used for this is actually allocated _inside_ the `native_thread_init_stack` frame; that means the caller might allocate a VALUE on the stack that actually lies outside the bounds stored in machine.stack_{start,end}. A local variable from one level above the topmost frame that stores VALUEs on the stack must be drilled down into the call to `native_thread_init_stack` to be used in the calculation. This probably doesn't _really_ matter for the win32 case (they'll be in the same memory mapping so VirtualQuery should return the same thing), but definitely could matter for the pthreads case. [Bug #20001]
2023-12-21Typo fixes for public headers [ci skip]Alan Wu
2023-12-14rb_ext_resolve_symbol: C API to resolve and return externed symbols [Feature ↵Satoshi Tagomori
#20005] This is a C API for extensions to resolve and get function symbols of other extensions. Extensions can check the expected symbol is correctly loaded and accessible, and use it if it is available. Otherwise, extensions can raise their own error to guide users to setup their environments correctly and what's missing.
2023-11-30Add `RUBY_REFERENCES`Nobuyoshi Nakada
Instead of `RUBY_REFERENCES_START` and `RUBY_REFERENCES_END`, so that auto-indent works well.
2023-11-30Prefix `REF_EDGE` and `REFS_LIST_PTR` with `RUBY_`Nobuyoshi Nakada
Also move `struct` so that `typedef`-ed names can be used.
2023-11-26Constify `RUBY_REFERENCES_START` tablesNobuyoshi Nakada
2023-11-08TypedData_Make_Struct0: cast RTYPEDDATA_GET_DATA return pointerJean Boussier
Fixes: ``` /usr/local/ruby/include/ruby-3.3.0+0/ruby/internal/core/rtypeddata.h:467:33: error: invalid conversion from ‘void*’ to ‘parser_t*’ [-fpermissive] 467 | (sval) = RTYPEDDATA_GET_DATA(result); \ | ~~~~~~~~~~~~~~~~~~~^~~~~~~~ | | | void* ```
2023-11-07Implement embedded TypedData objectsPeter Zhu
This commit adds a new flag RUBY_TYPED_EMBEDDABLE that allows the data of a TypedData object to be embedded after the object itself. This will improve cache locality and allow us to save the 8 byte data pointer. Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-09-29Fix documentation for rb_warn() and friendsBenoit Daloze
* rb_warn() does not warn if $VERBOSE is nil, the "always" is wrong. * Talk about $VERBOSE and not -W since $VERBOSE can be changed at runtime.
2023-09-27[DOC] Missing comment markersNobuyoshi Nakada
2023-09-16Fix comment for rb_enc_str_new [ci skip]John Hawthorn
2023-08-29Expose `rb_process_status_wait` and hide `rb_process_status_waitv`. (#8316)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-08-25workaround clang-17 -Wc2x-extensions卜部昌平
cf: https://github.com/llvm/llvm-project/commit/874217f99b99ab3c9026dc3b7bd84cd2beebde6e Notes: Merged: https://github.com/ruby/ruby/pull/8274
2023-08-02YJIT: Move ROBJECT_OFFSET_* to yjit.c (#8157)Takashi Kokubun
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-08-01support `rescue` event for TracePointKoichi Sasada
fix [Feature #19572] Notes: Merged: https://github.com/ruby/ruby/pull/8150
2023-07-24RString NULL ptr check only when RUBY_DEBUGNobuyoshi Nakada
Since edf01d4e82d8e44ee30ec41fbcb7f802bc8b8c5d, fake string treats NULL as an empty string.
2023-07-20Embed struct rmatch into GC slot (#8097)Kunshan Wang
2023-07-17Move `posix_signal` declaration internal with prefix `ruby_`Nobuyoshi Nakada
2023-07-13Remove RARRAY_CONST_PTR_TRANSIENTPeter Zhu
RARRAY_CONST_PTR now does the same things as RARRAY_CONST_PTR_TRANSIENT. Notes: Merged: https://github.com/ruby/ruby/pull/8071
2023-07-13Remove RARRAY_PTR_USE_TRANSIENTPeter Zhu
RARRAY_PTR_USE now does the same things as RARRAY_PTR_USE_TRANSIENT. Notes: Merged: https://github.com/ruby/ruby/pull/8071
2023-07-13Remove rb_array_ptr_use_{start,end}Peter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/8071
2023-07-13[Feature #19730] Remove transient heapPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/7942
2023-07-13[Feature #19757] Add new API `rb_data_define`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/8066
2023-07-13Store object age in a bitmapMatt Valentine-House
Closes [Feature #19729] Previously 2 bits of the flags on each RVALUE are reserved to store the number of GC cycles that each object has survived. This commit introduces a new bit array on the heap page, called age_bits, to store that information instead. This patch still reserves one of the age bits in the flags (the old FL_PROMOTED0 bit, now renamed FL_PROMOTED). This is set to 0 for young objects and 1 for old objects, and is used as a performance optimisation for the write barrier. Fetching the age_bits from the heap page and doing the required math to calculate if the object was old or not would slow down the write barrier. So we keep this bit synced in the flags for fast access. Notes: Merged: https://github.com/ruby/ruby/pull/7938
2023-07-04Remove reference to USE_RINCGCMatt Valentine-House
This compile time flag was removed in https://github.com/ruby/ruby/pull/7313 This commit cleans up some related dead code. Notes: Merged: https://github.com/ruby/ruby/pull/7982
2023-06-27Use `rb_reg_nth_defined` instead of `rb_match_nth_defined`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7983
2023-06-19Remove taint and untrusted flags (#7958)Nobuyoshi Nakada
* Make TAINT and UNTRUSTED flags zero These flags do nothing already, and should break nothing. * Remove TAINT and UNTRUSTED macros same as functions These macros had been defined to use with `#ifdef`, but should not be used anymore. Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
2023-06-17Fixes [Bug #19732]. Add missing stdint.h header to event.h.Peter Arato
Notes: Merged: https://github.com/ruby/ruby/pull/7945
2023-06-12[DOC] Should use `NULL` instead of zeroNobuyoshi Nakada
Since no type information is available for variadic arguments, 0 is passed as `int` without promoting to pointer. On platforms where `sizeof(int) < sizeof(void*)`, the terminator argument may be read together with an adjoining word, and may not be found.