Skip to content

Test #2991 #2993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 83 commits into from
Closed

Test #2991 #2993

wants to merge 83 commits into from

Conversation

shyouhei
Copy link
Member

Looking for the reasons why #2991 fails on appvayor. https://ci.appveyor.com/project/ruby/ruby/builds/31813063

shyouhei added 30 commits March 31, 2020 09:38
... on mswin.  According to 3ea6beb, it
is a wrong idea to define HAVE_SYS_TIME_H in case of mingw.
MakeMakefile#have_header do not know such restriction.  It is up to the
programmer to properly avoid such situation.

:FIXME: I suspect this is rather a bug of have_header.
I am going to modify C codes.  Must make sure that does not break
things.  This changeset adds many CI that basically just make
binaries with slightly distinct options each other.
The ruby/ruby.h, our main public header, is the biggest header file
except autogenerated ones under enc/unicode.  It has roughly 2,500 LOC.
It then includes ruby/intern.h, which is ~1,000 LOC.  Also included are
ruby/defines.h (~500 LOC), ruby/win32.h (~700 LOC), etc.

It's too big!  Nobody can understand what is going on.  We cannot
eliminate the contents for backward compatibility, but at least we can
split it into many, small parts.  I hope this improves understanding of
our public APIs.

This changeset is a pure refactoring that does not add or remove any
single LOC, except for obvious header include guards.
This header file improves consistency of macro definitions.  Let's use
it throughout the project.
This macro is worth defining becuase it elminates literally thousands of
lines of copy&paste.
When I made internal/compilers.h I was afraid of global namespace
pollutions.  Later it turned out that our public header defines
__has_attribute anyways.  Let's stop worrying.  Publicize what we
already have internally.

Doing so, however, is not a simple copy&paste business.  We only had to
consider C99 for internal headers.  But for public ones, we need to make
sure all other C/C++ versions work well.
Static assertion has already been somewhat done in our public header so
why not make our internal definition public.

Doing so however involves some extra handling of C++ situations.  Added
some more complexities.
Previously ASSUME was only for MSVC but nowadays Clang also has its
__builtin_assume intrinsic.  Why not use it.  In doing so there will be
3 situations:

- MSVC: has ASSUME but not UNREACHABLE
- GCC: has UNREACHABLE but not ASSUME
- Clang: has both.

We have to handle them altogether, and provide appropriate fallbacks.
Split each attributes into dedicated files.
Three more years have passed since commit 7c7133b.
I would like to assert today that no environments that are still alive
lack <stdbool.h>.  Let's also use it from our public headers.
Not a big rewrite, just add #pragma deprecated when available.
We already introduced RUBY3_COMPILER_SINCE.  We can safely migrate this
file using that macro.
Cosmetic updates only.  Eliminates nested #if.
Just eliminated nested #ifs.
Today as we assume C99 for ruby internals, it is practically very hard
(if not impossible) to find a situation where long long is not available.
Theoretically, extension libraries could be written in a different
language that lacks long long.  However I don't think we can support such
thing, if any, without a sane CI.

