mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Make rb_check_frozen_inline() static inline again
Since 730e3b2ce0
("Stop exposing `rb_str_chilled_p`"), we noticed a speed loss on a few
benchmarks that are string operations heavy. This is partially due to
routines no longer having the options to inline rb_check_frozen_inline()
in non-LTO builds. Make it an inlining candidate again to recover speed.
Testing this patch on my machine, the fannkuchredux benchmark gets a
1.15 speed-up with YJIT and 1.03 without YJIT.
This commit is contained in:
parent
30f2d69825
commit
8cf708d7b4
Notes:
git
2024-07-19 21:47:29 +00:00
2 changed files with 20 additions and 8 deletions
8
error.c
8
error.c
|
@ -4001,13 +4001,7 @@ rb_error_frozen_object(VALUE frozen_obj)
|
||||||
void
|
void
|
||||||
rb_check_frozen(VALUE obj)
|
rb_check_frozen(VALUE obj)
|
||||||
{
|
{
|
||||||
if (RB_UNLIKELY(RB_OBJ_FROZEN(obj))) {
|
rb_check_frozen_inline(obj);
|
||||||
rb_error_frozen_object(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RB_UNLIKELY(CHILLED_STRING_P(obj))) {
|
|
||||||
rb_str_modify(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -237,6 +237,8 @@ RBIMPL_ATTR_NORETURN()
|
||||||
*/
|
*/
|
||||||
void rb_error_arity(int argc, int min, int max);
|
void rb_error_arity(int argc, int min, int max);
|
||||||
|
|
||||||
|
void rb_str_modify(VALUE str);
|
||||||
|
|
||||||
RBIMPL_SYMBOL_EXPORT_END()
|
RBIMPL_SYMBOL_EXPORT_END()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +249,23 @@ RBIMPL_SYMBOL_EXPORT_END()
|
||||||
#define rb_check_frozen_internal rb_check_frozen
|
#define rb_check_frozen_internal rb_check_frozen
|
||||||
|
|
||||||
/** @alias{rb_check_frozen} */
|
/** @alias{rb_check_frozen} */
|
||||||
#define rb_check_frozen_inline rb_check_frozen
|
static inline void
|
||||||
|
rb_check_frozen_inline(VALUE obj)
|
||||||
|
{
|
||||||
|
if (RB_UNLIKELY(RB_OBJ_FROZEN(obj))) {
|
||||||
|
rb_error_frozen_object(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ref: internal CHILLED_STRING_P()
|
||||||
|
This is an implementation detail subject to change. */
|
||||||
|
if (RB_UNLIKELY(RB_TYPE_P(obj, T_STRING) && FL_TEST_RAW(obj, RUBY_FL_USER3))) {
|
||||||
|
rb_str_modify(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* rb_check_frozen() is available as a symbol, but have
|
||||||
|
* the inline version take priority for native consumers. */
|
||||||
|
#define rb_check_frozen rb_check_frozen_inline
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the passed integer is in the passed range. When you can use
|
* Ensures that the passed integer is in the passed range. When you can use
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue