This reverts commit 443389effc.
This reverts commit d94960f22e.
Inclusion of header files must be explicit. Every file shall directly
include what is necessary.
https://github.com/include-what-you-use/include-what-you-use says:
> When every file includes what it uses, then it is possible to edit any
> file and remove unused headers, without fear of accidentally breaking
> the upwards dependencies of that file. It also becomes easy to
> automatically track and update dependencies in the source code.
Though we don't use iwyu itself, the principle quoted above is a good
thing that we can agree.
Now that include guards were added to every and all of the headers
inside of our project this changeset does not increase compile time, at
least on my machine.
in debugflags, as requested by nobu
I actually wanted to check debugflags directly rather than MJIT_DEBUGFLAGS
because debugflags is always used but MJIT_DEBUGFLAGS may not be always used.
But I couldn't find a better way to check debugflags.
This is necessary to avoid converting a hard tab to just 1 space in
preprocessor to generate rb_mjit_header.h, which is helpful when using
gdb or perf report.
See also: [Misc #16112]
This reverts commit 91acdd17c4.
Fixed permission failure on Travis, encoding, and added SKIPPED_FILES.
Extract bundled gems under ".bundle/gems" and get rid of
duplication which cause constant redefinition warnings at
`test-all` after `extract-gems` and `test-bundler`.
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.
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.
On cross-compilation, compiled binary can no be created because
compiled binary should be created by same interpreter (on cross-
compilation, host ruby is used to build ruby (BASERUBY)).
So that cross-compilation system loads required scripts in text.
It is same as miniruby.
prelude.c is an automatically generated file by template/prelude.c.tmpl.
However it does not contain any required functions. So remove it from
dependency.
Also miniprelude.c is included by mini_builtin.c and does not need
to make miniprelude.o.
The script in prelude.rb was embed in MRI to load it (eval this
script at everyboot).
This commit change the loading process of prelude.rb. MRI doesn't
eval a script, but load from compiled binary with builtin feature.
So that Init_prelude() does not load `prelude.rb` now.
FreeBSD make works differently with `-j` option.
> -j max_jobs
> Specify the maximum number of jobs that `make` may have running
> at any one time. The value is saved in `.MAKE.JOBS.` Turns
> compatibility mode off, unless the `B` flag is also specified.
> When compatibility mode is off, all commands associated with a
> target are executed in a single shell invocation as opposed to
> the traditional one shell invocation per line. This can break
> traditional scripts which change directories on each command
> invocation and then expect to start with a fresh environment on
> the next line. It is more efficient to correct the scripts
> rather than turn backwards compatibility on.
Stop using exit, cd, exec in middle of commands.
Instead of reading from the files by the full-path at runtime. As
rbinc files need to be included in distributed tarballs, the
full-paths at the packaging are unavailable at compilation times.
IO#read/write_nonblock methods are defined in prelude.rb with
special private method __read/write_nonblock to reduce keyword
parameters overhead. We can move them into io.rb with builtin
functions.
Support loading builtin features written in Ruby, which implement
with C builtin functions.
[Feature #16254]
Several features:
(1) Load .rb file at boottime with native binary.
Now, prelude.rb is loaded at boottime. However, this file is contained
into the interpreter as a text format and we need to compile it.
This patch contains a feature to load from binary format.
(2) __builtin_func() in Ruby call func() written in C.
In Ruby file, we can write `__builtin_func()` like method call.
However this is not a method call, but special syntax to call
a function `func()` written in C. C functions should be defined
in a file (same compile unit) which load this .rb file.
Functions (`func` in above example) should be defined with
(a) 1st parameter: rb_execution_context_t *ec
(b) rest parameters (0 to 15).
(c) VALUE return type.
This is very similar requirements for functions used by
rb_define_method(), however `rb_execution_context_t *ec`
is new requirement.
(3) automatic C code generation from .rb files.
tool/mk_builtin_loader.rb creates a C code to load .rb files
needed by miniruby and ruby command. This script is run by
BASERUBY, so *.rb should be written in BASERUBY compatbile
syntax. This script load a .rb file and find all of __builtin_
prefix method calls, and generate a part of C code to export
functions.
tool/mk_builtin_binary.rb creates a C code which contains
binary compiled Ruby files needed by ruby command.
This update does not add any new codepoint assignments, it just
expands the range of emoji codepoint sequences recommended for
public interchange.
Depending on how emoji data files are cached, this commit may
require manual intervention in some build environments
(including some CI systems).
To perform a regular method call, the VM needs two structs,
`rb_call_info` and `rb_call_cache`. At the moment, we allocate these two
structures in separate buffers. In the worst case, the CPU needs to read
4 cache lines to complete a method call. Putting the two structures
together reduces the maximum number of cache line reads to 2.
Combining the structures also saves 8 bytes per call site as the current
layout uses separate two pointers for the call info and the call cache.
This saves about 2 MiB on Discourse.
This change improves the Optcarrot benchmark at least 3%. For more
details, see attached bugs.ruby-lang.org ticket.
Complications:
- A new instruction attribute `comptime_sp_inc` is introduced to
calculate SP increase at compile time without using call caches. At
compile time, a `TS_CALLDATA` operand points to a call info struct, but
at runtime, the same operand points to a call data struct. Instruction
that explicitly define `sp_inc` also need to define `comptime_sp_inc`.
- MJIT code for copying call cache becomes slightly more complicated.
- This changes the bytecode format, which might break existing tools.
[Misc #16258]
Requested by ko1 that ability of calling rb_raise from anywhere
outside of GVL is "too much". Give up that part, move the GVL
aquisition routine into gc.c, and make our new gc_raise().
Now that allocation routines like ALLOC_N() can raise exceptions
on integer overflows. This is a problem when the calling thread
has no GVL. Memory allocations has been allowed without it, but
can still fail.
Let's just relax rb_raise's restriction so that we can call it
with or without GVL. With GVL the behaviour is unchanged. With
no GVL, wait for it.
Also, integer overflows can theoretically occur during GC when
we expand the object space. We cannot do so much then. Call
rb_memerror and let that routine abort the process.
Flags for ruby core such as warning and `_FORTIFY_SOURCE` macro
are not necessary to make fake.rb, except for `RUBY_EXPORT` macro
which prevents to include ruby/backward.h.
* These seem to consistenly pass already
* Show actual command when running `make test-bundler`
Current the setup command that installs the necessary gems for testing
bundler was printed, but not the actual command that runs the tests.
That was a bit confusing.
* Borrow trick from setproctitle specs
* A title that long doesn't get set sometimes
No idea why, but the test doesn't need that the title is that long.
* Fix most gem helper spec ruby-core failures
* Fix the rest of the gem helper failures
* Fix version spec by improving the assertion
* Remove unnecessary `BUNDLE_RUBY` environment var
We can use `RUBY` when necessary, and `BUNDLE_RUBY` is not a good name
because bundler considers `BUNDLE_*` variables as settings.
* Rename `BUNDLE_GEM` to `GEM_COMMAND`
This is more descriptive I think, and also friendlier for bundler
because `BUNDLE_` env variables are interpreted by bundler as settings,
and this is not a bundler setting.
This fixes one bundler spec failure in config specs against ruby-core.
* Fix quality spec when run in core
Use the proper path helper.
* Fix dummy lib builder to never load default gems
If a dummy library is named as a default gem, when requiring the library
from its executable, the default gem would be loaded when running from
core, because in core all default gems share path with bundler, and thus
they are always in the $LOAD_PATH. We fix the issue by loading lib
relatively inside dummy lib executables.
* More exact assertions
Sometimes I have the problem that I do some "print debugging" inside
specs, and suddently the spec passes. This happens when the assertion is
too relaxed, and the things I print make it match, specially when they
are simple strings like "1.0" than can be easily be part of gem paths
that I print for debugging.
I fix this by making a more exact assertion.
* Detect the correct shebang when ENV["RUBY"] is set
* Relax assertion
So that the spec passes even if another paths containing "ext" are in
the load path. This works to fix a ruby-core issue, but it's a better
assertion in general. We just want to know that the extension path was
added.
* Use folder structure independent path helper
It should fix this spec for ruby-core.
* Fix the last failing spec on ruby-core
* Skip `bundle open <default_gem>` spec when no default gems
debug utility macro rp() (rp_m()) and bp() are introduced.
* rp(obj) shows obj information w/o any side-effect to STDERR.
* rp_m(m, obj) is similar to rp(obj), but show m before.
* bp() is alias of ruby_debug_breakpoint(), which is registered
as a breakpoint in run.gdb (used by `make gdb` or make gdb-ruby`).
As `make test-tool` does not use gems, and no Rubygems stuffs is
needed, so moved such things to test/runner.rb. Also no longer
nees `--test-target-dir` option.
And `make test-tool` includes `make test-testframework`.
This change may be arguable because I'm unsure who is an intended user
of `make check`: a normal user, or Ruby-core developer. Normal users
don't have to run `make test-tool` for testing their installation, but
Ruby committers should run it before they commit anything.
In this case, I'd be conservative; `make check` includes `test-tool`.
If normal users often report a failure of `make test-tool`, then we can
consider to split `make check` for two sets of target users.
tool/test/runner.rb had been copied from test/runner.rb.
test/runner.rb was for `make test-all`, and tool/test/runner.rb was for
`make test-testframework` and `make test-tool`.
But I want to avoid the code clones.
This change makes tool/test/runner.rb support --test-target-dir option
which allows tool/test/runner.rb to run `make test-all`.
Now we can remove test/runner.rb.
because v0.14.18 was actually not working with `make run`.
In `make run`, `Gem` is defined but `Gem::Version` isn't.
v0.14.19 checks `defined?(Gem::Version)` instead of `defined?(Gem)`.