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

1584 Коммитов

Автор SHA1 Сообщение Дата
git 73904abb95 * expand tabs. 2019-07-14 17:45:52 +09:00
Nobuyoshi Nakada 32f0135144
Split RUBY_ASSERT and so on under include/ruby 2019-07-14 17:45:21 +09:00
Samuel Williams d17344cfc5 Remove IA64 support. 2019-06-19 23:30:04 +12:00
Nobuyoshi Nakada c8b001858e
Revert "marshal.c: new functions for extensions"
This reverts a commit miss, 24a96a0228.
2019-06-04 19:06:19 +09:00
Nobuyoshi Nakada 24a96a0228
marshal.c: new functions for extensions
* marshal.c (rb_marshal_dump_limited): new function for extension
  libraries to dump object with limited nest level.

* marshal.c (rb_marshal_load_with_proc): new function for extension
  libraries to load object with hook proc.
2019-06-04 18:59:03 +09:00
Nobuyoshi Nakada fb568fe724
Added missing predicate macros 2019-05-28 23:46:30 +09:00
Koichi Sasada 8a2b497e3b remove obsolete rb_gc_finalize_deferred().
rb_gc_finalize_deferred() is remained for compatibility with
C-extensions. However, this function is no longer working
from Ruby 2.4 (crash with SEGV immediately).
So remove it completely.
2019-05-28 15:57:20 +09:00
Jeremy Evans 39eadca76b Add FrozenError#receiver
Similar to NameError#receiver, this returns the object on which
the modification was attempted.  This is useful as it can pinpoint
exactly what is frozen.  In many cases when a FrozenError is
raised, you cannot determine from the context which object is
frozen that you attempted to modify.

Users of the current rb_error_frozen C function will have to switch
to using rb_error_frozen_object or the new rb_frozen_error_raise
in order to set the receiver of the FrozenError.

To allow the receiver to be set from Ruby, support an optional
second argument to FrozenError#initialize.

Implements [Feature #15751]
2019-05-26 11:09:21 -07:00
Nobuyoshi Nakada fe3ff5afb0
Suppress paranoid warnings for external/3rd-party libraries
[Feature #15665]
2019-05-23 17:36:26 +09:00
Alan Wu b00f280d4b
Eagerly name modules and classes
* variable.c: make the hidden ivars `classpath` and `tmp_classpath` the source
  of truth for module and constant names. Assign to them when modules are bind
  to constants.

* variable.c: remove references to module name cache, as what used to be the cache
  is now the source of truth. Remove rb_class_path_no_cache().

* variable.c: remove the hidden ivar `classid`. This existed for the purposes of
  module name search, which is now replaced. Also, remove the associated
  rb_name_class().

* class.c: use rb_set_class_path_string to set the name of Object during boot.
  Must use a fstring as this runs before rb_cString is initialized and
  creating a normal string leads to a VALUE without a class.

* spec/ruby/core/module/name_spec.rb: add a few specs to specify what happens
  to Module#name across multiple operations. These specs pass without other
  code changes in this commit.

[Feature #15765]
2019-05-22 15:46:47 +09:00
Aaron Patterson 154a67f140
Rename rb_gc_new_location to rb_gc_location
The function will return new or existing locations depending on whether
or not the object actually moved, so give it a more appropriate name.
2019-05-18 12:24:28 +03:00
Nobuyoshi Nakada b1b385465e
Do not call memcpy if copying nothing
c.f.
* e7b18ca6d9
* 34e1079aef
2019-05-17 13:16:39 +09:00
Lourens Naudé a47f598d77
Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most pattern matches are less than or equal to 4 results
Closes: https://github.com/ruby/ruby/pull/2135
2019-05-07 21:58:55 +09:00
Lourens Naudé cf930985da Remove member char_offset_updated from struct rmatch as member char_offset_num_allocated can serve the same purpose as that predicate 2019-04-24 02:02:05 +09:00
Lourens Naudé 31cf13060c Only define history_root member of the Oniguruma re_registers struct if USE_CAPTURE_HISTORY is enabled 2019-04-24 00:40:17 +09:00
SHIBATA Hiroshi 184447d91c
ViewVC of svn.ruby-lang.org was shutdown status. 2019-04-22 19:37:22 +09:00
naruse d3df725f9e Make rb_hash_bulk_insert public
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-21 05:37:11 +00:00
tenderlove 91793b8967 Add `GC.compact` again.
🙏

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 01:19:47 +00:00
tenderlove 744e5df715 Reverting compaction for now
For some reason symbols (or classes) are being overridden in trunk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 09:41:41 +00:00
ktsj 9738f96fcf Introduce pattern matching [EXPERIMENTAL]
[ruby-core:87945] [Feature #14912]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 06:48:03 +00:00
tenderlove 3c55b643ae Adding `GC.compact` and compacting GC support.
This commit adds the new method `GC.compact` and compacting GC support.
Please see this issue for caveats:

  https://bugs.ruby-lang.org/issues/15626

[Feature #15626]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17 03:17:25 +00:00
svn 481481b81a * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 09:16:00 +00:00
kazu 25c1fd3b90 Reverting all commits from r67479 to r67496 because of CI failures
Because hard to specify commits related to r67479 only.
So please commit again.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10 09:15:21 +00:00
tenderlove 73f891f1a5 fix RMoved definition location
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09 23:23:39 +00:00
tenderlove 3ef4db15e9 Adding `GC.compact` and compacting GC support.
This commit adds the new method `GC.compact` and compacting GC support.
Please see this issue for caveats:

  https://bugs.ruby-lang.org/issues/15626

[Feature #15626]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09 20:32:04 +00:00
mrkn 7570864267 Introduce RVALUE_EMBED_LEN_MAX to remove a magic number
* include/ruby/ruby.h: replace a magic number with RVALUE_EMBED_LEN_MAX,
  which indicates the number of VALUE elements can be embedded in a RVALUE.

* internal.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-14 15:29:04 +00:00
normal 23444302d9 introduce rb_nogvl C-API to mark ubf as async-signal-safe
zlib and bignum both contain unblocking functions which are
async-signal-safe and do not require spawning additional
threads.

We can execute those functions directly in signal handlers
without incurring overhead of extra threads, so provide C-API
users the ability to deal with that.  Other C-API users may
have similar need.

This flexible API can supercede existing uses of
rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by
introducing a flags argument to control behavior.

Note: this API is NOT finalized.  It needs approval from other
committers.  I prefer shorter name than previous
rb_thread_call_without_gvl* functions because my eyes requires
big fonts.

[Bug #15499]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04 13:14:11 +00:00
matz 3a0471faa0 version.h (RUBY_VERSION): 2.7.0 development has started.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-25 13:45:17 +00:00
ko1 a976acd603 remove "deprecated" for rb_frame_method_id_and_class [Bug #15300]
* include/ruby/backward.h (rb_frame_method_id_and_class): we had labeled
  `rb_frame_method_id_and_class()` as deprecated because MRI internal
  doesn't use it, but we found there are user of this API in external
  C-extensions. Now we don't have proper alternative API and no time
  to make alternative API, so I remove "deprecated" label.
  [Bug #15300]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24 02:02:47 +00:00
nobu c6ef5bc31e complex.c: new APIs for Complex
[Feature #15066]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 11:06:48 +00:00
nobu dc8afd385d complex.c: rb_complex_new_polar
* complex.c (rb_complex_new_polar): renamed with _new to clarify
  that it creates a new instance, but is not an instance method.

* complex.c (rb_complex_polar): deprecated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 11:06:47 +00:00
mrkn 31eb48a0ac enumerator.c: Add rb_arithmetic_sequence_components_t
Add rb_arithmetic_sequence_components_t struct for encapsulating
the components of ArithmeticSequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 07:16:07 +00:00
mrkn 914a290324 enumerator.c: rb_arithmetic_sequence_extract
New public C-API for extracting components of Enumerator::ArithmeticSequence
or Range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12 06:39:58 +00:00
naruse 7405bbda27 Define HAVE_STMT_AND_DECL_IN_EXPR and use it [Bug #15293]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-10 13:58:36 +00:00
ko1 5ac990e83e `script_compiled` TracePoint event [Feature #15287]
* vm_trace.c: add `script_compiled` event. This event invoked
  after script compiling and before evaluating compiled script.
  Also the following methods are added:

  `TracePoint#compiled_instruction_sequence` method to get compiled
  `RubyVM::InstructionSequence` instance.

  `TracePoint#compiled_eval_script` method to get compiled script (String)
  by *eval methods (return nil if compiling by file).

* vm_trace.c (tracepoint_attr_raised_exception):


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 13:42:32 +00:00
naruse 8b14bd4e14 Should be true fix for r66200
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 12:35:00 +00:00
naruse 956d35e2d0 refix of r66200
Though internal.h has the prototype, it still shows symbol lookup error...
https://rubyci.org/logs/rubyci.s3.amazonaws.com/icc-x64/ruby-trunk/log/20181206T050002Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 10:02:04 +00:00
ko1 eb79191f16 Introduce "COLDFUNC" function attribute.
* include/ruby/defines.h: introduce "COLDFUNC" function attribute
  on several compilers for called unlikely functions.
  Apply to rb_memerror, rb_warn and rb_bug.

  A patch form  methodmissing <lourens@bearmetal.eu>.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-05 17:23:32 +00:00
ko1 5e11de6585 make `RARRAY_PTR_USE` more conservertive.
* include/ruby/ruby.h: de-transient at
  `RARRAY_PTR_USE` and `RARRAY_PTR_USE_START`.
  Introduce `RARRAY_PTR_USE_TRANSIENT` and
  `RARRAY_PTR_USE_START_TRANSIENT` if you don't want to
  de-transient an array. Generally, it is difficult
  so C-extension writers should not use them.

* array.c: use `RARRAY_PTR_USE_TRANSIENT` if possible.

* hash.c: ditto.

* enum.c (enum_sort_by): remove `rb_ary_transient_heap_evacuate()`
  because `RARRAY_PTR_USE` do de-transient.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03 12:36:39 +00:00
odaira 3385395796 errno.h must be included after config.h because config.h might define
_REENTRANT, _THREAD_SAFE, etc., which affect how errno is defined
on some architectures

* ext/openssl/ossl.h: include errno.h after ruby.h

* include/ruby/io.h: include errno.h after ruby/config.h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-21 20:39:09 +00:00
nobu de790435fa ruby/ruby.h: void rb_scan_args_verify
* include/ruby/ruby.h (rb_scan_args_verify): void the never used
  result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19 15:00:35 +00:00
svn 9c8119e78b * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15 22:28:06 +00:00
normal 51aaf74bba include/ruby/ruby.h (RB_ALLOCV*): remove unnecessary GC guard
text	   data	    bss	    dec	    hex	filename
 3535061	  21232	  72944	3629237	 3760b5	ruby.before
 3534141	  21232	  72944	3628317	 375d1d	ruby.after

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15 22:28:03 +00:00
svn cc7fcbbc25 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-01 08:53:53 +00:00
ko1 c39797e872 introduce USE_TRANSIENT_HEAP to enable/disable theap.
* include/ruby/ruby.h: intrdocue `USE_TRANSIENT_HEAP` macro
  to enable/disable transient heap.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-01 08:53:44 +00:00
ko1 8f675cdd00 support theap for T_HASH. [Feature #14989]
* hash.c, internal.h: support theap for small Hash.
  Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
  (<=8 entries) are managed by an array data structure.
  This array data can be managed by theap.
  If st_table is needed, then converting array data to st_table data.

  For st_table using code, we prepare "stlike" APIs which accepts hash value
  and are very similar to st_ APIs.

  This work is based on the GSoC achievement
  by tacinight <tacingiht@gmail.com> and refined by ko1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 22:11:51 +00:00
ko1 312b105d0e introduce TransientHeap. [Bug #14858]
* transient_heap.c, transient_heap.h: implement TransientHeap (theap).
  theap is designed for Ruby's object system. theap is like Eden heap
  on generational GC terminology. theap allocation is very fast because
  it only needs to bump up pointer and deallocation is also fast because
  we don't do anything. However we need to evacuate (Copy GC terminology)
  if theap memory is long-lived. Evacuation logic is needed for each type.

  See [Bug #14858] for details.

* array.c: Now, theap for T_ARRAY is supported.

  ary_heap_alloc() tries to allocate memory area from theap. If this trial
  sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on.
  We don't need to free theap ptr.

* ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that
  if ary is allocated at theap, force evacuation to malloc'ed memory.
  It makes programs slow, but very compatible with current code because
  theap memory can be evacuated (theap memory will be recycled).

  If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT()
  instead of RARRAY_CONST_PTR(). If you can't understand when evacuation
  will occur, use RARRAY_CONST_PTR().

(re-commit of r65444)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 21:53:56 +00:00
ko1 7d359f9b69 revert r65444 and r65446 because of commit miss
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 21:01:55 +00:00
ko1 90ac549fa6 introduce TransientHeap. [Bug #14858]
* transient_heap.c, transient_heap.h: implement TransientHeap (theap).
  theap is designed for Ruby's object system. theap is like Eden heap
  on generational GC terminology. theap allocation is very fast because
  it only needs to bump up pointer and deallocation is also fast because
  we don't do anything. However we need to evacuate (Copy GC terminology)
  if theap memory is long-lived. Evacuation logic is needed for each type.

  See [Bug #14858] for details.

* array.c: Now, theap for T_ARRAY is supported.

  ary_heap_alloc() tries to allocate memory area from theap. If this trial
  sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on.
  We don't need to free theap ptr.

* ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that
  if ary is allocated at theap, force evacuation to malloc'ed memory.
  It makes programs slow, but very compatible with current code because
  theap memory can be evacuated (theap memory will be recycled).

  If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT()
  instead of RARRAY_CONST_PTR(). If you can't understand when evacuation
  will occur, use RARRAY_CONST_PTR().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 20:46:24 +00:00
normal b67d76b3a6 Revert "vm_trace: implement postponed_jobs as st_table"
This reverts commit 5a1dfb04bc (r63451)

And mark the functions as async-signal-safe while we're at it to
prevent future developers from making the same mistake as I did :x

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23 03:47:45 +00:00
nobu f2427a436f Define PRIdPTR etc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 16:21:07 +00:00
svn 6938834c08 * remove trailing space. [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 13:57:38 +00:00
k0kubun 71e70d2802 include/ruby/ruby.h: comment about mswin RUBY_EXTERN [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 13:57:36 +00:00
k0kubun ad2d2e3f0f include/ruby/ruby.h: import external symbols
properly on MinGW MJIT.

test_jit.rb: all MJIT tests are now passing on MinGW.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 13:46:42 +00:00
k0kubun fd719c59e9 include/ruby/intern.h: don't modify MJIT_FUNC_EXPORTED
on most of platforms except mswin.

Changing it to static was needed for mswin because it doesn't use
transform_mjit_header, but for platforms that use it, it causes link
error like:

/usr/bin/ld: /tmp/_ruby_mjit_p21652u0.o: relocation R_X86_64_PC32 against undefined symbol `rb_vm_search_method_slowpath' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

include/ruby/defines.h: MJIT_FUNC_EXPORTED moved to intern.h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-07 14:00:04 +00:00
k0kubun d590027fd2 vm_core.h: fix inconsistent prototype declarations
like "error: static declaration of 'xxx' follows non-static declaration".
r64940 is successfully built on mswin but not built on almost all other environments.

internal.h: ditto

include/ruby/intern.h: MJIT_STATIC is moved to this file since this file
also needs to use this.

mjit.h: MJIT_STATIC is moved from this.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-07 13:34:59 +00:00
shyouhei bc2d493e0d use configure-defined macro instead of __GNUC__
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26 06:16:32 +00:00
nobu c46515e42a backward.h: removed stale declarations
* include/ruby/backward.h (rb_complex_set_real, rb_complex_set_imag):
  removed useless declarations which have been deprecated from the
  beginning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05 20:02:32 +00:00
nobu 868ad2104c ruby.h: removed internal macros
* 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
2018-09-04 12:30:34 +00:00
nobu 1cf2bb4b20 use mingw ANSI stdio
[Bug #13496]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-04 08:39:14 +00:00
nobu c115b39e03 Declare as gnu_printf on mingw
[Bug #13496]

From: MSP-Greg <MSP-Greg@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-03 08:20:41 +00:00
nobu 762f44cf49 configure.ac: printf prifix for int64_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-27 05:39:09 +00:00
kazu 842b735979 add 'x' mode character for O_EXCL
[Feature #11258]
Patch by cremno (cremno phobia)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09 08:49:09 +00:00
kazu 14892a26a5 use https:// instead of http://
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-28 10:00:27 +00:00
mame ffb09d8e87 eval.c: rename "rb_frozen_class_p" to "rb_class_modify_check"
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
2018-07-27 13:57:14 +00:00
nobu 97e05dad7f UNREACHABLE_RETURN
* include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end
  of non-void functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-24 05:38:07 +00:00
nobu cb5598a419 Improve branch misses
Improve branch misses on frozen object predicate checks negatively
affecting performance of most setters as most objects are not frozen.

[Fix GH-1913]

From: Lourens Naudé <lourens@bearmetal.eu>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-12 05:01:04 +00:00
kazu bcf8ce8494 Fix compile error on debian8 and gentoo
https://rubyci.org/logs/rubyci.s3.amazonaws.com/debian8/ruby-trunk/log/20180711T213004Z.log.html.gz#miniruby
https://rubyci.org/logs/rubyci.s3.amazonaws.com/gentoo/ruby-trunk/log/20180711T213003Z.log.html.gz#miniruby
```
./include/ruby/ruby.h:2213:49: error: missing binary operator before token "("
 # if defined(__has_attribute) && __has_attribute(diagnose_if)
                                                 ^
```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-12 03:59:13 +00:00
naruse 4b2f2225e4 Use "diagnose_if" attribute for clang
Before this patch, clang shows many "division by zero is undefined" errors
if a files has syntax error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-10 16:10:57 +00:00
nobu c69b33c468 rb_enc_alias
`rb_encdb`-prefixed functions are only for internal use.
use rb_enc_alias instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-28 23:46:59 +00:00
ko1 d0fb73a0f0 check enc_capable.
* encoding.c (rb_enc_capable): make it extern to check enc_capable.
  enc_index can be set to limited types such as T_STRING, T_REGEX
  and so on. This function check an object is this kind of types.

* include/ruby/encoding.h: ditto.

* encoding.c (enc_set_index): check a given object is enc_capable.

* include/ruby/encoding.h (PUREFUNC):

* marshal.c (encoding_name): check `rb_enc_capable` first.

* marshal.c (r_ivar): ditto. If it is not enc_capable, it should be
  malformed data.

* spec/ruby/optional/capi/encoding_spec.rb: remove tests depending
  on the wrong feature: all objects can set enc_index.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-28 08:35:48 +00:00
nobu 8f6b3ef184 use the prefixed macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-27 14:00:34 +00:00
ko1 07a5e55f11 Introduce `USE_GC_MALLOC_OBJ_INFO_DETAILS`. [Feature #14857]
* include/ruby/defines.h: introduce `USE_GC_MALLOC_OBJ_INFO_DETAILS`
  to show malloc statistics by replace ruby_xmalloc() and so on with
  macros.

* gc.c (struct malloc_obj_info): introduced to save per-malloc information.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-20 07:53:29 +00:00
nobu c9b8a361be intern.h: suppress warnings
* include/ruby/intern.h (rb_fd_select): turned into an inline
  function, to suppress -Waddress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-11 23:34:11 +00:00
ngoto b7595f2c2e include/ruby/missing.h: defined(__cplusplus) before using __cplusplus
* include/ruby/missing.h (isinf, isnan): For non-C++ programs,
  defined(__cplusplus) may be needed before using __cplusplus.
  [Bug #14816]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-05 14:16:50 +00:00
shyouhei b5d6db65b4 `int isnan(double)` is a POSIXism
- `isnan` is something relatively new.  We need to provide one for
  those systems without it.  However:
- X/Open defines `int isnan(double)`. Note the `int`.
- C99 defines `isnan(x)` to be a macro.
- C++11 nukes them all, undefines all the "masking macro"s, and
  defines its own `bool isnan(double)`.  Note the `bool`.
- In C++, `int isnan(double)` and `bool isnan(double)` are
  incompatible.
- So the mess.

[Bug #14816][ruby-core:87364]
further reading: https://developers.redhat.com/blog/2016/02/29/why-cstdlib-is-more-complicated-than-you-might-think/


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-05 06:50:20 +00:00
naruse bcdf08dd83 export rb_hash_bulk_insert
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
2018-05-22 07:31:36 +00:00
shyouhei 9930481a23 Prefer alignof() over _Alignof()
to allow C++ programs include <ruby.h>. [Bug #14668]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-09 02:40:12 +00:00
nobu b2033b8b84 Signature of rb_uint2inum and rb_int2inum
* include/ruby/ruby.h (rb_int2inum, rb_uint2inum): adjust
  declarations.  [ruby-core:83424] [Bug #14036]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-20 09:38:55 +00:00
nobu d77e8a7da5 Signature of rb_uint2big and rb_int2big
* include/ruby/ruby.h (rb_uint2big, rb_int2big): declare with
  uintptr_t and intptr_t instead of VALUE and SIGNED_VALUE
  respectively.  [ruby-core:83424] [Bug #14036]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-20 08:01:44 +00:00
k0kubun 288b44328d Export some missing symbols for MJIT
tool/ruby_vm/views/_insn_name_info.erb: on Linux, rb_vm_insn_name_offset
was needed to compile with --jit-debug (Usually --jit-debug requires
more symbols than the situation without --jit-debug because -O2 skips
some functions to compile).

vm.c: when running transform_mjit_header.rb with --jit-wait,
rb_source_location_cstr was repoted to be missing.

string.c: ditto, for rb_str_eql
numeric.c: ditto, for rb_float_eql

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 13:54:37 +00:00
k0kubun ed935aa5be mjit_compile.c: merge initial JIT compiler
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
2018-02-04 11:22:28 +00:00
nobu eaf301d2be backward.h: adjusted NORETURN declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-03 01:57:00 +00:00
nobu 4c577c4a45 backward.h: rb_mod_const_missing is internal function
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-02 16:02:03 +00:00
nobu 6eeb0f7ef4 ruby.h: relax rb_funcall(obj, id, 0, 0) case only
* include/ruby/ruby.h (rb_varargs_argc_valid_p): relax rb_funcall
  check on extra args only if argc == 0, for the compatibility
  with wrong code which is probably confused with rb_funcallv.
  [Bug #14425]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-01 03:55:55 +00:00
normal 3ce9a14040 ruby.h: relax rb_funcall check on extra args for clang
clang 5.+ (tested clang 7.0.0) seems to be attempting division-by-zero
and giving a very large number for static args to rb_funcall.

* include/ruby/ruby.h (rb_varargs_bad_length): relax check for clang
* ext/-test-/funcall/funcall.c: renamed from passing_block.c
  define extra_args_name function
* test/-ext-/funcall/test_funcall.rb: new test
  [ruby-core:85266] [Bug #14425]

From: Eric Wong <e@80x24.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30 23:55:49 +00:00
kazu ef83b306e2 Fix duplicated HAVE_NAN
And remove redundant `HAVE_*` macros,
and use `USE_RB_*` macros instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-27 04:14:26 +00:00
usa d2bd7d7b98 need to declare the prototype of nan() if missing
* include/ruby/missing.h (nan): need to declare the prototype of nan() if
  missing.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-26 16:38:38 +00:00
normal 7e669f40be ruby/ruby.h: remove unnecessary exports from C-API
Needlessly exporting can reduce performance locally and increase
binary size.

Increasing the footprint of our C-API larger is also detrimental
to our development as it encourages tighter coupling with our
internals; making it harder for us to preserve compatibility.

If some parts of the core codebase needs access to globals,
internal.h should be used instead of anything in include/ruby/*.

"Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote:
> On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > shyouhei@ruby-lang.org wrote:
> >>   https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908
> >>
> >>     export rb_mFConst
> >
> > Why are we exporting all these and making the public C-API bigger?
> > If anything, we should make these static.  Thanks.
>
> No concrete reason, except they have already been externed in 2.5.
> These variables had lacked declarations so far, which resulted in their
> visibility to be that of extern. The commit is just confirming the status quo.
>
> I'm not against to turn them into static.

This reverts changes from r61910, r61909, r61908, r61907, and r61906.

* transcode.c (rb_eUndefinedConversionError): make static
  (rb_eInvalidByteSequenceError): ditto
  (rb_eConverterNotFoundError): ditto
* process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto
* file.c (rb_mFConst): ditto
* error.c (rb_mWarning, rb_cWarningBuffer): ditto
* enumerator.c (rb_cLazy): ditto
  [Misc #14381]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24 21:07:14 +00:00
shyouhei de9d264026 there is no guarantee that mode_t is as wide as int
POSIX only defines mode_t to be "an integer typea", and in fact
MacOS defines it to be uint16_t.  We didn't have NUM2USHORT before
so it did not make sense but now that we have it.  Why not check
apptopriately.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 09:12:06 +00:00
shyouhei 3ca0948f68 INFINITY is float. That of double is HUGE_VAL.
It seems HUGE_VAL is already used. Why not eliminate INTINITY.
NAN is also float. That of double is called nan(). This is also
fixed.

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 01:45:36 +00:00
shyouhei 8fc054fdff export transcode exceptions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:35 +00:00
shyouhei 2950cb0637 export rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:34 +00:00
shyouhei f64c6997be export rb_mFConst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:34 +00:00
shyouhei 3cc4559c48 export ruby_mWarning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:33 +00:00
shyouhei 8dc9ecfef6 export rb_cLazy
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:32 +00:00
shyouhei 585a21318f sort lines
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 09:44:32 +00:00
ngoto f62a2fd1eb fix macro argument names inconsistency
* include/ruby/defines.h (RUBY_ALIGNAS): Fix macro definition.
  Fix compile error with Fujitsu C Compiler (fcc) on Solaris.

* include/ruby/defines.h (RUBY_ALIGNOF): Fix macro argument name.
  Fix compile error with fcc and Oracle Solaris Studio 12.4 on Solaris.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 05:49:01 +00:00
shyouhei 8a52dbdb2a ruby_aligned_char no longer needed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 07:30:43 +00:00
shyouhei 8699a7a006 take alignof instead of sizeof
win32ole.c includes ALLOCA_N(struct myCPINFOEX, 1).  On such case
it is not a wise idea to align to the size of that struct.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 06:47:56 +00:00
shyouhei 369aca64cf also blacklist gcc 4.9 for __builtin_alloca_with_align
Reports show that gcc (Raspbian 4.9.2-10) 4.9.2 fails here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 05:51:46 +00:00
shyouhei 39ee36f63d disable __builtin_alloca_with_align for GCC 4.8
It seems to be a false positive that the configure detects this
undocumented function to be available on the compiler.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 04:36:09 +00:00
shyouhei e41b4a45a4 give up RSTRING_PTR() being VALUE-aligned
rb_setup_fake_str() can take arbitrary char* address, typicalluy
C string literals.  These arguments have no guarantee of
alignment at all.  It was not a wise idea for me to think
RSTRING_PTR can be aligned.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 04:36:09 +00:00
shyouhei cabc3b6516 __declspec(align(#)) does not take sizeof()
Use compile-time constant expression instead.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:59:18 +00:00
shyouhei 8f745a2fab more support for NORETURN
Before this NORETURN was checked only for __attribute__ or __declspec,
but nowadays other ways are there to tell compilers that a function
never returns.  Take them into account.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:20 +00:00
shyouhei df9a70900a __builtin_alloca_with_align for optimal memory access
ALLOCA_N takes type arugment.  It is natural that the returned
value to be used as an array of type, thus type-aligned.
Luckily GCC has a builtin to tell compiler such alignment info.
This should generate beter instructions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:19 +00:00
shyouhei 21429b1488 __alignof__ to take alignment of a type
C11 and C++11 has this feature so why not use it when available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:17 +00:00
shyouhei f089a52865 __attibute__((__aligned__)) for RSTRING_PTR()
For instance array.c:rb_ary_product() uses RSTRING_PTR() as an
array of int. So to avoid misaligned memory access RSTRING_PTR()
must at least be sizeof(int)-aligned.  However the type of
RSTRING_PTR() is char*, which of course can expect alignment as
much as 1.  This is a problem.

The reality is, there is no misaligned memory access because the
memory region behind RSTRING_PTR() is allocated using malloc().
Memory regions returned from malloc() are always aligned
appropriately.  So let's tell the compiler about this information.
It seems GCC, clang, and MSVC have such feature.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-15 02:35:16 +00:00
kazu 51edb30042 Include ruby/{io,encoding}.h before internal.h
because of r61712 and r61713

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 12:35:12 +00:00
nobu f651ff638d wrap statement expression with __extension__
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 00:25:27 +00:00
shyouhei a6b50f379d statement experssion is a GCCism
should mark as such.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:41:53 +00:00
shyouhei 67b547d06a __VA_ARGS__ is a C99ism
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:41:45 +00:00
matz 0af050993e version.h (RUBY_VERSION): 2.6.0 development has started.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 14:05:59 +00:00
naruse 98bddfefc1 undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P on GCC 4.8
GCC 4.8 with optimization causes error if it compiles following code.
[Bug #14221]

```c
__builtin_choose_expr(__builtin_constant_p(b),0,1)
```

https://github.com/ruby/ruby/pull/1778

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-23 16:17:57 +00:00
usa 52220154a8 force hash values fixable
* include/ruby/ruby.h (RB_ST2FIX): force fixable on LLP64 environment.

* hash.c (any_hash): ditto.
  [ruby-core:84395] [Bug #14218]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:52:11 +00:00
mame c08e8886ba compile.c: add a RUBY_EVENT_COVERAGE_LINE event for line coverage
2.5's line coverage measurement was about two times slower than 2.4
because of two reasons; (1) vm_trace uses rb_iseq_event_flags (which
takes O(n) currently where n is the length of iseq) to get an event
type, and (2) RUBY_EVENT_LINE uses setjmp to call an event hook.

This change adds a special event for line coverage,
RUBY_EVENT_COVERAGE_LINE, and adds `tracecoverage` instructions where
the event occurs in iseq.
`tracecoverage` instruction calls an event hook without vm_trace.
And, RUBY_EVENT_COVERAGE_LINE is an internal event which does not
use setjmp.

This change also cancells lineno change due to the deletion of trace
instructions [Feature #14104].  So fixes [Bug #14191].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 04:24:14 +00:00
naruse 027b576b31 suppress warning: 'const' attribute on function returning 'void'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 09:03:59 +00:00
shyouhei b57915eddc Add FrozenError as a subclass of RuntimeError
FrozenError will be used instead of RuntimeError for exceptions
raised when there is an attempt to modify a frozen object. The
reason for this change is to differentiate exceptions related
to frozen objects from generic exceptions such as those generated
by Kernel#raise without an exception class.

From: Jeremy Evans <code@jeremyevans.net>
Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:46:34 +00:00
usa f623428d1a undef previous definition of `SIZEOF_STRUCT_STAT_ST_INO`
trying to solve build problem of MinGW.  see [Bug #14165]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 16:06:41 +00:00
naruse 189ecfd2eb extern rb_time_utc_offset to get utc offset
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 12:09:47 +00:00
usa 91de3d6539 support 128bit ino on Windows (if available)
* win32/win32.c, include/ruby/win32.h (stati128, rb_{,u,l,ul}stati128): rename
  from stati64ns, change the type of st_ino to 64bit and added st_inohigh.

* dir.c, file.c (stat, lstat): follow above changes.

* file.c (rb_stat_ino): support 128bit ino.

* win32/win32.c (rb_{,u,l,ul}stati128): ditto.
  [Feature #13731]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-10 17:26:58 +00:00
mame 55f93cb63f vm_core.h (RUBY_EVENT_COVERAGE_BRANCH): renamed
This change moves RUBY_EVENT_COVERAGE from include/ruby/ruby.h to
vm_core.h and renames it to RUBY_EVENT_COVERAGE_BRANCH.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 07:19:17 +00:00
mame 9be95d2a71 Remove RUBY_EVENT_SPECIFIED_LINE
Follow up of r61044

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-06 07:19:16 +00:00
usa ce7c1c0577 support nanosec file timestamp on newer Windows
Support nanosec file timestamp on Windows 8 or later.
Original patches are written by kubo (Kubo Takehiro).
Windows 7 and earlier also supports nanosec file timestamp, but it's too
accurate than system time.  so, this feature is disabled on such versions.
[Feature #13726]

this change also includes [Misc #13702]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04 10:48:30 +00:00
naruse 31796f17d3 Update to Onigmo 6.1.3-669ac9997619954c298da971fcfacccf36909d05.
[Bug #13892]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 13:50:13 +00:00
k0kubun 857827e3ee vm.c: partially revert r60558
because it was actually used in
https://github.com/tmm1/rbtrace/blob/v0.4.8/ext/rbtrace.c#L329
and deprecated in r60579 AFTER removal in r60558.

ko1 agreed that we should keep just deprecated in Ruby 2.5 and remove it
later, and I'm commiting this because I want to make rbtrace.gem
installation successful.

backward.h: modify r60579 to make rb_frame_method_id_and_class()
compilable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 12:26:40 +00:00
nobu cea5a91163 util.h: remove my_getcwd
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-26 01:36:33 +00:00
ko1 aaa43037c2 export rb_tracearg_callee_id().
* include/ruby/debug.h (rb_tracearg_callee_id): export.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 07:41:33 +00:00
nobu b6946d31fc backward.h: rb_frame_method_id_and_class
* include/ruby/backward.h (rb_frame_method_id_and_class): moved
  a deprecated declaration from intern.h, for r60558.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-30 05:45:21 +00:00
sonots 47dd9bf7d8 Add doxygen comments
* include/ruby/ruby.h (enum ruby_value_type): add doxygen comments
* internal.h (enum imemo_type, struct vm_svar): add doxygen comments
* method.h (rb_method_type_t, rb_method_iseq_t): add doxygen comments

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:31:21 +00:00
nobu 41910c0d0e defines.h: warn EXTERN
* include/ruby/defines.h (EXTERN): warn as deprecated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-13 08:29:52 +00:00
nobu 65b87de350 ruby.h: unnormalized Fixnum value
* include/ruby/ruby.h (ST2FIX): fix unnormalized Fixnum value bug
  on mingw/mswin.  [ruby-core:82687] [Bug #13877]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-07 03:24:08 +00:00
nobu 17b3441ac4 non-keywords hash
* class.c (rb_scan_args), include/ruby/ruby.h (rb_scan_args_set):
  return non-keywords elements only in the last hash when keyword
  arguments are extracted from it, as well as methods defined in
  ruby level.  [ruby-core:82427] [Bug #13830]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-20 06:08:25 +00:00
nobu 3632bd45f5 ruby.h: fix rb_scan_args_trail_idx
* include/ruby/ruby.h (rb_scan_args_trail_idx): fix the case both
  of optional and rest arguments are defined.
  [ruby-core:82427] [Bug #13830]

* include/ruby/ruby.h (rb_scan_args_n_trail): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-19 23:39:03 +00:00
nobu 1ebd2b3702 ruby.h: NULL as empty array
* include/ruby/ruby.h (rb_yield_values, rb_funcall): call with
  NULL when no arguments, for clang which defines static array
  when an empty array is used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-03 08:09:24 +00:00
ko1 fb29a4dcda should not copy promoted flags.
* include/ruby/ruby.h (rb_clone_setup): should not copy some flags
  (FL_PROMOTED0|FL_PROMOTED1|FL_FINALIZE).
  [Bug #13775]

* test/ruby/test_object.rb: add a test (note that this test will fail
  only when RGENGC_CHECK_MODE >= 2).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-01 02:10:19 +00:00
yugui 7b19e6f3fd Add documents
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-22 06:30:53 +00:00
nobu be701dc57f debug.c: more enums
* debug.c (ruby_dummy_gdb_enums): add enums for RObject, RModule,
  RString, RArray.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01 04:43:03 +00:00
normal 190e29f72e attempt to fix rb_alloc_tmp_buffer2 for ALLOCV_N
This is a confusing function to my arithmetic-challenged mind,
but nobu seems alright with this.  Anyways this lets me use
large values of elsize without segfaulting, and "make exam"
passes.

* include/ruby/ruby.h (rb_alloc_tmp_buffer2): attempt to fix
  [ruby-core:81388] [ruby-core:81391] [Bug #13595]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26 07:28:23 +00:00
naruse 9cf7985893 Merge Onigmo 6.1.2
1364ae3488

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-17 05:38:37 +00:00
rhe 70c9bb4b81 Remove missing/strtol.c
It is never used. We don't need it anyway as it's part of C89 which is
our current minimum requirement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 06:03:12 +00:00
nobu c483ae6572 Suppress a warning in ruby/win32.h [Fix GH-1591]
Fix a warning in ruby/win32.h which can cause failures with mkmf

The return value is implicit type casted from 'long double' to 'double', currently.
This causes a gcc warning like this:

```
In file included from C:\Ruby24-x64\include\ruby-2.4.0/ruby/defines.h:243:0,
                 from C:\Ruby24-x64\include\ruby-2.4.0/ruby/ruby.h:36,
                 from C:\Ruby24-x64\include\ruby-2.4.0/ruby.h:33,
                 from conftest.c:1:
C:\Ruby24-x64\include\ruby-2.4.0/ruby/win32.h: In function 'rb_w32_pow':
C:\Ruby24-x64\include\ruby-2.4.0/ruby/win32.h:786:12: warning: conversion to 'double' from 'long double' may alter its value [-Wfloat-conversion]
     return powl(x, y);
            ^~~~~~~~~~
```

This is fixed by the attached explicit type cast.

Moreover when CFLAGS is set to '-Wconversion', it prevents the compiler from
building. This is the case at the nokogiri gem.

The original issue arose at RubyInstaller2: 576a0eb70a

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21 00:11:56 +00:00
nobu 0472578b26 ruby.h: check argc to rb_funcall
* include/ruby/ruby.h (rb_funcall): check if argc matches the
  number of variadic arguments, and replace with rb_funcallv.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-15 02:09:27 +00:00
normal 8e64799c96 fix RSTRUCT_LEN macro in public C API
rb_struct_size returns an Integer VALUE, so it must be converted
to a `long` for compatibility with previous Ruby C API versions.

* ext/-test-/struct/len.c: new
* test/-ext-/struct/test_len.rb: new
* include/ruby/ruby.h (RSTRUCT_LEN): use NUM2LONG
  [ruby-core:80692] [Bug #13439]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-15 00:46:00 +00:00
nobu cb52dda146 ruby.h: check argc to rb_yield_values
* include/ruby/ruby.h (rb_yield_values): check if argc matches the
  number of variadic arguments, and replace with rb_yield_values2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14 08:33:08 +00:00
nobu ea7af54e73 thread.c: rb_thread_fd_close [ci skip]
* thread.c (rb_thread_fd_close): remove deprecated. a couple of
  external libraries used it.  [ruby-core:80078] [Bug #13304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 05:30:44 +00:00
nobu c617568c53 thread.c: rb_thread_fd_close [ci skip]
* thread.c (rb_thread_fd_close): re-define only for abi-check,
  abort if called.  [ruby-core:80078] [Bug #13304]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 02:14:15 +00:00
shyouhei c56edb9a59 revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]
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
2017-03-09 02:31:23 +00:00
shyouhei b515528271 re-introduce __builtin_add_overflow
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
2017-03-08 04:50:22 +00:00
naruse 63c7ccc64b Always use old RB_FIXABLE to allow double as argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-07 19:48:00 +00:00