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

62277 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 4989987419
Explicit conversion to boolean to suppress shorten-64-to-32 warnings 2020-07-10 13:02:31 +09:00
Nobuyoshi Nakada a82252df42
Fixed another typo 2020-07-10 12:48:47 +09:00
Nobuyoshi Nakada 234f8eee33
Fixed typos 2020-07-10 12:32:48 +09:00
卜部昌平 e4ee992099 vm_push_frame_debug_counter_inc: use branches
Ko1 doesn't like previous code.
2020-07-10 12:23:41 +09:00
卜部昌平 0e276dc458 vm_push_frame: move assignments around
Struct assignment using a compound literal is more readable than before,
to me at least.  It seems compilers reorder assignments anyways.
Neither speedup nor slowdown is observed on my machine.
2020-07-10 12:23:41 +09:00
卜部昌平 215c6fa3d0 RUBY_CONST_ASSERT: use STATIC_ASSERT instead
Static assertions shall be done using STATIC_ASSERT these days.
2020-07-10 12:23:41 +09:00
卜部昌平 4b8170ce80 vm_push_frame: move assertions out of the function
These assertions are purely static.  Ned not be checked on-the-fly.
2020-07-10 12:23:41 +09:00
卜部昌平 1d93705d6a vm_push_frame: hoist out debug codes
Made it a bit readable.
2020-07-10 12:23:41 +09:00
卜部昌平 db7f3496dd nobody uses the return value of vm_push_frame
Surprised to see such a waste of time in this super duper hot path.
2020-07-10 12:23:41 +09:00
Masataka Pocke Kuwabara ba81bc24e6
Add instance_methods to class generated by DelegateClass
Also, make DelegateClass.instance_method fallback to superclass.

