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

185 Коммитов

Автор SHA1 Сообщение Дата
Alan Wu 264e4cd04f Remove write barrier exemption for T_ICLASS
Before this commit, iclasses were "shady", or not protected by write
barriers. Because of that, the GC needs to spend more time marking these
objects than otherwise.

Applications that make heavy use of modules should see reduction in GC
time as they have a significant number of live iclasses on the heap.

 - Put logic for iclass method table ownership into a function
 - Remove calls to WB_UNPROTECT and insert write barriers for iclasses

This commit relies on the following invariant: for any non oirigin
iclass `I`, `RCLASS_M_TBL(I) == RCLASS_M_TBL(RBasic(I)->klass)`. This
invariant did not hold prior to 98286e9 for classes and modules that
have prepended modules.

[Feature #16984]
2020-08-17 17:17:47 -04:00
Samuel Williams 0a218a97ad Expose ec -> backtrace (internal) and use it to implement fiber backtrace.
See <https://bugs.ruby-lang.org/issues/16815> for more details.
2020-08-18 00:56:35 +12:00
卜部昌平 ff30358d13 RARRAY_AREF: convert into an inline function
RARRAY_AREF has been a macro for reasons.  We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.
2020-08-15 12:09:26 +09:00
Alan Wu 37e6c83609 Lazily insert origins on prepend to save memory
98286e9850 made it so that
`Module#include` allocates an origin iclass on each use. Since `include`
is widely used, the extra allocation can contribute significantly to
memory usage.

Instead of always allocating in anticipation of prepend, this change
takes a different approach. The new setup inserts a origin iclass into
the super chains of all the children of the module when prepend happens
for the first time.

rb_ensure_origin is made static again since now that adding an origin
now means walking over all usages, we want to limit the number of places
where we do it.
2020-07-22 19:01:28 -04:00
Samuel Williams 1b3a6847be Move declarations to private `internal/thread.h` header. 2020-07-20 13:20:58 +12:00
卜部昌平 802bcd3ec8 fix MJIT link error 2020-07-13 08:56:18 +09:00
卜部昌平 9721f477c7 inline Primitive.cexpr!
We can obtain the verbatim source code of Primitive.cexpr!.  Why not
paste that content into the JITed program.
2020-07-13 08:56:18 +09:00
Alan Wu cbf52087a2 Fix missing imemo cases in objspace_dump by refactoring
imemo_callcache and imemo_callinfo were not handled by the `objspace`
module and were showing up as "unknown" in the dump. Extract the code for
naming imemos and use that in both the GC and the `objspace` module.
2020-07-10 22:42:35 -04:00
Koichi Sasada a0f12a0258
Use ID instead of GENTRY for gvars. (#3278)
Use ID instead of GENTRY for gvars.

Global variables are compiled into GENTRY (a pointer to struct
rb_global_entry). This patch replace this GENTRY to ID and
make the code simple.

We need to search GENTRY from ID every time (st_lookup), so
additional overhead will be introduced.
However, the performance of accessing global variables is not
important now a day and this simplicity helps Ractor development.
2020-07-03 16:56:44 +09:00
Nobuyoshi Nakada 254bed3027
Renamed `nurat_sub` compliant with `rb_rational_plus` 2020-07-01 22:41:15 +09:00
Nobuyoshi Nakada 184f78314e Properly resolve refinements in defined? on private call [Bug #16932] 2020-06-04 02:12:57 +09:00
Jeremy Evans 98286e9850 Ensure origins for all included, prepended, and refined modules
This fixes various issues when a module is included in or prepended
to a module or class, and then refined, or refined and then included
or prepended to a module or class.

Implement by renaming ensure_origin to rb_ensure_origin, making it
non-static, and calling it when refining a module.

Fix Module#initialize_copy to handle origins correctly.  Previously,
Module#initialize_copy did not handle origins correctly.  For example,
this code:

```ruby
module B; end
class A
  def b; 2 end
  prepend B
end
a = A.dup.new
class A
  def b; 1 end
end
p a.b
```

Printed 1 instead of 2.  This is because the super chain for
a.singleton_class was:

```
a.singleton_class
A.dup
B(iclass)
B(iclass origin)
A(origin) # not A.dup(origin)
```

The B iclasses would not be modified, so the includer entry would be
still be set to A and not A.dup.

This modifies things so that if the class/module has an origin,
all iclasses between the class/module and the origin are duplicated
and have the correct includer entry set, and the correct origin
is created.

This requires other changes to make sure all tests still pass:

* rb_undef_methods_from doesn't automatically handle classes with
  origins, so pass it the origin for Comparable when undefing
  methods in Complex. This fixed a failure in the Complex tests.

* When adding a method, the method cache was not cleared
  correctly if klass has an origin.  Clear the method cache for
  the klass before switching to the origin of klass.  This fixed
  failures in the autoload tests related to overridding require,
  without breaking the optimization tests.  Also clear the method
  cache for both the module and origin when removing a method.

* Module#include? is fixed to skip origin iclasses.

* Refinements are fixed to use the origin class of the module that
  has an origin.

* RCLASS_REFINED_BY_ANY is removed as it was only used in a single
  place and is no longer needed.

* Marshal#dump is fixed to skip iclass origins.

* rb_method_entry_make is fixed to handled overridden optimized
  methods for modules that have origins.

Fixes [Bug #16852]
2020-06-03 09:50:37 -07:00
Alan D. Salewski c15cddd1d5 Allow Dir.home to work for non-login procs when $HOME not set
Allow the 'Dir.home' method to reliably locate the user's home directory when
all three of the following are true at the same time:

    1. Ruby is running on a Unix-like OS
    2. The $HOME environment variable is not set
    3. The process is not a descendant of login(1) (or a work-alike)

The prior behavior was that the lookup could only work for login-descended
processes.

This is accomplished by looking up the user's record in the password database
by uid (getpwuid_r(3)) as a fallback to the lookup by name (getpwname_r(3))
which is still attempted first (based on the name, if any, returned by
getlogin_r(3)).

If getlogin_r(3), getpwnam_r(3), and/or getpwuid_r(3) is not available at
compile time, will fallback on using their respective non-*_r() variants:
getlogin(3), getpwnam(3), and/or getpwuid(3).

The rationale for attempting to do the lookup by name prior to doing it by uid
is to accommodate the possibility of multiple login names (each with its own
record in the password database, so each with a potentially different home
directory) being mapped to the same uid (as is explicitly allowed for by
POSIX; see getlogin(3posix)).

Preserves the existing behavior for login-descended processes, and adds the
new capability of having Dir.home being able to find the user's home directory
for non-login-descended processes.

Fixes [Bug #16787]

Related discussion:
    https://bugs.ruby-lang.org/issues/16787
    https://github.com/ruby/ruby/pull/3034
2020-05-23 23:16:28 +09:00
Jeremy Evans ad729a1d11 Fix origin iclass pointer for modules
If a module has an origin, and that module is included in another
module or class, previously the iclass created for the module had
an origin pointer to the module's origin instead of the iclass's
origin.

Setting the origin pointer correctly requires using a stack, since
the origin iclass is not created until after the iclass itself.
Use a hidden ruby array to implement that stack.

Correctly assigning the origin pointers in the iclass caused a
use-after-free in GC.  If a module with an origin is included
in a class, the iclass shares a method table with the module
and the iclass origin shares a method table with module origin.

Mark iclass origin with a flag that notes that even though the
iclass is an origin, it shares a method table, so the method table
should not be garbage collected.  The shared method table will be
garbage collected when the module origin is garbage collected.
I've tested that this does not introduce a memory leak.

This change caused a VM assertion failure, which was traced to callable
method entries using the incorrect defined_class.  Update
rb_vm_check_redefinition_opt_method and find_defined_class_by_owner
to treat iclass origins different than class origins to avoid this
issue.

This also includes a fix for Module#included_modules to skip
iclasses with origins.

Fixes [Bug #16736]
2020-05-22 20:31:23 -07:00
Jeremy Evans 8d798e7c53 Revert "Fix origin iclass pointer for modules"
This reverts commit c745a60634.

This triggers a VM assertion.  Reverting until the issue can be
debugged.
2020-05-22 07:54:34 -07:00
Jeremy Evans c745a60634 Fix origin iclass pointer for modules
If a module has an origin, and that module is included in another
module or class, previously the iclass created for the module had
an origin pointer to the module's origin instead of the iclass's
origin.

Setting the origin pointer correctly requires using a stack, since
the origin iclass is not created until after the iclass itself.
Use a hidden ruby array to implement that stack.

Correctly assigning the origin pointers in the iclass caused a
use-after-free in GC.  If a module with an origin is included
in a class, the iclass shares a method table with the module
and the iclass origin shares a method table with module origin.

Mark iclass origin with a flag that notes that even though the
iclass is an origin, it shares a method table, so the method table
should not be garbage collected.  The shared method table will be
garbage collected when the module origin is garbage collected.
I've tested that this does not introduce a memory leak.

This also includes a fix for Module#included_modules to skip
iclasses with origins.

Fixes [Bug #16736]
2020-05-22 07:36:52 -07:00
Kazuhiro NISHIYAMA cf31e98079
Fix a typo [ci skip] 2020-05-18 17:42:50 +09:00
Yusuke Endoh 39365b46e2
Merge pull request #3047 from mame/suppress-backtrace
Add `--suppress-backtrace=num` option to limit the backtrace length
2020-05-15 01:22:56 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 97672f669a sed -i s/RUBY3/RBIMPL/g
Devs do not love "3".  The only exception is RUBY3_KEYWORDS in parse.y,
which seems unrelated to our interests.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
Aaron Patterson ff4f9cf95d
Allow global variables to move
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-07 11:42:39 -07:00
Yusuke Endoh b78fba447a internal/process.h: forgot to guard "#ifdef HAVE_WORKING_FORK" 2020-05-02 22:17:03 +09:00
Yusuke Endoh 91e4e2403e internal/process.h: add a no-warning simple wrapper for fork(2)
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 f22c4ff359.
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-05-02 21:34:10 +09:00
卜部昌平 735e035bf5 __GNUC__ is too lax
Ditto for 4b853932ea
2020-04-21 13:07:02 +09:00
Nobuyoshi Nakada d72fd1e45b
Added rb_syserr_new_path
Similar to rb_syserr_fail_path, but just returns the created
exception instance instead of raising it.
2020-04-15 21:00:53 +09:00
卜部昌平 5dc6080cb8 delete CACHELINE
Since https://github.com/ruby/ruby/pull/2888 this macro is no longer
used in any place.
2020-04-13 16:38:22 +09:00
卜部昌平 4ff3f20540 add #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
2020-04-13 16:06:00 +09:00
Nobuyoshi Nakada e6551d835f PAGER without fork&exec too [Feature #16754] 2020-04-12 14:58:13 +09:00
Yusuke Endoh 9af3469b84 internal/bits.h: Suppress "uninitialized variable"
Coverity Scan says "Using uninitialized value c.fixnum when calling
__builtin_mul_overflow_p."
2020-04-09 09:38:57 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada 9ddf147237
Export `rb_deprecate_constant` 2020-04-02 22:53:26 +09:00
Nobuyoshi Nakada 5b287481be
Removed non-RUBY_INTEGER_UNIFICATION code 2020-03-21 16:59:55 +09:00
Yusuke Endoh 47141797be hash.c: Do not use the fast path (rb_yield_values) for lambda blocks
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
b9d2960337 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-16 23:17:12 +09:00
K.Takata e89ebdcb87
Fix typos (#2958)
* Fix a typo

* Fix typos in st.[ch]
2020-03-11 00:43:12 -07:00
Takashi Kokubun adcf0316d1
Prevent unloading methods used in root_fiber while calling another Fiber (#2939)
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
2020-02-28 23:58:33 -08:00
Koichi Sasada b9007b6c54 Introduce disposable call-cache.
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.
2020-02-22 09:58:59 +09:00
Koichi Sasada f2286925f0 VALUE size packed callinfo (ci).
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.
2020-02-22 09:58:59 +09:00
Nobuyoshi Nakada 8c5ca318cb
`Proc` made by `Symbol#to_proc` should be a lambda [Bug #16260]
With refinements, too.
2020-02-22 00:45:05 +09:00
Nobuyoshi Nakada aeaf0dc555
Separate objspace argument for rb_gc_disable and rb_gc_enable 2020-02-09 17:06:31 +09:00
Tanaka Akira 338c5b8c1d Extract a function, ruby_reset_timezone().
Initial implementation of ruby_reset_timezone()
assigns ruby_tz_uptodate_p to false.
2020-01-28 23:40:25 +09:00
Nobuyoshi Nakada aefb13eb63
Added rb_warn_deprecated_to_remove
Warn the deprecation and future removal, with obeying the warning
flag.
2020-01-23 21:42:15 +09:00
Kenta Murata 07ce51c5aa
internal/rational.h: insert assertions in RATIONAL_SET_{NUM,DEN} 2020-01-17 10:06:58 +09:00
Kenta Murata 019a0ed0c7
Make RATIONAL_SET_{NUM,DEN} static inline functions 2020-01-17 10:04:19 +09:00
卜部昌平 135b533e84 add missing #include 2020-01-10 21:17:15 +09:00
卜部昌平 13064fe5db avoid 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
2020-01-10 21:17:15 +09:00
卜部昌平 79dcd26aec more 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.
2020-01-10 21:17:15 +09:00
卜部昌平 7fed7eb50b fix 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.
2020-01-10 21:17:15 +09:00
卜部昌平 db0398dc04 fix typos 2020-01-10 21:17:15 +09:00
Jeremy Evans beae6cbf0f Fully separate positional arguments and keyword arguments
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().
2020-01-02 18:40:45 -08:00
Koichi Sasada 9f460e017b move internal/debug.h definitions to internal.h
Debug utilities should be accessible from any internal code.
2020-01-03 04:46:51 +09:00
Kenta Murata e082f41611
Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)
* bignum.h: Add BIGNUM_EMBED_P

* bignum.c: Use macros for handling BIGNUM_EMBED_FLAG
2019-12-31 22:48:23 +09:00
Nobuyoshi Nakada 8ce5d46e66
Fixed an unavailable sanitizer feature 2019-12-29 08:19:43 +09:00
卜部昌平 8c5430e274 reroute 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-27 10:17:06 +09:00
Kazuhiro NISHIYAMA 018769e291
Try to fix error on Solaris 2019-12-27 09:20:58 +09:00
卜部昌平 8184adabe5 internal/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.
2019-12-26 20:45:12 +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
卜部昌平 bf53d6c7d1 other 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).
2019-12-26 20:45:12 +09:00
卜部昌平 3ae09b30f8 internal/vm.h rework
Rearranged contents, then added MJIT_FUNC_EXPORTED function
declarations.
2019-12-26 20:45:12 +09:00
卜部昌平 e0b1be0162 internal/thread.h rework
Rather trivial, added missed MJIT_FUNC_EXPORTED function declaration.
2019-12-26 20:45:12 +09:00
卜部昌平 ce2c97d738 internal/symbol.h rework
Some declatations are moved from internal/parse.h, to reflect the fact
that they are defined in symbol.c.
2019-12-26 20:45:12 +09:00
卜部昌平 1a80d7bcda internal/string.h rework
Reduced the number of macros defined in the file.  Also made it explicit
for MJIT_FUNC_EXPORTTED functions to be so.
2019-12-26 20:45:12 +09:00
卜部昌平 797c46917e internal/range.h rework
Eliminate macros for better readability.
2019-12-26 20:45:12 +09:00
卜部昌平 719efe72b0 internal/process.h rework
Eliminated the macro to convert into an inline function.
2019-12-26 20:45:12 +09:00
卜部昌平 c524df0780 internal/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.
2019-12-26 20:45:12 +09:00
卜部昌平 d0e0c884bb internal/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.
2019-12-26 20:45:12 +09:00
卜部昌平 c27bcd7057 internal/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.
2019-12-26 20:45:12 +09:00
卜部昌平 adc49f0f9a internal/sanitizers.h rework
Rearrange macro orders for better readability.
2019-12-26 20:45:12 +09:00
卜部昌平 ec6f6b53d8 internal/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.
2019-12-26 20:45:12 +09:00
卜部昌平 23c2a27bf6 internal/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.
2019-12-26 20:45:12 +09:00
卜部昌平 0723db6c39 internal/array.h rework
Rearrange contents for better readability, reduce macros for the same
reason, and mark MJIT_FUNC_EXPORTED functions as such.
2019-12-26 20:45:12 +09:00
卜部昌平 f3a229fe2d internal/variable.h rework
Eliminated macros.  Also marked MJIT_FUNC_EXPORTED functions as such.
Some of them are declared in constant.h so edited that file also.
2019-12-26 20:45:12 +09:00
卜部昌平 989068cf70 internal/imemo.h rework
Arrange contents and eliminate macros, to make them readable.

Macro IFUNC_NEW was deleted because there was only one usage.
2019-12-26 20:45:12 +09:00
卜部昌平 63c9f620cf internal/class.h rework
This file has almost nothing to do.  Added some #ifdef lines and
rearranged file contents.

Those macros are unable to translate into inline functions, because they
are used as lvalues of assignments.
2019-12-26 20:45:12 +09:00
卜部昌平 7d71d916a2 internal/struct.h rework
Replace macros with inline functions of equivalent contents, for much
improved readability.
2019-12-26 20:45:12 +09:00
卜部昌平 e72b8592d9 internal/hash.h rework
Reduce macros to make them inline functions, as well as mark
MJIT_FUNC_EXPORTED functions explicitly as such.

Definition of ar_hint_t is simplified.  This has been the only possible
definition so far.
2019-12-26 20:45:12 +09:00
卜部昌平 f0c02a0949 internal/numeric.h rework
Marked MJIT_FUNC_EXPORTED functions as such.  Other changes are rather
cosmetic.
2019-12-26 20:45:12 +09:00
卜部昌平 099778a6da internal/bingnum.h rework
Turn macros into inline functions for better readability.  Also add
rb_int128t2big delcaration, which was missing.
2019-12-26 20:45:12 +09:00
卜部昌平 f6dc053faf internal/fixnum.h rework
Add #include lines, move FIXNUM_POSITIVE_P etc. from numeric.h.
2019-12-26 20:45:12 +09:00
卜部昌平 68c0dc8d36 internal/static_assert.h rework
ISO/IEC 9899:2011 section 7.2 states that <assert.h> must define
static_assert.  Use it when available.
2019-12-26 20:45:12 +09:00
卜部昌平 6581db2187 internal/warnings.h rework
Not a big rewrite.  Just to make those macros readable.
2019-12-26 20:45:12 +09:00
卜部昌平 64ec438b5b internal/bits.h rework
Improving readability by converting some macros into inline functions.
Also improved support for recent x86_64 processors, which have better
instructions for the purposes.
2019-12-26 20:45:12 +09:00
卜部昌平 0958e19ffb add several __has_something macro
With these macros implemented we can write codes just like we can assume
the compiler being clang.  MSC_VERSION_SINCE is defined to implement
those macros, but turned out to be handy for other places.  The -fdeclspec
compiler flag is necessary for clang to properly handle __has_declspec().
2019-12-26 20:45:12 +09:00
卜部昌平 863dbb21d8 assume C99
Now that we no longer support old compilers, we can safely delete
several obsolete #ifdef gurads.  Also because (as of writing) it is
impossible to compile the program using C++ compilers, lets just
entirely prohibit __cplusplus to reduce # of LOCs.

Note however that we still cannot eliminate __STDC_VERSION__ checks,
because MSVC does not define it, saying its C99 support is partial.
See also https://social.msdn.microsoft.com/Forums/vstudio/en-US/53a4fd75-9f97-48b2-aa63-2e2e5a15efa3
2019-12-26 20:45:12 +09:00
卜部昌平 b739a63eb4 split internal.h into files
One day, I could not resist the way it was written.  I finally started
to make the code clean.  This changeset is the beginning of a series of
housekeeping commits.  It is a simple refactoring; split internal.h into
files, so that we can divide and concur in the upcoming commits.  No
lines of codes are either added or removed, except the obvious file
headers/footers.  The generated binary is identical to the one before.
2019-12-26 20:45:12 +09:00