Improve branch misses

Improve branch misses on frozen object predicate checks negatively
affecting performance of most setters as most objects are not frozen.

[Fix GH-1913]

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-07-12 05:01:04 +00:00
parent bcf8ce8494
commit cb5598a419

View File

@ -254,7 +254,7 @@ void rb_check_frozen(VALUE);
void rb_check_trusted(VALUE); void rb_check_trusted(VALUE);
#define rb_check_frozen_internal(obj) do { \ #define rb_check_frozen_internal(obj) do { \
VALUE frozen_obj = (obj); \ VALUE frozen_obj = (obj); \
if (RB_OBJ_FROZEN(frozen_obj)) { \ if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
rb_error_frozen_object(frozen_obj); \ rb_error_frozen_object(frozen_obj); \
} \ } \
} while (0) } while (0)