An instruction is leaf if it has no rb_funcall inside. In order to
check this property, we introduce stack canary which is a random
number collected at runtime. Stack top is always filled with this
number and checked for stack smashing operations, when VM_CHECK_MODE.
[GH-1947]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RCOMPLEX_SET_REAL, RCOMPLEX_SET_IMAG): removed
macros for internal use, which have been exposed by accident.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_args.c: rb_ary_dup(args->rest) to be used at most once during
parameter setup. [Feature #15010]
A patch by chopraanmol1 (Anmol Chopra) <chopraanmol1@gmail.com>.
* array.c (rb_ary_behead): added to remove first n elements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This reverts commit 194a6a2c68 (r64203).
Race conditions which caused the original reversion will be fixed
in the subsequent commit.
[ruby-core:88360] [Misc #14937]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
by sharing it with vm.c in internal.h.
vm.c: ditto
internal.h: ditto
mjit.h: share more.
mjit.c: make sure the third arguemnt is not used
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit introduces new core class Enumerator::ArithmeticSequence.
Enumerator::ArithmeticSequence is a subclass of Enumerator, and
represents a number generator of an arithmetic sequence.
After this commit, Numeric#step and Range#step without blocks
returned an ArithmeticSequence object instead of an Enumerator.
This class introduces the following incompatibilities:
- You can create a zero-step ArithmeticSequence,
and its size is not ArgumentError, but Infinity.
- You can create a negative-step ArithmeticSequence from a range.
[ruby-core:82816] [Feature #13904]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We see several occurrence of "diagnostic push/pop" so why not
make them macros. Tested on GCC8 / Clang 6.
Note that ruby.h is intentionally left untouched because we don't
want to introduce new public macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To reduce resource use and reduce CI failure; remove
timer-thread. Single-threaded Ruby processes (including forked
children) will never see extra thread overhead. This prevents
glibc and jemalloc from going into multi-threaded mode and
initializing locks or causing fragmentation via arena explosion.
The GVL is implements its own wait-queue as a ccan/list to
permit controlling wakeup order. Timeslice under contention is
handled by a designated timer thread (similar to choosing a
"patrol_thread" for current deadlock checking).
There is only one self-pipe, now, as wakeups for timeslice are
done independently using condition variables. This reduces FD
pressure slightly.
Signal handling is handled directly by a Ruby Thread (instead
of timer-thread) by exposing signal self-pipe to callers of
rb_thread_fd_select, native_sleep, rb_wait_for_single_fd, etc...
Acquiring, using, and releasing the self-pipe is exposed via 4
new internal functions:
1) rb_sigwait_fd_get - exclusively acquire timer_thread_pipe.normal[0]
2) rb_sigwait_fd_sleep - sleep and wait for signal (and no other FDs)
3) rb_sigwait_fd_put - release acquired result from rb_sigwait_fd_get
4) rb_sigwait_fd_migrate - migrate signal handling to another thread
after calling rb_sigwait_fd_put.
rb_sigwait_fd_migrate is necessary for waitpid callers because
only one thread can wait on self-pipe at a time, otherwise a
deadlock will occur if threads fight over the self-pipe.
TRAP_INTERRUPT_MASK is now set for the main thread directly in
signal handler via rb_thread_wakeup_timer_thread.
Originally, I wanted to use POSIX timers
(timer_create/timer_settime) for this. Unfortunately, this
proved unfeasible as Mutex#sleep resumes on spurious wakeups and
test/thread/test_cv.rb::test_condvar_timed_wait failed. Using
pthread_sigmask to mask out SIGVTALRM fixed that test, but
test/fiddle/test_function.rb::test_nogvl_poll proved there'd be
some unavoidable (and frequent) incompatibilities from that
approach.
Finally, this allows us to drop thread_destruct_lock and
interrupt current ec directly.
We don't need to rely on vm->thread_destruct_lock or a coherent
vm->running_thread on any platform. Separate timer-thread for
time slice and signal handling is relegated to thread_win32.c,
now.
[ruby-core:88088] [Misc #14937]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Just refactoring. Despite its name, the function does NOT return a
boolean but raises an exception when the class given is frozen.
I don't think the new name "rb_class_modify_check" is the best, but
it follows the precedeint "rb_ary_modify_check", and is definitely
better than "*_p".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We need to preserve "IGNORE" behavior from Ruby 2.5 and earlier.
We can't rely on SA_NOCLDWAIT any more, since we always need
system() and MJIT to work; so we fake that behavior using
dedicated reaper (currently in timer-thread).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Both timegmw and gmtimew ignores leap second if the timezone doesn't
have leap seconds on the first call of init_leap_second_info()
* Add Bug::Time.reset_leap_second_info for testing
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Reading win32/win32.c waitpid implementation, maybe waitpid(-1, ...)
on that platform will never conflict with mjit use of waitpid.
In any case, I've added WAITPID_USE_SIGCHLD macro to vm_core.h
so it can be easy for Linux/BSD users to test (hopefully!)
win32-compatible code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The change is unstable on Windows. Please re-commit it when it correctly
supports Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use a global SIGCHLD handler to guard all callers of rb_waitpid.
To work safely with multi-threaded programs, we introduce a
VM-wide waitpid_lock to be acquired BEFORE fork/vfork spawns the
process. This is to be combined with the new ruby_waitpid_locked
function used by mjit.c in a non-Ruby thread.
Ruby-level SIGCHLD handlers registered with Signal.trap(:CHLD)
continues to work as before and there should be no regressions
in any existing use cases.
Splitting the wait queues for PID > 0 and groups (PID <= 0)
ensures we favor PID > 0 callers.
The disabling of SIGCHLD in rb_f_system is longer necessary,
as we use deferred signal handling and no longer make ANY
blocking waitpid syscalls in other threads which could "beat"
the waitpid call made by rb_f_system.
We prevent SIGCHLD from firing in normal Ruby Threads and only
enable it in the timer-thread, to prevent spurious wakeups
from in test/-ext-/gvl/test_last_thread.rb with MJIT enabled.
I've tried to guard as much of the code for RUBY_SIGCHLD==0
using C "if" statements rather than CPP "#if" so to reduce
the likelyhood of portability problems as the compiler will
see more code.
We also work to suppress false-positives from
Process.wait(-1, Process::WNOHANG) to quiets warnings from
spec/ruby/core/process/wait2_spec.rb with MJIT enabled.
Lastly, we must implement rb_grantpt for ext/pty. We need a
MJIT-compatible way of supporting grantpt(3) which may spawn
the `pt_chown' binary and call waitpid(2) on it.
[ruby-core:87605] [Ruby trunk Bug#14867]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (rb_dbl_complex_polar): utility function, which
returns more precise value in right angle cases.
* bignum.c (rb_big_pow): use rb_dbl_complex_polar().
* numeric.c (rb_float_pow, fix_pow): create a Complex by polar
form.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (int_pow_tmp3): get rid of redefined Integer#> on
internal calculations, as well as the GMP version.
* bignum.c (rb_int_powm): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_gc_mark_encodings has been empty for a decade
(since r17875 / 28b216ac45).
Just remove it and its only caller in gc.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
msgpack-ruby requests this function public because they want to
create a hash with bulk key value pairs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit eliminates (char **)RSTRING_PTR(...) like usages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
imemo_alloc is used for three purposes: auto-free pointer (alternative
of alloca), alloc_tmp_buffer, and heap allocation for bison.
To make it clear, this change introduces three functions:
rb_imemo_alloc_auto_free_pointer,
rb_imemo_alloc_auto_free_maybe_mark_buffer, and
rb_imemo_alloc_parser_heap.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_imemo_alloc_new returns rb_imemo_alloc_t*, but took VALUEs, which is
inconsistent. To make the intention clear, it now takes only a pointer
to the buffer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
However this function is listed in ruby/io.h. We cannot but
define a new, void-returning variant to use instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c (range_each_func): adjust the signature of the callback
function to rb_str_upto_each, and exit the loop if the callback
returned non-zero.
* string.c (rb_str_upto_endless_each): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Instead of allocating and registering the altstack in different
places, do it together to reduce code and improve readability.
When thread cache is enabled, storing altstack in rb_thread_t
is wasteful and we may reuse altstack in the same pthread.
This also lets us clearly allow use of xmalloc to allow GC to
recover from ENOMEM.
[ruby-core:85621] [Feature #14487]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
range.c: cast the function type to meet the declaration
This change is for fixing build error on AppVeyor:
https://ci.appveyor.com/project/ruby/ruby/build/1.0.8177
string.c
../string.c(4330) : error C4028: formal parameter 2 different from declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Typical usages:
```
p ary[1..] # drop the first element; identical to ary[1..-1]
(1..).each {|n|...} # iterate forever from 1; identical to 1.step{...}
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (nometh_err_initialize): do not shirtcut rb_call_super,
to push proper control frame. [ruby-dev:50522] [Bug #14670]
* error.c (rb_nomethod_err_new): allocate and initialize a new
NoMethodError instance.
* vm_eval.c (rb_make_no_method_exception): create a new exception
instance directly without method calls, to prevent influence of
ruby level method definitions, which can cause an unpredictable
behavior, e.g., infinite recursion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Support `exception:` keyword argument in Kernel#Integer().
If `exception:` is `false`, `Kernel#Integer()` returns `nil` if the given
value cannot be interpreted as an integer value.
The default value of `exception:` is `true`.
This is part of [Feature #12732].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit.c (form_args): do not use va_copy, which cannot detect
appropriate way to simulate when cross compiling.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tool/ruby_vm/views/_mjit_compile_send.erb: `printf` modifier for
`rb_serial_t` which may not be `long long`, and '%ll' may not be
supported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (ruby_engine): remove declaration of ruby_engine because
it's declared at ruby/version.h.
* ruby.c: include ruby/version.h for ruby_engine.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
which has been developed by Takashi Kokubun <takashikkbn@gmail> as
YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>.
This JIT compiler is designed to be a safe migration path to introduce
JIT compiler to MRI. So this commit does not include any bytecode
changes or dynamic instruction modifications, which are done in original
MJIT.
This commit even strips off some aggressive optimizations from
YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still
fairly faster than Ruby 2.5 in some benchmarks (attached below).
Note that this JIT compiler passes `make test`, `make test-all`, `make
test-spec` without JIT, and even with JIT. Not only it's perfectly safe
with JIT disabled because it does not replace VM instructions unlike
MJIT, but also with JIT enabled it stably runs Ruby applications
including Rails applications.
I'm expecting this version as just "initial" JIT compiler. I have many
optimization ideas which are skipped for initial merging, and you may
easily replace this JIT compiler with a faster one by just replacing
mjit_compile.c. `mjit_compile` interface is designed for the purpose.
common.mk: update dependencies for mjit_compile.c.
internal.h: declare `rb_vm_insn_addr2insn` for MJIT.
vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to
compiler. This avoids to include some functions which take a long time
to compile, e.g. vm_exec_core. Some of the purpose is achieved in
transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are
manually resolved for now. Load mjit_helper.h for MJIT header.
mjit_helper.h: New. This is a file used only by JIT-ed code. I'll
refactor `mjit_call_cfunc` later.
vm_eval.c: add some #ifdef switches to skip compiling some functions
like Init_vm_eval.
win32/mkexports.rb: export thread/ec functions, which are used by MJIT.
include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify
that a function is exported only for MJIT.
array.c: export a function used by MJIT.
bignum.c: ditto.
class.c: ditto.
compile.c: ditto.
error.c: ditto.
gc.c: ditto.
hash.c: ditto.
iseq.c: ditto.
numeric.c: ditto.
object.c: ditto.
proc.c: ditto.
re.c: ditto.
st.c: ditto.
string.c: ditto.
thread.c: ditto.
variable.c: ditto.
vm_backtrace.c: ditto.
vm_insnhelper.c: ditto.
vm_method.c: ditto.
I would like to improve maintainability of function exports, but I
believe this way is acceptable as initial merging if we clarify the
new exports are for MJIT (so that we can use them as TODO list to fix)
and add unit tests to detect unresolved symbols.
I'll add unit tests of JIT compilations in succeeding commits.
Author: Takashi Kokubun <takashikkbn@gmail.com>
Contributor: wanabe <s.wanabe@gmail.com>
Part of [Feature #14235]
---
* Known issues
* Code generated by gcc is faster than clang. The benchmark may be worse
in macOS. Following benchmark result is provided by gcc w/ Linux.
* Performance is decreased when Google Chrome is running
* JIT can work on MinGW, but it doesn't improve performance at least
in short running benchmark.
* Currently it doesn't perform well with Rails. We'll try to fix this
before release.
---
* Benchmark reslts
Benchmarked with:
Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores
- 2.0.0-p0: Ruby 2.0.0-p0
- r62186: Ruby trunk (early 2.6.0), before MJIT changes
- JIT off: On this commit, but without `--jit` option
- JIT on: On this commit, and with `--jit` option
** Optcarrot fps
Benchmark: https://github.com/mame/optcarrot
| |2.0.0-p0 |r62186 |JIT off |JIT on |
|:--------|:--------|:--------|:--------|:--------|
|fps |37.32 |51.46 |51.31 |58.88 |
|vs 2.0.0 |1.00x |1.38x |1.37x |1.58x |
** MJIT benchmarks
Benchmark: https://github.com/benchmark-driver/mjit-benchmarks
(Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks)
| |2.0.0-p0 |r62186 |JIT off |JIT on |
|:----------|:--------|:--------|:--------|:--------|
|aread |1.00 |1.09 |1.07 |2.19 |
|aref |1.00 |1.13 |1.11 |2.22 |
|aset |1.00 |1.50 |1.45 |2.64 |
|awrite |1.00 |1.17 |1.13 |2.20 |
|call |1.00 |1.29 |1.26 |2.02 |
|const2 |1.00 |1.10 |1.10 |2.19 |
|const |1.00 |1.11 |1.10 |2.19 |
|fannk |1.00 |1.04 |1.02 |1.00 |
|fib |1.00 |1.32 |1.31 |1.84 |
|ivread |1.00 |1.13 |1.12 |2.43 |
|ivwrite |1.00 |1.23 |1.21 |2.40 |
|mandelbrot |1.00 |1.13 |1.16 |1.28 |
|meteor |1.00 |2.97 |2.92 |3.17 |
|nbody |1.00 |1.17 |1.15 |1.49 |
|nest-ntimes|1.00 |1.22 |1.20 |1.39 |
|nest-while |1.00 |1.10 |1.10 |1.37 |
|norm |1.00 |1.18 |1.16 |1.24 |
|nsvb |1.00 |1.16 |1.16 |1.17 |
|red-black |1.00 |1.02 |0.99 |1.12 |
|sieve |1.00 |1.30 |1.28 |1.62 |
|trees |1.00 |1.14 |1.13 |1.19 |
|while |1.00 |1.12 |1.11 |2.41 |
** Discourse's script/bench.rb
Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb
NOTE: Rails performance was somehow a little degraded with JIT for now.
We should fix this.
(At least I know opt_aref is performing badly in JIT and I have an idea
to fix it. Please wait for the fix.)
*** JIT off
Your Results: (note for timings- percentile is first, duration is second in millisecs)
categories_admin:
50: 17
75: 18
90: 22
99: 29
home_admin:
50: 21
75: 21
90: 27
99: 40
topic_admin:
50: 17
75: 18
90: 22
99: 32
categories:
50: 35
75: 41
90: 43
99: 77
home:
50: 39
75: 46
90: 49
99: 95
topic:
50: 46
75: 52
90: 56
99: 101
*** JIT on
Your Results: (note for timings- percentile is first, duration is second in millisecs)
categories_admin:
50: 19
75: 21
90: 25
99: 33
home_admin:
50: 24
75: 26
90: 30
99: 35
topic_admin:
50: 19
75: 20
90: 25
99: 30
categories:
50: 40
75: 44
90: 48
99: 76
home:
50: 42
75: 48
90: 51
99: 89
topic:
50: 49
75: 55
90: 58
99: 99
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I plan to use this macro to pack other enums in the VM.
* internal.h: add BITFIELD macro
* method.h: use BITFIELD for rb_method_visibility_t
[ruby-core:85074] [Misc #14395]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_check_to_array): conversion to array by to_a method.
returns nil if not possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/-ext-/ast/test_ast.rb: Add tests for Node
code locations. This file tests
1. There are no Node whose code location is default
value (#test_not_cared)
2. There are no Node whose children's code locations
exceed parent's code location (#test_ranges)
* ext/-test-/ast/ast.c, ext/-test-/ast/extconf.rb:
Define AST module to help tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
struct.c: define rb_struct_s_keyword_init to shared with marshal.c
internal.h: add the declaration to be used by marshal.c
test/ruby/test_marshal.rb: add test for Bug#14314
[Feature #14314] [ruby-core:84629]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (struct vm_ifunc_argc): Bit fields are unsigned by default.
For storing nagative values to bit fields, they must be declated as
signed int. Fix multiple test failure observed by 32-bit binaries
compiled with Oracle Developer Studio (Solaris Studio) 12.x on
Solaris 10 on sparc architecture. [Bug #14260]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Traditionally, method coverage measurement was implemented by inserting
`trace2` instruction to the head of method iseq. So, it just measured
methods defined by `def` keyword.
This commit drastically changes the measuring mechanism of method
coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t*
to runs (i.e., it counts the runs per method entry), and at
`Coverage.result`, it creates the result hash by enumerating all
`rb_method_entry_t*` objects (by `ObjectSpace.each_object`).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is based on the pull-request #1320 created by Makoto Kishimoto.
[Feature #12508] [Feature #11003] [close GH-1320]
* bignum.c (rb_int_powm): Added for Integer#pow(b, m).
* internal.h (rb_int_powm): Declared to refer in numeric.c.
* bignum.c (bary_powm_gmp): Added for Integer#pow(b, m) using GMP.
* bignum.c (int_pow_tmp1): Added for implementing Integer#pow(b, m).
* bignum.c (int_pow_tmp2, int_pow_tmp3): ditto.
* internal.h (rb_num_positive_int_p): Moved from numeric.c for sharing
the definition with bignum.c.
* internal.h (rb_num_negative_int_p, rb_num_compare_with_zero): ditto.
* numeric.c(negative_int_p): Moved to internal.h for sharing the
definition with bignum.c.
* numeric.c (positive_int_p, compare_with_zero): ditto.
* numeric.c (rb_int_odd_p): Exported (renamed from int_odd_p).
* internal.h (rb_int_odd_p): ditto.
* internal.h (HALF_LONG_MSB): Added.
* numeric.c (SQRT_LONG_MAX): Redefined by using HALF_LONG_MSB.
* test/ruby/test_numeric.rb (test_pow): Added for Integer#pow(b, m).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c (rb_source_loc): rename to rb_source_location_cstr()
to make behavior clear compare with rb_source_location().
* error.c (warning_string): use rb_source_location_cstr() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c (rb_sourcefilename): removed because nobody use it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Just refactoring.
NODE_STRTERM and NODE_HEREDOC are not an internal node of AST, but a
temporary storage for managing termination of string literals and
heredocs. Instead of NODE abuse, I want to use imemo for the storage
in order to avoid (my) confusion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This re-introduces r60485.
This reverts commit 5a176b75b1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NODEs in AST are no longer objects managed by GC. This change will
remove the restriction imposed by the GC. For example, a NODE can use
more than five words (this is my primary purpose; we want to store the
position data for each NODE, for coverage library), or even a NODE can
have variable length (some kinds of NODEs have unused fields).
To do this, however, we need more work, since Ripper still uses T_NODE
objects managed by the GC.
The life time of NODEs is more obvious than other kinds of objects; they
are created at parsing, and they become disused immediately after
compilation. This change releases all NODEs by a few `xfree`s after
compilation, so performance will be improved a bit. In extreme example,
`eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my
machine).
The most important part of this change is `ast_t` struct, which has
three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to
the root NODE, and (3) an array that contains objects that must be
marked during parsing (such as literal objects). Some functions that
had received `NODE*` arguments, must now receive `ast_t*`.
* node.c, node.h: defines `ast_t` struct and related operations.
* gc.c, internal.h: defines `imemo_ast`.
* parse.y: makes `parser_params` struct have a reference to `ast_t`.
Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE.
* iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some
functions to handle `ast_t*` instead of `NODE*`.
* test/ruby/test_gc.rb: ad-hoc fix for a failed test. The test assumes
GC eden is increased at startup by NODE object creation. However,
this change now create no NODE object, so GC eden is not necessarily
increased.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to represent execution context [Feature #14038]
* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
There are many code using `th` to represent execution context
(such as cfp, VM stack and so on). To access `ec`, they need to
use `th->ec->...` (adding one indirection) so that we need to
replace them by passing `ec` instead of `th`.
* vm_core.h (GET_EC()): introduced to access current ec. Also
remove `ruby_current_thread` global variable.
* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
rb_context_t::thread_value.
* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.
* cont.c (ec_switch): added to switch ec explicitly.
* cont.c (rb_fiber_close): added to terminate fibers explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_to_array_type): make public to share common code
internally.
* hash.c (rb_to_hash_type): make public to share common code
internally.
* symbol.c (rb_to_symbol_type): make public to share common code
internally.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (vm_opt_aref): optimize on other than fixnum
argument too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: imemo_mask is not a valid imemo type but
switch statements show warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_imemo_alloc_struct), gc.c (gc_mark_imemo): turned
next into the pointer to chain.
* parse.y (NEWHEAP): needs a cast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The new function rb_yield_assoc_or_values() will reduce branching.
* vm_eval.c: add rb_yield_assoc_or_values()
* internal.h: ditto
* hash.c: use rb_yield_assoc_or_values()
* struct.c: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
st.c was improved in r56650 that it permits deletion during iteration.
In this commit, special treatments for previous implementation are
removed.
* hash.c: don't use *_check and *_safe functions in st.c
* internal.h: remove HASH_DELETED flag
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis <lars@greiz-reinsdorf.de>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_check_realpath): returns real path which has no
symbolic links. similar to rb_realpath except for returning
Qnil if any parts did not exist.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c (rb_context_t): introduce saved_ec instaad of saved_thread.
We only need to transfer ec data (not all of thread data).
Introduce `thread_value` field to point creation thread.
To acccess this field, `cont_thread_value()` is introduced.
* vm.c (rb_execution_context_mark): remove `static` and use it
from cont.c (use this function instead of `rb_thread_mark`).
* vm_insnhelper.c (rb_vm_push_frame): accept ec instead of th.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sometimes, size of a hash can be calcluated a priori. By providing
such info to the constructor we can avoid unnecessary internal re-
allocations. This can boost for instance creation of hash literals.
[Bug #13861]
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To prepare new measuring targets: branch and method coverages.
So far, iseq->coverage was an array of counts executed for line coverage.
Now, it is a three-element array for each measuring target,
whose first element is an array for line coverage.
The second element is planned for branch coverage, and the third will be
for method coverage.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* cont.c (fiber_to_s): return with block and status information.
* proc.c (proc_to_s_): removed and introduce rb_block_to_s() function
to return block information string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_initialize): new function to (re)initialize a
string with data and encoding. extracted from
rb_external_str_new_with_enc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
These caused numerous CI failures I haven't been able to
reproduce [ruby-core:82102]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_collect): make the block arity same as the given
block. [Bug #13391]
* internal.h (vm_ifunc): store arity instead of unused id.
* proc.c (rb_vm_block_min_max_arity): return ifunc arity.
* vm_eval.c (rb_lambda_call): call method with lambda block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c (rb_block_min_max_arity): new function to get arity range
from the current block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The same hash keys may be loaded from tainted data sources
frequently (e.g. parsing headers from socket or loading
YAML data from a file). If a non-tainted fstring already
exists (because the application expects the hash key),
cache and deduplicate the tainted version in the new
tainted_frozen_strings table.
For non-embedded strings, this also allows sharing with the
underlying malloc-ed data.
* vm_core.h (rb_vm_struct): add tainted_frozen_strings
* vm.c (ruby_vm_destruct): free tainted_frozen_strings
(Init_vm_objects): initialize tainted_frozen_strings
(rb_vm_tfstring_table): accessor for tainted_frozen_strings
* internal.h: declare rb_fstring_existing, rb_vm_tfstring_table
* hash.c (fstring_existing_str): remove (moved to string.c)
(hash_aset_str): use rb_fstring_existing
* string.c (rb_fstring_existing): new, based on fstring_existing_str
(tainted_fstr_update): new
(rb_fstring_existing0): new, based on fstring_existing_str
(rb_tainted_fstring_existing): new, special case for tainted strings
(rb_str_free): delete from tainted_frozen_strings table
* test/ruby/test_optimization.rb (test_hash_reuse_fstring): new test
[ruby-core:82012] [Bug #13737]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This hasn't been used since r36709 (2012-08-15)
("Kernel#inspect: improve consistency and do not call #to_s.")
and was never part of public API in include/ruby/
* class.c (rb_obj_basic_to_s_p): remove function
* internal.h (rb_obj_basic_to_s_p): remove declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (rbuy_kill): removed. This function is used
with SIGSEGV, SIGBUS, SIGKILL, SIGILL, SIGFPE and SIGSTOP
and these signals are affect immediately. So that `kill(2)'
is enough for them.
* signal.c (rb_f_kill): ditto.
* vm_core.h (rb_thread_t::interrupt_cond): removed because
only `ruby_kill()' uses this field.
* test/ruby/test_signal.rb: Without this patch sending SIGSTOP to own
process wait another interrupt even if another process sends SIGCONT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c (rb_dir_getwd_ospath): return cwd path in the OS path
encoding.
* file.c (rb_realpath_internal): work in the OS path encoding
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_yield_lambda): rename to rb_yield_force_blockarg()
because this function prohibt lambda arg setup (strict setup).
* vm.c (invoke_iseq_block_from_c): remove splattable argument because
it is not used.
* vm.c (invoke_block_from_c_splattable): rename to invoke_block_from_c_bh()
because `splattable` doesn't make sense on current this function.
Also accept `force_blockarg' parameter instead of `splattable` parameter.
It is more clear.
* vm.c (invoke_block_from_c_unsplattable): rename to
invoke_block_from_c_proc() and accept `proc` instead of `block'.
This function is used only by proc block invocation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* load.c (rb_require_internal): convert to path name with the
given safe level, without setting global safe level.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
To convert the object implicitly, it has had two parts in convert_type() which are
1. lookink up the method's id
2. calling the method
Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up
the method's id for type conversion.
This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id)
to call the method without looking up the method's id when convert the object.
Array#flatten -> 19 % up
Array#+ -> 3 % up
[ruby-dev:50024] [Bug #13341] [Fix GH-1537]
### Before
Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s
Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s
### After
Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s
Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s
### Test Code
require 'benchmark/ips'
class Foo
def to_ary
[1,2,3]
end
end
Benchmark.ips do |x|
ary = []
100.times { |i| ary << i }
array = [ary]
x.report "Array#flatten" do |i|
i.times { array.flatten }
end
x.report "Array#+" do |i|
obj = Foo.new
i.times { array + obj }
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (rb_eql_opt): should call #eql? on Float and
String, not #==.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This improvement is similar with https://github.com/ruby/ruby/pull/1552
internal.h: add declaration of rb_eql_opt() API.
vm_insnhelper.c (rb_eql_opt): add rb_eql_opt() API which provides optimized
path for #eql? method such as rb_equal_opt().
object.c (rb_eql): optimize using rb_eql_opt() such as rb_equal().
Array#eql? and some methods have used rb_eql() and Array#eql? will be faster
around 20%.
[ruby-core:80761] [Bug #13447] [Fix GH-#1589]
### Before
user system total real
1.570000 0.000000 1.570000 ( 1.569754)
### After
user system total real
1.300000 0.000000 1.300000 ( 1.303624)
### Test code
require 'benchmark'
Benchmark.bmbm do |x|
ary1 = Array.new(1000) { rand(1000) }
ary2 = Array.new(1000) { rand(1000) }
x.report do
5000000.times do
ary1.eql?(ary2)
end
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* load.c: send as a single string.
* error.c: expose the string formatted by rb_warning as rb_warning_string().
* test/ruby/test_exception.rb: update tests.
[ruby-core:80850] [Bug #13505]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c (rb_hash_bulk_insert): new API to bulk insert entries
into a hash. Given arguments are first inserted into the
table at once, then reindexed. This is faster than inserting
things using rb_hash_aset() one by one.
This arrangement (rb_ prefixed function placed in st.c) is
unavoidable because it both touches table internal and write
barrier at once.
* internal.h: delcare the new function.
* hash.c (rb_hash_s_create): use the new function.
* vm.c (core_hash_merge): ditto.
* insns.def (newhash): ditto.
* test/ruby/test_hash.rb: more coverage on hash creation.
* test/ruby/test_literal.rb: ditto.
-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name before after
loop_whileloop2 0.136 0.137
vm2_bighash* 1.249 0.623
Speedup ratio: compare with the result of `before' (greater is better)
name after
loop_whileloop2 0.996
vm2_bighash* 2.004
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We need to fix GC bug before merging this. Revert revisions
58452, 58435, 58434, 58428, 58427 in this order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Same as rb_ary_tmp_new_from_values(), it reduces vm_exec_core binary
size from 26,176 bytes to 26,080 bytes. But this time, also with a
bit of optimizations:
- Because we are allocating a new hash and no back references are
introduced at all, we can safely skip write barriers.
- Also, the iteration never recurs. We can avoid complicated
function callbacks by using st_insert instead of st_update.
----
* hash.c (rb_hash_new_from_values): refactor
extract the bulk insert into a function.
* hash.c (rb_hash_new_from_object): also refactor.
* hash.c (rb_hash_s_create): use the new functions.
* insns.def (newhash): ditto.
* vm.c (core_hash_from_ary): ditto.
* iternal.h: export the new function.
-----------------------------------------------------------
benchmark results:
minimum results in each 7 measurements.
Execution time (sec)
name before after
loop_whileloop2 0.135 0.134
vm2_bighash* 1.236 0.687
Speedup ratio: compare with the result of `before' (greater is better)
name after
loop_whileloop2 1.008
vm2_bighash* 1.798
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_backtrace.c (rb_threadptr_backtrace_object): rename and
extern.
* vm_backtrace.c (rb_threadptr_backtrace_str_ary): rename as
threadptr since the parameter is rb_thread_t*.
* vm_backtrace.c (rb_threadptr_backtrace_location_ary): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: introduce imemo_type_p() which checks the given value is
T_IMEMO and imemo_type() == given imemo_type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (THROW_DATA_P): parenthesize the argument which is
casted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c: get return_value from imemo_throw_data object (THROW_DATA_VAL()).
imemo_throw_data (TAG_BREAK) contains returned value.
However, imemo_throw_data (TAG_BREAK) can skip several frames so that
we need to use it only once (at most internal frame). To record it,
we introduced THROW_DATA_CONSUMED and check it.
* internal.h: define THROW_DATA_CONSUMED flag.
* test/ruby/test_settracefunc.rb: add tests for [Bug #13369]
* vm_insnhelper.h: add THROW_DATA_CONSUMED_P() and
THROW_DATA_CONSUMED_SET().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Init_frozen_strings definition is removed in r51511.
https://bugs.ruby-lang.org/issues/11423
Patch by Kohei Suzuki <eagletmt@gmail.com>
* internal.h: Remove declaration of unexist function
[Fix GH-1558]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c: define warning functions in all combinations of
* no errno, system errno, argument
* without/with encoding
* enabled/disabled by default
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_yield_lambda): new function which yields an array
to a proc and splat to a lambda. mainly for Enumerable only.
* vm_args.c (setup_parameters_complex): remove special lambda
splatting for [Bug #9605]. [ruby-core:77065] [Bug #12705]
* vm_insnhelper.c (vm_callee_setup_block_arg): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is auto-generated using following command:
svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
r57789 (74cdd89) was gradually "improve"d by naruse through r57793 to
r57806, resulted in reverting the efect of r57789 while retaining its
complexity. I think the current situation is slightly worse than
before (same output complicated source code).
Here I introduce __builtin_add_overflow again, which (I think) is what
naruse wanted to do in r57793.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Looking at the source code, FIXABLE tends to be just before LOING2FIX
to check applicability of that operation. Why not try computing first
then check for overflow, which should be optimial.
I also tried the same thing for unsigned types but resulted in slower
execution. It seems RB_POSFIXABLE() is fast enough on modern CPUs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I was not aware of cases when LONG_LONG_MAX is undefined. Sorry.
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c (opt_eq_func): method to dispatch is resolved by
only the receiver's class, not including the argument class.
even if basic operation is redefined, other class conditions
never meet. optimize Float and non-Float case, delegate to
rb_float_equal directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
We already check for __builtin_mul_overflow in configure but never
actually referred it before. Why not call it if available, because
that should render supposedly-optimial assembly outputs.
Optionally if __builtin_mul_overflow_p is available, which is the case
for recent GCC, use that to detect fixnum overflow. This is much
faster than the previous. On my machine generated assembly of
numeric.c:int_pow reduces from 480 to 448 bytes, according to nm(1).
Also on my machine, following script boosts from 7.819 to 6.929 sec.
time ./miniruby -e 'i=0; while i < 30_000_000 do i += 1; 7 ** 23; end'
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval_error.c (rb_threadptr_error_print): print backtrace and
error message in reverse order if STDERR is unchanged and a tty.
[Feature #8661]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (num_clone, num_dup): no longer raises TypeError,
returns the receiver instead as well as Integer and Float.
[ruby-core:79636] [Bug #13237]
* object.c (rb_immutable_obj_clone): immutable object clone with
freeze optional keyword argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_compile_error_str): remove declaration of removed
internal function at r54189.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_overflowed_fix_to_int): invert sign bit. should
not set LSB of fixnum value, which is always set, to MSB.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NOTE:
(1) Fixnum's LSB is always 1.
It means you can always run `x - 1` without overflow.
(2) Of course `z = x + (y-1)` may overflow.
Now z's LSB is always 1, and the MSB of true result is also 1.
You can get true result in long as `(1<<63)|(z>>1)`,
and it equals to `(z<<63)|(z>>1)` == `ror(z)`.
GCC and Clang have __builtin_add_ovewflow:
* https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
* https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (STR_IS_SHARED_M): new flag to mark shared mulitple times
(STR_SET_SHARED): set STR_IS_SHARED_M
(rb_str_tmp_frozen_acquire, rb_str_tmp_frozen_release): new functions
(str_new_frozen): set/unset STR_IS_SHARED_M as appropriate
* internal.h: declare new functions
* io.c (fwrite_arg, fwrite_do, fwrite_end): new
(io_fwrite): use new functions
Introduce rb_str_tmp_frozen_acquire and rb_str_tmp_frozen_release
to manage a hidden, frozen string. Reuse one bit of the embed
length for shared strings as STR_IS_SHARED_M to indicate a string
has been shared multiple times. In the common case, the string
is only shared once so the object slot can be reclaimed immediately.
minimum results in each 3 measurements. (time and size)
Execution time (sec)
name trunk built
io_copy_stream_write 0.682 0.254
io_copy_stream_write_socket 1.225 0.751
Speedup ratio: compare with the result of `trunk' (greater is better)
name built
io_copy_stream_write 2.680
io_copy_stream_write_socket 1.630
Memory usage (last size) (B)
name trunk built
io_copy_stream_write 95436800.000 6512640.000
io_copy_stream_write_socket 117628928.000 7127040.000
Memory consuming ratio (size) with the result of `trunk' (greater is better)
name built
io_copy_stream_write 14.654
io_copy_stream_write_socket 16.505
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: Microsoft Visual C++ has never supported C99 yet,
even in 2017.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
17+ years passed since standardized in ISO, 8 years since we added
AC_HEADER_STDBOOL to configure.in. I'm quite confident that it's
already safe to use <stdbool.h>.
I understand that when we introduced AC_HEADER_STDBOOL, <stdbool.h>
was remain not included because C standard and SVR4 curses conflicted
miserably back then (#1). Though I believe such situation has been
fixed already(#2), I'm afraid of your operating system might ship a
proprietary curses that still conflicts with the standard. So to avoid
potential problem, we limit the inclusion to our internal use only.
#1 : 1997 version of SUSv2 said bool is "defined though typedef" in
<curses.h>, while C99 said bool is a macro, plus in C++ bool is a
keyword. AFASIK the curses library has never been a part of
POSIX.
#2 : In reality ncurses and NetBSD curses both just follow C99 to
include <stdbool.h> from <curses.h>. I think C99 is now widely
adopted.
----
* internal.h: #include <stdbool.h> if present. That is
believed to be the case for 99.9% systems that lives today.
Non-C99, non-C++ situations are intentionally left
undefined, advised by Motohiro Kosaki. If you have such
compiler, please fill the definition appropriately.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* eval.c (setup_exception): make unfrozen copy of special
exception before setting up a cause.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c (rb_get_path_check_convert): refine the error message
when the path name contains null byte.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Patch by Eric Wong [ruby-core:78797].
I don't like the idea of making insns.def any bigger to support
a corner case, and "test_hash_aref_fstring_identity" shows
how contrived this is.
[ruby-core:78783] [Bug #12855]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (rb_int_fdiv_double): reduce first for more precise
result. [ruby-core:78886] [Bug #13078]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_match_m_p): inverse of Regexp#match?. based on
the patch by Herwin Weststrate <herwin@snt.utwente.nl>.
[Fix GH-1483] [Feature #12898]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_gt_p): optimize f_gt_p for specific types of arguments.
* internal.h (rb_int_gt, rb_float_gt, rb_rational_cmp): exported.
* numeric.c (rb_float_gt): rename from flo_gt and be exported.
* numeric.c (rb_int_gt): rename from int_gt and be exported.
* rational.c (rb_rational_cmp): rename from nurat_cmp and be exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (f_negate): optimize for special numeric types.
* complex.c (nucomp_expt): use rb_int_uminus instead of f_negate for
fixnum value.
* internal.h (rb_float_uminus, rb_rational_uminus): exported.
* numeric.c (rb_float_uminus): rename from flo_uminus.
* rational.c (rb_rational_uminus): rename from nurat_negate, and add
assertion for the parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* complex.c (numeric_polar): optimize for Integer, Float, and Rational.
* complex.c (numeric_arg): directly create the value of pi.
* complex.c (f_negative_p): optimize for Integer, Float, and Rational.
* rational.c (INT_NEGATIVE_P): move the definition into internal.h.
* internal.h (INT_NEGATIVE_P): ditto.
* numeric.c (rb_float_abs): rename from flo_abs and export to be used
from other source files..
* internal.h (rb_float_abs): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rational.c (nurat_to_double): introduce to convert rational to double
without object allocation.
* rational.c (rb_rational_plus, nurat_{sub,mul,to_f}): rewrite by using
nurat_to_double.
* bignum.c (rb_big_fdiv_double): introduce to calculate fdiv and return
the result as a double value.
* bignum.c (big_fdiv{,_int,_float}): change the return types for
implementing rb_big_fdiv_double.
* bignum.c (rb_big_fdiv): rewrite by using rb_big_fdiv_double.
* numeric.c (rb_int_fdiv_double): introduce to calculate fdiv and return
the result as a double value.
* numeric.c (fix_fdiv_double): rewrite from fix_fdiv to return the
result as a double value.
* numeric.c (rb_int_fdiv): rewrite by using rb_int_fdiv_double.
* internal.h (rb_{big,int}_fdiv_double): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Feature #12142]
See header of st.c for improvment details.
You can see all of code history here:
<https://github.com/vnmakarov/ruby/tree/hash_tables_with_open_addressing>
This improvement is discussed at
<https://bugs.ruby-lang.org/issues/12142>
with many people, especially with Yura Sokolov.
* st.c: improve st_table.
* include/ruby/st.h: ditto.
* internal.h, numeric.c, hash.c (rb_dbl_long_hash): extract a function.
* ext/-test-/st/foreach/foreach.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (flo_round, int_round): support round-to-nearest-even
semantics of IEEE 754 to match sprintf behavior, and add `half:`
optional keyword argument for the old behavior.
[ruby-core:76273] [Bug #12548]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* class.c (rb_undef_methods_from): undefine methods defined in
super from klass.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
a hash value of Object might be Bignum, but it causes many troubles
expecially the Object is used as a key of a hash. so I've gave up
to do so.
* array.c (rb_ary_hash): use above macro.
* bignum.c (rb_big_hash): ditto.
* hash.c (rb_obj_hash, rb_hash_hash): ditto.
* numeric.c (rb_dbl_hash): ditto.
* proc.c (proc_hash): ditto.
* re.c (rb_reg_hash, match_hash): ditto.
* string.c (rb_str_hash_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fix compile error with some non-GCC compilers such as
Oracle Solaris Studio 12.3 on Solaris 10.
[Bug #12767] [ruby-dev:49807]
* internal.h (WARN_UNUSED_RESULT): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
actually check its availability rather to check GCC's version.
* configure.in (WARN_UNUSED_RESULT): moved to here.
* configure.in (RUBY_FUNC_ATTRIBUTE): change function declaration
to return int rather than void, because it makes no sense for a
warn_unused_result attributed function to return void.
Funny thing however is that it also makes no sense for noreturn
attributed function to return int. So there is a fundamental
conflict between them. While I tested this, I confirmed both
GCC 6 and Clang 3.8 prefers int over void to correctly detect
necessary attributes under this setup. Maybe subject to change
in future.
* internal.h (UNINITIALIZED_VAR): renamed to MAYBE_UNUSED, then
moved to configure.in for the same reason we move
WARN_UNUSED_RESULT.
* configure.in (MAYBE_UNUSED): moved to here.
* internal.h (__has_attribute): deleted, because it has no use now.
* string.c (rb_str_enumerate_lines): refactor macro rename.
* string.c (rb_str_enumerate_bytes): ditto.
* string.c (rb_str_enumerate_chars): ditto.
* string.c (rb_str_enumerate_codepoints): ditto.
* thread.c (do_select): ditto.
* vm_backtrace.c (rb_debug_inspector_open): ditto.
* vsnprintf.c (BSD_vfprintf): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c (rb_deprecate_constant): new function to deprecate a
constant by the name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (MEMO_V1_SET, MEMO_V2_SET): fix typos. use the macro
parameter, not the local variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (struct RStruct): no longer.
* internal.h (struct RStruct): moved here.
* struct.c (rb_struct_ptr): a compensation function for the lack
of RSTRUCT_PTR. But now that we have RSTRUCT_GET/SET, that must
not be used anyway. I mark this deprecated. Dont use it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are imemo objects (imemo_env).
* NEWS: describe this change. I believe nobody touch these objects
because there are no method defined.
* vm_core.h: remove the following definitions.
* rb_cEnv decl.
* GetEnvPtr() because Env is no longer T_DATA object.
* vm_core.h (rb_env_t): fix layout for imemo values.
* vm_core.h (vm_assert_env): added.
* vm_core.h (vm_env_new): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Bug #12628]
This patch introduce many changes.
* Introduce concept of "Block Handler (BH)" to represent
passed blocks.
* move rb_control_frame_t::flag to ep[0] (as a special local
variable). This flags represents not only frame type, but also
env flags such as escaped.
* rename `rb_block_t` to `struct rb_block`.
* Make Proc, Binding and RubyVM::Env objects wb-protected.
Check [Bug #12628] for more details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash_add_new_element): add new element or do nothing
if it is contained already.
* array.c (ary_add_hash, ary_add_hash_by): use
rb_hash_add_new_element.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
termlen and resize heap for the terminator. This is split from
rb_str_fill_terminator (str_fill_term) because filling terminator
and changing terminator length are different things. [Bug #12536]
* internal.h: declaration for rb_str_change_terminator_length.
* string.c (str_fill_term): Simplify only to zero-fill the terminator.
For non-shared strings, it assumes that (capa + termlen) bytes of
heap is allocated. This partially reverts r55557.
* encoding.c (rb_enc_associate_index): rb_str_change_terminator_length
is used, and it should be called whenever the termlen is changed.
* string.c (str_capacity): New static function to return capacity
of a string with the given termlen, because the termlen may
sometimes be different from TERM_LEN(str) especially during
changing termlen or filling terminator with specific termlen.
* string.c (rb_str_capacity): Use str_capacity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RUBY_INTEGER_UNIFICATION): macro to tell if
Integer is integrated. [ruby-core:75718][Bug #12427]
* include/ruby/backward.h, internal.h (rb_cFixnum, rb_cBignum):
fallback to rb_cInteger.
* bignum.c, numeric.c, ext/json/generator/generator.{c,h}: use the
macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Fix failure of TestMkmf::TestConvertible on Solaris with
Oracle Solaris Studio 12. [ruby-dev:49651] [Bug #12470]
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* transcode.c (str_transcode0): scrub in the given encoding when
the source encoding is given, not in the encoding of the
receiver. [ruby-core:75732] [Bug #12431]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_sum): Optimize for a range from int to int.
* test/ruby/test_enum.rb (test_range_sum): Move from test_range.rb,
and add assertions for some conditions.
* test/ruby/test_enum.rb (test_hash_sum): Move from test_hash.rb.
* test/ruby/test_hash.rb, test/ruby/test_range.rb: Remove test_sum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and define CONSTFUNC and PUREFUNC if available.
Note that I don't add those options as default because
it still shows many false-positive (it seems not to consider
longjmp).
* vm_eval.c (stack_check): get rb_thread_t* as an argument
to avoid duplicate call of GET_THREAD().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
only if it can use SSE 4.2 POPCNT whose latency is 3 cycle.
* internal.h (rb_popcount64): use __builtin_popcountll because now
it is in fast path.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (__builtin_ctz): check.
* configure.in (__builtin_ctzll): check.
* internal.h (rb_popcount32): defined for ntz_int32.
it can use __builtin_popcount but this function is not used on
GCC environment because it uses __builtin_ctz.
When another function uses this, using __builtin_popcount
should be re-considered.
* internal.h (rb_popcount64): ditto.
* internal.h (ntz_int32): defined for ntz_intptr.
* internal.h (ntz_int64): defined for ntz_intptr.
* internal.h (ntz_intptr): defined as ntz for uintptr_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (ruby_only_for_internal_use): raise fatal error when
deprecated function only for internal use is called, not just a
warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (rb_int_bit_length): {Fixnum,Bignum}#bit_length is
unified into Integer.
* bignum.c (rb_big_bit_length): Don't define Bignum#bit_length.
* internal.h (rb_big_bit_length): Declared.
--This iine, and those below, will be ignored--
M ChangeLog
M bignum.c
M internal.h
M numeric.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (append_compile_error): use rb_syntax_error_append.
* error.c (rb_syntax_error_append): append messages into a
SyntaxError exception instance.
* parse.y (yycompile0): make new SyntaxError instance in main
mode, otherwize error_buffer should be a SyntaxError if error
has occurred.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c (append_compile_error, compile_bug): pass iseq and get
error info and file from it, not by the thread error info.
* error.c (rb_report_bug_valist): take va_list instead of variadic
arguments, and just report the bug but not abort.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_compile_bug): remove unused function, which has
never been exposed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_big_size): add wrapper function of BIGSIZE and
rename the method funtion with _m suffix.
* numeric.c (int_round_zero_p): extracted from rb_int_round.
optimize for Bignum, and convert VALUE returned by Numeric#size
to long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bignum.c (rb_cstr_parse_inum): [EXPERIMENTAL] new function to
parse integer in C-string with length. the name and the
arguments may be changed in the future.
* bignum.c (rb_str_to_inum): preserve encoding of the argument in
error messages, and no longer needs to copy non-terminated
strings.
* bignum.c (rb_str2big_{poweroftwo,normal,karatsuba,gmp}): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (struct parser_params): move parse_in_eval flag from
rb_thread_t.
* parse.y (rb_parser_set_context): set parsing context, not only
mild error flag.
* iseq.c (rb_iseq_compile_with_option): the parser now refers no
thread local states to be restored.
* vm_eval.c (eval_string_with_cref): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* numeric.c (rb_int2str): conversion function to String for
generic Integer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* strftime.c (rb_strftime_with_timespec): append formatted results
to the given string with expanding, and also deal with NUL chars.
* strftime.c (rb_strftime, rb_strftime_timespec): return formatted
string, not the length put in the given buffer.
* time.c (rb_strftime_alloc): no longer needs to retry with
reallocating buffers.
* time.c (time_strftime): no longer needs to split by NUL chars.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
expected compiler to handle well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
but LONG_LONG is always defined as 64bit), or there's int128_t.
* internal.h (DL2NUM): defined if DLONG is defined.
* internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`.
* insns.def (opt_mul): use rb_fix_mul_fix().
* numeric.c (fix_mul): ditto.
* time.c (mul): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
internal.h so that they are exported only for ruby itself.
* internal.h (rb_big_odd_p, rb_big_even_p): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (rb_iseq_compile_with_option): make the parser in mild
error.
* load.c (rb_load_internal0): ditto.
* parse.y (yycompile0): return the error message within the error
to be raised. [Feature #11951]
* parse.y (parser_compile_error): accumulate error messages in the
error_buffer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Feature #12172]
* internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can
use it.
* test/ruby/test_array.rb (test_max, test_min): tests for Array#max
and Array#min.
* test/ruby/test_enum.rb (test_max, test_min): revised a bit to test
Enumerable#max and #min explicitly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
integers including Bignums.
* internal.h (rb_fix_plus): Declared to be usable from enum_inject.
* numeric.c (rb_fix_plus): Defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_gc_mark_global_tbl): should be private,
but was accidentally exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: move function declarations for class internals from
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e