Skip to content

Commit da66b64

Browse files
committed
merge revision(s) 9d44cb0, 367ddd4, 48dce78: [Backport #21655]
[PATCH] Remove rbimpl_rstring_getmem() usage as workaround for GCC 15.2.1 optimization bug. [Bug #21655] [PATCH] include/ruby/internal/core/rstring.h: Remove rbimpl_rstring_getmem() definition. [PATCH] simplify RSRING_GETMEM() definition.
1 parent 1adfd3e commit da66b64

2 files changed

Lines changed: 10 additions & 49 deletions

File tree

include/ruby/internal/core/rstring.h

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -369,41 +369,6 @@ RSTRING_LEN(VALUE str)
369369
return RSTRING(str)->len;
370370
}
371371

372-
RBIMPL_WARNING_PUSH()
373-
#if RBIMPL_COMPILER_IS(Intel)
374-
RBIMPL_WARNING_IGNORED(413)
375-
#endif
376-
377-
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
378-
RBIMPL_ATTR_ARTIFICIAL()
379-
/**
380-
* @private
381-
*
382-
* "Expands" an embedded string into an ordinal one. This is a function that
383-
* returns aggregated type. The returned struct always has its `as.heap.len`
384-
* an `as.heap.ptr` fields set appropriately.
385-
*
386-
* This is an implementation detail that 3rd parties should never bother.
387-
*/
388-
static inline struct RString
389-
rbimpl_rstring_getmem(VALUE str)
390-
{
391-
RBIMPL_ASSERT_TYPE(str, RUBY_T_STRING);
392-
393-
if (RB_FL_ANY_RAW(str, RSTRING_NOEMBED)) {
394-
return *RSTRING(str);
395-
}
396-
else {
397-
/* Expecting compilers to optimize this on-stack struct away. */
398-
struct RString retval = {RBASIC_INIT};
399-
retval.len = RSTRING_LEN(str);
400-
retval.as.heap.ptr = RSTRING(str)->as.embed.ary;
401-
return retval;
402-
}
403-
}
404-
405-
RBIMPL_WARNING_POP()
406-
407372
RBIMPL_ATTR_ARTIFICIAL()
408373
/**
409374
* Queries the contents pointer of the string.
@@ -415,7 +380,9 @@ RBIMPL_ATTR_ARTIFICIAL()
415380
static inline char *
416381
RSTRING_PTR(VALUE str)
417382
{
418-
char *ptr = rbimpl_rstring_getmem(str).as.heap.ptr;
383+
char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
384+
RSTRING(str)->as.heap.ptr :
385+
RSTRING(str)->as.embed.ary;
419386

420387
if (RUBY_DEBUG && RB_UNLIKELY(! ptr)) {
421388
/* :BEWARE: @shyouhei thinks that currently, there are rooms for this
@@ -441,14 +408,17 @@ RBIMPL_ATTR_ARTIFICIAL()
441408
static inline char *
442409
RSTRING_END(VALUE str)
443410
{
444-
struct RString buf = rbimpl_rstring_getmem(str);
411+
char *ptr = RB_FL_TEST_RAW(str, RSTRING_NOEMBED) ?
412+
RSTRING(str)->as.heap.ptr :
413+
RSTRING(str)->as.embed.ary;
414+
long len = RSTRING_LEN(str);
445415

446-
if (RUBY_DEBUG && RB_UNLIKELY(! buf.as.heap.ptr)) {
416+
if (RUBY_DEBUG && RB_UNLIKELY(!ptr)) {
447417
/* Ditto. */
448418
rb_debug_rstring_null_ptr("RSTRING_END");
449419
}
450420

451-
return &buf.as.heap.ptr[buf.len];
421+
return &ptr[len];
452422
}
453423

454424
RBIMPL_ATTR_ARTIFICIAL()
@@ -477,16 +447,7 @@ RSTRING_LENINT(VALUE str)
477447
* @param ptrvar Variable where its contents is stored.
478448
* @param lenvar Variable where its length is stored.
479449
*/
480-
#ifdef HAVE_STMT_AND_DECL_IN_EXPR
481-
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
482-
__extension__ ({ \
483-
struct RString rbimpl_str = rbimpl_rstring_getmem(str); \
484-
(ptrvar) = rbimpl_str.as.heap.ptr; \
485-
(lenvar) = rbimpl_str.len; \
486-
})
487-
#else
488450
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
489451
((ptrvar) = RSTRING_PTR(str), \
490452
(lenvar) = RSTRING_LEN(str))
491-
#endif /* HAVE_STMT_AND_DECL_IN_EXPR */
492453
#endif /* RBIMPL_RSTRING_H */

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 7
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 64
14+
#define RUBY_PATCHLEVEL 65
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)