Fixes [Bug #16982]
2020-07-09 15:01:10 -07:00
git 7a479b30b6 * 2020-07-10 [ci skip] 2020-07-10 06:50:04 +09:00
Jeremy Evans e1bbb9ea9c Document that Kernel#load will load relative to current directory [ci skip]
Update and format the Kernel#load documentation to separate the
three cases (absolute path, explicit relative path, other), and
also document that it raises LoadError on failure.

Fixes [Bug #16988]
2020-07-09 14:47:13 -07:00
Kazuhiro NISHIYAMA addbb7d16e
Fix typos [ci skip] 2020-07-09 18:14:53 +09:00
git cb0404cc51 * 2020-07-09 [ci skip] 2020-07-09 13:56:06 +09:00
Nobuyoshi Nakada a0a5eec0e7
Bail out when unsupported coroutine target 2020-07-09 13:53:20 +09:00
Burdette Lamar 9fc25811d5
Enhanced RDoc for Array (#3282)
Methods:

    reject!
    reject
    delete_if
    zip
    transpose
    replace
    clear
2020-07-08 09:27:10 -05:00
Watson 23655e6de5 Fix build error on Apple silicon macOS
This patch will fix following build error on macOS 11.0 + Xcode 12 beta.

```
$ ./configure
$ make V=1
	BASERUBY = /Users/watson/.rbenv/shims/ruby --disable=gems
	CC = clang -fdeclspec
	LD = ld
	LDSHARED = clang -fdeclspec -dynamiclib
	CFLAGS = -O3 -ggdb3 -Wall -Wextra -Werror=deprecated-declarations -Werror=division-by-zero -Werror=implicit-function-declaration -Werror=implicit-int -Werror=misleading-indentation -Werror=pointer-arith -Werror=shorten-64-to-32 -Werror=write-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Werror=extra-tokens -std=gnu99  -pipe
	XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/arm64-darwin20 -I./include -I. -I./enc/unicode/12.1.0
	CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT
	DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -fstack-protector-strong -Wl,-pie -framework Security -framework Foundation
	SOLIBS = -lpthread -ldl -lobjc
	LANG = ja_JP.UTF-8
	LC_ALL =
	LC_CTYPE =
	MFLAGS =
Apple clang version 12.0.0 (clang-1200.0.22.19)
Target: arm64-apple-darwin20.0.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang -fdeclspec -O3 -ggdb3 -Wall -Wextra -Werror=deprecated-declarations -Werror=division-by-zero -Werror=implicit-function-declaration -Werror=implicit-int -Werror=misleading-indentation -Werror=pointer-arith -Werror=shorten-64-to-32 -Werror=write-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Werror=extra-tokens -std=gnu99  -pipe  -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -DRUBY_DEVEL=1 -fvisibility=hidden -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/arm64-darwin20 -I./include -I. -I./enc/unicode/12.1.0 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -o cont.o -c cont.c
In file included from cont.c:19:
./coroutine/ucontext/Context.h:32:5: error: 'getcontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    getcontext(&context->state);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:37:6: note: 'getcontext' has been
      explicitly marked deprecated here
int  getcontext(ucontext_t *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
     ^
In file included from cont.c:19:
./coroutine/ucontext/Context.h:51:5: error: 'makecontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    makecontext(&context->state, (void(*)(void))coroutine_trampoline, 2, (void*)start, (void*)context);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:38:6: note: 'makecontext' has been
      explicitly marked deprecated here
void makecontext(ucontext_t *, void (*)(), int, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_2_0) __WATCHOS_PROHI...
     ^
In file included from cont.c:19:
./coroutine/ucontext/Context.h:59:5: error: 'swapcontext' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
    swapcontext(&current->state, &target->state);
    ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ucontext.h:40:6: note: 'swapcontext' has been
      explicitly marked deprecated here
int  swapcontext(ucontext_t * __restrict, const ucontext_t * __restrict) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_2_0, __IPHONE_...
     ^
3 errors generated.
make: *** [cont.o] Error 1
```
2020-07-08 22:56:49 +09:00
Nobuyoshi Nakada 11af12026e
Hoisted out functions for no name rest argument symbol 2020-07-08 18:35:46 +09:00
Nobuyoshi Nakada 6a05532315
Constified NODE pointer in ASTNodeData 2020-07-08 18:26:12 +09:00
manga_osyo ff5e660340 Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of `RubyVM::AbstractSyntaxTree`. 2020-07-08 17:43:04 +09:00
git 57cde28c20 * 2020-07-08 [ci skip] 2020-07-08 10:00:30 +09:00
Yusuke Endoh ecfc09d053 gc.c: Cast int literal "1" to bits_t
... because shifting by more than 31 bits has undefined behavior
(depending upon platform). Coverity Scan found this issue.
2020-07-08 09:58:48 +09:00
Aaron Patterson b06a4dc6f1
Expand heap pages to be exactly 16kb
This commit expands heap pages to be exactly 16KiB and eliminates the
`REQUIRED_SIZE_BY_MALLOC` constant.

I believe the goal of `REQUIRED_SIZE_BY_MALLOC` was to make the heap
pages consume some multiple of OS page size.  16KiB is convenient because
OS page size is typically 4KiB, so one Ruby page is four OS pages.

Do not guess how malloc works
=============================

We should not try to guess how `malloc` works and instead request (and
use) four OS pages.

Here is my reasoning:

1. Not all mallocs will store metadata in the same region as user requested
memory.  jemalloc specifically states[1]:

> Information about the states of the runs is stored as a page map at the beginning of each chunk.

2. We're using `posix_memalign` to request memory.  This means that the
   first address must be divisible by the alignment.  Our allocation is
   page aligned, so if malloc is storing metadata *before* the page,
   then we've already crossed page boundaries.

3. Some allocators like glibc will use the memory at the end of the
   page.  I am able to demonstrate that glibc will return pointers
   within the page boundary that contains `heap_page_body`[2].  We
   *expected* the allocation to look like this:

![Expected alignment](https://user-images.githubusercontent.com/3124/85803661-8a81d600-b6fc-11ea-8cb6-7dbdb434a43b.png)

   But since `heap_page` is allocated immediately after
   `heap_page_body`[3], instead the layout looks like this:

![Actual alignment](https://user-images.githubusercontent.com/3124/85803714-a1c0c380-b6fc-11ea-8c17-8b37369e17ee.png)

   This is not optimal because `heap_page` gets allocated immediately
   after `heap_page_body`.  We frequently write to `heap_page`, so the
   bottom OS page of `heap_page_body` is very likely to be copied.

One more object per page
========================

In jemalloc, allocation requests are rounded to the nearest boundary,
which in this case is 16KiB[4], so `REQUIRED_SIZE_BY_MALLOC` space is
just wasted on jemalloc.

On glibc, the space is not wasted, but instead it is very likely to
cause page faults.

Instead of wasting space or causing page faults, lets just use the space
to store one more Ruby object.  Using the space to store one more Ruby
object will prevent page faults, stop wasting space, decrease memory
usage, decrease GC time, etc.

1. https://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf
2. 33390d15e7
3  289a28e68f/gc.c (L1757-L1763)
4. https://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf page 4

Co-authored-by: John Hawthorn <john@hawthorn.email>
2020-07-06 14:17:54 -07:00
git b02a9584a1 * 2020-07-07 [ci skip] 2020-07-07 00:26:58 +09:00
Jean Boussier 2c6512fe67 Get rid of the redundant stat() in rb_check_realpath_internal 2020-07-07 00:26:37 +09:00
Takashi Kokubun 167d139487
Inline builtin struct aref
We don't do this for aset because it might raise a FrozenError.

```
$ benchmark-driver -v --rbenv 'before;after;before --jit;after --jit' benchmark/mjit_struct_aref.yml --repeat-count=4
before: ruby 2.8.0dev (2020-07-06T01:47:11Z master d94ef7c6b6) [x86_64-linux]
after: ruby 2.8.0dev (2020-07-06T07:11:51Z master 85425168f4) [x86_64-linux]
last_commit=Inline builtin struct aref
before --jit: ruby 2.8.0dev (2020-07-06T01:47:11Z master d94ef7c6b6) +JIT [x86_64-linux]
after --jit: ruby 2.8.0dev (2020-07-06T07:11:51Z master 85425168f4) +JIT [x86_64-linux]
last_commit=Inline builtin struct aref
Calculating -------------------------------------
                             before       after  before --jit  after --jit
mjit_struct_aref(struct)    34.783M     34.810M       48.321M      58.378M i/s -     40.000M times in 1.149996s 1.149097s 0.827794s 0.685192s

Comparison:
             mjit_struct_aref(struct)
             after --jit:  58377836.7 i/s
            before --jit:  48321205.7 i/s - 1.21x  slower
                   after:  34809935.5 i/s - 1.68x  slower
                  before:  34782736.5 i/s - 1.68x  slower
```
2020-07-06 00:14:00 -07:00
Nobuyoshi Nakada d94ef7c6b6
Run method_missing in the same execution context 2020-07-06 10:47:11 +09:00
Kenta Murata efe851a0df
[ruby/bigdecimal] Version 2.0.1
https://github.com/ruby/bigdecimal/commit/3fa4f2ac67
2020-07-06 01:15:47 +09:00
Kenta Murata 6a826eb4b0
[ruby/bigdecimal] Return US-ASCII string from BigDecimal#to_s
Fixes #159

https://github.com/ruby/bigdecimal/commit/57ee92e700
2020-07-06 01:15:47 +09:00
Kenta Murata e794d96ca4
[ruby/bigdecimal] Drop Ruby 2.3 support
https://github.com/ruby/bigdecimal/commit/79a819d205
2020-07-06 01:15:47 +09:00
Kenta Murata 40b82afe6a
[ruby/bigdecimal] Support Ruby < 2.6
https://github.com/ruby/bigdecimal/commit/61ec452599
2020-07-06 01:15:46 +09:00
Kenta Murata 03a33603c6
[ruby/bigdecimal] Add Complex#to_d
https://github.com/ruby/bigdecimal/commit/97e794ac97
2020-07-06 01:15:46 +09:00
Jeremy Evans 6607212224
[ruby/bigdecimal] Make tests pass on Ruby 2.4
https://github.com/ruby/bigdecimal/commit/9d19e842ee
2020-07-06 01:15:46 +09:00
Jeremy Evans d36b197d7c
[ruby/bigdecimal] Remove definition of BigDecimal#initialize_copy
This leaves the default definition, which will raise FrozenError.

https://github.com/ruby/bigdecimal/commit/05e843d838
2020-07-06 01:15:46 +09:00
Kenta Murata f00efef30a
[ruby/bigdecimal] Support a Complex in Kernel.BigDecimal()
https://github.com/ruby/bigdecimal/commit/00795cb01f
2020-07-06 01:15:46 +09:00
Jeremy Evans ceb9d516c6
[ruby/bigdecimal] Undef BigDecimal#initialize_copy
Both BigDecimal#clone and BigDecimal#dup return self, there is no
reason to have initialize_copy exposed as a Ruby method.

The same is true for initialize_clone and initialize_dup.

https://github.com/ruby/bigdecimal/commit/aaf237fa9e
2020-07-06 01:15:45 +09:00
Nobuyoshi Nakada d69510b6cd
Removed ext/bigdecimal/util/depend unused since dd0c75fdc2 2020-07-06 01:15:23 +09:00
Nobuyoshi Nakada 1aed23c18d
tool/sync_default_gems.rb: Accept multiple commit ranges 2020-07-06 00:48:33 +09:00
manga_osyo 8e189df32c Add operator info to `OP_ASGN2` of `RubyVM::AbstractSyntaxTree`. 2020-07-06 00:48:15 +09:00
git 988b4bc9ea * 2020-07-06 [ci skip] 2020-07-06 00:28:53 +09:00
Nobuyoshi Nakada 41fef191d1
tool/sync_default_gems.rb: Added bigdecimal 2020-07-05 22:08:04 +09:00
Nobuyoshi Nakada 6236bbf363
Removed duplicate test with test_BigDecimal_bug7522 2020-07-05 22:02:59 +09:00
Nobuyoshi Nakada 4ea57c2a39
Escape `#` for GNU make 3 2020-07-05 19:15:03 +09:00
Nobuyoshi Nakada 12b377a96c
Updated bundled gems 2020-07-05 19:00:46 +09:00
Nobuyoshi Nakada 358f91bf6f
Skip comment and empty lines in gems/bundled_gems file 2020-07-05 18:59:06 +09:00
Nobuyoshi Nakada 41168f69fb
Prefix export symbol prefix to coroutine_transfer 2020-07-05 17:27:12 +09:00
Nobuyoshi Nakada 04c704c5c9
Removed trailing spaces [ci skip] 2020-07-05 17:12:20 +09:00
Koichi Sasada 95f5fd9a55 fix up Primitive.cinit! code
Recent changes break Primitive.cinit!(c_code) so fix it.
2020-07-05 10:44:36 +09:00
Takashi Kokubun e4f7eee009
Check ROBJECT_EMBED on guards-merged ivar access
Fix CI failure like
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3043247
introduced by a69dd699ee
2020-07-04 16:02:46 -07:00
Jeremy Evans c146362555 Use static variables in Range#minmax 2020-07-04 13:34:38 -07:00