summaryrefslogtreecommitdiff
path: root/internal
AgeCommit message (Collapse)Author
2020-05-07Allow global variables to moveAaron Patterson
This patch allows global variables that have been assigned in Ruby to move. I added a new function for the GC to call that will update global references and introduced a new callback in the global variable struct for updating references. Only pure Ruby global variables are supported right now, other references will be pinned.
2020-05-02internal/process.h: forgot to guard "#ifdef HAVE_WORKING_FORK"Yusuke Endoh
2020-05-02internal/process.h: add a no-warning simple wrapper for fork(2)Yusuke Endoh
As fork(2) is deprecated, its calls must be guarded by `COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)`. All usages of fork(2) in process have been alread guarded. A new call to fork(2) was added in ruby.c with f22c4ff359498ab342e4b6d6feb21af6004ee270. This caused a build failure on Solaris 11. It may hide a bug to guard big code unnecessarily, so this change introduces a simple wrapper "rb_fork" whose definition is guarded, and replaces all calls to fork(2) with the wrapper function.
2020-04-21__GNUC__ is too lax卜部昌平
Ditto for 4b853932eaa7fa4acf8a0f0c9b7c695bb4f5e76d
2020-04-15Added rb_syserr_new_pathNobuyoshi Nakada
Similar to rb_syserr_fail_path, but just returns the created exception instance instead of raising it. Notes: Merged: https://github.com/ruby/ruby/pull/3035
2020-04-13delete CACHELINE卜部昌平
Since https://github.com/ruby/ruby/pull/2888 this macro is no longer used in any place.
2020-04-13add #include guard hack卜部昌平
According to MSVC manual (*1), cl.exe can skip including a header file when that: - contains #pragma once, or - starts with #ifndef, or - starts with #if ! defined. GCC has a similar trick (*2), but it acts more stricter (e. g. there must be _no tokens_ outside of #ifndef...#endif). Sun C lacked #pragma once for a looong time. Oracle Developer Studio 12.5 finally implemented it, but we cannot assume such recent version. This changeset modifies header files so that each of them include strictly one #ifndef...#endif. I believe this is the most portable way to trigger compiler optimizations. [Bug #16770] *1: https://docs.microsoft.com/en-us/cpp/preprocessor/once *2: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html Notes: Merged: https://github.com/ruby/ruby/pull/3023
2020-04-12PAGER without fork&exec too [Feature #16754]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3000
2020-04-09internal/bits.h: Suppress "uninitialized variable"Yusuke Endoh
Coverity Scan says "Using uninitialized value c.fixnum when calling __builtin_mul_overflow_p."
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-04-02Export `rb_deprecate_constant`Nobuyoshi Nakada
2020-03-21Removed non-RUBY_INTEGER_UNIFICATION codeNobuyoshi Nakada
2020-03-16hash.c: Do not use the fast path (rb_yield_values) for lambda blocksYusuke Endoh
As a semantics, Hash#each yields a 2-element array (pairs of keys and values). So, `{ a: 1 }.each(&->(k, v) { })` should raise an exception due to lambda's arity check. However, the optimization that avoids Array allocation by using rb_yield_values for blocks whose arity is more than 1 (introduced at b9d29603375d17c3d1d609d9662f50beaec61fa1 and some commits), seemed to overlook the lambda case, and wrongly allowed the code above to work. This change experimentally attempts to make it strict; now the code above raises an ArgumentError. This is an incompatible change; if the compatibility issue is bigger than our expectation, it may be reverted (until Ruby 3.0 release). [Bug #12706]
2020-03-11Fix typos (#2958)K.Takata
* Fix a typo * Fix typos in st.[ch] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-02-28Prevent unloading methods used in root_fiber while calling another Fiber (#2939)Takashi Kokubun
Fixing SEGVs like: http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400 Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-02-22Introduce disposable call-cache.Koichi Sasada
This patch contains several ideas: (1) Disposable inline method cache (IMC) for race-free inline method cache * Making call-cache (CC) as a RVALUE (GC target object) and allocate new CC on cache miss. * This technique allows race-free access from parallel processing elements like RCU. (2) Introduce per-Class method cache (pCMC) * Instead of fixed-size global method cache (GMC), pCMC allows flexible cache size. * Caching CCs reduces CC allocation and allow sharing CC's fast-path between same call-info (CI) call-sites. (3) Invalidate an inline method cache by invalidating corresponding method entries (MEs) * Instead of using class serials, we set "invalidated" flag for method entry itself to represent cache invalidation. * Compare with using class serials, the impact of method modification (add/overwrite/delete) is small. * Updating class serials invalidate all method caches of the class and sub-classes. * Proposed approach only invalidate the method cache of only one ME. See [Feature #16614] for more details. Notes: Merged: https://github.com/ruby/ruby/pull/2888
2020-02-22VALUE size packed callinfo (ci).Koichi Sasada
Now, rb_call_info contains how to call the method with tuple of (mid, orig_argc, flags, kwarg). Most of cases, kwarg == NULL and mid+argc+flags only requires 64bits. So this patch packed rb_call_info to VALUE (1 word) on such cases. If we can not represent it in VALUE, then use imemo_callinfo which contains conventional callinfo (rb_callinfo, renamed from rb_call_info). iseq->body->ci_kw_size is removed because all of callinfo is VALUE size (packed ci or a pointer to imemo_callinfo). To access ci information, we need to use these functions: vm_ci_mid(ci), _flag(ci), _argc(ci), _kwarg(ci). struct rb_call_info_kw_arg is renamed to rb_callinfo_kwarg. rb_funcallv_with_cc() and rb_method_basic_definition_p_with_cc() is temporary removed because cd->ci should be marked. Notes: Merged: https://github.com/ruby/ruby/pull/2888
2020-02-22`Proc` made by `Symbol#to_proc` should be a lambda [Bug #16260]Nobuyoshi Nakada
With refinements, too.
2020-02-09Separate objspace argument for rb_gc_disable and rb_gc_enableNobuyoshi Nakada
2020-01-28Extract a function, ruby_reset_timezone().Tanaka Akira
Initial implementation of ruby_reset_timezone() assigns ruby_tz_uptodate_p to false.
2020-01-23Added rb_warn_deprecated_to_removeNobuyoshi Nakada
Warn the deprecation and future removal, with obeying the warning flag.
2020-01-17internal/rational.h: insert assertions in RATIONAL_SET_{NUM,DEN}Kenta Murata
2020-01-17Make RATIONAL_SET_{NUM,DEN} static inline functionsKenta Murata
2020-01-10add missing #include卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/2824
2020-01-10avoid undefined behaviour when n==0卜部昌平
ISO/IEC 9899:1999 section 6.5.7 states that "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined". So we have to take care of such situations. This has not been a problem because contemporary C compilers are extraordinary smart to compile the series of shifts into a single ROTLQ/ROTRQ machine instruction. In contrast to what C says those instructions have fully defined behaviour for all possible inputs. Hence it has been quite difficult to observe the undefined-ness of such situations. But undefined is undefined. We should not rely on such target-specific assumptions. We are fixing the situation by carefully avoiding shifts with out-of- range values. At least GCC since 4.6.3 and Clang since 8.0 can issue the exact same instructions like before the changeset. Also in case of Intel processors, there supposedly be intrinsics named _rotr/_rotl that do exactly what we need. They, in practice, are absent on Clang before 9.x so we cannot blindly use. But we can at least save MSVC. See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57157 https://bugs.llvm.org/show_bug.cgi?id=17332 Notes: Merged: https://github.com/ruby/ruby/pull/2824
2020-01-10more use of MSC_VERSION_SINCE卜部昌平
Replaces `#ifdef _MSC_VER` with more accurate version checks. Also, `defined(_WIN64) && defined(__AVX2__)` is redundant because there is no such tihng like a 32bit AVX2 machine. Notes: Merged: https://github.com/ruby/ruby/pull/2824
2020-01-10fix Windows breakage卜部昌平
Fixing typo revealed that _BitScanReverse is BSR, which behaves differently than LZCNT. What we want here is LZCNT so we have to emulate. Notes: Merged: https://github.com/ruby/ruby/pull/2824
2020-01-10fix typos卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/2824
2020-01-02Fully separate positional arguments and keyword argumentsJeremy Evans
This removes the warnings added in 2.7, and changes the behavior so that a final positional hash is not treated as keywords or vice-versa. To handle the arg_setup_block splat case correctly with keyword arguments, we need to check if we are taking a keyword hash. That case didn't have a test, but it affects real-world code, so add a test for it. This removes rb_empty_keyword_given_p() and related code, as that is not needed in Ruby 3. The empty keyword case is the same as the no keyword case in Ruby 3. This changes rb_scan_args to implement keyword argument separation for C functions when the : character is used. For backwards compatibility, it returns a duped hash. This is a bad idea for performance, but not duping the hash breaks at least Enumerator::ArithmeticSequence#inspect. Instead of having RB_PASS_CALLED_KEYWORDS be a number, simplify the code by just making it be rb_keyword_given_p(). Notes: Merged: https://github.com/ruby/ruby/pull/2794
2020-01-03move internal/debug.h definitions to internal.hKoichi Sasada
Debug utilities should be accessible from any internal code.
2019-12-31Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)Kenta Murata
* bignum.h: Add BIGNUM_EMBED_P * bignum.c: Use macros for handling BIGNUM_EMBED_FLAG Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2019-12-29Fixed an unavailable sanitizer featureNobuyoshi Nakada
2019-12-27reroute macro conflicts on OpenBSD卜部昌平
OpenBSD's <sys/endian.h> has its own swap32() etc. We have to avoid name conflicts. See also https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20191226T210011Z.log.html.gz#miniruby
2019-12-27Try to fix error on SolarisKazuhiro NISHIYAMA
2019-12-26internal/stdbool.h rework卜部昌平
Noticed that internal/stdbool.h and addr2line.c are the only two place where missing/stdbool.h is included. Why not delete the file so that we can merge internal/stdbool.h and missing/stdbool.h into one. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26decouple 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). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26other minior internal header tweaks卜部昌平
These headers need no rewrite. Just add some minor tweaks, like addition of #include lines. Mainly cosmetic. TIMET_MAX_PLUS_ONE was deleted because the macro was used from only one place (directly write expression there). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/vm.h rework卜部昌平
Rearranged contents, then added MJIT_FUNC_EXPORTED function declarations. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/thread.h rework卜部昌平
Rather trivial, added missed MJIT_FUNC_EXPORTED function declaration. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/symbol.h rework卜部昌平
Some declatations are moved from internal/parse.h, to reflect the fact that they are defined in symbol.c. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/string.h rework卜部昌平
Reduced the number of macros defined in the file. Also made it explicit for MJIT_FUNC_EXPORTTED functions to be so. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/range.h rework卜部昌平
Eliminate macros for better readability. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/process.h rework卜部昌平
Eliminated the macro to convert into an inline function. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/proc.h rework卜部昌平
Annotated MJIT_FUNC_EXPORTED functions as such. Declaration of rb_sym_to_proc is moved into this file because the function is defined in proc.c rather than string.c. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/object.h rework卜部昌平
Eliminated macros. As a side effect struct RBasicRaw is no longer required because we can now define anonymous structs inside of inline functions. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/gc.h rework卜部昌平
Improved readability by reducing the use of macros. Also moved some part of internal/compilers.h into this file, because it seems to be the right place for them. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/sanitizers.h rework卜部昌平
Rearrange macro orders for better readability. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/error.h rework卜部昌平
Reduce macros for readability. Also transplanted some part of internal/file.h into here because the delcared functions are in fact defined in error.c. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/compile.h rework卜部昌平
This file containes other materials than in compile.c. I could perhaps split them into files, but felt overkill. Just add comments that describe the situations. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/array.h rework卜部昌平
Rearrange contents for better readability, reduce macros for the same reason, and mark MJIT_FUNC_EXPORTED functions as such. Notes: Merged: https://github.com/ruby/ruby/pull/2711