Let me drop support of long long -less environment.  If you have one,
please tell us about it.
We have experienced several issues around alignas / alignof (e.g. Bug
#14668).  Let's make them fully explicitly C++ -aware.
Properly apply RUBY3_ / ruby3_ prefixes for internal macros / aliases.
Other changes are cosmetic.
This one is trivial.  Cosmetic updates only.
Autoconf checks __VA_ARGS__ only for C and C++ situation is remain
untested.  We need to check here.
`__VA_OPT__` is a new preprocessor construt introduced in C++2a (also
proposed for C2x).  This is a (expectedly) portable replacement of
previous `,##__VA_ARGS__` GCC extension.  Let's use it when available.
Currently GCC and Clang are known to understand it.

See also:
  - https://wg21.link/P0306
  - http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2153.htm
Added fine-grained function attributes, which are ugly (I admit).
However they generate better codes for C++ situations, because the
compiler can now assume no C++ exceptions to be thrown from inside of
xmalloc().
Gathered scattering definition of RUBY_EXTERN in front.  Other changes
are trivial.
Updated preprocessor tihngs only.  Improve readability by reducing
mested #ifndef, and add some comments.
What remains in this header file are true miscellanea.  Move
definitions around for better readability.
Added 3 new macros, RUBY3_VALUE_{NULL,FULL,ONE}, which I found are handy
on occasions.

Note also that RUBY3_VALUE_NULL is a valid null pointer constant at the
same time, according to ISO/IEC 9899:1999 section 6.3.2.3.
Converted function-like macros into real inline functions.  Several new
attributes are introduced in order to define them.
Inserted RUBY3_CAST().  Other changes are rather cosmetic.
Made RBASIC_CLASS an inline function.  Also added a C++ constructor for
struct RBasic, which is deemed necessary (read the comment).
Turned macros into inline functions.
shyouhei added 25 commits March 31, 2020 10:20
Eliminated nested #ifdef, and use RB_ prefixed variants.
It seems none of the macros defined in this header can be converted into
inline functions.  Let's make them as readable as possible then.
By moving this function to public header, we can validate the arguments
of MEMCPY etc.
This previous code was not only too cryptic but also a warning on MSVC.
Deleted C-style cast (problematic in C++).
CLASS_OF is literally everywhere.  When you call a method, the
class has to be inferred from its receiver, which is done by this.

So even a small fraction of it has a very huge impact on runtime
performance.  Looking at the implementation the `RBASIC(obj)` part
was at the very end of the function body.  This, however, is
expected to be the most frequently-entering branch because most
method calls for fixnums etc. are special-cased in insns.def.

Moving what is likely to happen right in front of the function
makes it easier for compilers to emit optimal codes.  This re-
arrangement does not speed things up at all if you use gcc 9, but
for clang 10, the impact is considerable.

Calculating -------------------------------------
                         ours@clang-10  ours@gcc-9  master@clang-10 master@gcc-9
Optcarrot Lan_Master.nes        45.471      47.408           38.084       44.744 fps

Comparison:
             Optcarrot Lan_Master.nes
              ours@gcc-9:        47.4 fps
           ours@clang-10:        45.5 fps - 1.04x  slower
            master@gcc-9:        44.7 fps - 1.06x  slower
         master@clang-10:        38.1 fps - 1.24x  slower
Added assertions and RUBY3_CAST where necessary.
__attribute__((diagnose_if)) is separated.  Apart from that, all changes
are to improve readability e.g. eliminating goto into a if branch.
Refactored a part of macros into an inline function.
Instead of including <sys/time.h>, directly declare what is necessary.
This is portable, and concise.
Workarounds C style casts, and forward declaration instead of #include.
Turned macros into inline functions.
It has multiple places to apply so deserves its own header file.
Almost nothing changed; st.h was missing.
Turned macros into inline functions.  That increased file size.  To
reroute, split select.h file so that each file has each definition of
rb_fd_set.

Note rb_fd_resize macro may or may not exist, thus considered broken.
Deleted needless #ifdef __GNUC__ (was this actually effective?)
Minor updates, like adding empty lines for readability.
NORETURN() was missing from the included files, so fixed it.
Reduced use of ruby/backward/2/attributes.h when only one macro from
that header was used in the file.  Direct use new syntax.
The file was necessary because ruby internals tend to confuse VALUE and
void*.  That was a bad habit of 20th century.  Let's not be loose.
The header is emppty now.
It seems gcc takes more time to compile ruby than before.  That also
impacts on JIT.  Extended timeouts for them.
When SIZEOF_INT == SIZEOF_LONG these functions are not used.  In spite
of that they need to exist to prevent link error.  This is to fix builds
on Sparc machines.
@shyouhei
Copy link
Member Author

Weird that this time no error is seen...

@shyouhei shyouhei closed this Mar 31, 2020
@shyouhei shyouhei deleted the test-2991 branch July 4, 2023 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant