2011-05-18 09:41:54 -04:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
internal.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Tue May 17 11:42:20 JST 2011
|
|
|
|
|
|
|
|
Copyright (C) 2011 Yukihiro Matsumoto
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef RUBY_INTERNAL_H
|
|
|
|
#define RUBY_INTERNAL_H 1
|
|
|
|
|
2014-11-15 06:49:06 -05:00
|
|
|
#include "ruby.h"
|
|
|
|
|
2011-05-18 09:41:54 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#if 0
|
|
|
|
} /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-29 23:42:04 -05:00
|
|
|
#ifdef HAVE_STDBOOL_H
|
|
|
|
# include <stdbool.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __bool_true_false_are_defined
|
|
|
|
# ifndef __cplusplus
|
2017-01-29 23:54:52 -05:00
|
|
|
# undef bool
|
|
|
|
# undef false
|
|
|
|
# undef true
|
|
|
|
# define bool signed char
|
|
|
|
# define false 0
|
|
|
|
# define true 1
|
|
|
|
# define __bool_true_false_are_defined 1
|
2017-01-29 23:42:04 -05:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2017-12-03 21:35:40 -05:00
|
|
|
/* The most significant bit of the lower part of half-long integer.
|
|
|
|
* If sizeof(long) == 4, this is 0x8000.
|
|
|
|
* If sizeof(long) == 8, this is 0x80000000.
|
|
|
|
*/
|
|
|
|
#define HALF_LONG_MSB ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
|
|
|
|
|
2016-04-23 03:15:25 -04:00
|
|
|
#define LIKELY(x) RB_LIKELY(x)
|
|
|
|
#define UNLIKELY(x) RB_UNLIKELY(x)
|
|
|
|
|
2016-09-16 08:29:42 -04:00
|
|
|
#ifndef MAYBE_UNUSED
|
|
|
|
# define MAYBE_UNUSED(x) x
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WARN_UNUSED_RESULT
|
|
|
|
# define WARN_UNUSED_RESULT(x) x
|
|
|
|
#endif
|
|
|
|
|
2018-11-05 21:57:28 -05:00
|
|
|
#if 0
|
|
|
|
#elif defined(NO_SANITIZE)
|
|
|
|
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
|
|
|
|
NO_SANITIZE("address", NOINLINE(x))
|
|
|
|
#elif defined(NO_SANITIZE_ADDRESS)
|
|
|
|
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
|
|
|
|
NO_SANITIZE_ADDRESS(NOINLINE(x))
|
|
|
|
#elif defined(NO_ADDRESS_SAFETY_ANALYSIS)
|
|
|
|
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \
|
|
|
|
NO_ADDRESS_SAFETY_ANALYSIS(NOINLINE(x))
|
|
|
|
#else
|
2018-11-05 22:18:23 -05:00
|
|
|
# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) x
|
2018-11-05 21:57:28 -05:00
|
|
|
#endif
|
|
|
|
|
2018-11-06 23:56:24 -05:00
|
|
|
#if defined(NO_SANITIZE) && defined(__GNUC__) &&! defined(__clang__)
|
|
|
|
/* GCC warns about unknown sanitizer, which is annoying. */
|
|
|
|
#undef NO_SANITIZE
|
|
|
|
#define NO_SANITIZE(x, y) \
|
|
|
|
COMPILER_WARNING_PUSH; \
|
|
|
|
COMPILER_WARNING_IGNORED(-Wattributes); \
|
|
|
|
__attribute__((__no_sanitize__(x))) y; \
|
|
|
|
COMPILER_WARNING_POP
|
|
|
|
#endif
|
|
|
|
|
2018-11-06 00:06:20 -05:00
|
|
|
#ifndef NO_SANITIZE
|
2018-11-06 05:06:07 -05:00
|
|
|
# define NO_SANITIZE(x, y) y
|
2018-11-06 00:06:20 -05:00
|
|
|
#endif
|
|
|
|
|
2013-08-05 23:26:34 -04:00
|
|
|
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
|
|
|
# include <valgrind/memcheck.h>
|
|
|
|
# ifndef VALGRIND_MAKE_MEM_DEFINED
|
|
|
|
# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
|
|
|
|
# endif
|
|
|
|
# ifndef VALGRIND_MAKE_MEM_UNDEFINED
|
|
|
|
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
|
|
|
|
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
|
|
|
|
#endif
|
|
|
|
|
* internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
error.c, ruby.c: Remove the definitions of numberof.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 06:01:19 -04:00
|
|
|
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
|
|
|
|
|
2015-07-14 11:09:23 -04:00
|
|
|
#ifndef __has_feature
|
|
|
|
# define __has_feature(x) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __has_extension
|
|
|
|
# define __has_extension __has_feature
|
|
|
|
#endif
|
|
|
|
|
2018-11-06 06:53:01 -05:00
|
|
|
#ifndef MJIT_HEADER
|
|
|
|
|
2018-11-06 05:06:07 -05:00
|
|
|
#ifdef HAVE_SANITIZER_ASAN_INTERFACE_H
|
|
|
|
# include <sanitizer/asan_interface.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !__has_feature(address_sanitizer)
|
|
|
|
# define __asan_poison_memory_region(x, y)
|
|
|
|
# define __asan_unpoison_memory_region(x, y)
|
|
|
|
# define __asan_region_is_poisoned(x, y) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
|
|
|
|
# include <sanitizer/msan_interface.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !__has_feature(memory_sanitizer)
|
|
|
|
# define __msan_allocated_memory(x, y)
|
|
|
|
# define __msan_poison(x, y)
|
|
|
|
# define __msan_unpoison(x, y)
|
|
|
|
# define __msan_unpoison_string(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
poison_memory_region(const volatile void *ptr, size_t size)
|
|
|
|
{
|
|
|
|
__msan_poison(ptr, size);
|
|
|
|
__asan_poison_memory_region(ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
poison_object(VALUE obj)
|
|
|
|
{
|
|
|
|
struct RVALUE *ptr = (void *)obj;
|
|
|
|
poison_memory_region(ptr, SIZEOF_VALUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
|
|
|
|
{
|
|
|
|
__asan_unpoison_memory_region(ptr, size);
|
|
|
|
if (malloc_p) {
|
|
|
|
__msan_allocated_memory(ptr, size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
__msan_unpoison(ptr, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
unpoison_object(VALUE obj, bool newobj_p)
|
|
|
|
{
|
|
|
|
struct RVALUE *ptr = (void *)obj;
|
|
|
|
unpoison_memory_region(ptr, SIZEOF_VALUE, newobj_p);
|
|
|
|
}
|
|
|
|
|
2018-11-06 06:53:01 -05:00
|
|
|
#endif
|
|
|
|
|
2018-08-13 17:34:20 -04:00
|
|
|
/* Prevent compiler from reordering access */
|
|
|
|
#define ACCESS_ONCE(type,x) (*((volatile type *)&(x)))
|
|
|
|
|
2018-01-02 01:41:51 -05:00
|
|
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
2014-11-12 22:44:54 -05:00
|
|
|
# define STATIC_ASSERT(name, expr) _Static_assert(expr, #name ": " #expr)
|
2018-01-02 01:41:51 -05:00
|
|
|
#elif GCC_VERSION_SINCE(4, 6, 0) || __has_extension(c_static_assert)
|
|
|
|
# define STATIC_ASSERT(name, expr) RB_GNUC_EXTENSION _Static_assert(expr, #name ": " #expr)
|
2014-11-12 21:56:14 -05:00
|
|
|
#else
|
|
|
|
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
|
|
|
|
#endif
|
|
|
|
|
2013-04-27 02:52:17 -04:00
|
|
|
#define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1)
|
|
|
|
#define SIGNED_INTEGER_MAX(sint_type) \
|
2013-07-03 11:36:10 -04:00
|
|
|
(sint_type) \
|
2013-04-27 02:52:17 -04:00
|
|
|
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) | \
|
|
|
|
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) - 1))
|
|
|
|
#define SIGNED_INTEGER_MIN(sint_type) (-SIGNED_INTEGER_MAX(sint_type)-1)
|
|
|
|
#define UNSIGNED_INTEGER_MAX(uint_type) (~(uint_type)0)
|
|
|
|
|
2013-03-26 16:15:44 -04:00
|
|
|
#if SIGNEDNESS_OF_TIME_T < 0 /* signed */
|
2013-04-27 02:52:17 -04:00
|
|
|
# define TIMET_MAX SIGNED_INTEGER_MAX(time_t)
|
|
|
|
# define TIMET_MIN SIGNED_INTEGER_MIN(time_t)
|
2013-03-26 16:15:44 -04:00
|
|
|
#elif SIGNEDNESS_OF_TIME_T > 0 /* unsigned */
|
2013-04-27 02:52:17 -04:00
|
|
|
# define TIMET_MAX UNSIGNED_INTEGER_MAX(time_t)
|
|
|
|
# define TIMET_MIN ((time_t)0)
|
2013-03-26 16:15:44 -04:00
|
|
|
#endif
|
2013-03-26 23:03:36 -04:00
|
|
|
#define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
|
2013-03-26 11:30:27 -04:00
|
|
|
|
2017-03-06 01:04:52 -05:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW_P
|
|
|
|
#define MUL_OVERFLOW_P(a, b) \
|
|
|
|
__builtin_mul_overflow_p((a), (b), (__typeof__(a * b))0)
|
|
|
|
#elif defined HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW
|
|
|
|
#define MUL_OVERFLOW_P(a, b) \
|
2018-01-02 01:41:53 -05:00
|
|
|
RB_GNUC_EXTENSION_BLOCK(__typeof__(a) c; __builtin_mul_overflow((a), (b), &c))
|
2017-03-06 01:04:52 -05:00
|
|
|
#endif
|
|
|
|
|
2013-04-09 07:39:53 -04:00
|
|
|
#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
|
|
|
|
(a) == 0 ? 0 : \
|
|
|
|
(a) == -1 ? (b) < -(max) : \
|
|
|
|
(a) > 0 ? \
|
|
|
|
((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
|
|
|
|
((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
|
2017-03-06 01:04:52 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_MUL_OVERFLOW_P
|
|
|
|
/* __builtin_mul_overflow_p can take bitfield */
|
|
|
|
/* and GCC permits bitfields for integers other than int */
|
2018-01-02 01:41:53 -05:00
|
|
|
#define MUL_OVERFLOW_FIXNUM_P(a, b) RB_GNUC_EXTENSION_BLOCK( \
|
2017-09-25 04:19:10 -04:00
|
|
|
struct { long fixnum : SIZEOF_LONG * CHAR_BIT - 1; } c; \
|
2017-03-06 01:04:52 -05:00
|
|
|
__builtin_mul_overflow_p((a), (b), c.fixnum); \
|
2018-01-02 01:41:53 -05:00
|
|
|
)
|
2017-03-06 01:04:52 -05:00
|
|
|
#else
|
2013-04-09 07:39:53 -04:00
|
|
|
#define MUL_OVERFLOW_FIXNUM_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
|
2017-03-06 01:04:52 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MUL_OVERFLOW_P
|
|
|
|
#define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
|
|
|
#define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
|
|
|
#define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
|
|
|
|
#else
|
2017-03-06 02:25:18 -05:00
|
|
|
#define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
|
2017-03-06 01:04:52 -05:00
|
|
|
#define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
|
|
|
|
#define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
|
|
|
|
#endif
|
2013-04-09 07:39:53 -04:00
|
|
|
|
2013-11-24 11:03:22 -05:00
|
|
|
#ifndef swap16
|
|
|
|
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP16
|
|
|
|
# define swap16(x) __builtin_bswap16(x)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2013-06-21 13:22:14 -04:00
|
|
|
#ifndef swap16
|
|
|
|
# define swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef swap32
|
2013-07-14 10:28:33 -04:00
|
|
|
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP32
|
2013-06-21 13:22:14 -04:00
|
|
|
# define swap32(x) __builtin_bswap32(x)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef swap32
|
|
|
|
# define swap32(x) ((uint32_t)((((x)&0xFF)<<24) \
|
|
|
|
|(((x)>>24)&0xFF) \
|
|
|
|
|(((x)&0x0000FF00)<<8) \
|
|
|
|
|(((x)&0x00FF0000)>>8) ))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef swap64
|
2013-07-14 10:28:33 -04:00
|
|
|
# ifdef HAVE_BUILTIN___BUILTIN_BSWAP64
|
2013-06-21 13:22:14 -04:00
|
|
|
# define swap64(x) __builtin_bswap64(x)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef swap64
|
|
|
|
# ifdef HAVE_INT64_T
|
|
|
|
# define byte_in_64bit(n) ((uint64_t)0xff << (n))
|
|
|
|
# define swap64(x) ((uint64_t)((((x)&byte_in_64bit(0))<<56) \
|
|
|
|
|(((x)>>56)&0xFF) \
|
|
|
|
|(((x)&byte_in_64bit(8))<<40) \
|
|
|
|
|(((x)&byte_in_64bit(48))>>40) \
|
|
|
|
|(((x)&byte_in_64bit(16))<<24) \
|
|
|
|
|(((x)&byte_in_64bit(40))>>24) \
|
|
|
|
|(((x)&byte_in_64bit(24))<<8) \
|
|
|
|
|(((x)&byte_in_64bit(32))>>8)))
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
2013-08-31 20:57:00 -04:00
|
|
|
nlz_int(unsigned int x)
|
|
|
|
{
|
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CLZ)
|
|
|
|
if (x == 0) return SIZEOF_INT * CHAR_BIT;
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)__builtin_clz(x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#else
|
|
|
|
unsigned int y;
|
|
|
|
# if 64 < SIZEOF_INT * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 128;
|
2013-08-31 20:57:00 -04:00
|
|
|
# elif 32 < SIZEOF_INT * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 64;
|
2013-08-31 20:57:00 -04:00
|
|
|
# else
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 32;
|
2013-08-31 20:57:00 -04:00
|
|
|
# endif
|
|
|
|
# if 64 < SIZEOF_INT * CHAR_BIT
|
|
|
|
y = x >> 64; if (y) {n -= 64; x = y;}
|
|
|
|
# endif
|
|
|
|
# if 32 < SIZEOF_INT * CHAR_BIT
|
|
|
|
y = x >> 32; if (y) {n -= 32; x = y;}
|
|
|
|
# endif
|
|
|
|
y = x >> 16; if (y) {n -= 16; x = y;}
|
|
|
|
y = x >> 8; if (y) {n -= 8; x = y;}
|
|
|
|
y = x >> 4; if (y) {n -= 4; x = y;}
|
|
|
|
y = x >> 2; if (y) {n -= 2; x = y;}
|
|
|
|
y = x >> 1; if (y) {return n - 2;}
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)(n - x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
2013-08-31 20:57:00 -04:00
|
|
|
nlz_long(unsigned long x)
|
|
|
|
{
|
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CLZL)
|
|
|
|
if (x == 0) return SIZEOF_LONG * CHAR_BIT;
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)__builtin_clzl(x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#else
|
|
|
|
unsigned long y;
|
|
|
|
# if 64 < SIZEOF_LONG * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 128;
|
2013-08-31 20:57:00 -04:00
|
|
|
# elif 32 < SIZEOF_LONG * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 64;
|
2013-08-31 20:57:00 -04:00
|
|
|
# else
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 32;
|
2013-08-31 20:57:00 -04:00
|
|
|
# endif
|
|
|
|
# if 64 < SIZEOF_LONG * CHAR_BIT
|
|
|
|
y = x >> 64; if (y) {n -= 64; x = y;}
|
|
|
|
# endif
|
|
|
|
# if 32 < SIZEOF_LONG * CHAR_BIT
|
|
|
|
y = x >> 32; if (y) {n -= 32; x = y;}
|
|
|
|
# endif
|
|
|
|
y = x >> 16; if (y) {n -= 16; x = y;}
|
|
|
|
y = x >> 8; if (y) {n -= 8; x = y;}
|
|
|
|
y = x >> 4; if (y) {n -= 4; x = y;}
|
|
|
|
y = x >> 2; if (y) {n -= 2; x = y;}
|
|
|
|
y = x >> 1; if (y) {return n - 2;}
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)(n - x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LONG_LONG
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
2013-08-31 20:57:00 -04:00
|
|
|
nlz_long_long(unsigned LONG_LONG x)
|
|
|
|
{
|
|
|
|
#if defined(HAVE_BUILTIN___BUILTIN_CLZLL)
|
|
|
|
if (x == 0) return SIZEOF_LONG_LONG * CHAR_BIT;
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)__builtin_clzll(x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#else
|
|
|
|
unsigned LONG_LONG y;
|
|
|
|
# if 64 < SIZEOF_LONG_LONG * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 128;
|
2013-08-31 20:57:00 -04:00
|
|
|
# elif 32 < SIZEOF_LONG_LONG * CHAR_BIT
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 64;
|
2013-08-31 20:57:00 -04:00
|
|
|
# else
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 32;
|
2013-08-31 20:57:00 -04:00
|
|
|
# endif
|
|
|
|
# if 64 < SIZEOF_LONG_LONG * CHAR_BIT
|
|
|
|
y = x >> 64; if (y) {n -= 64; x = y;}
|
|
|
|
# endif
|
|
|
|
# if 32 < SIZEOF_LONG_LONG * CHAR_BIT
|
|
|
|
y = x >> 32; if (y) {n -= 32; x = y;}
|
|
|
|
# endif
|
|
|
|
y = x >> 16; if (y) {n -= 16; x = y;}
|
|
|
|
y = x >> 8; if (y) {n -= 8; x = y;}
|
|
|
|
y = x >> 4; if (y) {n -= 4; x = y;}
|
|
|
|
y = x >> 2; if (y) {n -= 2; x = y;}
|
|
|
|
y = x >> 1; if (y) {return n - 2;}
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)(n - x);
|
2013-08-31 20:57:00 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_UINT128_T
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
2013-08-31 20:57:00 -04:00
|
|
|
nlz_int128(uint128_t x)
|
|
|
|
{
|
|
|
|
uint128_t y;
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int n = 128;
|
2013-08-31 20:57:00 -04:00
|
|
|
y = x >> 64; if (y) {n -= 64; x = y;}
|
|
|
|
y = x >> 32; if (y) {n -= 32; x = y;}
|
|
|
|
y = x >> 16; if (y) {n -= 16; x = y;}
|
|
|
|
y = x >> 8; if (y) {n -= 8; x = y;}
|
|
|
|
y = x >> 4; if (y) {n -= 4; x = y;}
|
|
|
|
y = x >> 2; if (y) {n -= 2; x = y;}
|
|
|
|
y = x >> 1; if (y) {return n - 2;}
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)(n - x);
|
2013-08-31 20:57:00 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
|
|
|
nlz_intptr(uintptr_t x)
|
|
|
|
{
|
2018-01-02 01:41:44 -05:00
|
|
|
#if SIZEOF_UINTPTR_T == SIZEOF_INT
|
2016-04-30 18:32:05 -04:00
|
|
|
return nlz_int(x);
|
2018-01-02 01:41:44 -05:00
|
|
|
#elif SIZEOF_UINTPTR_T == SIZEOF_LONG
|
|
|
|
return nlz_long(x);
|
|
|
|
#elif SIZEOF_UINTPTR_T == SIZEOF_LONG_LONG
|
|
|
|
return nlz_long_long(x);
|
|
|
|
#else
|
|
|
|
#error no known integer type corresponds uintptr_t
|
|
|
|
return /* sane compiler */ ~0;
|
2016-04-30 18:32:05 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-22 15:58:55 -05:00
|
|
|
static inline unsigned int
|
|
|
|
rb_popcount32(uint32_t x)
|
|
|
|
{
|
2016-05-03 09:14:30 -04:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
|
2016-12-22 15:58:55 -05:00
|
|
|
return (unsigned int)__builtin_popcount(x);
|
2016-05-03 09:14:30 -04:00
|
|
|
#else
|
2016-04-30 11:39:02 -04:00
|
|
|
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
|
|
|
|
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
|
|
|
|
x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
|
|
|
|
x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
|
|
|
|
return (x & 0x0000003f) + (x >>16 & 0x0000003f);
|
2016-05-03 09:14:30 -04:00
|
|
|
#endif
|
2016-04-30 11:39:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-12-22 15:58:55 -05:00
|
|
|
rb_popcount64(uint64_t x)
|
|
|
|
{
|
2016-05-03 09:14:30 -04:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_POPCOUNT
|
|
|
|
return __builtin_popcountll(x);
|
|
|
|
#else
|
2016-04-30 11:39:02 -04:00
|
|
|
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
|
|
|
|
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
|
|
|
|
x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
|
|
|
|
x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
|
|
|
|
x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
|
|
|
|
return (x & 0x7f) + (x >>32 & 0x7f);
|
2016-05-03 09:14:30 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-12-22 15:58:55 -05:00
|
|
|
rb_popcount_intptr(uintptr_t x)
|
|
|
|
{
|
2016-05-03 09:14:30 -04:00
|
|
|
#if SIZEOF_VOIDP == 8
|
|
|
|
return rb_popcount64(x);
|
|
|
|
#elif SIZEOF_VOIDP == 4
|
|
|
|
return rb_popcount32(x);
|
|
|
|
#endif
|
2016-04-30 11:39:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-12-22 15:58:55 -05:00
|
|
|
ntz_int32(uint32_t x)
|
|
|
|
{
|
2016-04-30 11:39:02 -04:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_CTZ
|
|
|
|
return __builtin_ctz(x);
|
|
|
|
#else
|
|
|
|
return rb_popcount32((~x) & (x-1));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-12-22 15:58:55 -05:00
|
|
|
ntz_int64(uint64_t x)
|
|
|
|
{
|
2016-04-30 11:39:02 -04:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_CTZLL
|
|
|
|
return __builtin_ctzll(x);
|
|
|
|
#else
|
|
|
|
return rb_popcount64((~x) & (x-1));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2016-12-22 15:58:55 -05:00
|
|
|
ntz_intptr(uintptr_t x)
|
|
|
|
{
|
2016-04-30 11:39:02 -04:00
|
|
|
#if SIZEOF_VOIDP == 8
|
|
|
|
return ntz_int64(x);
|
|
|
|
#elif SIZEOF_VOIDP == 4
|
|
|
|
return ntz_int32(x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-20 07:10:43 -04:00
|
|
|
#if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
|
|
|
|
# define DLONG LONG_LONG
|
|
|
|
# define DL2NUM(x) LL2NUM(x)
|
|
|
|
#elif defined(HAVE_INT128_T)
|
|
|
|
# define DLONG int128_t
|
2017-03-07 23:50:22 -05:00
|
|
|
# define DL2NUM(x) (RB_FIXABLE(x) ? LONG2FIX(x) : rb_int128t2big(x))
|
2016-03-20 07:10:43 -04:00
|
|
|
VALUE rb_int128t2big(int128_t n);
|
2016-03-20 08:18:28 -04:00
|
|
|
#endif
|
2016-03-20 07:10:43 -04:00
|
|
|
|
2017-02-03 01:11:32 -05:00
|
|
|
static inline long
|
|
|
|
rb_overflowed_fix_to_int(long x)
|
2017-02-02 10:54:51 -05:00
|
|
|
{
|
2017-02-03 01:11:32 -05:00
|
|
|
return (long)((unsigned long)(x >> 1) ^ (1LU << (SIZEOF_LONG * CHAR_BIT - 1)));
|
2017-02-02 10:54:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
rb_fix_plus_fix(VALUE x, VALUE y)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_ADD_OVERFLOW
|
|
|
|
long lz;
|
|
|
|
/* NOTE
|
2017-02-04 13:14:42 -05:00
|
|
|
* (1) `LONG2FIX(FIX2LONG(x)+FIX2LONG(y))`
|
|
|
|
+ = `((lx*2+1)/2 + (ly*2+1)/2)*2+1`
|
|
|
|
+ = `lx*2 + ly*2 + 1`
|
|
|
|
+ = `(lx*2+1) + (ly*2+1) - 1`
|
|
|
|
+ = `x + y - 1`
|
|
|
|
* (2) Fixnum's LSB is always 1.
|
2017-02-02 10:54:51 -05:00
|
|
|
* It means you can always run `x - 1` without overflow.
|
2017-02-04 13:14:42 -05:00
|
|
|
* (3) Of course `z = x + (y-1)` may overflow.
|
|
|
|
* At that time true value is
|
|
|
|
* * positive: 0b0 1xxx...1, and z = 0b1xxx...1
|
|
|
|
* * nevative: 0b1 0xxx...1, and z = 0b0xxx...1
|
|
|
|
* To convert this true value to long,
|
|
|
|
* (a) Use arithmetic shift
|
|
|
|
* * positive: 0b11xxx...
|
|
|
|
* * negative: 0b00xxx...
|
|
|
|
* (b) invert MSB
|
|
|
|
* * positive: 0b01xxx...
|
|
|
|
* * negative: 0b10xxx...
|
2017-02-02 10:54:51 -05:00
|
|
|
*/
|
|
|
|
if (__builtin_add_overflow((long)x, (long)y-1, &lz)) {
|
2017-02-03 01:11:32 -05:00
|
|
|
return rb_int2big(rb_overflowed_fix_to_int(lz));
|
2017-02-02 10:54:51 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (VALUE)lz;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
long lz = FIX2LONG(x) + FIX2LONG(y);
|
|
|
|
return LONG2NUM(lz);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
rb_fix_minus_fix(VALUE x, VALUE y)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_SUB_OVERFLOW
|
|
|
|
long lz;
|
|
|
|
if (__builtin_sub_overflow((long)x, (long)y-1, &lz)) {
|
2017-02-03 01:11:32 -05:00
|
|
|
return rb_int2big(rb_overflowed_fix_to_int(lz));
|
2017-02-02 10:54:51 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return (VALUE)lz;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
long lz = FIX2LONG(x) - FIX2LONG(y);
|
|
|
|
return LONG2NUM(lz);
|
|
|
|
#endif
|
|
|
|
}
|
2016-10-04 12:25:01 -04:00
|
|
|
|
2016-03-20 07:10:43 -04:00
|
|
|
/* arguments must be Fixnum */
|
|
|
|
static inline VALUE
|
|
|
|
rb_fix_mul_fix(VALUE x, VALUE y)
|
|
|
|
{
|
|
|
|
long lx = FIX2LONG(x);
|
|
|
|
long ly = FIX2LONG(y);
|
|
|
|
#ifdef DLONG
|
|
|
|
return DL2NUM((DLONG)lx * (DLONG)ly);
|
|
|
|
#else
|
2016-03-21 09:09:26 -04:00
|
|
|
if (MUL_OVERFLOW_FIXNUM_P(lx, ly)) {
|
|
|
|
return rb_big_mul(rb_int2big(lx), rb_int2big(ly));
|
2016-03-20 07:10:43 -04:00
|
|
|
}
|
|
|
|
else {
|
2016-03-21 09:09:26 -04:00
|
|
|
return LONG2FIX(lx * ly);
|
2016-03-20 07:10:43 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-03-08 04:15:18 -05:00
|
|
|
/*
|
|
|
|
* This behaves different from C99 for negative arguments.
|
|
|
|
* Note that div may overflow fixnum.
|
|
|
|
*/
|
|
|
|
static inline void
|
2016-04-27 01:29:07 -04:00
|
|
|
rb_fix_divmod_fix(VALUE a, VALUE b, VALUE *divp, VALUE *modp)
|
|
|
|
{
|
2016-03-08 04:15:18 -05:00
|
|
|
/* assume / and % comply C99.
|
|
|
|
* ldiv(3) won't be inlined by GCC and clang.
|
|
|
|
* I expect / and % are compiled as single idiv.
|
|
|
|
*/
|
2016-03-21 09:36:03 -04:00
|
|
|
long x = FIX2LONG(a);
|
|
|
|
long y = FIX2LONG(b);
|
|
|
|
long div, mod;
|
|
|
|
if (x == FIXNUM_MIN && y == -1) {
|
|
|
|
if (divp) *divp = LONG2NUM(-FIXNUM_MIN);
|
|
|
|
if (modp) *modp = LONG2FIX(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
div = x / y;
|
|
|
|
mod = x % y;
|
2016-03-08 04:15:18 -05:00
|
|
|
if (y > 0 ? mod < 0 : mod > 0) {
|
|
|
|
mod += y;
|
|
|
|
div -= 1;
|
|
|
|
}
|
2016-03-21 09:36:03 -04:00
|
|
|
if (divp) *divp = LONG2FIX(div);
|
|
|
|
if (modp) *modp = LONG2FIX(mod);
|
2016-03-08 04:15:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* div() for Ruby
|
|
|
|
* This behaves different from C99 for negative arguments.
|
|
|
|
*/
|
2016-03-21 09:36:03 -04:00
|
|
|
static inline VALUE
|
2016-04-27 01:29:07 -04:00
|
|
|
rb_fix_div_fix(VALUE x, VALUE y)
|
|
|
|
{
|
2016-03-21 09:36:03 -04:00
|
|
|
VALUE div;
|
|
|
|
rb_fix_divmod_fix(x, y, &div, NULL);
|
2016-03-08 04:15:18 -05:00
|
|
|
return div;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mod() for Ruby
|
|
|
|
* This behaves different from C99 for negative arguments.
|
|
|
|
*/
|
2016-03-21 09:36:03 -04:00
|
|
|
static inline VALUE
|
2016-04-27 01:29:07 -04:00
|
|
|
rb_fix_mod_fix(VALUE x, VALUE y)
|
|
|
|
{
|
2016-03-21 09:36:03 -04:00
|
|
|
VALUE mod;
|
|
|
|
rb_fix_divmod_fix(x, y, NULL, &mod);
|
2016-03-08 04:15:18 -05:00
|
|
|
return mod;
|
|
|
|
}
|
|
|
|
|
2018-01-02 01:41:47 -05:00
|
|
|
#if defined(HAVE_UINT128_T) && defined(HAVE_LONG_LONG)
|
2013-08-31 20:57:00 -04:00
|
|
|
# define bit_length(x) \
|
2016-12-22 15:58:55 -05:00
|
|
|
(unsigned int) \
|
2013-09-02 21:17:36 -04:00
|
|
|
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
|
|
|
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
|
|
|
sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
|
|
|
|
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
|
2018-01-02 01:41:47 -05:00
|
|
|
#elif defined(HAVE_UINT128_T)
|
|
|
|
# define bit_length(x) \
|
|
|
|
(unsigned int) \
|
|
|
|
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
|
|
|
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
|
|
|
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
|
2013-08-31 20:57:00 -04:00
|
|
|
#elif defined(HAVE_LONG_LONG)
|
|
|
|
# define bit_length(x) \
|
2016-12-22 15:58:55 -05:00
|
|
|
(unsigned int) \
|
2013-09-02 21:17:36 -04:00
|
|
|
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
|
|
|
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
|
|
|
SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)))
|
2013-08-31 20:57:00 -04:00
|
|
|
#else
|
|
|
|
# define bit_length(x) \
|
2016-12-22 15:58:55 -05:00
|
|
|
(unsigned int) \
|
2013-09-02 21:17:36 -04:00
|
|
|
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
|
|
|
SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)))
|
2013-08-31 20:57:00 -04:00
|
|
|
#endif
|
|
|
|
|
2014-02-17 06:01:12 -05:00
|
|
|
#ifndef BDIGIT
|
|
|
|
# if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
|
|
|
# define BDIGIT unsigned int
|
2014-04-12 23:48:17 -04:00
|
|
|
# define SIZEOF_BDIGIT SIZEOF_INT
|
2014-02-17 06:01:12 -05:00
|
|
|
# define BDIGIT_DBL unsigned LONG_LONG
|
|
|
|
# define BDIGIT_DBL_SIGNED LONG_LONG
|
|
|
|
# define PRI_BDIGIT_PREFIX ""
|
|
|
|
# define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
|
|
|
|
# elif SIZEOF_INT*2 <= SIZEOF_LONG
|
|
|
|
# define BDIGIT unsigned int
|
2014-04-12 23:48:17 -04:00
|
|
|
# define SIZEOF_BDIGIT SIZEOF_INT
|
2014-02-17 06:01:12 -05:00
|
|
|
# define BDIGIT_DBL unsigned long
|
|
|
|
# define BDIGIT_DBL_SIGNED long
|
|
|
|
# define PRI_BDIGIT_PREFIX ""
|
|
|
|
# define PRI_BDIGIT_DBL_PREFIX "l"
|
|
|
|
# elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
|
|
|
# define BDIGIT unsigned short
|
2014-04-12 23:48:17 -04:00
|
|
|
# define SIZEOF_BDIGIT SIZEOF_SHORT
|
2014-02-17 06:01:12 -05:00
|
|
|
# define BDIGIT_DBL unsigned long
|
|
|
|
# define BDIGIT_DBL_SIGNED long
|
|
|
|
# define PRI_BDIGIT_PREFIX "h"
|
|
|
|
# define PRI_BDIGIT_DBL_PREFIX "l"
|
|
|
|
# else
|
|
|
|
# define BDIGIT unsigned short
|
2014-04-12 23:48:17 -04:00
|
|
|
# define SIZEOF_BDIGIT (SIZEOF_LONG/2)
|
2014-02-17 06:01:12 -05:00
|
|
|
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
|
|
|
|
# define BDIGIT_DBL unsigned long
|
|
|
|
# define BDIGIT_DBL_SIGNED long
|
|
|
|
# define PRI_BDIGIT_PREFIX "h"
|
|
|
|
# define PRI_BDIGIT_DBL_PREFIX "l"
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifndef SIZEOF_ACTUAL_BDIGIT
|
2014-04-12 23:48:17 -04:00
|
|
|
# define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGIT
|
2014-02-17 06:01:12 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PRI_BDIGIT_PREFIX
|
|
|
|
# define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
|
|
|
|
# define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
|
|
|
|
# define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
|
|
|
|
# define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
|
|
|
|
# define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
|
|
|
|
# define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PRI_BDIGIT_DBL_PREFIX
|
|
|
|
# define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
|
|
|
|
# define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
|
|
|
|
# define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
|
|
|
|
# define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
|
|
|
|
# define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
|
|
|
|
# define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
|
|
|
|
#endif
|
|
|
|
|
2014-02-15 16:17:34 -05:00
|
|
|
#define BIGNUM_EMBED_LEN_NUMBITS 3
|
|
|
|
#ifndef BIGNUM_EMBED_LEN_MAX
|
|
|
|
# if (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT) < (1 << BIGNUM_EMBED_LEN_NUMBITS)-1
|
|
|
|
# define BIGNUM_EMBED_LEN_MAX (SIZEOF_VALUE*3/SIZEOF_ACTUAL_BDIGIT)
|
2014-02-14 10:29:10 -05:00
|
|
|
# else
|
2014-02-15 16:17:34 -05:00
|
|
|
# define BIGNUM_EMBED_LEN_MAX ((1 << BIGNUM_EMBED_LEN_NUMBITS)-1)
|
2014-02-14 10:29:10 -05:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct RBignum {
|
|
|
|
struct RBasic basic;
|
|
|
|
union {
|
|
|
|
struct {
|
2014-04-18 21:11:04 -04:00
|
|
|
size_t len;
|
2014-02-14 10:29:10 -05:00
|
|
|
BDIGIT *digits;
|
|
|
|
} heap;
|
2014-02-15 16:17:34 -05:00
|
|
|
BDIGIT ary[BIGNUM_EMBED_LEN_MAX];
|
2014-02-14 10:29:10 -05:00
|
|
|
} as;
|
|
|
|
};
|
2016-12-22 15:58:55 -05:00
|
|
|
#define BIGNUM_SIGN_BIT ((VALUE)FL_USER1)
|
2014-02-14 10:29:10 -05:00
|
|
|
/* sign: positive:1, negative:0 */
|
2014-02-15 16:17:34 -05:00
|
|
|
#define BIGNUM_SIGN(b) ((RBASIC(b)->flags & BIGNUM_SIGN_BIT) != 0)
|
|
|
|
#define BIGNUM_SET_SIGN(b,sign) \
|
|
|
|
((sign) ? (RBASIC(b)->flags |= BIGNUM_SIGN_BIT) \
|
|
|
|
: (RBASIC(b)->flags &= ~BIGNUM_SIGN_BIT))
|
|
|
|
#define BIGNUM_POSITIVE_P(b) BIGNUM_SIGN(b)
|
|
|
|
#define BIGNUM_NEGATIVE_P(b) (!BIGNUM_SIGN(b))
|
2016-02-15 00:15:33 -05:00
|
|
|
#define BIGNUM_NEGATE(b) (RBASIC(b)->flags ^= BIGNUM_SIGN_BIT)
|
2014-02-15 16:17:34 -05:00
|
|
|
|
2016-12-22 15:58:55 -05:00
|
|
|
#define BIGNUM_EMBED_FLAG ((VALUE)FL_USER2)
|
2018-10-03 00:37:43 -04:00
|
|
|
#define BIGNUM_EMBED_LEN_MASK \
|
|
|
|
(~(~(VALUE)0U << BIGNUM_EMBED_LEN_NUMBITS) << BIGNUM_EMBED_LEN_SHIFT)
|
|
|
|
#define BIGNUM_EMBED_LEN_SHIFT \
|
|
|
|
(FL_USHIFT+3) /* bit offset of BIGNUM_EMBED_LEN_MASK */
|
2014-02-15 16:17:34 -05:00
|
|
|
#define BIGNUM_LEN(b) \
|
|
|
|
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
2016-12-22 15:58:55 -05:00
|
|
|
(size_t)((RBASIC(b)->flags >> BIGNUM_EMBED_LEN_SHIFT) & \
|
|
|
|
(BIGNUM_EMBED_LEN_MASK >> BIGNUM_EMBED_LEN_SHIFT)) : \
|
2014-02-14 10:29:10 -05:00
|
|
|
RBIGNUM(b)->as.heap.len)
|
2014-02-15 16:17:34 -05:00
|
|
|
/* LSB:BIGNUM_DIGITS(b)[0], MSB:BIGNUM_DIGITS(b)[BIGNUM_LEN(b)-1] */
|
|
|
|
#define BIGNUM_DIGITS(b) \
|
|
|
|
((RBASIC(b)->flags & BIGNUM_EMBED_FLAG) ? \
|
2014-02-14 10:29:10 -05:00
|
|
|
RBIGNUM(b)->as.ary : \
|
|
|
|
RBIGNUM(b)->as.heap.digits)
|
2014-02-15 16:17:34 -05:00
|
|
|
#define BIGNUM_LENINT(b) rb_long2int(BIGNUM_LEN(b))
|
2014-02-14 10:29:10 -05:00
|
|
|
|
|
|
|
#define RBIGNUM(obj) (R_CAST(RBignum)(obj))
|
|
|
|
|
2014-05-17 12:37:41 -04:00
|
|
|
struct RRational {
|
|
|
|
struct RBasic basic;
|
|
|
|
const VALUE num;
|
|
|
|
const VALUE den;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RRATIONAL(obj) (R_CAST(RRational)(obj))
|
2016-02-22 02:15:56 -05:00
|
|
|
#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
|
|
|
|
#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
|
2014-05-17 12:37:41 -04:00
|
|
|
|
2014-06-23 00:12:19 -04:00
|
|
|
struct RFloat {
|
|
|
|
struct RBasic basic;
|
|
|
|
double float_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RFLOAT(obj) (R_CAST(RFloat)(obj))
|
|
|
|
|
2014-06-23 00:41:27 -04:00
|
|
|
struct RComplex {
|
|
|
|
struct RBasic basic;
|
|
|
|
const VALUE real;
|
|
|
|
const VALUE imag;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
|
|
|
|
|
2018-09-04 08:30:34 -04:00
|
|
|
/* shortcut macro for internal only */
|
2014-06-23 00:41:27 -04:00
|
|
|
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
|
|
|
|
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
|
|
|
|
|
2018-10-30 18:11:51 -04:00
|
|
|
enum ruby_rhash_flags {
|
|
|
|
RHASH_ST_TABLE_FLAG = FL_USER3,
|
|
|
|
RHASH_ARRAY_MAX_SIZE = 8,
|
|
|
|
RHASH_ARRAY_SIZE_MASK = (FL_USER4|FL_USER5|FL_USER6|FL_USER7),
|
|
|
|
RHASH_ARRAY_SIZE_SHIFT = (FL_USHIFT+4),
|
|
|
|
RHASH_ARRAY_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11),
|
|
|
|
RHASH_ARRAY_BOUND_SHIFT = (FL_USHIFT+8),
|
|
|
|
|
|
|
|
RHASH_ENUM_END
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HASH_PROC_DEFAULT FL_USER2
|
|
|
|
|
|
|
|
#define RHASH_ARRAY_SIZE_RAW(h) \
|
2018-11-03 02:55:57 -04:00
|
|
|
((unsigned int)((RBASIC(h)->flags & RHASH_ARRAY_SIZE_MASK) >> RHASH_ARRAY_SIZE_SHIFT))
|
2018-10-30 18:11:51 -04:00
|
|
|
|
|
|
|
int rb_hash_array_p(VALUE hash);
|
|
|
|
struct li_table *rb_hash_array(VALUE hash);
|
|
|
|
st_table *rb_hash_st_table(VALUE hash);
|
|
|
|
void rb_hash_st_table_set(VALUE hash, st_table *st);
|
|
|
|
|
|
|
|
#if 0 /* for debug */
|
|
|
|
#define RHASH_ARRAY_P(hash) rb_hash_array_p(hash)
|
|
|
|
#define RHASH_ARRAY(h) rb_hash_array(h)
|
|
|
|
#define RHASH_ST_TABLE(h) rb_hash_st_table(h)
|
|
|
|
#else
|
|
|
|
#define RHASH_ARRAY_P(hash) (!FL_TEST_RAW((hash), RHASH_ST_TABLE_FLAG))
|
|
|
|
#define RHASH_ARRAY(hash) (RHASH(hash)->as.li)
|
|
|
|
#define RHASH_ST_TABLE(hash) (RHASH(hash)->as.st)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define RHASH(obj) (R_CAST(RHash)(obj))
|
|
|
|
#define RHASH_ST_SIZE(h) (RHASH_ST_TABLE(h)->num_entries)
|
|
|
|
#define RHASH_TABLE_P(h) (!RHASH_ARRAY_P(h))
|
|
|
|
#define RHASH_CLEAR(h) (FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG), RHASH(h)->as.li = NULL)
|
|
|
|
|
|
|
|
#define RHASH_ARRAY_SIZE_MASK (VALUE)RHASH_ARRAY_SIZE_MASK
|
|
|
|
#define RHASH_ARRAY_SIZE_SHIFT RHASH_ARRAY_SIZE_SHIFT
|
|
|
|
#define RHASH_ARRAY_BOUND_MASK (VALUE)RHASH_ARRAY_BOUND_MASK
|
|
|
|
#define RHASH_ARRAY_BOUND_SHIFT RHASH_ARRAY_BOUND_SHIFT
|
2018-11-01 04:53:44 -04:00
|
|
|
|
|
|
|
#if USE_TRANSIENT_HEAP
|
2018-10-30 18:11:51 -04:00
|
|
|
#define RHASH_TRANSIENT_FLAG FL_USER14
|
|
|
|
#define RHASH_TRANSIENT_P(hash) FL_TEST_RAW((hash), RHASH_TRANSIENT_FLAG)
|
2018-11-01 04:53:44 -04:00
|
|
|
#define RHASH_SET_TRANSIENT_FLAG(h) FL_SET_RAW(h, RHASH_TRANSIENT_FLAG)
|
|
|
|
#define RHASH_UNSET_TRANSIENT_FLAG(h) FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG)
|
|
|
|
#else
|
|
|
|
#define RHASH_TRANSIENT_P(hash) 0
|
|
|
|
#define RHASH_SET_TRANSIENT_FLAG(h) ((void)0)
|
|
|
|
#define RHASH_UNSET_TRANSIENT_FLAG(h) ((void)0)
|
|
|
|
#endif
|
2018-10-30 18:11:51 -04:00
|
|
|
|
|
|
|
#define RHASH_ARRAY_MAX_SIZE 8
|
|
|
|
#define RHASH_ARRAY_MAX_BOUND RHASH_ARRAY_MAX_SIZE
|
|
|
|
|
|
|
|
typedef struct li_table_entry {
|
|
|
|
VALUE hash;
|
|
|
|
VALUE key;
|
|
|
|
VALUE record;
|
|
|
|
} li_table_entry;
|
|
|
|
|
|
|
|
typedef struct li_table {
|
|
|
|
li_table_entry entries[RHASH_ARRAY_MAX_SIZE];
|
|
|
|
} li_table;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RHASH_ARRAY_P(h):
|
|
|
|
* * as.li == NULL or
|
|
|
|
* as.li points li_table.
|
|
|
|
* * as.li is allocated by transient heap or xmalloc.
|
|
|
|
*
|
|
|
|
* !RHASH_ARRAY_P(h):
|
|
|
|
* * as.st points st_table.
|
|
|
|
*/
|
2014-06-23 03:26:03 -04:00
|
|
|
struct RHash {
|
|
|
|
struct RBasic basic;
|
2018-10-30 18:11:51 -04:00
|
|
|
union {
|
2018-10-30 18:12:12 -04:00
|
|
|
struct st_table *st;
|
|
|
|
struct li_table *li; /* possibly 0 */
|
2018-10-30 18:11:51 -04:00
|
|
|
} as;
|
2014-06-23 03:26:03 -04:00
|
|
|
int iter_lev;
|
|
|
|
const VALUE ifnone;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef RHASH_ITER_LEV
|
2018-10-30 18:11:51 -04:00
|
|
|
# undef RHASH_ITER_LEV
|
|
|
|
# undef RHASH_IFNONE
|
|
|
|
# undef RHASH_SIZE
|
|
|
|
|
|
|
|
# define RHASH_ITER_LEV(h) (RHASH(h)->iter_lev)
|
|
|
|
# define RHASH_IFNONE(h) (RHASH(h)->ifnone)
|
|
|
|
# define RHASH_SIZE(h) (RHASH_ARRAY_P(h) ? RHASH_ARRAY_SIZE_RAW(h) : RHASH_ST_SIZE(h))
|
|
|
|
#endif /* #ifdef RHASH_ITER_LEV */
|
2014-06-23 03:26:03 -04:00
|
|
|
|
2014-11-19 10:57:31 -05:00
|
|
|
/* missing/setproctitle.c */
|
|
|
|
#ifndef HAVE_SETPROCTITLE
|
|
|
|
extern void ruby_init_setproctitle(int argc, char *argv[]);
|
|
|
|
#endif
|
|
|
|
|
2016-08-01 03:23:56 -04:00
|
|
|
#define RSTRUCT_EMBED_LEN_MAX RSTRUCT_EMBED_LEN_MAX
|
|
|
|
#define RSTRUCT_EMBED_LEN_MASK RSTRUCT_EMBED_LEN_MASK
|
|
|
|
#define RSTRUCT_EMBED_LEN_SHIFT RSTRUCT_EMBED_LEN_SHIFT
|
2018-10-30 18:03:42 -04:00
|
|
|
|
2016-08-01 03:23:56 -04:00
|
|
|
enum {
|
|
|
|
RSTRUCT_EMBED_LEN_MAX = 3,
|
|
|
|
RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
|
|
|
|
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
|
2018-10-30 18:03:42 -04:00
|
|
|
RSTRUCT_TRANSIENT_FLAG = FL_USER3,
|
2016-08-01 03:23:56 -04:00
|
|
|
|
|
|
|
RSTRUCT_ENUM_END
|
|
|
|
};
|
|
|
|
|
2018-11-01 04:53:44 -04:00
|
|
|
#if USE_TRANSIENT_HEAP
|
2018-10-30 18:03:42 -04:00
|
|
|
#define RSTRUCT_TRANSIENT_P(st) FL_TEST_RAW((obj), RSTRUCT_TRANSIENT_FLAG)
|
2018-11-01 04:53:44 -04:00
|
|
|
#define RSTRUCT_TRANSIENT_SET(st) FL_SET_RAW((st), RSTRUCT_TRANSIENT_FLAG)
|
|
|
|
#define RSTRUCT_TRANSIENT_UNSET(st) FL_UNSET_RAW((st), RSTRUCT_TRANSIENT_FLAG)
|
|
|
|
#else
|
|
|
|
#define RSTRUCT_TRANSIENT_P(st) 0
|
|
|
|
#define RSTRUCT_TRANSIENT_SET(st) ((void)0)
|
|
|
|
#define RSTRUCT_TRANSIENT_UNSET(st) ((void)0)
|
|
|
|
#endif
|
2018-10-30 18:03:42 -04:00
|
|
|
|
2016-08-01 03:23:56 -04:00
|
|
|
struct RStruct {
|
|
|
|
struct RBasic basic;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
long len;
|
|
|
|
const VALUE *ptr;
|
|
|
|
} heap;
|
|
|
|
const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
|
|
|
|
} as;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef RSTRUCT_LEN
|
|
|
|
#undef RSTRUCT_PTR
|
|
|
|
#undef RSTRUCT_SET
|
|
|
|
#undef RSTRUCT_GET
|
|
|
|
#define RSTRUCT_EMBED_LEN(st) \
|
|
|
|
(long)((RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & \
|
|
|
|
(RSTRUCT_EMBED_LEN_MASK >> RSTRUCT_EMBED_LEN_SHIFT))
|
|
|
|
#define RSTRUCT_LEN(st) rb_struct_len(st)
|
|
|
|
#define RSTRUCT_LENINT(st) rb_long2int(RSTRUCT_LEN(st))
|
|
|
|
#define RSTRUCT_CONST_PTR(st) rb_struct_const_ptr(st)
|
|
|
|
#define RSTRUCT_PTR(st) ((VALUE *)RSTRUCT_CONST_PTR(RB_OBJ_WB_UNPROTECT_FOR(STRUCT, st)))
|
|
|
|
#define RSTRUCT_SET(st, idx, v) RB_OBJ_WRITE(st, &RSTRUCT_CONST_PTR(st)[idx], (v))
|
|
|
|
#define RSTRUCT_GET(st, idx) (RSTRUCT_CONST_PTR(st)[idx])
|
|
|
|
#define RSTRUCT(obj) (R_CAST(RStruct)(obj))
|
|
|
|
|
|
|
|
static inline long
|
|
|
|
rb_struct_len(VALUE st)
|
|
|
|
{
|
|
|
|
return (RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
|
|
|
RSTRUCT_EMBED_LEN(st) : RSTRUCT(st)->as.heap.len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const VALUE *
|
|
|
|
rb_struct_const_ptr(VALUE st)
|
|
|
|
{
|
|
|
|
return FIX_CONST_VALUE_PTR((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
|
|
|
|
RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
|
|
|
|
}
|
|
|
|
|
2018-10-30 18:03:42 -04:00
|
|
|
static inline const VALUE *
|
|
|
|
rb_struct_const_heap_ptr(VALUE st)
|
|
|
|
{
|
|
|
|
/* TODO: check embed on debug mode */
|
|
|
|
return RSTRUCT(st)->as.heap.ptr;
|
|
|
|
}
|
|
|
|
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
/* class.c */
|
2015-06-01 02:48:07 -04:00
|
|
|
|
|
|
|
struct rb_deprecated_classext_struct {
|
|
|
|
char conflict[sizeof(VALUE) * 3];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rb_subclass_entry;
|
|
|
|
typedef struct rb_subclass_entry rb_subclass_entry_t;
|
|
|
|
|
|
|
|
struct rb_subclass_entry {
|
|
|
|
VALUE klass;
|
|
|
|
rb_subclass_entry_t *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(HAVE_LONG_LONG)
|
|
|
|
typedef unsigned LONG_LONG rb_serial_t;
|
|
|
|
#define SERIALT2NUM ULL2NUM
|
2018-02-10 19:19:03 -05:00
|
|
|
#define PRI_SERIALT_PREFIX PRI_LL_PREFIX
|
2015-06-01 02:48:07 -04:00
|
|
|
#elif defined(HAVE_UINT64_T)
|
|
|
|
typedef uint64_t rb_serial_t;
|
|
|
|
#define SERIALT2NUM SIZET2NUM
|
2018-02-10 19:19:03 -05:00
|
|
|
#define PRI_SERIALT_PREFIX PRI_64_PREFIX
|
2015-06-01 02:48:07 -04:00
|
|
|
#else
|
|
|
|
typedef unsigned long rb_serial_t;
|
|
|
|
#define SERIALT2NUM ULONG2NUM
|
2018-02-10 19:19:03 -05:00
|
|
|
#define PRI_SERIALT_PREFIX PRI_LONG_PREFIX
|
2015-06-01 02:48:07 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rb_classext_struct {
|
|
|
|
struct st_table *iv_index_tbl;
|
|
|
|
struct st_table *iv_tbl;
|
use id_table for constant tables
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage
when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit
before: HEAP SUMMARY:
in use at exit: 2,913,448 bytes in 27,394 blocks
total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc
after: HEAP SUMMARY:
in use at exit: 2,880,056 bytes in 26,712 blocks
total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc
* class.c (struct clone_const_arg): adjust for id_table
(clone_const): ditto
(clone_const_i): ditto
(rb_mod_init_copy): ditto
(rb_singleton_class_clone_and_attach): ditto
(rb_include_class_new): ditto
(include_modules_at): ditto
* constant.h (rb_free_const_table): ditto
* gc.c (free_const_entry_i): ditto
(rb_free_const_table): ditto
(obj_memsize_of): ditto
(mark_const_entry_i): ditto
(mark_const_tbl): ditto
* internal.h (struct rb_classext_struct): ditto
* object.c (rb_mod_const_set): resolve class name on assignment
* variable.c (const_update): replace with const_tbl_update
(const_tbl_update): new function
(fc_i): adjust for id_table
(find_class_path): ditto
(autoload_const_set): st_update => const_tbl_update
(rb_const_remove): adjust for id_table
(sv_i): ditto
(rb_local_constants_i): ditto
(rb_local_constants): ditto
(rb_mod_const_at): ditto
(rb_mod_const_set): ditto
(rb_const_lookup): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 15:19:14 -05:00
|
|
|
struct rb_id_table *const_tbl;
|
2015-08-12 04:43:55 -04:00
|
|
|
struct rb_id_table *callable_m_tbl;
|
2015-06-01 02:48:07 -04:00
|
|
|
rb_subclass_entry_t *subclasses;
|
|
|
|
rb_subclass_entry_t **parent_subclasses;
|
|
|
|
/**
|
|
|
|
* In the case that this is an `ICLASS`, `module_subclasses` points to the link
|
|
|
|
* in the module's `subclasses` list that indicates that the klass has been
|
|
|
|
* included. Hopefully that makes sense.
|
|
|
|
*/
|
|
|
|
rb_subclass_entry_t **module_subclasses;
|
|
|
|
rb_serial_t class_serial;
|
|
|
|
const VALUE origin_;
|
|
|
|
VALUE refined_class;
|
|
|
|
rb_alloc_func_t allocator;
|
|
|
|
};
|
|
|
|
|
2015-07-27 21:32:15 -04:00
|
|
|
typedef struct rb_classext_struct rb_classext_t;
|
|
|
|
|
|
|
|
#undef RClass
|
|
|
|
struct RClass {
|
|
|
|
struct RBasic basic;
|
|
|
|
VALUE super;
|
|
|
|
rb_classext_t *ptr;
|
2015-08-12 04:43:55 -04:00
|
|
|
struct rb_id_table *m_tbl;
|
2015-07-27 21:32:15 -04:00
|
|
|
};
|
|
|
|
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
void rb_class_subclass_add(VALUE super, VALUE klass);
|
|
|
|
void rb_class_remove_from_super_subclasses(VALUE);
|
2015-12-22 08:15:58 -05:00
|
|
|
int rb_singleton_class_internal_p(VALUE sklass);
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
|
2011-06-17 23:05:11 -04:00
|
|
|
#define RCLASS_EXT(c) (RCLASS(c)->ptr)
|
|
|
|
#define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
|
|
|
|
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
|
2015-03-05 17:20:14 -05:00
|
|
|
#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
|
* method.h: introduce rb_callable_method_entry_t to remove
rb_control_frame_t::klass.
[Bug #11278], [Bug #11279]
rb_method_entry_t data belong to modules/classes.
rb_method_entry_t::owner points defined module or class.
module M
def foo; end
end
In this case, owner is M.
rb_callable_method_entry_t data belong to only classes.
For modules, MRI creates corresponding T_ICLASS internally.
rb_callable_method_entry_t can also belong to T_ICLASS.
rb_callable_method_entry_t::defined_class points T_CLASS or
T_ICLASS.
rb_method_entry_t data for classes (not for modules) are also
rb_callable_method_entry_t data because it is completely same data.
In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
For example, there are classes C and D, and incldues M,
class C; include M; end
class D; include M; end
then, two T_ICLASS objects for C's super class and D's super class
will be created.
When C.new.foo is called, then M#foo is searcheed and
rb_callable_method_t data is used by VM to invoke M#foo.
rb_method_entry_t data is only one for M#foo.
However, rb_callable_method_entry_t data are two (and can be more).
It is proportional to the number of including (and prepending)
classes (the number of T_ICLASS which point to the module).
Now, created rb_callable_method_entry_t are collected when
the original module M was modified. We can think it is a cache.
We need to select what kind of method entry data is needed.
To operate definition, then you need to use rb_method_entry_t.
You can access them by the following functions.
* rb_method_entry(VALUE klass, ID id);
* rb_method_entry_with_refinements(VALUE klass, ID id);
* rb_method_entry_without_refinements(VALUE klass, ID id);
* rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
To invoke methods, then you need to use rb_callable_method_entry_t
which you can get by the following APIs corresponding to the
above listed functions.
* rb_callable_method_entry(VALUE klass, ID id);
* rb_callable_method_entry_with_refinements(VALUE klass, ID id);
* rb_callable_method_entry_without_refinements(VALUE klass, ID id);
* rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
returns rb_callable_method_entry_t.
You can check a super class of current method by
rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
rb_callable_method_entry_t data.
We need to consider abotu this field again because it is only
active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
rb_callable_method_t has all information.
* vm_core.h: remove several fields.
* rb_control_frame_t::klass.
* rb_block_t::klass.
And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 07:24:50 -04:00
|
|
|
#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
|
2013-12-20 00:10:07 -05:00
|
|
|
#define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
|
2015-03-11 05:15:20 -04:00
|
|
|
#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
|
2012-08-06 03:00:19 -04:00
|
|
|
#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
|
2013-12-09 06:00:23 -05:00
|
|
|
#define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
|
2011-06-17 23:05:11 -04:00
|
|
|
|
2015-03-11 05:15:20 -04:00
|
|
|
#define RICLASS_IS_ORIGIN FL_USER5
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
|
|
|
|
{
|
|
|
|
RB_OBJ_WRITE(klass, &RCLASS_ORIGIN(klass), origin);
|
|
|
|
if (klass != origin) FL_SET(origin, RICLASS_IS_ORIGIN);
|
|
|
|
}
|
|
|
|
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:49:11 -04:00
|
|
|
#undef RCLASS_SUPER
|
|
|
|
static inline VALUE
|
2013-06-07 04:31:48 -04:00
|
|
|
RCLASS_SUPER(VALUE klass)
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:49:11 -04:00
|
|
|
{
|
2013-12-20 00:10:07 -05:00
|
|
|
return RCLASS(klass)->super;
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:49:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
2013-06-07 04:31:48 -04:00
|
|
|
RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
2013-05-25 10:55:18 -04:00
|
|
|
{
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
if (super) {
|
|
|
|
rb_class_remove_from_super_subclasses(klass);
|
|
|
|
rb_class_subclass_add(super, klass);
|
|
|
|
}
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 03:07:47 -05:00
|
|
|
RB_OBJ_WRITE(klass, &RCLASS(klass)->super, super);
|
2013-06-07 04:31:48 -04:00
|
|
|
return super;
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:49:11 -04:00
|
|
|
}
|
2015-03-11 06:36:17 -04:00
|
|
|
/* IMEMO: Internal memo object */
|
|
|
|
|
2015-03-18 15:57:53 -04:00
|
|
|
#ifndef IMEMO_DEBUG
|
|
|
|
#define IMEMO_DEBUG 0
|
|
|
|
#endif
|
2015-03-11 06:36:17 -04:00
|
|
|
|
|
|
|
struct RIMemo {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE v0;
|
|
|
|
VALUE v1;
|
|
|
|
VALUE v2;
|
|
|
|
VALUE v3;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum imemo_type {
|
2017-11-04 06:56:50 -04:00
|
|
|
imemo_env = 0,
|
|
|
|
imemo_cref = 1, /*!< class reference */
|
|
|
|
imemo_svar = 2, /*!< special variable */
|
|
|
|
imemo_throw_data = 3,
|
|
|
|
imemo_ifunc = 4, /*!< iterator function */
|
|
|
|
imemo_memo = 5,
|
|
|
|
imemo_ment = 6,
|
|
|
|
imemo_iseq = 7,
|
2018-05-09 03:11:59 -04:00
|
|
|
imemo_tmpbuf = 8,
|
2017-11-04 06:56:50 -04:00
|
|
|
imemo_ast = 9,
|
|
|
|
imemo_parser_strterm = 10
|
2015-03-11 06:36:17 -04:00
|
|
|
};
|
2017-10-21 06:21:31 -04:00
|
|
|
#define IMEMO_MASK 0x0f
|
2015-03-11 06:36:17 -04:00
|
|
|
|
|
|
|
static inline enum imemo_type
|
|
|
|
imemo_type(VALUE imemo)
|
|
|
|
{
|
2017-10-21 06:21:31 -04:00
|
|
|
return (RBASIC(imemo)->flags >> FL_USHIFT) & IMEMO_MASK;
|
2015-03-11 06:36:17 -04:00
|
|
|
}
|
|
|
|
|
2017-04-07 02:41:32 -04:00
|
|
|
static inline int
|
|
|
|
imemo_type_p(VALUE imemo, enum imemo_type imemo_type)
|
|
|
|
{
|
|
|
|
if (LIKELY(!RB_SPECIAL_CONST_P(imemo))) {
|
|
|
|
/* fixed at compile time if imemo_type is given. */
|
2017-10-21 06:21:31 -04:00
|
|
|
const VALUE mask = (IMEMO_MASK << FL_USHIFT) | RUBY_T_MASK;
|
2017-04-07 02:41:32 -04:00
|
|
|
const VALUE expected_type = (imemo_type << FL_USHIFT) | T_IMEMO;
|
|
|
|
/* fixed at runtime. */
|
|
|
|
return expected_type == (RBASIC(imemo)->flags & mask);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-21 06:26:31 -04:00
|
|
|
/* FL_USER0 to FL_USER3 is for type */
|
2017-10-21 04:40:28 -04:00
|
|
|
#define IMEMO_FL_USHIFT (FL_USHIFT + 4)
|
|
|
|
#define IMEMO_FL_USER0 FL_USER4
|
|
|
|
#define IMEMO_FL_USER1 FL_USER5
|
|
|
|
#define IMEMO_FL_USER2 FL_USER6
|
|
|
|
#define IMEMO_FL_USER3 FL_USER7
|
|
|
|
#define IMEMO_FL_USER4 FL_USER8
|
2015-06-10 19:55:33 -04:00
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/* CREF (Class REFerence) is defined in method.h */
|
2015-03-11 08:27:34 -04:00
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/*! SVAR (Special VARiable) */
|
2015-03-11 08:27:34 -04:00
|
|
|
struct vm_svar {
|
|
|
|
VALUE flags;
|
2017-10-21 10:31:21 -04:00
|
|
|
const VALUE cref_or_me; /*!< class reference or rb_method_entry_t */
|
2015-03-11 08:27:34 -04:00
|
|
|
const VALUE lastline;
|
|
|
|
const VALUE backref;
|
|
|
|
const VALUE others;
|
|
|
|
};
|
|
|
|
|
2015-03-11 08:49:27 -04:00
|
|
|
|
2017-04-05 22:56:23 -04:00
|
|
|
#define THROW_DATA_CONSUMED IMEMO_FL_USER0
|
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/*! THROW_DATA */
|
2015-03-11 08:49:27 -04:00
|
|
|
struct vm_throw_data {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE reserved;
|
|
|
|
const VALUE throw_obj;
|
|
|
|
const struct rb_control_frame_struct *catch_frame;
|
|
|
|
VALUE throw_state;
|
|
|
|
};
|
|
|
|
|
2017-04-06 00:42:41 -04:00
|
|
|
#define THROW_DATA_P(err) RB_TYPE_P((VALUE)(err), T_IMEMO)
|
2015-03-11 08:49:27 -04:00
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/* IFUNC (Internal FUNCtion) */
|
2015-03-11 09:31:11 -04:00
|
|
|
|
2017-07-18 04:31:02 -04:00
|
|
|
struct vm_ifunc_argc {
|
|
|
|
#if SIZEOF_INT * 2 > SIZEOF_VALUE
|
2017-12-30 11:38:22 -05:00
|
|
|
signed int min: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
|
|
|
signed int max: (SIZEOF_VALUE * CHAR_BIT) / 2;
|
2017-07-18 04:31:02 -04:00
|
|
|
#else
|
|
|
|
int min, max;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/*! IFUNC (Internal FUNCtion) */
|
2015-03-11 09:31:11 -04:00
|
|
|
struct vm_ifunc {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE reserved;
|
|
|
|
VALUE (*func)(ANYARGS);
|
|
|
|
const void *data;
|
2017-07-18 04:31:02 -04:00
|
|
|
struct vm_ifunc_argc argc;
|
2015-03-11 09:31:11 -04:00
|
|
|
};
|
|
|
|
|
2015-03-27 19:51:18 -04:00
|
|
|
#define IFUNC_NEW(a, b, c) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
2017-07-18 04:31:02 -04:00
|
|
|
struct vm_ifunc *rb_vm_ifunc_new(VALUE (*func)(ANYARGS), const void *data, int min_argc, int max_argc);
|
|
|
|
static inline struct vm_ifunc *
|
|
|
|
rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
|
|
|
|
{
|
|
|
|
return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
|
|
|
|
}
|
2015-03-11 09:31:11 -04:00
|
|
|
|
2018-05-09 03:11:59 -04:00
|
|
|
typedef struct rb_imemo_tmpbuf_struct {
|
2017-10-21 04:40:28 -04:00
|
|
|
VALUE flags;
|
|
|
|
VALUE reserved;
|
|
|
|
VALUE *ptr; /* malloc'ed buffer */
|
2018-05-09 03:11:59 -04:00
|
|
|
struct rb_imemo_tmpbuf_struct *next; /* next imemo */
|
2017-10-21 04:40:28 -04:00
|
|
|
size_t cnt; /* buffer size in VALUE */
|
2018-05-09 03:11:59 -04:00
|
|
|
} rb_imemo_tmpbuf_t;
|
2017-10-21 04:40:28 -04:00
|
|
|
|
2018-05-09 03:11:59 -04:00
|
|
|
VALUE rb_imemo_tmpbuf_auto_free_pointer(void *buf);
|
|
|
|
VALUE rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(void *buf, size_t cnt);
|
|
|
|
rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
|
2017-10-25 09:38:53 -04:00
|
|
|
|
2018-05-13 23:30:03 -04:00
|
|
|
#define RB_IMEMO_TMPBUF_PTR(v) \
|
|
|
|
((void *)(((const struct rb_imemo_tmpbuf_struct *)(v))->ptr))
|
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(VALUE str)
|
|
|
|
{
|
|
|
|
const void *src;
|
|
|
|
void *dst;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
SafeStringValue(str);
|
|
|
|
len = RSTRING_LEN(str);
|
|
|
|
src = RSTRING_PTR(str);
|
|
|
|
dst = ruby_xmalloc(len);
|
|
|
|
memcpy(dst, src, len);
|
|
|
|
return rb_imemo_tmpbuf_auto_free_pointer(dst);
|
|
|
|
}
|
|
|
|
|
2017-11-04 03:21:36 -04:00
|
|
|
void rb_strterm_mark(VALUE obj);
|
|
|
|
|
2017-10-21 10:31:21 -04:00
|
|
|
/*! MEMO
|
|
|
|
*
|
|
|
|
* @see imemo_type
|
|
|
|
* */
|
2015-03-10 20:20:45 -04:00
|
|
|
struct MEMO {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE reserved;
|
2015-03-11 19:13:01 -04:00
|
|
|
const VALUE v1;
|
|
|
|
const VALUE v2;
|
2015-03-10 20:20:45 -04:00
|
|
|
union {
|
|
|
|
long cnt;
|
|
|
|
long state;
|
2015-03-11 19:13:01 -04:00
|
|
|
const VALUE value;
|
2015-03-10 20:20:45 -04:00
|
|
|
VALUE (*func)(ANYARGS);
|
|
|
|
} u3;
|
|
|
|
};
|
|
|
|
|
2016-09-02 03:07:01 -04:00
|
|
|
#define MEMO_V1_SET(m, v) RB_OBJ_WRITE((m), &(m)->v1, (v))
|
|
|
|
#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((m), &(m)->v2, (v))
|
2015-03-11 19:13:01 -04:00
|
|
|
|
2015-03-10 20:20:45 -04:00
|
|
|
#define MEMO_CAST(m) ((struct MEMO *)m)
|
2015-03-18 15:57:53 -04:00
|
|
|
|
2015-03-11 19:13:01 -04:00
|
|
|
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
|
|
|
|
2015-06-21 07:28:12 -04:00
|
|
|
#define roomof(x, y) (((x) + (y) - 1) / (y))
|
|
|
|
#define type_roomof(x, y) roomof(sizeof(x), sizeof(y))
|
2015-03-11 19:13:01 -04:00
|
|
|
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
|
|
|
|
#define NEW_MEMO_FOR(type, value) \
|
|
|
|
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
|
2016-05-20 06:48:51 -04:00
|
|
|
#define NEW_PARTIAL_MEMO_FOR(type, value, member) \
|
|
|
|
((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), \
|
|
|
|
rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
|
|
|
|
MEMO_FOR(type, value))
|
2015-03-10 20:20:45 -04:00
|
|
|
|
2016-01-07 08:06:23 -05:00
|
|
|
#define STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
|
|
|
|
|
2016-06-13 07:34:56 -04:00
|
|
|
#ifdef RUBY_INTEGER_UNIFICATION
|
|
|
|
# define rb_cFixnum rb_cInteger
|
|
|
|
# define rb_cBignum rb_cInteger
|
|
|
|
#endif
|
|
|
|
|
2016-01-07 08:06:23 -05:00
|
|
|
enum {
|
|
|
|
cmp_opt_Fixnum,
|
|
|
|
cmp_opt_String,
|
2017-04-13 03:22:35 -04:00
|
|
|
cmp_opt_Float,
|
2016-01-07 08:06:23 -05:00
|
|
|
cmp_optimizable_count
|
|
|
|
};
|
|
|
|
|
2016-03-17 08:03:48 -04:00
|
|
|
struct cmp_opt_data {
|
2016-12-22 15:58:55 -05:00
|
|
|
unsigned int opt_methods;
|
|
|
|
unsigned int opt_inited;
|
2016-03-17 08:03:48 -04:00
|
|
|
};
|
|
|
|
|
2016-05-20 06:48:51 -04:00
|
|
|
#define NEW_CMP_OPT_MEMO(type, value) \
|
|
|
|
NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
|
2016-01-07 08:06:23 -05:00
|
|
|
#define CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
|
|
|
|
#define CMP_OPTIMIZABLE(data, type) \
|
2016-03-17 08:03:48 -04:00
|
|
|
(((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
|
|
|
|
((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
|
|
|
|
(((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
|
2016-01-07 08:06:23 -05:00
|
|
|
rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
|
2016-03-17 08:03:48 -04:00
|
|
|
((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
|
2016-01-07 08:06:23 -05:00
|
|
|
|
2016-03-17 08:14:21 -04:00
|
|
|
#define OPTIMIZED_CMP(a, b, data) \
|
|
|
|
((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Fixnum)) ? \
|
|
|
|
(((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
|
|
|
|
(STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
|
|
|
|
rb_str_cmp(a, b) : \
|
2017-04-13 03:22:35 -04:00
|
|
|
(RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(data, Float)) ? \
|
|
|
|
rb_float_cmp(a, b) : \
|
2016-03-17 08:14:21 -04:00
|
|
|
rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
|
|
|
|
|
2015-06-02 00:20:30 -04:00
|
|
|
/* ment is in method.h */
|
|
|
|
|
2015-03-11 21:55:58 -04:00
|
|
|
/* global variable */
|
|
|
|
|
|
|
|
struct rb_global_entry {
|
|
|
|
struct rb_global_variable *var;
|
|
|
|
ID id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rb_global_entry *rb_global_entry(ID);
|
|
|
|
VALUE rb_gvar_get(struct rb_global_entry *);
|
|
|
|
VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
|
|
|
|
VALUE rb_gvar_defined(struct rb_global_entry *);
|
|
|
|
|
2011-06-18 04:26:19 -04:00
|
|
|
/* array.c */
|
2018-10-30 17:53:56 -04:00
|
|
|
|
|
|
|
#ifndef ARRAY_DEBUG
|
|
|
|
#define ARRAY_DEBUG 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ARRAY_DEBUG
|
|
|
|
#define RARRAY_PTR_IN_USE_FLAG FL_USER14
|
|
|
|
#define ARY_PTR_USING_P(ary) FL_TEST_RAW((ary), RARRAY_PTR_IN_USE_FLAG)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* disable debug function */
|
|
|
|
#undef RARRAY_PTR_USE_START
|
|
|
|
#undef RARRAY_PTR_USE_END
|
|
|
|
#define RARRAY_PTR_USE_START(a) ((VALUE *)RARRAY_CONST_PTR_TRANSIENT(a))
|
|
|
|
#define RARRAY_PTR_USE_END(a)
|
|
|
|
#define ARY_PTR_USING_P(ary) 0
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-11-01 04:53:44 -04:00
|
|
|
#if USE_TRANSIENT_HEAP
|
|
|
|
#define RARY_TRANSIENT_SET(ary) FL_SET_RAW((ary), RARRAY_TRANSIENT_FLAG);
|
|
|
|
#define RARY_TRANSIENT_UNSET(ary) FL_UNSET_RAW((ary), RARRAY_TRANSIENT_FLAG);
|
|
|
|
#else
|
|
|
|
#undef RARRAY_TRANSIENT_P
|
|
|
|
#define RARRAY_TRANSIENT_P(a) 0
|
|
|
|
#define RARY_TRANSIENT_SET(ary) ((void)0)
|
|
|
|
#define RARY_TRANSIENT_UNSET(ary) ((void)0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-06-18 02:16:39 -04:00
|
|
|
VALUE rb_ary_last(int, const VALUE *, VALUE);
|
2011-07-29 10:53:51 -04:00
|
|
|
void rb_ary_set_len(VALUE, long);
|
2012-11-25 08:39:26 -05:00
|
|
|
void rb_ary_delete_same(VALUE, VALUE);
|
2014-08-15 06:32:58 -04:00
|
|
|
VALUE rb_ary_tmp_new_fill(long capa);
|
2015-11-09 07:27:26 -05:00
|
|
|
VALUE rb_ary_at(VALUE, VALUE);
|
2017-10-21 20:19:12 -04:00
|
|
|
VALUE rb_ary_aref1(VALUE ary, VALUE i);
|
|
|
|
VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
|
2014-11-18 10:13:05 -05:00
|
|
|
size_t rb_ary_memsize(VALUE);
|
2017-10-26 03:23:23 -04:00
|
|
|
VALUE rb_to_array_type(VALUE obj);
|
2018-01-27 04:27:47 -05:00
|
|
|
VALUE rb_check_to_array(VALUE ary);
|
2018-06-26 20:57:16 -04:00
|
|
|
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
|
2018-08-28 03:06:06 -04:00
|
|
|
VALUE rb_ary_behead(VALUE, long);
|
2018-01-02 01:41:45 -05:00
|
|
|
#if defined(__GNUC__) && defined(HAVE_VA_ARGS_MACRO)
|
2014-10-09 03:53:54 -04:00
|
|
|
#define rb_ary_new_from_args(n, ...) \
|
|
|
|
__extension__ ({ \
|
|
|
|
const VALUE args_to_new_ary[] = {__VA_ARGS__}; \
|
|
|
|
if (__builtin_constant_p(n)) { \
|
|
|
|
STATIC_ASSERT(rb_ary_new_from_args, numberof(args_to_new_ary) == (n)); \
|
|
|
|
} \
|
|
|
|
rb_ary_new_from_values(numberof(args_to_new_ary), args_to_new_ary); \
|
|
|
|
})
|
|
|
|
#endif
|
2011-06-18 04:26:19 -04:00
|
|
|
|
2018-02-12 10:25:58 -05:00
|
|
|
static inline VALUE
|
|
|
|
rb_ary_entry_internal(VALUE ary, long offset)
|
|
|
|
{
|
|
|
|
long len = RARRAY_LEN(ary);
|
2018-10-30 17:53:56 -04:00
|
|
|
const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
|
2018-02-12 10:25:58 -05:00
|
|
|
if (len == 0) return Qnil;
|
|
|
|
if (offset < 0) {
|
|
|
|
offset += len;
|
|
|
|
if (offset < 0) return Qnil;
|
|
|
|
}
|
|
|
|
else if (len <= offset) {
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
return ptr[offset];
|
|
|
|
}
|
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* bignum.c */
|
2014-11-18 10:13:05 -05:00
|
|
|
extern const char ruby_digitmap[];
|
2016-11-11 10:55:30 -05:00
|
|
|
double rb_big_fdiv_double(VALUE x, VALUE y);
|
2011-05-29 02:09:08 -04:00
|
|
|
VALUE rb_big_uminus(VALUE x);
|
2016-03-18 09:33:42 -04:00
|
|
|
VALUE rb_big_hash(VALUE);
|
2016-03-19 12:08:52 -04:00
|
|
|
VALUE rb_big_odd_p(VALUE);
|
|
|
|
VALUE rb_big_even_p(VALUE);
|
2016-04-13 01:12:01 -04:00
|
|
|
size_t rb_big_size(VALUE);
|
2012-07-16 05:41:25 -04:00
|
|
|
VALUE rb_integer_float_cmp(VALUE x, VALUE y);
|
2012-07-16 06:39:42 -04:00
|
|
|
VALUE rb_integer_float_eq(VALUE x, VALUE y);
|
2016-04-08 13:05:12 -04:00
|
|
|
VALUE rb_cstr_parse_inum(const char *str, ssize_t len, char **endp, int base);
|
2018-03-15 03:19:43 -04:00
|
|
|
VALUE rb_str_convert_to_inum(VALUE str, int base, int badcheck, int raise_exception);
|
2016-04-29 23:30:53 -04:00
|
|
|
VALUE rb_big_comp(VALUE x);
|
2016-04-27 07:56:03 -04:00
|
|
|
VALUE rb_big_aref(VALUE x, VALUE y);
|
2016-04-26 06:59:27 -04:00
|
|
|
VALUE rb_big_abs(VALUE x);
|
2016-04-26 07:47:14 -04:00
|
|
|
VALUE rb_big_size_m(VALUE big);
|
2016-04-26 07:17:37 -04:00
|
|
|
VALUE rb_big_bit_length(VALUE big);
|
2016-04-30 04:27:30 -04:00
|
|
|
VALUE rb_big_remainder(VALUE x, VALUE y);
|
2016-04-30 06:42:06 -04:00
|
|
|
VALUE rb_big_gt(VALUE x, VALUE y);
|
2016-04-30 06:26:17 -04:00
|
|
|
VALUE rb_big_ge(VALUE x, VALUE y);
|
2016-04-30 06:10:23 -04:00
|
|
|
VALUE rb_big_lt(VALUE x, VALUE y);
|
2016-04-30 05:48:25 -04:00
|
|
|
VALUE rb_big_le(VALUE x, VALUE y);
|
2017-12-03 21:35:40 -05:00
|
|
|
VALUE rb_int_powm(int const argc, VALUE * const argv, VALUE const num);
|
2011-05-29 02:09:08 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* class.c */
|
2016-03-06 23:28:32 -05:00
|
|
|
VALUE rb_class_boot(VALUE);
|
|
|
|
VALUE rb_class_inherited(VALUE, VALUE);
|
|
|
|
VALUE rb_make_metaclass(VALUE, VALUE);
|
|
|
|
VALUE rb_include_class_new(VALUE, VALUE);
|
2015-01-19 09:09:20 -05:00
|
|
|
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
void rb_class_detach_subclasses(VALUE);
|
|
|
|
void rb_class_detach_module_subclasses(VALUE);
|
|
|
|
void rb_class_remove_from_module_subclasses(VALUE);
|
2014-06-18 02:16:39 -04:00
|
|
|
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
|
|
|
|
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
|
|
|
|
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
|
|
|
|
VALUE rb_obj_public_methods(int argc, const VALUE *argv, VALUE obj);
|
2012-08-06 11:31:13 -04:00
|
|
|
VALUE rb_special_singleton_class(VALUE);
|
2012-12-28 21:37:47 -05:00
|
|
|
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach);
|
2013-05-13 01:50:38 -04:00
|
|
|
VALUE rb_singleton_class_get(VALUE obj);
|
2011-06-18 00:41:53 -04:00
|
|
|
void Init_class_hierarchy(void);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2015-05-31 15:17:18 -04:00
|
|
|
int rb_class_has_methods(VALUE c);
|
2016-10-23 21:49:52 -04:00
|
|
|
void rb_undef_methods_from(VALUE klass, VALUE super);
|
2015-05-31 15:17:18 -04:00
|
|
|
|
2013-02-17 06:55:50 -05:00
|
|
|
/* compar.c */
|
|
|
|
VALUE rb_invcmp(VALUE, VALUE);
|
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* compile.c */
|
2016-07-28 07:02:30 -04:00
|
|
|
struct rb_block;
|
|
|
|
int rb_dvar_defined(ID, const struct rb_block *);
|
|
|
|
int rb_local_defined(ID, const struct rb_block *);
|
2017-12-18 04:03:59 -05:00
|
|
|
const char * rb_insns_name(int i);
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
VALUE rb_insns_name_array(void);
|
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 06:22:28 -05:00
|
|
|
int rb_vm_insn_addr2insn(const void *);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2016-05-04 10:12:10 -04:00
|
|
|
/* complex.c */
|
2016-07-12 09:17:04 -04:00
|
|
|
VALUE rb_complex_plus(VALUE, VALUE);
|
|
|
|
VALUE rb_complex_mul(VALUE, VALUE);
|
2016-07-12 10:13:46 -04:00
|
|
|
VALUE rb_complex_abs(VALUE x);
|
|
|
|
VALUE rb_complex_sqrt(VALUE x);
|
2018-11-03 20:22:13 -04:00
|
|
|
VALUE rb_dbl_complex_polar_pi(double abs, double ang);
|
2018-10-19 22:49:18 -04:00
|
|
|
VALUE rb_complex_pow(VALUE self, VALUE other);
|
2016-05-04 10:12:10 -04:00
|
|
|
|
2018-11-06 05:19:55 -05:00
|
|
|
struct rb_thread_struct;
|
2012-02-15 09:00:11 -05:00
|
|
|
/* cont.c */
|
|
|
|
VALUE rb_obj_is_fiber(VALUE);
|
2018-11-06 05:19:55 -05:00
|
|
|
void rb_fiber_reset_root_local_storage(struct rb_thread_struct *);
|
2013-11-15 12:15:31 -05:00
|
|
|
void ruby_register_rollback_func_for_ensure(VALUE (*ensure_func)(ANYARGS), VALUE (*rollback_func)(ANYARGS));
|
2012-02-15 09:00:11 -05:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* debug.c */
|
|
|
|
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
|
|
|
|
2017-06-07 21:58:44 -04:00
|
|
|
/* dir.c */
|
|
|
|
VALUE rb_dir_getwd_ospath(void);
|
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* dmyext.c */
|
2014-11-18 10:13:05 -05:00
|
|
|
void Init_enc(void);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void Init_ext(void);
|
|
|
|
|
|
|
|
/* encoding.c */
|
2013-07-02 04:22:15 -04:00
|
|
|
ID rb_id_encoding(void);
|
2018-01-09 01:24:11 -05:00
|
|
|
#ifdef RUBY_ENCODING_H
|
2014-11-18 10:13:05 -05:00
|
|
|
rb_encoding *rb_enc_get_from_index(int index);
|
2015-10-29 05:10:32 -04:00
|
|
|
rb_encoding *rb_enc_check_str(VALUE str1, VALUE str2);
|
2018-01-09 01:24:11 -05:00
|
|
|
#endif
|
2014-11-18 10:13:05 -05:00
|
|
|
int rb_encdb_replicate(const char *alias, const char *orig);
|
|
|
|
int rb_encdb_alias(const char *alias, const char *orig);
|
|
|
|
int rb_encdb_dummy(const char *name);
|
|
|
|
void rb_encdb_declare(const char *name);
|
|
|
|
void rb_enc_set_base(const char *name, const char *orig);
|
|
|
|
int rb_enc_set_dummy(int index);
|
|
|
|
void rb_encdb_set_unicode(int index);
|
2016-05-08 13:44:51 -04:00
|
|
|
PUREFUNC(int rb_data_is_encoding(VALUE obj));
|
2014-11-18 10:13:05 -05:00
|
|
|
|
|
|
|
/* enum.c */
|
|
|
|
VALUE rb_f_send(int argc, VALUE *argv, VALUE recv);
|
2016-03-17 08:37:20 -04:00
|
|
|
VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
/* error.c */
|
2014-11-18 10:13:05 -05:00
|
|
|
extern VALUE rb_eEAGAIN;
|
|
|
|
extern VALUE rb_eEWOULDBLOCK;
|
|
|
|
extern VALUE rb_eEINPROGRESS;
|
2016-04-19 00:46:20 -04:00
|
|
|
void rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args);
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
VALUE rb_check_backtrace(VALUE);
|
2011-06-28 17:17:29 -04:00
|
|
|
NORETURN(void rb_async_bug_errno(const char *,int));
|
2012-06-28 22:26:46 -04:00
|
|
|
const char *rb_builtin_type_name(int t);
|
2012-11-11 01:38:17 -05:00
|
|
|
const char *rb_builtin_class_name(VALUE x);
|
2017-03-27 09:15:48 -04:00
|
|
|
PRINTF_ARGS(void rb_sys_warn(const char *fmt, ...), 1, 2);
|
|
|
|
PRINTF_ARGS(void rb_syserr_warn(int err, const char *fmt, ...), 2, 3);
|
2018-01-09 01:24:11 -05:00
|
|
|
PRINTF_ARGS(void rb_sys_warning(const char *fmt, ...), 1, 2);
|
|
|
|
PRINTF_ARGS(void rb_syserr_warning(int err, const char *fmt, ...), 2, 3);
|
|
|
|
#ifdef RUBY_ENCODING_H
|
|
|
|
VALUE rb_syntax_error_append(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
|
2015-02-06 03:37:24 -05:00
|
|
|
PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
2017-03-27 09:15:48 -04:00
|
|
|
PRINTF_ARGS(void rb_sys_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
|
|
|
PRINTF_ARGS(void rb_syserr_enc_warn(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
|
2015-02-06 03:37:24 -05:00
|
|
|
PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
|
|
|
PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3);
|
2017-03-27 09:15:48 -04:00
|
|
|
PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fmt, ...), 3, 4);
|
2018-01-09 01:24:11 -05:00
|
|
|
#endif
|
2017-03-27 09:15:48 -04:00
|
|
|
|
2017-05-02 03:35:20 -04:00
|
|
|
#define rb_raise_cstr(etype, mesg) \
|
|
|
|
rb_exc_raise(rb_exc_new_str(etype, rb_str_new_cstr(mesg)))
|
|
|
|
#define rb_raise_static(etype, mesg) \
|
|
|
|
rb_exc_raise(rb_exc_new_str(etype, rb_str_new_static(mesg, rb_strlen_lit(mesg))))
|
|
|
|
|
2015-10-28 02:23:16 -04:00
|
|
|
VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method);
|
|
|
|
#define rb_name_err_raise_str(mesg, recv, name) \
|
|
|
|
rb_exc_raise(rb_name_err_new(mesg, recv, name))
|
|
|
|
#define rb_name_err_raise(mesg, recv, name) \
|
|
|
|
rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name))
|
2018-04-11 23:48:48 -04:00
|
|
|
VALUE rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv);
|
2017-09-18 04:05:53 -04:00
|
|
|
VALUE rb_key_err_new(VALUE mesg, VALUE recv, VALUE name);
|
|
|
|
#define rb_key_err_raise(mesg, recv, name) \
|
|
|
|
rb_exc_raise(rb_key_err_new(mesg, recv, name))
|
2017-02-17 00:45:44 -05:00
|
|
|
NORETURN(void ruby_deprecated_internal_feature(const char *));
|
|
|
|
#define DEPRECATED_INTERNAL_FEATURE(func) \
|
|
|
|
(ruby_deprecated_internal_feature(func), UNREACHABLE)
|
2017-04-25 04:17:24 -04:00
|
|
|
VALUE rb_warning_warn(VALUE mod, VALUE str);
|
2018-07-03 21:26:36 -04:00
|
|
|
PRINTF_ARGS(VALUE rb_warning_string(const char *fmt, ...), 1, 2);
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
|
* revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
definition, so ci->me is set to a method entry allocated in the
stack, and it causes SEGV/ILL. In this commit, a method entry
with VM_METHOD_TYPE_REFINED holds the whole original method entry.
Furthermore, rb_thread_mark() is changed to mark cfp->klass to
avoid GC for iclasses created by copy_refinement_iclass().
* vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
the target module is a refinement. When a method entry with
VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
the same name is searched in refinements. If such a method is
found, the method is invoked. Otherwise, the original method in
the refined class (rb_method_definition_t::body.orig_me) is
invoked. This change is made to simplify the normal method lookup
and to improve the performance of normal method calls.
* vm_method.c (EXPR1, search_method, rb_method_entry),
vm_eval.c (rb_call0, rb_search_method_entry): do not use
refinements for method lookup.
* vm_insnhelper.c (vm_call_method): search methods in refinements if
ci->me is VM_METHOD_TYPE_REFINED. If the method is called by
super (i.e., ci->call == vm_call_super_method), skip the same
method entry as the current method to avoid infinite call of the
same method.
* class.c (include_modules_at): add a refined method entry for each
method defined in a module included in a refinement.
* class.c (rb_prepend_module): set an empty table to
RCLASS_M_TBL(klass) to add refined method entries, because
refinements should have priority over prepended modules.
* proc.c (mnew): use rb_method_entry_with_refinements() to get
a refined method.
* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
copy_refinement_iclass().
* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.
* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
the test because it should pass successfully.
* test/ruby/test_refinement.rb (test_redefine_refined_method): new
test for the case a refined method is redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 08:08:41 -05:00
|
|
|
/* eval.c */
|
|
|
|
VALUE rb_refinement_module_get_refined_class(VALUE module);
|
2018-01-18 04:44:36 -05:00
|
|
|
extern ID ruby_static_id_signo, ruby_static_id_status;
|
2018-07-27 09:57:14 -04:00
|
|
|
void rb_class_modify_check(VALUE);
|
2018-01-18 04:44:36 -05:00
|
|
|
#define id_signo ruby_static_id_signo
|
|
|
|
#define id_status ruby_static_id_status
|
* revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
definition, so ci->me is set to a method entry allocated in the
stack, and it causes SEGV/ILL. In this commit, a method entry
with VM_METHOD_TYPE_REFINED holds the whole original method entry.
Furthermore, rb_thread_mark() is changed to mark cfp->klass to
avoid GC for iclasses created by copy_refinement_iclass().
* vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
the target module is a refinement. When a method entry with
VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
the same name is searched in refinements. If such a method is
found, the method is invoked. Otherwise, the original method in
the refined class (rb_method_definition_t::body.orig_me) is
invoked. This change is made to simplify the normal method lookup
and to improve the performance of normal method calls.
* vm_method.c (EXPR1, search_method, rb_method_entry),
vm_eval.c (rb_call0, rb_search_method_entry): do not use
refinements for method lookup.
* vm_insnhelper.c (vm_call_method): search methods in refinements if
ci->me is VM_METHOD_TYPE_REFINED. If the method is called by
super (i.e., ci->call == vm_call_super_method), skip the same
method entry as the current method to avoid infinite call of the
same method.
* class.c (include_modules_at): add a refined method entry for each
method defined in a module included in a refinement.
* class.c (rb_prepend_module): set an empty table to
RCLASS_M_TBL(klass) to add refined method entries, because
refinements should have priority over prepended modules.
* proc.c (mnew): use rb_method_entry_with_refinements() to get
a refined method.
* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
copy_refinement_iclass().
* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.
* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
the test because it should pass successfully.
* test/ruby/test_refinement.rb (test_redefine_refined_method): new
test for the case a refined method is redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 08:08:41 -05:00
|
|
|
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
/* eval_error.c */
|
|
|
|
VALUE rb_get_backtrace(VALUE info);
|
|
|
|
|
|
|
|
/* eval_jump.c */
|
|
|
|
void rb_call_end_proc(VALUE data);
|
2012-07-19 01:30:46 -04:00
|
|
|
void rb_mark_end_proc(void);
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* file.c */
|
2018-02-08 03:09:49 -05:00
|
|
|
extern const char ruby_null_device[];
|
2013-07-25 00:06:50 -04:00
|
|
|
VALUE rb_home_dir_of(VALUE user, VALUE result);
|
|
|
|
VALUE rb_default_home_dir(VALUE result);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict);
|
2017-09-21 03:29:16 -04:00
|
|
|
VALUE rb_check_realpath(VALUE basedir, VALUE path);
|
2012-03-01 02:13:22 -05:00
|
|
|
void rb_file_const(const char*, VALUE);
|
|
|
|
int rb_file_load_ok(const char *);
|
2012-08-23 23:44:56 -04:00
|
|
|
VALUE rb_file_expand_path_fast(VALUE, VALUE);
|
|
|
|
VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE);
|
2012-11-05 10:27:08 -05:00
|
|
|
VALUE rb_get_path_check_to_string(VALUE, int);
|
|
|
|
VALUE rb_get_path_check_convert(VALUE, VALUE, int);
|
2017-06-01 09:05:54 -04:00
|
|
|
VALUE rb_get_path_check(VALUE, int);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void Init_File(void);
|
2015-10-17 17:09:10 -04:00
|
|
|
int ruby_is_fd_loadable(int fd);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2013-03-15 01:51:37 -04:00
|
|
|
#ifdef RUBY_FUNCTION_NAME_STRING
|
2013-03-15 02:08:13 -04:00
|
|
|
# if defined __GNUC__ && __GNUC__ >= 4
|
|
|
|
# pragma GCC visibility push(default)
|
|
|
|
# endif
|
2013-03-15 07:19:56 -04:00
|
|
|
NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path));
|
2013-10-20 02:29:06 -04:00
|
|
|
NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path));
|
2013-03-15 02:08:13 -04:00
|
|
|
# if defined __GNUC__ && __GNUC__ >= 4
|
|
|
|
# pragma GCC visibility pop
|
|
|
|
# endif
|
2013-03-15 07:19:56 -04:00
|
|
|
# define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
|
2013-10-20 02:29:06 -04:00
|
|
|
# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
|
2013-03-15 01:51:37 -04:00
|
|
|
#else
|
|
|
|
# define rb_sys_fail_path(path) rb_sys_fail_str(path)
|
2013-10-21 22:03:49 -04:00
|
|
|
# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
|
2013-03-15 01:51:37 -04:00
|
|
|
#endif
|
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* gc.c */
|
2014-11-18 09:58:03 -05:00
|
|
|
extern VALUE *ruby_initial_gc_stress_ptr;
|
2014-11-18 10:13:05 -05:00
|
|
|
extern int ruby_disable_gc;
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void Init_heap(void);
|
2012-01-09 22:49:10 -05:00
|
|
|
void *ruby_mimmalloc(size_t size);
|
2013-11-21 20:38:08 -05:00
|
|
|
void ruby_mimfree(void *ptr);
|
2013-05-26 20:21:02 -04:00
|
|
|
void rb_objspace_set_event_hook(const rb_event_flag_t event);
|
2014-09-08 00:11:00 -04:00
|
|
|
#if USE_RGENGC
|
|
|
|
void rb_gc_writebarrier_remember(VALUE obj);
|
|
|
|
#else
|
|
|
|
#define rb_gc_writebarrier_remember(obj) 0
|
|
|
|
#endif
|
2013-12-04 19:19:13 -05:00
|
|
|
void ruby_gc_set_params(int safe_level);
|
2014-11-18 10:13:05 -05:00
|
|
|
void rb_copy_wb_protected_attribute(VALUE dest, VALUE obj);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2013-12-03 09:48:20 -05:00
|
|
|
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
|
2013-11-24 20:13:31 -05:00
|
|
|
#define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size)
|
2013-12-10 02:16:06 -05:00
|
|
|
#define ruby_sized_xrealloc2(ptr, new_count, element_size, old_count) ruby_xrealloc(ptr, new_count, element_size)
|
2013-11-24 20:13:31 -05:00
|
|
|
#define ruby_sized_xfree(ptr, size) ruby_xfree(ptr)
|
|
|
|
#define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)
|
|
|
|
#else
|
2018-05-23 01:51:43 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2013-10-22 08:59:27 -04:00
|
|
|
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_ALLOC_SIZE((2));
|
2013-12-13 10:44:13 -05:00
|
|
|
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_ALLOC_SIZE((2, 3));
|
2013-10-17 04:41:23 -04:00
|
|
|
void ruby_sized_xfree(void *x, size_t size);
|
2018-05-23 01:51:43 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2013-10-17 04:41:23 -04:00
|
|
|
#define SIZED_REALLOC_N(var,type,n,old_n) ((var)=(type*)ruby_sized_xrealloc((char*)(var), (n) * sizeof(type), (old_n) * sizeof(type)))
|
2013-11-24 20:13:31 -05:00
|
|
|
#endif
|
2013-10-17 03:57:03 -04:00
|
|
|
|
2015-10-29 03:26:44 -04:00
|
|
|
/* optimized version of NEWOBJ() */
|
|
|
|
#undef NEWOBJF_OF
|
|
|
|
#undef RB_NEWOBJ_OF
|
|
|
|
#define RB_NEWOBJ_OF(obj,type,klass,flags) \
|
|
|
|
type *(obj) = (type*)(((flags) & FL_WB_PROTECTED) ? \
|
|
|
|
rb_wb_protected_newobj_of(klass, (flags) & ~FL_WB_PROTECTED) : \
|
|
|
|
rb_wb_unprotected_newobj_of(klass, flags))
|
|
|
|
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
|
|
|
|
|
2018-10-30 17:53:56 -04:00
|
|
|
void *rb_aligned_malloc(size_t, size_t);
|
|
|
|
void rb_aligned_free(void *);
|
|
|
|
|
2013-05-26 12:19:04 -04:00
|
|
|
/* hash.c */
|
2018-10-30 18:11:51 -04:00
|
|
|
#if RHASH_CONVERT_TABLE_DEBUG
|
|
|
|
struct st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
|
|
|
|
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
|
|
|
|
#else
|
2013-05-26 12:19:04 -04:00
|
|
|
struct st_table *rb_hash_tbl_raw(VALUE hash);
|
2018-10-30 18:11:51 -04:00
|
|
|
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h)
|
|
|
|
#endif
|
|
|
|
|
2017-09-05 00:48:19 -04:00
|
|
|
VALUE rb_hash_new_with_size(st_index_t size);
|
2017-12-05 02:16:42 -05:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
|
|
|
VALUE rb_hash_new_compare_by_id(void);
|
|
|
|
RUBY_SYMBOL_EXPORT_END
|
* rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
[Feature #10440] (Details are described in this ticket)
Most of complex part is moved to vm_args.c.
Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
* introduce rb_call_info_kw_arg_t to represent keyword arguments.
* add rb_call_info_t::kw_arg.
* rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
* rename rb_iseq_t::arg_keywords to arg_keyword_num.
* rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
to represent keyword bitmap parameter index.
This bitmap parameter shows that which keyword parameters are given
or not given (0 for given).
It is refered by `checkkeyword' instruction described bellow.
* rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
to represent keyword rest parameter index.
* add rb_iseq_t::arg_keyword_default_values to represent default
keyword values.
* rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
to represent
(ci->flag & (SPLAT|BLOCKARG)) &&
ci->blockiseq == NULL &&
ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
* rewrite splat argument code.
* rewrite keyword arguments/parameters code.
* merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
not. If Hash object and all keys are Symbol literals, they are
compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
This instruction check the availability of corresponding keyword.
For example, a method "def foo k1: 'v1'; end" is cimpiled to the
following instructions.
0000 checkkeyword 2, 0 # check k1 is given.
0003 branchif 9 # if given, jump to address #9
0005 putstring "v1"
0007 setlocal_OP__WC__0 3 # k1 = 'v1'
0009 trace 8
0011 putnil
0012 trace 16
0014 leave
* insns.def (opt_send_simple): removed and add new instruction
"opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
has parameter variables "k1, kr1, k2, &b, internal_id, krest",
but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
(locate a block variable at last)
* parse.y (vtable_pop): added.
This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 13:02:55 -05:00
|
|
|
VALUE rb_hash_has_key(VALUE hash, VALUE key);
|
2015-11-11 04:30:31 -05:00
|
|
|
VALUE rb_hash_default_value(VALUE hash, VALUE key);
|
2014-11-14 02:29:33 -05:00
|
|
|
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
|
2014-11-18 10:13:05 -05:00
|
|
|
long rb_objid_hash(st_index_t index);
|
2016-11-06 19:45:00 -05:00
|
|
|
long rb_dbl_long_hash(double d);
|
2015-01-23 06:01:02 -05:00
|
|
|
st_table *rb_init_identtable(void);
|
|
|
|
st_table *rb_init_identtable_with_size(st_index_t size);
|
2017-01-07 06:31:53 -05:00
|
|
|
VALUE rb_hash_compare_by_id_p(VALUE hash);
|
2017-10-26 03:23:23 -04:00
|
|
|
VALUE rb_to_hash_type(VALUE obj);
|
2017-12-29 19:00:23 -05:00
|
|
|
VALUE rb_hash_key_str(VALUE);
|
2014-05-07 00:26:53 -04:00
|
|
|
VALUE rb_hash_keys(VALUE hash);
|
2013-10-08 03:11:15 -04:00
|
|
|
VALUE rb_hash_values(VALUE hash);
|
2015-12-10 21:38:20 -05:00
|
|
|
VALUE rb_hash_rehash(VALUE hash);
|
2016-07-20 04:35:25 -04:00
|
|
|
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val);
|
2018-09-20 11:06:56 -04:00
|
|
|
VALUE rb_hash_set_pair(VALUE hash, VALUE pair);
|
2018-10-30 18:11:51 -04:00
|
|
|
void rb_hash_bulk_insert(long, const VALUE *, VALUE);
|
|
|
|
|
|
|
|
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
|
|
|
|
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
|
|
|
|
int rb_hash_stlike_foreach(VALUE hash, int (*func)(ANYARGS), st_data_t arg);
|
|
|
|
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func func, st_data_t arg);
|
2013-05-26 12:19:04 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* inits.c */
|
|
|
|
void rb_call_inits(void);
|
|
|
|
|
|
|
|
/* io.c */
|
|
|
|
const char *ruby_get_inplace_mode(void);
|
|
|
|
void ruby_set_inplace_mode(const char *);
|
|
|
|
ssize_t rb_io_bufread(VALUE io, void *buf, size_t size);
|
|
|
|
void rb_stdio_set_default_encoding(void);
|
2013-08-15 07:53:41 -04:00
|
|
|
VALUE rb_io_flush_raw(VALUE, int);
|
2018-01-09 01:24:10 -05:00
|
|
|
#ifdef RUBY_IO_H
|
2014-11-18 10:13:05 -05:00
|
|
|
size_t rb_io_memsize(const rb_io_t *);
|
2018-01-09 01:24:10 -05:00
|
|
|
#endif
|
2017-02-22 03:50:25 -05:00
|
|
|
int rb_stderr_tty_p(void);
|
2018-05-04 11:03:37 -04:00
|
|
|
void rb_io_fptr_finalize_internal(void *ptr);
|
|
|
|
#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* load.c */
|
|
|
|
VALUE rb_get_load_path(void);
|
2012-11-05 10:27:08 -05:00
|
|
|
VALUE rb_get_expanded_load_path(void);
|
2014-12-03 03:13:26 -05:00
|
|
|
int rb_require_internal(VALUE fname, int safe);
|
2012-03-07 02:30:31 -05:00
|
|
|
NORETURN(void rb_load_fail(VALUE, const char*));
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2014-11-18 10:13:05 -05:00
|
|
|
/* loadpath.c */
|
|
|
|
extern const char ruby_exec_prefix[];
|
|
|
|
extern const char ruby_initial_load_paths[];
|
|
|
|
|
|
|
|
/* localeinit.c */
|
|
|
|
int Init_enc_set_filesystem_encoding(void);
|
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* math.c */
|
2011-07-09 06:50:51 -04:00
|
|
|
VALUE rb_math_atan2(VALUE, VALUE);
|
|
|
|
VALUE rb_math_cos(VALUE);
|
|
|
|
VALUE rb_math_cosh(VALUE);
|
|
|
|
VALUE rb_math_exp(VALUE);
|
|
|
|
VALUE rb_math_hypot(VALUE, VALUE);
|
2014-06-18 02:16:39 -04:00
|
|
|
VALUE rb_math_log(int argc, const VALUE *argv);
|
2011-07-09 06:50:51 -04:00
|
|
|
VALUE rb_math_sin(VALUE);
|
|
|
|
VALUE rb_math_sinh(VALUE);
|
|
|
|
VALUE rb_math_sqrt(VALUE);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2018-08-09 07:31:41 -04:00
|
|
|
/* mjit.c */
|
2018-10-20 02:53:00 -04:00
|
|
|
|
|
|
|
#if USE_MJIT
|
2018-08-09 07:31:41 -04:00
|
|
|
extern int mjit_enabled;
|
2018-08-09 07:39:07 -04:00
|
|
|
VALUE mjit_pause(int wait_p);
|
2018-08-09 07:31:41 -04:00
|
|
|
VALUE mjit_resume(void);
|
2018-10-20 02:53:00 -04:00
|
|
|
#else
|
|
|
|
#define mjit_enabled 0
|
|
|
|
static inline VALUE mjit_pause(int wait_p){ return Qnil; } /* unreachable */
|
|
|
|
static inline VALUE mjit_resume(void){ return Qnil; } /* unreachable */
|
|
|
|
#endif
|
2018-08-09 07:31:41 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* newline.c */
|
|
|
|
void Init_newline(void);
|
|
|
|
|
|
|
|
/* numeric.c */
|
2016-11-11 09:39:25 -05:00
|
|
|
|
2016-11-12 01:07:24 -05:00
|
|
|
#define FIXNUM_POSITIVE_P(num) ((SIGNED_VALUE)(num) > (SIGNED_VALUE)INT2FIX(0))
|
2016-11-11 09:39:25 -05:00
|
|
|
#define FIXNUM_NEGATIVE_P(num) ((SIGNED_VALUE)(num) < 0)
|
|
|
|
#define FIXNUM_ZERO_P(num) ((num) == INT2FIX(0))
|
|
|
|
|
2016-11-15 23:25:35 -05:00
|
|
|
#define INT_NEGATIVE_P(x) (FIXNUM_P(x) ? FIXNUM_NEGATIVE_P(x) : BIGNUM_NEGATIVE_P(x))
|
|
|
|
|
2016-11-05 05:49:39 -04:00
|
|
|
#ifndef ROUND_DEFAULT
|
2016-12-09 21:36:16 -05:00
|
|
|
# define ROUND_DEFAULT RUBY_NUM_ROUND_HALF_UP
|
2016-11-05 05:49:39 -04:00
|
|
|
#endif
|
|
|
|
enum ruby_num_rounding_mode {
|
|
|
|
RUBY_NUM_ROUND_HALF_UP,
|
|
|
|
RUBY_NUM_ROUND_HALF_EVEN,
|
2016-11-25 01:28:00 -05:00
|
|
|
RUBY_NUM_ROUND_HALF_DOWN,
|
2016-11-05 05:49:39 -04:00
|
|
|
RUBY_NUM_ROUND_DEFAULT = ROUND_DEFAULT
|
|
|
|
};
|
2016-11-25 01:28:00 -05:00
|
|
|
#define ROUND_TO(mode, even, up, down) \
|
2016-11-18 01:29:51 -05:00
|
|
|
((mode) == RUBY_NUM_ROUND_HALF_EVEN ? even : \
|
2016-11-25 01:28:00 -05:00
|
|
|
(mode) == RUBY_NUM_ROUND_HALF_UP ? up : down)
|
2016-11-18 01:29:51 -05:00
|
|
|
#define ROUND_FUNC(mode, name) \
|
2016-11-25 01:28:00 -05:00
|
|
|
ROUND_TO(mode, name##_half_even, name##_half_up, name##_half_down)
|
2016-11-18 01:29:51 -05:00
|
|
|
#define ROUND_CALL(mode, name, args) \
|
|
|
|
ROUND_TO(mode, name##_half_even args, \
|
2016-11-25 01:28:00 -05:00
|
|
|
name##_half_up args, name##_half_down args)
|
2016-11-05 05:49:39 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
int rb_num_to_uint(VALUE val, unsigned int *ret);
|
2013-03-06 01:30:03 -05:00
|
|
|
VALUE ruby_num_interval_step_size(VALUE from, VALUE to, VALUE step, int excl);
|
2018-04-19 11:18:50 -04:00
|
|
|
int ruby_float_step(VALUE from, VALUE to, VALUE step, int excl, int allow_endless);
|
2012-03-14 02:10:01 -04:00
|
|
|
double ruby_float_mod(double x, double y);
|
2013-02-21 22:46:47 -05:00
|
|
|
int rb_num_negative_p(VALUE);
|
2013-03-04 20:20:20 -05:00
|
|
|
VALUE rb_int_succ(VALUE num);
|
|
|
|
VALUE rb_int_pred(VALUE num);
|
2016-03-25 21:54:16 -04:00
|
|
|
VALUE rb_int_uminus(VALUE num);
|
2016-11-18 10:17:19 -05:00
|
|
|
VALUE rb_float_uminus(VALUE num);
|
2016-03-25 21:54:16 -04:00
|
|
|
VALUE rb_int_plus(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_minus(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_mul(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_idiv(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_modulo(VALUE x, VALUE y);
|
2016-11-05 05:49:39 -04:00
|
|
|
VALUE rb_int_round(VALUE num, int ndigits, enum ruby_num_rounding_mode mode);
|
2016-03-25 21:55:14 -04:00
|
|
|
VALUE rb_int2str(VALUE num, int base);
|
2015-03-17 23:01:58 -04:00
|
|
|
VALUE rb_dbl_hash(double d);
|
2016-03-17 05:50:19 -04:00
|
|
|
VALUE rb_fix_plus(VALUE x, VALUE y);
|
2016-11-22 00:21:12 -05:00
|
|
|
VALUE rb_int_gt(VALUE x, VALUE y);
|
2017-04-13 03:22:35 -04:00
|
|
|
int rb_float_cmp(VALUE x, VALUE y);
|
2016-11-22 00:21:12 -05:00
|
|
|
VALUE rb_float_gt(VALUE x, VALUE y);
|
2016-05-17 11:08:33 -04:00
|
|
|
VALUE rb_int_ge(VALUE x, VALUE y);
|
2016-11-05 05:49:39 -04:00
|
|
|
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
|
2016-11-11 10:55:30 -05:00
|
|
|
double rb_int_fdiv_double(VALUE x, VALUE y);
|
2016-11-11 11:38:28 -05:00
|
|
|
VALUE rb_int_pow(VALUE x, VALUE y);
|
|
|
|
VALUE rb_float_pow(VALUE x, VALUE y);
|
2016-11-11 20:29:01 -05:00
|
|
|
VALUE rb_int_cmp(VALUE x, VALUE y);
|
2016-11-11 21:24:32 -05:00
|
|
|
VALUE rb_int_equal(VALUE x, VALUE y);
|
rational.c: optimize Rational#{floor,ceil,round,truncate}
* rational.c (f_{expt10,round_common},nurat_{floor,ceil,round_half_{up,even}}):
optimize Rational#{floor,ceil,round,truncate}.
Author: Tadashi Saito <tad.a.digger@gmail.com>
* numeric.c (rb_int_divmod): rename from int_divmod to be exported.
* numeric.c (rb_int_and): rename from int_and to be exported.
* intern.h (rb_int_{divmod,and}): exported.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 01:45:11 -05:00
|
|
|
VALUE rb_int_divmod(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_and(VALUE x, VALUE y);
|
2016-11-12 06:52:00 -05:00
|
|
|
VALUE rb_int_lshift(VALUE x, VALUE y);
|
2016-11-12 10:43:26 -05:00
|
|
|
VALUE rb_int_div(VALUE x, VALUE y);
|
|
|
|
VALUE rb_int_abs(VALUE num);
|
2017-12-03 21:35:40 -05:00
|
|
|
VALUE rb_int_odd_p(VALUE num);
|
2018-06-14 03:09:02 -04:00
|
|
|
int rb_int_positive_p(VALUE num);
|
|
|
|
int rb_int_negative_p(VALUE num);
|
2018-10-19 22:49:18 -04:00
|
|
|
VALUE rb_num_pow(VALUE x, VALUE y);
|
2017-12-03 21:35:40 -05:00
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
rb_num_compare_with_zero(VALUE num, ID mid)
|
|
|
|
{
|
|
|
|
VALUE zero = INT2FIX(0);
|
|
|
|
VALUE r = rb_check_funcall(num, mid, 1, &zero);
|
|
|
|
if (r == Qundef) {
|
|
|
|
rb_cmperr(num, zero);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
rb_num_positive_int_p(VALUE num)
|
|
|
|
{
|
|
|
|
const ID mid = '>';
|
|
|
|
|
|
|
|
if (FIXNUM_P(num)) {
|
|
|
|
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
|
|
|
return FIXNUM_POSITIVE_P(num);
|
|
|
|
}
|
|
|
|
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
|
|
|
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
|
|
|
return BIGNUM_POSITIVE_P(num);
|
|
|
|
}
|
|
|
|
return RTEST(rb_num_compare_with_zero(num, mid));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
rb_num_negative_int_p(VALUE num)
|
|
|
|
{
|
|
|
|
const ID mid = '<';
|
|
|
|
|
|
|
|
if (FIXNUM_P(num)) {
|
|
|
|
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
|
|
|
return FIXNUM_NEGATIVE_P(num);
|
|
|
|
}
|
|
|
|
else if (RB_TYPE_P(num, T_BIGNUM)) {
|
|
|
|
if (rb_method_basic_definition_p(rb_cInteger, mid))
|
|
|
|
return BIGNUM_NEGATIVE_P(num);
|
|
|
|
}
|
|
|
|
return RTEST(rb_num_compare_with_zero(num, mid));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-15 23:25:35 -05:00
|
|
|
VALUE rb_float_abs(VALUE flt);
|
2017-03-06 01:44:11 -05:00
|
|
|
VALUE rb_float_equal(VALUE x, VALUE y);
|
2017-05-25 01:29:35 -04:00
|
|
|
VALUE rb_float_eql(VALUE x, VALUE y);
|
2011-06-09 10:45:56 -04:00
|
|
|
|
2013-09-25 03:58:49 -04:00
|
|
|
#if USE_FLONUM
|
|
|
|
#define RUBY_BIT_ROTL(v, n) (((v) << (n)) | ((v) >> ((sizeof(v) * 8) - n)))
|
|
|
|
#define RUBY_BIT_ROTR(v, n) (((v) >> (n)) | ((v) << ((sizeof(v) * 8) - n)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static inline double
|
2015-08-13 01:36:33 -04:00
|
|
|
rb_float_flonum_value(VALUE v)
|
2013-09-25 03:58:49 -04:00
|
|
|
{
|
|
|
|
#if USE_FLONUM
|
2015-08-13 01:36:33 -04:00
|
|
|
if (v != (VALUE)0x8000000000000002) { /* LIKELY */
|
|
|
|
union {
|
|
|
|
double d;
|
|
|
|
VALUE v;
|
|
|
|
} t;
|
|
|
|
|
|
|
|
VALUE b63 = (v >> 63);
|
|
|
|
/* e: xx1... -> 011... */
|
|
|
|
/* xx0... -> 100... */
|
|
|
|
/* ^b63 */
|
2016-12-22 15:58:55 -05:00
|
|
|
t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~(VALUE)0x03), 3);
|
2015-08-13 01:36:33 -04:00
|
|
|
return t.d;
|
2013-09-25 03:58:49 -04:00
|
|
|
}
|
|
|
|
#endif
|
2015-08-13 01:36:33 -04:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline double
|
|
|
|
rb_float_noflonum_value(VALUE v)
|
|
|
|
{
|
2013-09-25 03:58:49 -04:00
|
|
|
return ((struct RFloat *)v)->float_value;
|
|
|
|
}
|
|
|
|
|
2015-08-13 01:36:33 -04:00
|
|
|
static inline double
|
|
|
|
rb_float_value_inline(VALUE v)
|
|
|
|
{
|
|
|
|
if (FLONUM_P(v)) {
|
|
|
|
return rb_float_flonum_value(v);
|
|
|
|
}
|
|
|
|
return rb_float_noflonum_value(v);
|
|
|
|
}
|
|
|
|
|
2013-09-25 03:58:49 -04:00
|
|
|
static inline VALUE
|
|
|
|
rb_float_new_inline(double d)
|
|
|
|
{
|
|
|
|
#if USE_FLONUM
|
|
|
|
union {
|
|
|
|
double d;
|
|
|
|
VALUE v;
|
|
|
|
} t;
|
|
|
|
int bits;
|
|
|
|
|
|
|
|
t.d = d;
|
|
|
|
bits = (int)((VALUE)(t.v >> 60) & 0x7);
|
|
|
|
/* bits contains 3 bits of b62..b60. */
|
|
|
|
/* bits - 3 = */
|
|
|
|
/* b011 -> b000 */
|
|
|
|
/* b100 -> b001 */
|
|
|
|
|
|
|
|
if (t.v != 0x3000000000000000 /* 1.72723e-77 */ &&
|
|
|
|
!((bits-3) & ~0x01)) {
|
|
|
|
return (RUBY_BIT_ROTL(t.v, 3) & ~(VALUE)0x01) | 0x02;
|
|
|
|
}
|
|
|
|
else if (t.v == (VALUE)0) {
|
|
|
|
/* +0.0 */
|
|
|
|
return 0x8000000000000002;
|
|
|
|
}
|
|
|
|
/* out of range */
|
|
|
|
#endif
|
|
|
|
return rb_float_new_in_heap(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define rb_float_value(v) rb_float_value_inline(v)
|
|
|
|
#define rb_float_new(d) rb_float_new_inline(d)
|
|
|
|
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
/* object.c */
|
2014-06-22 22:33:15 -04:00
|
|
|
void rb_obj_copy_ivar(VALUE dest, VALUE obj);
|
2016-05-08 13:44:51 -04:00
|
|
|
CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
|
|
|
|
CONSTFUNC(VALUE rb_obj_not(VALUE obj));
|
2014-04-14 03:59:42 -04:00
|
|
|
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
|
2015-12-02 02:27:22 -05:00
|
|
|
NORETURN(void rb_undefined_alloc(VALUE klass));
|
2015-08-13 01:36:33 -04:00
|
|
|
double rb_num_to_dbl(VALUE val);
|
2015-11-09 07:27:26 -05:00
|
|
|
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
|
2017-02-21 21:02:11 -05:00
|
|
|
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
|
split insns.def into functions
Contemporary C compilers are good at function inlining. They fold
multiple functions into one. However they are not yet smart enough to
unfold a function into several ones. So generally speaking, it is
wiser for a C programmer to manually split C functions whenever
possible. That should make rooms for compilers to optimize at will.
Before this changeset insns.def was converted into single HUGE
function called vm_exec_core(). By moving each instruction's core
into individual functions, generated C source code is reduced from
3,428 lines to 2,847 lines. Looking at the generated assembly
however, it seems my compiler (gcc 6.2) is extraordinary smart so that
it inlines almost all functions I introduced in this changeset back
into that vm_exec_core. On my machine compiled machine binary of the
function does not shrink very much in size (28,432 bytes to 26,816
bytes, according to nm(1)).
I believe this change is zero-cost. Several benchmarks I exercised
showed no significant difference beyond error mergin. For instance
3 repeated runs of optcarrot benchmark on my machine resulted in:
before this: 28.330329285707490, 27.513378371065920, 29.40420215754537
after this: 27.107195867280414, 25.549324021385907, 30.31581919050884
in fps (greater==faster).
----
* internal.h (rb_obj_not_equal): used from vm_insnhelper.c
* insns.def: move vast majority of lines into vm_insnhelper.c
* vm_insnhelper.c: moved here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18 06:58:49 -04:00
|
|
|
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
|
2017-05-31 08:30:57 -04:00
|
|
|
VALUE rb_convert_type_with_id(VALUE,int,const char*,ID);
|
|
|
|
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:49:11 -04:00
|
|
|
|
|
|
|
struct RBasicRaw {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE klass;
|
|
|
|
};
|
|
|
|
|
2016-08-08 01:11:51 -04:00
|
|
|
#define RBASIC_CLEAR_CLASS(obj) memset(&(((struct RBasicRaw *)((VALUE)(obj)))->klass), 0, sizeof(VALUE))
|
2016-08-08 00:19:58 -04:00
|
|
|
#define RBASIC_SET_CLASS_RAW(obj, cls) memcpy(&((struct RBasicRaw *)((VALUE)(obj)))->klass, &(cls), sizeof(VALUE))
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 14:07:47 -04:00
|
|
|
#define RBASIC_SET_CLASS(obj, cls) do { \
|
|
|
|
VALUE _obj_ = (obj); \
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 03:07:47 -05:00
|
|
|
RB_OBJ_WRITE(_obj_, &((struct RBasicRaw *)(_obj_))->klass, cls); \
|
* gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
you want to access raw pointers. If you modify the contents which
pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
move flag bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 14:07:47 -04:00
|
|
|
} while (0)
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* parse.y */
|
2014-03-26 01:39:22 -04:00
|
|
|
#ifndef USE_SYMBOL_GC
|
|
|
|
#define USE_SYMBOL_GC 1
|
|
|
|
#endif
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
VALUE rb_parser_get_yydebug(VALUE);
|
|
|
|
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
2018-01-15 18:43:17 -05:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2016-07-28 07:02:30 -04:00
|
|
|
VALUE rb_parser_set_context(VALUE, const struct rb_block *, int);
|
2018-01-15 18:43:17 -05:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2016-03-19 01:46:20 -04:00
|
|
|
void *rb_parser_load_file(VALUE parser, VALUE name);
|
2011-07-22 08:06:42 -04:00
|
|
|
int rb_is_const_name(VALUE name);
|
|
|
|
int rb_is_class_name(VALUE name);
|
|
|
|
int rb_is_global_name(VALUE name);
|
|
|
|
int rb_is_instance_name(VALUE name);
|
|
|
|
int rb_is_attrset_name(VALUE name);
|
|
|
|
int rb_is_local_name(VALUE name);
|
|
|
|
int rb_is_method_name(VALUE name);
|
|
|
|
int rb_is_junk_name(VALUE name);
|
2016-05-08 13:44:51 -04:00
|
|
|
PUREFUNC(int rb_is_const_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_class_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_global_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_instance_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_attrset_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_local_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_method_sym(VALUE sym));
|
|
|
|
PUREFUNC(int rb_is_junk_sym(VALUE sym));
|
2014-02-05 06:56:35 -05:00
|
|
|
ID rb_make_internal_id(void);
|
2014-03-26 00:57:47 -04:00
|
|
|
void rb_gc_free_dsymbol(VALUE);
|
2014-07-09 02:14:41 -04:00
|
|
|
ID rb_id_attrget(ID id);
|
|
|
|
|
2011-06-18 04:26:19 -04:00
|
|
|
/* proc.c */
|
|
|
|
VALUE rb_proc_location(VALUE self);
|
2012-02-20 19:13:44 -05:00
|
|
|
st_index_t rb_hash_proc(st_index_t hash, VALUE proc);
|
2013-07-15 00:26:58 -04:00
|
|
|
int rb_block_arity(void);
|
2017-07-18 03:48:37 -04:00
|
|
|
int rb_block_min_max_arity(int *max);
|
2015-11-10 04:24:41 -05:00
|
|
|
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
|
2017-07-18 04:31:02 -04:00
|
|
|
VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
|
2017-08-09 22:58:36 -04:00
|
|
|
VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
|
2011-06-18 04:26:19 -04:00
|
|
|
|
2012-06-04 06:19:32 -04:00
|
|
|
/* process.c */
|
2013-02-20 23:41:39 -05:00
|
|
|
#define RB_MAX_GROUPS (65536)
|
2012-06-04 06:19:32 -04:00
|
|
|
|
2018-10-29 21:34:48 -04:00
|
|
|
struct waitpid_state;
|
2012-06-20 07:46:50 -04:00
|
|
|
struct rb_execarg {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
VALUE shell_script;
|
|
|
|
} sh;
|
|
|
|
struct {
|
|
|
|
VALUE command_name;
|
|
|
|
VALUE command_abspath; /* full path string or nil */
|
|
|
|
VALUE argv_str;
|
|
|
|
VALUE argv_buf;
|
|
|
|
} cmd;
|
|
|
|
} invoke;
|
|
|
|
VALUE redirect_fds;
|
|
|
|
VALUE envp_str;
|
|
|
|
VALUE envp_buf;
|
|
|
|
VALUE dup2_tmpbuf;
|
2014-11-22 20:49:57 -05:00
|
|
|
unsigned use_shell : 1;
|
2012-06-22 07:30:29 -04:00
|
|
|
unsigned pgroup_given : 1;
|
2012-06-20 08:27:09 -04:00
|
|
|
unsigned umask_given : 1;
|
2012-06-22 21:43:51 -04:00
|
|
|
unsigned unsetenv_others_given : 1;
|
|
|
|
unsigned unsetenv_others_do : 1;
|
2012-06-23 00:23:03 -04:00
|
|
|
unsigned close_others_given : 1;
|
|
|
|
unsigned close_others_do : 1;
|
2012-06-23 02:23:35 -04:00
|
|
|
unsigned chdir_given : 1;
|
2012-06-23 10:21:47 -04:00
|
|
|
unsigned new_pgroup_given : 1;
|
|
|
|
unsigned new_pgroup_flag : 1;
|
2012-10-09 04:13:29 -04:00
|
|
|
unsigned uid_given : 1;
|
|
|
|
unsigned gid_given : 1;
|
2018-01-24 09:11:25 -05:00
|
|
|
unsigned exception : 1;
|
2018-10-29 21:34:48 -04:00
|
|
|
struct waitpid_state *waitpid_state; /* for async process management */
|
2012-06-24 22:35:29 -04:00
|
|
|
rb_pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */
|
2012-06-23 03:30:26 -04:00
|
|
|
VALUE rlimit_limits; /* Qfalse or [[rtype, softlim, hardlim], ...] */
|
2012-06-20 08:27:09 -04:00
|
|
|
mode_t umask_mask;
|
2012-10-09 04:13:29 -04:00
|
|
|
rb_uid_t uid;
|
|
|
|
rb_gid_t gid;
|
2014-11-22 20:49:57 -05:00
|
|
|
int close_others_maxhint;
|
2012-06-23 07:35:32 -04:00
|
|
|
VALUE fd_dup2;
|
|
|
|
VALUE fd_close;
|
|
|
|
VALUE fd_open;
|
|
|
|
VALUE fd_dup2_child;
|
2012-06-23 04:18:34 -04:00
|
|
|
VALUE env_modification; /* Qfalse or [[k1,v1], ...] */
|
2016-11-05 20:58:49 -04:00
|
|
|
VALUE path_env;
|
2012-06-23 02:23:35 -04:00
|
|
|
VALUE chdir_dir;
|
2012-06-20 07:46:50 -04:00
|
|
|
};
|
|
|
|
|
2012-06-04 07:01:41 -04:00
|
|
|
/* argv_str contains extra two elements.
|
|
|
|
* The beginning one is for /bin/sh used by exec_with_sh.
|
|
|
|
* The last one for terminating NULL used by execve.
|
2012-06-04 06:19:32 -04:00
|
|
|
* See rb_exec_fillarg() in process.c. */
|
2018-05-13 23:30:03 -04:00
|
|
|
#define ARGVSTR2ARGV(argv_str) ((char **)RB_IMEMO_TMPBUF_PTR(argv_str) + 1)
|
|
|
|
|
|
|
|
static inline size_t
|
|
|
|
ARGVSTR2ARGC(VALUE argv_str)
|
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
char *const *p = ARGVSTR2ARGV(argv_str);
|
|
|
|
while (p[i++])
|
|
|
|
;
|
|
|
|
return i - 1;
|
|
|
|
}
|
2012-06-04 06:19:32 -04:00
|
|
|
|
2012-06-10 07:21:07 -04:00
|
|
|
rb_pid_t rb_fork_ruby(int *status);
|
2012-08-29 10:44:08 -04:00
|
|
|
void rb_last_status_clear(void);
|
2012-06-10 07:21:07 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* rational.c */
|
2018-09-01 03:34:31 -04:00
|
|
|
VALUE rb_rational_canonicalize(VALUE x);
|
2016-11-18 10:17:19 -05:00
|
|
|
VALUE rb_rational_uminus(VALUE self);
|
2016-04-15 10:54:39 -04:00
|
|
|
VALUE rb_rational_plus(VALUE self, VALUE other);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
VALUE rb_lcm(VALUE x, VALUE y);
|
2011-07-09 07:06:43 -04:00
|
|
|
VALUE rb_rational_reciprocal(VALUE x);
|
2014-11-18 10:13:05 -05:00
|
|
|
VALUE rb_cstr_to_rat(const char *, int);
|
2016-11-15 23:25:35 -05:00
|
|
|
VALUE rb_rational_abs(VALUE self);
|
2016-11-22 00:21:12 -05:00
|
|
|
VALUE rb_rational_cmp(VALUE self, VALUE other);
|
2018-10-19 22:49:18 -04:00
|
|
|
VALUE rb_rational_pow(VALUE self, VALUE other);
|
2017-05-27 01:41:00 -04:00
|
|
|
VALUE rb_numeric_quo(VALUE x, VALUE y);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* re.c */
|
|
|
|
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline);
|
|
|
|
VALUE rb_reg_check_preprocess(VALUE);
|
2014-03-25 19:52:18 -04:00
|
|
|
long rb_reg_search0(VALUE, VALUE, long, int, int);
|
2016-12-11 21:56:12 -05:00
|
|
|
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos);
|
2017-10-21 02:51:01 -04:00
|
|
|
bool rb_reg_start_with_p(VALUE re, VALUE str);
|
2014-03-27 05:58:12 -04:00
|
|
|
void rb_backref_set_string(VALUE string, long pos, long len);
|
2016-01-14 03:36:49 -05:00
|
|
|
int rb_match_count(VALUE match);
|
|
|
|
int rb_match_nth_defined(int nth, VALUE match);
|
2018-06-26 20:57:16 -04:00
|
|
|
VALUE rb_reg_new_ary(VALUE ary, int options);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* signal.c */
|
2014-11-18 09:58:03 -05:00
|
|
|
extern int ruby_enable_coredump;
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
int rb_get_next_signal(void);
|
|
|
|
|
|
|
|
/* string.c */
|
2013-09-05 00:49:16 -04:00
|
|
|
VALUE rb_fstring(VALUE);
|
2014-06-30 10:59:44 -04:00
|
|
|
VALUE rb_fstring_new(const char *ptr, long len);
|
2015-06-23 23:47:37 -04:00
|
|
|
#define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
|
|
|
|
#define rb_fstring_literal(str) rb_fstring_lit(str)
|
2015-06-23 23:50:56 -04:00
|
|
|
VALUE rb_fstring_cstr(const char *str);
|
2016-05-12 14:12:46 -04:00
|
|
|
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
macros for skipping __extension__ on non-GCC compilers.
* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
__extension__ because __extension__ is a GNU extension.
Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
[Bug #12397] [ruby-dev:49629].
* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
rb_external_str_new_cstr, rb_locale_str_new_cstr,
rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20 08:29:06 -04:00
|
|
|
# define rb_fstring_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
|
2015-06-23 23:50:56 -04:00
|
|
|
(__builtin_constant_p(str)) ? \
|
|
|
|
rb_fstring_new((str), (long)strlen(str)) : \
|
Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
macros for skipping __extension__ on non-GCC compilers.
* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
__extension__ because __extension__ is a GNU extension.
Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
[Bug #12397] [ruby-dev:49629].
* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
rb_external_str_new_cstr, rb_locale_str_new_cstr,
rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20 08:29:06 -04:00
|
|
|
rb_fstring_cstr(str) \
|
|
|
|
)
|
2015-06-23 23:50:56 -04:00
|
|
|
#endif
|
2016-02-04 01:35:34 -05:00
|
|
|
#ifdef RUBY_ENCODING_H
|
|
|
|
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
|
|
|
|
#define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
|
|
|
|
#define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
|
|
|
|
VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
|
2016-05-12 14:12:46 -04:00
|
|
|
# ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
|
Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
macros for skipping __extension__ on non-GCC compilers.
* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
__extension__ because __extension__ is a GNU extension.
Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
[Bug #12397] [ruby-dev:49629].
* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
rb_external_str_new_cstr, rb_locale_str_new_cstr,
rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20 08:29:06 -04:00
|
|
|
# define rb_fstring_enc_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
|
2016-02-04 01:35:34 -05:00
|
|
|
(__builtin_constant_p(str)) ? \
|
|
|
|
rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
|
Use RB_GNUC_EXTENSION_BLOCK instead of __extension__
* include/ruby/defines.h (RB_GNUC_EXTENSION, RB_GNUC_EXTENSION_BLOCK):
macros for skipping __extension__ on non-GCC compilers.
* eval_error.c (warn_print): use RB_GNUC_EXTENSION_BLOCK instead of
__extension__ because __extension__ is a GNU extension.
Fix compile error on Solaris 10 with Oracle Solaris Studio 12.x.
[Bug #12397] [ruby-dev:49629].
* internal.h (rb_fstring_cstr, rb_fstring_enc_cstr): ditto
* include/ruby/encoding.h (rb_enc_str_new, rb_enc_str_new_cstr): ditto
* include/ruby/intern.h (rb_str_new, rb_str_new_cstr,
rb_usascii_str_new, rb_utf8_str_new, rb_tainted_str_new_cstr,
rb_usascii_str_new_cstr, rb_utf8_str_new_cstr,
rb_external_str_new_cstr, rb_locale_str_new_cstr,
rb_str_buf_new_cstr, rb_str_cat_cstr, rb_exc_new_cstr): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-20 08:29:06 -04:00
|
|
|
rb_fstring_enc_cstr(str, enc) \
|
|
|
|
)
|
2016-05-12 14:12:46 -04:00
|
|
|
# endif
|
2016-02-04 01:35:34 -05:00
|
|
|
#endif
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
|
2012-06-09 10:36:17 -04:00
|
|
|
int rb_str_symname_p(VALUE);
|
2012-12-22 10:04:57 -05:00
|
|
|
VALUE rb_str_quote_unprintable(VALUE);
|
|
|
|
VALUE rb_id_quote_unprintable(ID);
|
|
|
|
#define QUOTE(str) rb_str_quote_unprintable(str)
|
|
|
|
#define QUOTE_ID(id) rb_id_quote_unprintable(id)
|
2016-06-10 01:48:38 -04:00
|
|
|
char *rb_str_fill_terminator(VALUE str, const int termlen);
|
2016-07-05 06:45:23 -04:00
|
|
|
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen);
|
2013-07-28 04:49:25 -04:00
|
|
|
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
|
2017-01-30 15:40:18 -05:00
|
|
|
VALUE rb_str_tmp_frozen_acquire(VALUE str);
|
|
|
|
void rb_str_tmp_frozen_release(VALUE str, VALUE tmp);
|
2016-11-05 03:28:09 -04:00
|
|
|
VALUE rb_str_chomp_string(VALUE str, VALUE chomp);
|
2013-08-31 00:30:25 -04:00
|
|
|
#ifdef RUBY_ENCODING_H
|
2014-06-02 16:23:47 -04:00
|
|
|
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc);
|
2015-10-17 00:55:47 -04:00
|
|
|
VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len,
|
|
|
|
rb_encoding *from, int ecflags, VALUE ecopts);
|
2016-05-27 04:09:46 -04:00
|
|
|
VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl);
|
2017-07-29 22:56:29 -04:00
|
|
|
VALUE rb_str_initialize(VALUE str, const char *ptr, long len, rb_encoding *enc);
|
2013-08-31 00:30:25 -04:00
|
|
|
#endif
|
2014-02-04 02:12:49 -05:00
|
|
|
#define STR_NOEMBED FL_USER1
|
|
|
|
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
|
2015-07-22 21:25:49 -04:00
|
|
|
#define STR_EMBED_P(str) (!FL_TEST_RAW((str), STR_NOEMBED))
|
|
|
|
#define STR_SHARED_P(s) FL_ALL_RAW((s), STR_NOEMBED|ELTS_SHARED)
|
2013-11-11 04:39:13 -05:00
|
|
|
#define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
|
|
|
|
#define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
|
2014-11-18 10:13:05 -05:00
|
|
|
size_t rb_str_memsize(VALUE);
|
2016-07-28 07:02:30 -04:00
|
|
|
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc);
|
2015-10-06 02:38:08 -04:00
|
|
|
VALUE rb_sym_to_proc(VALUE sym);
|
2017-01-15 21:43:55 -05:00
|
|
|
char *rb_str_to_cstr(VALUE str);
|
2017-05-25 01:29:35 -04:00
|
|
|
VALUE rb_str_eql(VALUE str1, VALUE str2);
|
2018-06-26 20:57:16 -04:00
|
|
|
VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2015-11-08 02:46:39 -05:00
|
|
|
/* symbol.c */
|
|
|
|
#ifdef RUBY_ENCODING_H
|
2015-11-29 23:44:39 -05:00
|
|
|
VALUE rb_sym_intern(const char *ptr, long len, rb_encoding *enc);
|
|
|
|
VALUE rb_sym_intern_cstr(const char *ptr, rb_encoding *enc);
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define rb_sym_intern_cstr(ptr, enc) __extension__ ( \
|
|
|
|
{ \
|
|
|
|
(__builtin_constant_p(ptr)) ? \
|
|
|
|
rb_sym_intern((ptr), (long)strlen(ptr), (enc)) : \
|
|
|
|
rb_sym_intern_cstr((ptr), (enc)); \
|
|
|
|
})
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
VALUE rb_sym_intern_ascii(const char *ptr, long len);
|
|
|
|
VALUE rb_sym_intern_ascii_cstr(const char *ptr);
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define rb_sym_intern_ascii_cstr(ptr) __extension__ ( \
|
|
|
|
{ \
|
|
|
|
(__builtin_constant_p(ptr)) ? \
|
|
|
|
rb_sym_intern_ascii((ptr), (long)strlen(ptr)) : \
|
|
|
|
rb_sym_intern_ascii_cstr(ptr); \
|
|
|
|
})
|
2015-11-08 02:46:39 -05:00
|
|
|
#endif
|
2017-10-26 03:23:23 -04:00
|
|
|
VALUE rb_to_symbol_type(VALUE obj);
|
2015-11-08 02:46:39 -05:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* struct.c */
|
|
|
|
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
|
2015-11-16 04:21:56 -05:00
|
|
|
VALUE rb_struct_lookup(VALUE s, VALUE idx);
|
2018-01-05 06:44:31 -05:00
|
|
|
VALUE rb_struct_s_keyword_init(VALUE klass);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* time.c */
|
|
|
|
struct timeval rb_time_timeval(VALUE);
|
|
|
|
|
|
|
|
/* thread.c */
|
2017-09-03 10:26:06 -04:00
|
|
|
#define COVERAGE_INDEX_LINES 0
|
|
|
|
#define COVERAGE_INDEX_BRANCHES 1
|
|
|
|
#define COVERAGE_TARGET_LINES 1
|
|
|
|
#define COVERAGE_TARGET_BRANCHES 2
|
|
|
|
#define COVERAGE_TARGET_METHODS 4
|
2018-10-20 01:33:04 -04:00
|
|
|
#define COVERAGE_TARGET_ONESHOT_LINES 8
|
2017-09-03 10:26:06 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
VALUE rb_obj_is_mutex(VALUE obj);
|
2012-08-16 07:41:24 -04:00
|
|
|
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
|
2011-06-09 11:02:46 -04:00
|
|
|
void rb_thread_execute_interrupts(VALUE th);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void rb_clear_trace_func(void);
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
VALUE rb_get_coverages(void);
|
2018-10-20 01:33:04 -04:00
|
|
|
int rb_get_coverage_mode(void);
|
2017-09-03 10:26:06 -04:00
|
|
|
VALUE rb_default_coverage(int);
|
2012-07-05 04:32:23 -04:00
|
|
|
VALUE rb_thread_shield_new(void);
|
|
|
|
VALUE rb_thread_shield_wait(VALUE self);
|
|
|
|
VALUE rb_thread_shield_release(VALUE self);
|
|
|
|
VALUE rb_thread_shield_destroy(VALUE self);
|
2015-09-08 10:09:30 -04:00
|
|
|
int rb_thread_to_be_killed(VALUE thread);
|
2012-11-28 03:30:51 -05:00
|
|
|
void rb_mutex_allow_trap(VALUE self, int val);
|
2012-12-05 14:37:49 -05:00
|
|
|
VALUE rb_uninterruptible(VALUE (*b_proc)(ANYARGS), VALUE data);
|
2012-12-15 00:40:18 -05:00
|
|
|
VALUE rb_mutex_owned_p(VALUE self);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
2014-11-18 10:13:05 -05:00
|
|
|
/* transcode.c */
|
|
|
|
extern VALUE rb_cEncodingConverter;
|
2018-01-09 01:24:11 -05:00
|
|
|
#ifdef RUBY_ENCODING_H
|
2014-11-18 10:13:05 -05:00
|
|
|
size_t rb_econv_memsize(rb_econv_t *);
|
2018-01-09 01:24:11 -05:00
|
|
|
#endif
|
2014-11-18 10:13:05 -05:00
|
|
|
|
|
|
|
/* us_ascii.c */
|
2018-01-09 01:24:11 -05:00
|
|
|
#ifdef RUBY_ENCODING_H
|
2014-11-18 10:13:05 -05:00
|
|
|
extern rb_encoding OnigEncodingUS_ASCII;
|
2018-01-09 01:24:11 -05:00
|
|
|
#endif
|
2014-11-18 10:13:05 -05:00
|
|
|
|
|
|
|
/* util.c */
|
|
|
|
char *ruby_dtoa(double d_, int mode, int ndigits, int *decpt, int *sign, char **rve);
|
|
|
|
char *ruby_hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, char **rve);
|
|
|
|
|
|
|
|
/* utf_8.c */
|
2018-01-09 01:24:11 -05:00
|
|
|
#ifdef RUBY_ENCODING_H
|
2014-11-18 10:13:05 -05:00
|
|
|
extern rb_encoding OnigEncodingUTF_8;
|
2018-01-09 01:24:11 -05:00
|
|
|
#endif
|
2014-11-18 10:13:05 -05:00
|
|
|
|
|
|
|
/* variable.c */
|
2018-11-01 04:53:44 -04:00
|
|
|
#if USE_TRANSIENT_HEAP
|
|
|
|
#define ROBJECT_TRANSIENT_FLAG FL_USER13
|
|
|
|
#define ROBJ_TRANSIENT_P(obj) FL_TEST_RAW((obj), ROBJECT_TRANSIENT_FLAG)
|
|
|
|
#define ROBJ_TRANSIENT_SET(obj) FL_SET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
|
|
|
|
#define ROBJ_TRANSIENT_UNSET(obj) FL_UNSET_RAW((obj), ROBJECT_TRANSIENT_FLAG)
|
|
|
|
#else
|
|
|
|
#define ROBJ_TRANSIENT_P(obj) 0
|
|
|
|
#define ROBJ_TRANSIENT_SET(obj) ((void)0)
|
|
|
|
#define ROBJ_TRANSIENT_UNSET(obj) ((void)0)
|
|
|
|
#endif
|
2016-03-15 00:41:24 -04:00
|
|
|
void rb_gc_mark_global_tbl(void);
|
2014-11-18 10:13:05 -05:00
|
|
|
size_t rb_generic_ivar_memsize(VALUE);
|
2015-02-28 01:42:29 -05:00
|
|
|
VALUE rb_search_class_path(VALUE);
|
2015-05-29 20:20:15 -04:00
|
|
|
VALUE rb_attr_delete(VALUE, ID);
|
2015-10-28 02:36:13 -04:00
|
|
|
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
|
introduce rb_autoload_str to replace rb_autoload
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
2015-12-06 07:28:09 -05:00
|
|
|
void rb_autoload_str(VALUE mod, ID id, VALUE file);
|
2016-09-08 23:02:22 -04:00
|
|
|
void rb_deprecate_constant(VALUE mod, const char *name);
|
2018-02-02 11:02:03 -05:00
|
|
|
NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE));
|
2018-09-11 05:48:58 -04:00
|
|
|
rb_gvar_getter_t *rb_gvar_getter_function_of(const struct rb_global_entry *);
|
|
|
|
rb_gvar_setter_t *rb_gvar_setter_function_of(const struct rb_global_entry *);
|
|
|
|
bool rb_gvar_is_traced(const struct rb_global_entry *);
|
2014-11-18 10:13:05 -05:00
|
|
|
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
/* vm_insnhelper.h */
|
2013-11-08 22:34:49 -05:00
|
|
|
rb_serial_t rb_next_class_serial(void);
|
* class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: Implement class hierarchy method cache invalidation.
[ruby-core:55053] [Feature #8426] [GH-387]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 01:25:06 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
/* vm.c */
|
|
|
|
VALUE rb_obj_is_thread(VALUE obj);
|
|
|
|
void rb_vm_mark(void *ptr);
|
|
|
|
void Init_BareVM(void);
|
2014-05-04 09:04:37 -04:00
|
|
|
void Init_vm_objects(void);
|
2016-06-08 07:36:57 -04:00
|
|
|
PUREFUNC(VALUE rb_vm_top_self(void));
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void rb_thread_recycle_stack_release(VALUE *);
|
2018-09-12 16:49:10 -04:00
|
|
|
VALUE *rb_thread_recycle_stack(size_t);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
void rb_vm_change_state(void);
|
|
|
|
void rb_vm_inc_const_missing_count(void);
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
const void **rb_vm_get_insns_address_table(void);
|
2015-10-29 01:32:57 -04:00
|
|
|
VALUE rb_source_location(int *pline);
|
2017-11-16 00:52:19 -05:00
|
|
|
const char *rb_source_location_cstr(int *pline);
|
2018-10-07 09:34:59 -04:00
|
|
|
MJIT_STATIC void rb_vm_pop_cfunc_frame(void);
|
2014-11-18 10:13:05 -05:00
|
|
|
int rb_vm_add_root_module(ID id, VALUE module);
|
|
|
|
void rb_vm_check_redefinition_by_prepend(VALUE klass);
|
|
|
|
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
|
2018-10-07 09:34:59 -04:00
|
|
|
MJIT_STATIC VALUE ruby_vm_special_exception_copy(VALUE);
|
2016-05-08 13:44:51 -04:00
|
|
|
PUREFUNC(st_table *rb_vm_fstring_table(void));
|
2017-07-18 21:35:04 -04:00
|
|
|
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* vm_dump.c */
|
2013-04-02 03:02:54 -04:00
|
|
|
void rb_print_backtrace(void);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* vm_eval.c */
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
void Init_vm_eval(void);
|
2011-06-18 04:26:19 -04:00
|
|
|
VALUE rb_current_realfilepath(void);
|
2013-11-29 03:02:51 -05:00
|
|
|
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE);
|
2013-08-27 03:08:32 -04:00
|
|
|
typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
|
|
|
|
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
|
2012-12-23 01:05:50 -05:00
|
|
|
rb_check_funcall_hook *hook, VALUE arg);
|
iseq.c: dump type of branchiftype on disasm
This makes easier to debug scripts related to r59950.
* before
$ ./ruby --dump=insns -e '"#{a}"'
== disasm: #<ISeq:<main>@-e>============================================
0000 putobject "" ( 1)[Li]
0002 putself
0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0006 dup
0007 branchiftype 5, 15
0010 dup
0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0014 tostring
0015 concatstrings 2
0017 leave
* after
$ ./ruby --dump=insns -e '"#{a}"'
== disasm: #<ISeq:<main>@-e>============================================
0000 putobject "" ( 1)[Li]
0002 putself
0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0006 dup
0007 branchiftype T_STRING, 15
0010 dup
0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0014 tostring
0015 concatstrings 2
0017 leave
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13 11:07:52 -05:00
|
|
|
const char *rb_type_str(enum ruby_value_type type);
|
2015-11-09 07:48:20 -05:00
|
|
|
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
|
2015-10-10 17:22:54 -04:00
|
|
|
VALUE rb_yield_1(VALUE val);
|
2017-06-05 02:15:28 -04:00
|
|
|
VALUE rb_yield_force_blockarg(VALUE values);
|
2017-07-18 04:31:02 -04:00
|
|
|
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
|
|
|
|
rb_block_call_func_t bl_proc, int min_argc, int max_argc,
|
|
|
|
VALUE data2);
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
|
2013-08-27 03:46:08 -04:00
|
|
|
/* vm_insnhelper.c */
|
|
|
|
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
|
2017-05-25 00:25:39 -04:00
|
|
|
VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
|
2018-09-11 05:48:58 -04:00
|
|
|
void Init_vm_stack_canary(void);
|
2013-08-27 03:46:08 -04:00
|
|
|
|
* method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
declare internal functions.
Note that rb_method_entry_eq() is defined in vm_method.c but
there was a declaration in proc.c with different const-ness.
Now it is declared in method.h with same const-ness to the
definition.
* object.c (rb_mod_module_exec): don't declare functions declared in
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 23:49:33 -04:00
|
|
|
/* vm_method.c */
|
|
|
|
void Init_eval_method(void);
|
2012-05-24 02:09:23 -04:00
|
|
|
int rb_method_defined_by(VALUE obj, ID mid, VALUE (*cfunc)(ANYARGS));
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
|
|
|
|
/* miniprelude.c, prelude.c */
|
|
|
|
void Init_prelude(void);
|
2011-06-09 11:02:46 -04:00
|
|
|
|
2012-06-02 11:59:37 -04:00
|
|
|
/* vm_backtrace.c */
|
|
|
|
void Init_vm_backtrace(void);
|
2014-06-18 02:16:39 -04:00
|
|
|
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
|
|
|
|
VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval);
|
2012-11-19 01:07:06 -05:00
|
|
|
|
2012-06-02 11:59:37 -04:00
|
|
|
VALUE rb_make_backtrace(void);
|
|
|
|
void rb_backtrace_print_as_bugreport(void);
|
|
|
|
int rb_backtrace_p(VALUE obj);
|
|
|
|
VALUE rb_backtrace_to_str_ary(VALUE obj);
|
2013-12-12 23:31:06 -05:00
|
|
|
VALUE rb_backtrace_to_location_ary(VALUE obj);
|
2017-04-25 04:17:24 -04:00
|
|
|
void rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output);
|
2012-06-02 11:59:37 -04:00
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2011-06-30 04:37:06 -04:00
|
|
|
const char *rb_objspace_data_type_name(VALUE obj);
|
2011-07-10 01:19:47 -04:00
|
|
|
|
2011-07-10 08:52:03 -04:00
|
|
|
/* Temporary. This API will be removed (renamed). */
|
2011-07-10 01:19:47 -04:00
|
|
|
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
|
|
|
|
|
2018-11-03 07:20:54 -04:00
|
|
|
/* array.c (export) */
|
|
|
|
void rb_ary_detransient(VALUE a);
|
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* bignum.c (export) */
|
2013-07-07 10:01:40 -04:00
|
|
|
VALUE rb_big_mul_normal(VALUE x, VALUE y);
|
|
|
|
VALUE rb_big_mul_balance(VALUE x, VALUE y);
|
|
|
|
VALUE rb_big_mul_karatsuba(VALUE x, VALUE y);
|
2013-07-08 09:05:57 -04:00
|
|
|
VALUE rb_big_mul_toom3(VALUE x, VALUE y);
|
|
|
|
VALUE rb_big_sq_fast(VALUE x);
|
2013-09-04 12:10:06 -04:00
|
|
|
VALUE rb_big_divrem_normal(VALUE x, VALUE y);
|
2013-09-01 07:35:57 -04:00
|
|
|
VALUE rb_big2str_poweroftwo(VALUE x, int base);
|
|
|
|
VALUE rb_big2str_generic(VALUE x, int base);
|
2013-09-02 23:50:15 -04:00
|
|
|
VALUE rb_str2big_poweroftwo(VALUE arg, int base, int badcheck);
|
|
|
|
VALUE rb_str2big_normal(VALUE arg, int base, int badcheck);
|
|
|
|
VALUE rb_str2big_karatsuba(VALUE arg, int base, int badcheck);
|
2013-09-01 10:34:53 -04:00
|
|
|
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
|
|
|
|
VALUE rb_big_mul_gmp(VALUE x, VALUE y);
|
2013-09-04 19:22:27 -04:00
|
|
|
VALUE rb_big_divrem_gmp(VALUE x, VALUE y);
|
2013-09-01 10:34:53 -04:00
|
|
|
VALUE rb_big2str_gmp(VALUE x, int base);
|
2013-09-03 07:20:02 -04:00
|
|
|
VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
|
2013-09-01 10:34:53 -04:00
|
|
|
#endif
|
2017-03-15 23:21:12 -04:00
|
|
|
enum rb_int_parse_flags {
|
|
|
|
RB_INT_PARSE_SIGN = 0x01,
|
|
|
|
RB_INT_PARSE_UNDERSCORE = 0x02,
|
|
|
|
RB_INT_PARSE_PREFIX = 0x04,
|
|
|
|
RB_INT_PARSE_ALL = 0x07,
|
|
|
|
RB_INT_PARSE_DEFAULT = 0x07
|
|
|
|
};
|
|
|
|
VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
|
2013-06-06 07:57:35 -04:00
|
|
|
|
2018-08-06 05:08:28 -04:00
|
|
|
/* enumerator.c (export) */
|
|
|
|
VALUE rb_arith_seq_new(VALUE obj, VALUE meth, int argc, VALUE const *argv,
|
|
|
|
rb_enumerator_size_func *size_fn,
|
|
|
|
VALUE beg, VALUE end, VALUE step, int excl);
|
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* error.c (export) */
|
2013-10-16 04:39:39 -04:00
|
|
|
int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
|
2016-07-23 09:43:44 -04:00
|
|
|
NORETURN(void rb_unexpected_type(VALUE,int));
|
|
|
|
#undef Check_Type
|
|
|
|
#define Check_Type(v, t) \
|
|
|
|
(!RB_TYPE_P((VALUE)(v), (t)) || \
|
|
|
|
((t) == RUBY_T_DATA && RTYPEDDATA_P(v)) ? \
|
|
|
|
rb_unexpected_type((VALUE)(v), (t)) : (void)0)
|
2013-10-16 04:39:39 -04:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* file.c (export) */
|
2018-01-09 01:24:11 -05:00
|
|
|
#if defined HAVE_READLINK && defined RUBY_ENCODING_H
|
2015-09-05 10:00:15 -04:00
|
|
|
VALUE rb_readlink(VALUE path, rb_encoding *enc);
|
|
|
|
#endif
|
2013-08-10 16:44:10 -04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
VALUE rb_str_normalize_ospath(const char *ptr, long len);
|
|
|
|
#endif
|
|
|
|
|
2014-12-23 21:53:37 -05:00
|
|
|
/* hash.c (export) */
|
|
|
|
VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
|
2015-08-09 21:08:02 -04:00
|
|
|
VALUE rb_ident_hash_new(void);
|
2014-12-23 21:53:37 -05:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* io.c (export) */
|
2011-10-31 23:37:01 -04:00
|
|
|
void rb_maygvl_fd_fix_cloexec(int fd);
|
2015-11-23 19:16:37 -05:00
|
|
|
int rb_gc_for_fd(int err);
|
2016-03-06 20:58:09 -05:00
|
|
|
void rb_write_error_str(VALUE mesg);
|
2011-10-31 23:37:01 -04:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* numeric.c (export) */
|
2013-08-02 10:48:55 -04:00
|
|
|
VALUE rb_int_positive_pow(long x, unsigned long y);
|
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* process.c (export) */
|
2012-06-20 07:46:50 -04:00
|
|
|
int rb_exec_async_signal_safe(const struct rb_execarg *e, char *errmsg, size_t errmsg_buflen);
|
2012-06-09 21:29:58 -04:00
|
|
|
rb_pid_t rb_fork_async_signal_safe(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fds, char *errmsg, size_t errmsg_buflen);
|
2018-01-24 09:11:25 -05:00
|
|
|
VALUE rb_execarg_new(int argc, const VALUE *argv, int accept_shell, int allow_exc_opt);
|
2012-06-20 07:46:50 -04:00
|
|
|
struct rb_execarg *rb_execarg_get(VALUE execarg_obj); /* dangerous. needs GC guard. */
|
2018-01-24 09:11:25 -05:00
|
|
|
VALUE rb_execarg_init(int argc, const VALUE *argv, int accept_shell, VALUE execarg_obj, int allow_exc_opt);
|
2012-06-21 08:18:40 -04:00
|
|
|
int rb_execarg_addopt(VALUE execarg_obj, VALUE key, VALUE val);
|
2015-04-09 07:53:49 -04:00
|
|
|
void rb_execarg_parent_start(VALUE execarg_obj);
|
2015-04-09 08:44:35 -04:00
|
|
|
void rb_execarg_parent_end(VALUE execarg_obj);
|
2012-06-20 07:46:50 -04:00
|
|
|
int rb_execarg_run_options(const struct rb_execarg *e, struct rb_execarg *s, char* errmsg, size_t errmsg_buflen);
|
2012-06-26 20:15:51 -04:00
|
|
|
VALUE rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash);
|
|
|
|
void rb_execarg_setenv(VALUE execarg_obj, VALUE env);
|
2012-06-09 21:29:58 -04:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* rational.c (export) */
|
2016-12-27 23:40:58 -05:00
|
|
|
VALUE rb_gcd(VALUE x, VALUE y);
|
2013-09-06 08:07:08 -04:00
|
|
|
VALUE rb_gcd_normal(VALUE self, VALUE other);
|
|
|
|
#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
|
|
|
|
VALUE rb_gcd_gmp(VALUE x, VALUE y);
|
|
|
|
#endif
|
|
|
|
|
2018-07-04 23:02:33 -04:00
|
|
|
/* signal.c (export) */
|
|
|
|
int rb_grantpt(int fd);
|
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* string.c (export) */
|
2014-09-12 09:11:13 -04:00
|
|
|
#ifdef RUBY_ENCODING_H
|
|
|
|
/* internal use */
|
|
|
|
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc);
|
|
|
|
#endif
|
2018-04-28 07:16:54 -04:00
|
|
|
VALUE rb_str_upto_each(VALUE, VALUE, int, int (*each)(VALUE, VALUE), VALUE);
|
|
|
|
VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
|
2014-09-12 09:11:13 -04:00
|
|
|
|
2015-11-23 16:20:56 -05:00
|
|
|
/* thread.c (export) */
|
|
|
|
int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
|
|
|
|
|
2018-07-05 07:43:42 -04:00
|
|
|
/* time.c (export) */
|
2018-07-05 21:40:04 -04:00
|
|
|
void ruby_reset_leap_second_info(void);
|
2018-07-05 07:43:42 -04:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* util.c (export) */
|
2013-07-03 09:32:14 -04:00
|
|
|
extern const signed char ruby_digit36_to_number_table[];
|
2015-02-13 02:07:39 -05:00
|
|
|
extern const char ruby_hexdigits[];
|
2015-05-29 01:39:03 -04:00
|
|
|
extern unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
|
2013-07-03 09:32:14 -04:00
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* variable.c (export) */
|
2012-07-19 01:30:46 -04:00
|
|
|
void rb_mark_generic_ivar(VALUE);
|
2014-11-21 11:11:55 -05:00
|
|
|
VALUE rb_const_missing(VALUE klass, VALUE name);
|
2015-10-29 23:07:06 -04:00
|
|
|
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
|
2013-06-14 05:23:54 -04:00
|
|
|
st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
|
|
|
|
|
2014-11-18 22:55:45 -05:00
|
|
|
/* gc.c (export) */
|
2015-10-29 04:17:32 -04:00
|
|
|
VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
|
|
|
|
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE);
|
|
|
|
|
2013-11-09 06:51:32 -05:00
|
|
|
size_t rb_obj_memsize_of(VALUE);
|
2015-03-19 03:19:52 -04:00
|
|
|
void rb_gc_verify_internal_consistency(void);
|
|
|
|
|
2013-12-09 21:26:09 -05:00
|
|
|
#define RB_OBJ_GC_FLAGS_MAX 5
|
|
|
|
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
2014-09-11 06:34:09 -04:00
|
|
|
void rb_gc_mark_values(long n, const VALUE *values);
|
2013-11-09 06:51:32 -05:00
|
|
|
|
2015-03-18 15:57:53 -04:00
|
|
|
#if IMEMO_DEBUG
|
|
|
|
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
|
2015-03-27 19:51:09 -04:00
|
|
|
#define rb_imemo_new(type, v1, v2, v3, v0) rb_imemo_new_debug(type, v1, v2, v3, v0, __FILE__, __LINE__)
|
|
|
|
#else
|
2015-03-11 19:13:01 -04:00
|
|
|
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
|
2015-03-27 19:51:09 -04:00
|
|
|
#endif
|
2015-03-11 19:13:01 -04:00
|
|
|
|
2018-09-11 05:48:58 -04:00
|
|
|
/* random.c */
|
2018-09-11 07:05:20 -04:00
|
|
|
int ruby_fill_random_bytes(void *, size_t, int);
|
2018-09-11 05:48:58 -04:00
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2011-06-21 08:31:17 -04:00
|
|
|
|
2015-10-29 01:32:57 -04:00
|
|
|
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
|
2015-10-30 21:02:29 -04:00
|
|
|
RUBY_DTRACE_HOOK(name##_CREATE, arg)
|
|
|
|
#define RUBY_DTRACE_HOOK(name, arg) \
|
2015-10-29 01:32:57 -04:00
|
|
|
do { \
|
2015-10-30 21:02:29 -04:00
|
|
|
if (UNLIKELY(RUBY_DTRACE_##name##_ENABLED())) { \
|
2015-10-29 01:32:57 -04:00
|
|
|
int dtrace_line; \
|
2017-11-16 00:52:19 -05:00
|
|
|
const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
|
2015-10-29 01:32:57 -04:00
|
|
|
if (!dtrace_file) dtrace_file = ""; \
|
2015-10-30 21:02:29 -04:00
|
|
|
RUBY_DTRACE_##name(arg, dtrace_file, dtrace_line); \
|
2015-10-29 01:32:57 -04:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2016-10-28 02:58:19 -04:00
|
|
|
#define RB_OBJ_BUILTIN_TYPE(obj) rb_obj_builtin_type(obj)
|
|
|
|
#define OBJ_BUILTIN_TYPE(obj) RB_OBJ_BUILTIN_TYPE(obj)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define rb_obj_builtin_type(obj) \
|
|
|
|
__extension__({ \
|
|
|
|
VALUE arg_obj = (obj); \
|
|
|
|
RB_SPECIAL_CONST_P(arg_obj) ? -1 : \
|
|
|
|
RB_BUILTIN_TYPE(arg_obj); \
|
|
|
|
})
|
|
|
|
#else
|
|
|
|
static inline int
|
|
|
|
rb_obj_builtin_type(VALUE obj)
|
|
|
|
{
|
|
|
|
return RB_SPECIAL_CONST_P(obj) ? -1 :
|
|
|
|
RB_BUILTIN_TYPE(obj);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-13 06:45:25 -05:00
|
|
|
/* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
|
|
|
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
|
|
|
# define FLEX_ARY_LEN /* VALUE ary[]; */
|
|
|
|
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
|
|
# define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
|
|
|
|
#else
|
|
|
|
# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
|
|
|
|
#endif
|
|
|
|
|
2018-01-27 16:04:42 -05:00
|
|
|
/*
|
|
|
|
* For declaring bitfields out of non-unsigned int types:
|
|
|
|
* struct date {
|
2018-08-22 00:04:06 -04:00
|
|
|
* BITFIELD(enum months, month, 4);
|
2018-01-27 16:04:42 -05:00
|
|
|
* ...
|
|
|
|
* };
|
|
|
|
*/
|
|
|
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
2018-08-22 00:04:06 -04:00
|
|
|
# define BITFIELD(type, name, size) type name : size
|
2018-01-27 16:04:42 -05:00
|
|
|
#else
|
2018-08-22 00:04:06 -04:00
|
|
|
# define BITFIELD(type, name, size) unsigned int name : size
|
2018-01-27 16:04:42 -05:00
|
|
|
#endif
|
|
|
|
|
2018-07-30 03:07:48 -04:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
# define COMPILER_WARNING_PUSH __pragma(warning(push))
|
|
|
|
# define COMPILER_WARNING_POP __pragma(warning(pop))
|
|
|
|
# define COMPILER_WARNING_ERROR(flag) __pragma(warning(error: flag)))
|
|
|
|
# define COMPILER_WARNING_IGNORED(flag) __pragma(warning(suppress: flag)))
|
|
|
|
|
|
|
|
#elif defined(__clang__) /* clang 2.6 already had this feature */
|
|
|
|
# define COMPILER_WARNING_PUSH _Pragma("clang diagnostic push")
|
|
|
|
# define COMPILER_WARNING_POP _Pragma("clang diagnostic pop")
|
|
|
|
# define COMPILER_WARNING_SPECIFIER(kind, msg) \
|
|
|
|
clang diagnostic kind # msg
|
|
|
|
# define COMPILER_WARNING_ERROR(flag) \
|
|
|
|
COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
|
|
|
|
# define COMPILER_WARNING_IGNORED(flag) \
|
|
|
|
COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
|
|
|
|
|
|
|
|
#elif GCC_VERSION_SINCE(4, 2, 0)
|
|
|
|
/* https://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/Diagnostic-Pragmas.html */
|
|
|
|
# define COMPILER_WARNING_PUSH _Pragma("GCC diagnostic push")
|
|
|
|
# define COMPILER_WARNING_POP _Pragma("GCC diagnostic pop")
|
|
|
|
# define COMPILER_WARNING_SPECIFIER(kind, msg) \
|
|
|
|
GCC diagnostic kind # msg
|
|
|
|
# define COMPILER_WARNING_ERROR(flag) \
|
|
|
|
COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(error, flag))
|
|
|
|
# define COMPILER_WARNING_IGNORED(flag) \
|
|
|
|
COMPILER_WARNING_PRAGMA(COMPILER_WARNING_SPECIFIER(ignored, flag))
|
|
|
|
|
|
|
|
#else /* other compilers to follow? */
|
2018-07-30 04:22:50 -04:00
|
|
|
# define COMPILER_WARNING_PUSH /* nop */
|
|
|
|
# define COMPILER_WARNING_POP /* nop */
|
|
|
|
# define COMPILER_WARNING_ERROR(flag) /* nop */
|
|
|
|
# define COMPILER_WARNING_IGNORED(flag) /* nop */
|
2018-07-30 03:07:48 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define COMPILER_WARNING_PRAGMA(str) COMPILER_WARNING_PRAGMA_(str)
|
|
|
|
#define COMPILER_WARNING_PRAGMA_(str) _Pragma(#str)
|
|
|
|
|
2011-05-18 09:41:54 -04:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if 0
|
|
|
|
{ /* satisfy cc-mode */
|
|
|
|
#endif
|
|
|
|
} /* extern "C" { */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RUBY_INTERNAL_H */
|