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
* include/ruby/intern.h (rb_disable_super, rb_enable_super):
remove NORETURN. these do nothing but just return.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mul overflow efficiently.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): use rb_mul_size_overflow
and avoid division where it can define DSIZE_T.
* gc.c (xmalloc2_size): moved from ruby.h and use rb_mul_size_overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
avoid duplicated check of size.
* gc.c (ruby_xmalloc2): added to keep separate layers.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): added to check
the size more statically.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
used by objspace_xmalloc and objspace_xcalloc.
objspace_xmalloc introduces its own check in this commit.
objspace_xcalloc checks with xmalloc2_size (ruby_xmalloc2_size).
* gc.c (objspace_xmalloc0): common xmalloc function.
* gc.c (objspace_xmalloc): introduce its own size check.
* gc.c (objspace_xmalloc2): separated from ruby_xmalloc2 to clarify
the layer who has the responsibility to check the size.
* gc.c (objspace_xrealloc): remove duplicated size check.
* gc.c (ruby_xmalloc2): use objspace_xmalloc2.
* include/ruby/ruby.h (ruby_xmalloc2_size): follow the size limit
as SSIZE_MAX. Note that ISO C says size_t is unsigned integer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_isalnum, rb_isxdigit, rb_isblank, rb_isspace, rb_isblank,
rb_iscntrl, rb_isprint, rb_ispunct, rb_isgraph,
rb_tolower, rb_toupper): use inline function to avoid function call.
* include/ruby/ruby.h (rb_isascii): use inline function to clarify
the logic.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enc/unicode/case-folding.rb, casefold.h: Using above flag in data.
* enc/unicode.c: Marking capitalized character as unmodified if it is
already titlecase.
* test/ruby/enc/test_case_mapping.rb: Tests for above functionality.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54229 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
other source files, and remove documentation comment for Bignum#hash.
* bignum.c (Bignum#hash): remove its definition because it is unified
with Object#hash.
* include/ruby/intern.h (rb_big_hash): add a prototype declaration.
* hash.c (any_hash): treat Bignum values directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
to be available in other source files.
* include/ruby/intern.h (rb_big_even_p, rb_big_odd_p): add prototype
declarations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and macros to work with unified CaseMappingSpecials array.
(with Kimihito Matsui)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54101 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
space for titlecase indices; adding additional macros to add or
extract titlecase index; adding comments for better documentation.
* enc/unicode.c: Moving some macros to include/ruby/oniguruma.h;
activating use of titlecase indices.
(with Kimihito Matsui)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/encoding.h (rb_enc_asciicompat): turn into an
inline function to get rid of evalucating the argument twice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/io.h (RB_IO_BUFFER_INIT, RB_IO_FPTR_NEW): remove
old macros only for internal use and obsolete since 2.2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/missing.h (explicit_bzero_by_memset_s): remove
inline implementation by memset_s, which needs a macro before
including headers and can cause problems in extension libraries
by the order of the macro and headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P on C++.
[ruby-core:72736] [Bug #11962]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_readwrite_syserr_fail): works with the given errno than
thread local errno.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_autoload_str may be safer by preventing premature GC. It
can also be more efficient by passing a pre-frozen string that
can be deduped using rb_fstring. Common autoload callers (e.g.
rubygems, rdoc) already use string literals as the file
argument.
There seems to be no reason to expose rb_autoload_str to the
public C API since autoload is not performance-critical.
Applications may declare autoloads in Ruby code or via
rb_funcall; so merely deprecate rb_autoload without exposing
rb_autoload_str to new users.
Running: valgrind -v ruby -rrdoc -rubygems -e exit
shows a minor memory reduction (32-bit userspace)
before:
in use at exit: 1,600,621 bytes in 28,819 blocks
total heap usage: 55,786 allocs, 26,967 frees, 6,693,790 bytes allocated
after:
in use at exit: 1,599,778 bytes in 28,789 blocks
total heap usage: 55,739 allocs, 26,950 frees, 6,692,973 bytes allocated
* include/ruby/intern.h (rb_autoload): deprecate
* internal.h (rb_autoload_str): declare
* load.c (rb_mod_autoload): use rb_autoload_str
* variable.c (rb_autoload): become compatibility wrapper
(rb_autoload_str): hoisted out from old rb_autoload
[ruby-core:71369] [Feature #11664]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Turn into void expression not to use unexpected result.
Fix "operands have incompatible types" error with
Oracle Solaris Studio 12.x on Solaris.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_FL_{SET,UNSET,REVERSE,INFECT,FREEZE}):
turn into void expressions not to use unexpected results. these
macros were statements till 2.2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/missing.h: get rid of redefinition of
__STDC_WANT_LIB_EXT1__.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/missing.h: __STDC_WANT_LIB_EXT1__ is necessary for
memset_s.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/missing.h (explicit_bzero): use SecureZeroMemory on
Windows. assume Windows XP or later at compile time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/missing.h (explicit_bzero_by_memset_s): call
memset_s directly if available.
* missing/explicit_bzero.c: optimization is not a matter if
memset_s is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(potential divide by zero) for VisualC++. It's meaningless.
Before r26197, there is ruby_div0() in this place and it
actually made divide by zero. But now it's just garbage.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* common.mk: add a rule for explicit.o.
* configure.in: detect explicit_bzero and memset_s.
* include/ruby/missing.h: add explicit_bzero.
* random.c (init_randomseed): use explicit_bzero() instead of
memset(). memset could be eliminated by compiler optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* beos: Drop support for BeOS now that Haiku is stable.
[Fix GH-1112]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Suppress pointer type mismatch warnings occurred with old version
of Fujitsu C Compiler (fcc) on Solaris 10. The warnings cause
failure of TestMkmf::TestConvertible. [Bug #11644] [ruby-dev:49326]
* include/ruby/ruby.h (FIX_CONST_VALUE_PTR): macro for the above,
only effective with fcc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This is an implementation detail and should not be exposed to
C extension users. We may change this to id_table soon; and
id_table should not be exposed as a public API.
It is highly unlikely any existing C extensions require this;
so the risk of breakage is very low. Ideally, all of RObject
could be hidden.
[ruby-core:71306] [Feature #11647]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_wb_protected_newobj_of(), pass the WB_PROTECTED
information explicitly.
* internal.h: use introduced functions by NEWOBJ_OF().
`flag' is immediate value, so that C compilers can
solve them at compile time.
* include/ruby/ruby.h: add a commnent about that.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in: check INFINITY and NAN without an option for C99
so that rb_infinity and rb_nan are respectively available
regardless that option if they may be used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_data_object_{wrap,get,make}): warn only
if optimized, as __builtin_choose_expr() does not work fine
unless optimized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_OBJ_FROZEN_RAW): split from
RB_OBJ_FROZEN. valid only for non-special-const objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h: turn function macros into inline functions,
for debuggers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h: prefix RUBY or RB to global symbols to get
rid of name conflicts with other headers.
* include/ruby/encoding.h, include/ruby/intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (ASSUME): evaluate the argument just once
everywhere.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/win32.h: fix macro name for VC runtime version,
RT_VER is only in Makefile.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
fiber_switch. We need more discussion about this feature
so that I don't write it on NEWS.
[Feature #11348]
* test/ruby/test_settracefunc.rb: add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RClass): define only in C, `__attribute__`
between `struct` and the name can't compile with g++.
[ruby-core:70297] [Bug #11426]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/defines.h (RUBY_ALIAS_FUNCTION_TYPE): cast the
result to suppress warnings.
* include/ruby/defines.h (RUBY_ALIAS_FUNCTION_VOID): minimize if
possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (ALLOCV_N): check integer overflow, as well
as ruby_xmalloc2. pointed out by Paul <pawlkt AT gmail.com>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (struct RClass): moved from ruby/ruby.h to hide the
internals.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h: add raw FL macros, which assume always the
argument object is not a special constant.
* internal.h (STR_EMBED_P, STR_SHARED_P): valid only for T_STRING.
* string.c: deal with taint flags directly across String instances.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (ASSUME): hint for optimization, the
expression is assumed to be true always.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/win32.h: include windows.h before winsock2.h,
because mswsock.h included by the former uses SOCKET defined
after it in the latter. fix a build failure with VC6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/encoding.h (ENC_CODERANGE_CLEAN_P): predicate that
tells if the coderange is clean, that is 7bit or valid, and no
needs to scrub.
* re.c (rb_reg_expr_str): use ENC_CODERANGE_CLEAN_P.
* string.c (enc_strlen, rb_enc_cr_str_buf_cat, rb_str_scrub):
ditto.
* string.c (rb_str_enumerate_chars): ditto, and suppress a warning
by gcc6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This improves the bm_vm2_bighash benchmark significantly by
removing branches during insert, but slows down anything
requiring iteration with the more complex loop termination
checking.
Speedup ratio of 1.10 - 1.20 is typical for the vm2_bighash
benchmark.
v3 - st_head calculates list_head address in two steps
to avoid a bug in old gcc 4.4 (Debian 4.4.7-2)
bug which incorrectly warned with:
warning: dereferencing pointer ‘({anonymous})’ does break
strict-aliasing rules
* include/ruby/st.h (struct st_table): hide struct list_head
* st.c (struct st_table_entry): adjust struct
(head, tail): remove shortcut macros
(st_head): new wrapper function
(st_init_table_with_size): adjust to new struct and API
(st_clear): ditto
(add_direct): ditto
(unpack_entries): ditto
(rehash): ditto
(st_copy): ditto
(remove_entry): ditto
(st_shift): ditto
(st_foreach_check): ditto
(st_foreach): ditto
(get_keys): ditto
(get_values): ditto
(st_values_check): ditto
(st_reverse_foreach_check): ditto (unused)
(st_reverse_foreach): ditto (unused)
[ruby-core:69726] [Misc #10278]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This reverts commit r51044
Still getting failure notices from ko1's CI machine.
ref: g3qkqn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_strlen_lit): new macro to get the
length of a string literal, borrowed from mruby/mruby@e4afd53.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This recovers and improves performance of Marshal.dump/load on
Time objects compared to when we implemented generic ivars
entirely using st_table.
This also recovers some performance on other generic ivar objects,
but does not bring bring Marshal.dump/load performance up to
previous speeds.
benchmark results:
minimum results in each 10 measurements.
Execution time (sec)
name trunk geniv after
marshal_dump_flo 0.343 0.334 0.335
marshal_dump_load_geniv 0.487 0.527 0.495
marshal_dump_load_time 1.262 1.401 1.257
Speedup ratio: compare with the result of `trunk' (greater is better)
name geniv after
marshal_dump_flo 1.026 1.023
marshal_dump_load_geniv 0.925 0.985
marshal_dump_load_time 0.901 1.004
* include/ruby/intern.h (rb_generic_ivar_table): deprecate
* internal.h (rb_attr_delete): declare
* marshal.c (has_ivars): use rb_ivar_foreach
(w_ivar): ditto
(w_object): update for new interface
* time.c (time_mload): use rb_attr_delete
* variable.c (generic_ivar_delete): implement
(rb_ivar_delete): ditto
(rb_attr_delete): ditto
[ruby-core:69323] [Feature #11170]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_sym_count): move `rb_sym_all_symbols`
to a symbol.c specific section. a part of patch by Lourens
Naudé.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_data_typed_object_alloc),
(rb_data_object_alloc): warn use of old names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (Data_Make_Struct0): needs function pointer
casts to fix function overloading in C++.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (Data_Make_Struct0, TypedData_Make_Struct0):
explicit cast from void* is necessary as implicit cast is
disallowed in C++.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_f_notimplement): should not respond to
not-implemented methods. as the address inside a DLL and the
imported address are different on Windows, use an exported
variable to share the same address.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_data_object_wrap, rb_data_typed_object_wrap): rename
alloc as wrap. these functions do not allocate data pointers
but just wrap the given pointers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (Data_Make_Struct, TypedData_Make_Struct):
make statement-expression to get rid of strict-aliasing warnings
by old GCC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (Data_Make_Struct, TypedData_Make_Struct):
allocate wrapper data object before allocating DATA_PTR to get
rid of possible memory leak when the former failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h: remove stale declarations, which were
removed because of ripper.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32/win32.c (winnt_stat): stat with following symbolic links.
* win32/win32.c (winnt_lstat): rename old winnt_stat, which does
not follow symbolic links.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
For incremental GC, we need to get a pointer to the objspace.
We can share this pointer for the following WB process.
And considering icache hit ratio, prcess in the GC.
* gc.c (rb_gc_writebarrier): added.
* gc.c (gc_writebarrier_generational, gc_writebarrier_incremental):
make them NOINLINE because inlining them into rb_gc_writebarrier()
makes a prologue code of rb_gc_writebarrier() longer (storing callee
save registers).
This patch improve the performance of WB on micro-benchmarks.
name ruby 2.1 trunk modified
vm1_gc_wb_ary* 0.511 0.632 0.532
vm1_gc_wb_ary_promoted* 0.578 0.701 0.674
vm1_gc_wb_obj* 0.419 0.575 0.492
vm1_gc_wb_obj_promoted* 0.537 0.664 0.618
(sec)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_data_object_alloc_warning): enable only
if __builtin_choose_expr works with __builtin_constant_p so that
warnings will be suppressed if klass is 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
T_IMEMO is Internal Memo type, internal use only.
T_IMEMO has same purpose of NODE_MEMO.
To insert T_IMEMO, type numbers are modified a little.
* internal.h: define struct RIMemo. Each RIMemo objects
has imemo_type. We can observe it by the imemo_type() function.
* gc.c (rb_imemo_new): added.
* node.h: remove NODE_CREF and NEW_CREF().
* node.c (rb_gc_mark_node): ditto.
* vm.c (vm_cref_new): use rb_imem_new().
* vm_eval.c: ditto.
* vm_eval.c (eval_string_with_cref):
* vm_eval.c (rb_type_str):
* vm_insnhelper.c: use RIMemo objects for CREF.
* ext/objspace/objspace.c: support T_IMEMO.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
struct method_table_wrapper was introduced to avoid duplicate marking
for method tables.
For example, `module M1; def foo; end; end` make one method table
(mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl.
Classes C1 and C2 includes M1, then two T_ICLASS objects are created
and they points mtbl too. In this case, three objects (one T_MODULE
and two T_ICLASS objects) points same mtbl. On marking phase, these
three objects mark same mtbl. To avoid such duplication, struct
method_table_wrapper was introduced.
However, created two T_ICLASS objects have same or shorter lifetime
than M1 (T_MODULE) object. So that we only need to mark mtbl from M1,
not from T_ICLASS objects. This patch tries marking only from M1.
Note that one `Module#prepend` call creates two T_ICLASS objects.
One for refering to a prepending Module object, same as
`Module#include`. We don't nedd to care this T_ICLASS.
One for moving original mtbl from a prepending class. We need to
mark such mtbl from this T_ICLASS object. To mark the mtbl,
we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended
class `klass`.
* class.c: ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: ditto.
* include/ruby/ruby.h: define m_tbl directly. The definition of
struct RClass should be moved to (srcdir)/internal.h.
* method.h: remove decl of rb_free_m_tbl_wrapper().
* object.c: use RCLASS_M_TBL() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_str_new_literal): define on all
platforms, not only gcc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (PRIsVALUE): put a space after string
literals not to be confused with C++11 string literal suffix.
https://github.com/ruby/ruby/commit/a9f3eb7#commitcomment-9040169
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Class and Module objects can be living long life.
* iseq.c: Same for ISeq objects.
* gc.c (RVALUE_AGE_RESET): added.
* gc.c (newobj_of): allow to generate (age != 0) objects.
* gc.c (rb_copy_wb_protected_attribute): reset age for wb unprotected
objects.
* include/ruby/ruby.h: add RUBY_TYPED_PROMOTED1 as an unrecommended
flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (SIZED_ENUMERATOR): separate from
RETURN_SIZED_ENUMERATOR.
* string.c (rb_str_enumerate_chars): get rid of calling
rb_block_given_p() twice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_data_object_alloc_warning): no warnings
of internal hidden objects which klass == 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c (rb_reg_region_copy): new function to try with GC if copy
failed and return the error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is not required to split. It was useful to avoid whole process
blocking in Ruby 1.8 but not useful since write() is invoked without
GVL.
(FMODE_WSPLIT_INITIALIZED): Ditto.
* io.c (wsplit_p): Removed.
(io_writable_length): Removed.
(rb_fcntl): Don't update the removed flags.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_current_receiver): new function to return the
receiver in the current control frame. [Feature #10195]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
function to support nonblock-mode of pipes.
* win32/win32.c (rb_w32_read): nonblock-mode pipe returns ERROR_NO_DATA
if there is no data, but also returns it if remote-end is closed.
* win32/win32.c (rb_w32_write): if cannot to write any data, it may be
blocking.
* io.c (rb_io_set_nonblock): use rb_w32_set_nonblock for Windows.
* ext/io/nonblock/nonblock.c (rb_io_nonblock_set): use ruby's API when
setting nonblock-mode.
* test/ruby/test_io.rb: test nonblock pipes on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_disable_super, rb_enable_super): warn
as deprecated at build time, instead of ignoring silently or
warning at runtime only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_clear_cache): mark as deprecated, not
only warnings at runtime.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (PRIsVALUE), vsnprintf.c (BSD_vfprintf): add
RUBY_PRI_VALUE_MARK to reduce danger of accidental conflict with
plain "%i". binary incompatible with extension libraries using
PRIsVALUE and built for 2.1 and earlier. [EXPERIMENTAL]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_num2char_inline): use RB_TYPE_P for
optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Note: Some of the fixes are for newlib in general but not NaCl-specific.
* include/ruby/intern.h (rb_fd_select): declare struct timeval, or the
struct gets local to the function in C99.
* file.c (#include): add nacl/stat.h for PNaCl.
(utimes): added a declaration for PNaCl.
(stat_atimespec): stat::st_atimensec is long long but
timespec::tv_nsec is long in PNaCl.
(stat_mtimespec, stat_ctimespec): ditto.
(rb_group_member): disable getgroups unless HAVE_GETGROUPS.
(eaccess): unify the fallback to generic defined(USE_GETEUID).
* io.c: include sys/time.h for struct timeval.
(rb_close_before_exec): nothing we can do if F_GETFD is not
available.
(ioctl): pnacl newlib actually doesn't have ioctl.
* process.c (maxgroups): it is used iff
defined(_SC_NGROUPS_MAX) || defined(NGROUPS_MAX) but not
defined(HAVE_GETGROUPS) || defined(HAVE_SETGROUPS).
(obj2gid): fail unless the object is a Fixnum if getgrnam is not
available.
(disable_child_handler_fork_child): sigaction is not available in
PNaCl newlib.
* configure.in (warnflags, strict_warnflags): avoid -ansi for strlcpy.
(rb_cv_gcc_atomic_builtins): also check
__atomic_or_etch because it is used in ruby_atomic.h.
(rb_cv_gcc_sync_builtins): ditto.
(HAVE_GETGRNAM): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in (__builtin_choose_expr_constant_p): in gcc 4.8 or
earlier, __builtin_choose_expr() does not consider
__builtin_constant_p(variable) a constant expression.
* include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): fix for older gcc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RUBY_SAFE_LEVEL_CHECK): eliminate function
call for warning/error if not match to get rid of unconditional
warning/error by a certain compiler option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_make_open_file): move from include/ruby/io.h, and
hide too detailed implementations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/io.h (rb_io_mode_flags, rb_io_modenum_flags):
deprecate old macros for compatibility for ruby 1.8 and older.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This ensures a consistent implementation between 32 and 64-bit
platforms, as vm_trace.c limits events to 32-bits. This can
also open up struct packing opportunities.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_data_object_alloc_warning): warn
Data_Wrap_Struct and Data_Make_Struct only if
RUBY_UNTYPED_DATA_WARNING is set to 1.
* include/ruby/ruby.h (rb_data_object_get_warning): ditto for
Data_Get_Struct.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/intern.h (rb_str_new_literal): make ruby string
from literal C-string. incorporated from mruby.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* class.c (rb_freeze_singleton_class): get rid of freeze class of
hidden object to fix segfaults.
* include/ruby/ruby.h (rb_obj_freeze_inline): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (rb_check_safe_str, Check_SafeStr): show
error message to update for obsolete function and macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e