diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-06 17:24:48 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-07 10:32:47 +0900 |
commit | 11f33ba6204909ebbb142283bc9395d3343db28e (patch) | |
tree | a63b847cbc329ffeba428aed3f8e620da0de1d16 /eval_intern.h | |
parent | ef5b1d19c1573290bcf9d5b33bf12656825d2e3b (diff) | |
download | ruby-11f33ba6204909ebbb142283bc9395d3343db28e.tar.gz |
Add hints of tag jumps for optimization
Just as the state was originally passed as the return value of
`longjmp`, the state stored in EC cannot be 0 when the jump is
captured now too.
Diffstat (limited to 'eval_intern.h')
-rw-r--r-- | eval_intern.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/eval_intern.h b/eval_intern.h index 6cbaa51361..778b63e0ea 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -151,6 +151,7 @@ rb_ec_tag_state(const rb_execution_context_t *ec) enum ruby_tag_type state = tag->state; tag->state = TAG_NONE; rb_ec_vm_lock_rec_check(ec, tag->lock_rec); + RBIMPL_ASSUME(state != TAG_NONE); return state; } @@ -158,6 +159,7 @@ NORETURN(static inline void rb_ec_tag_jump(const rb_execution_context_t *ec, enu static inline void rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st) { + RUBY_ASSERT(st != TAG_NONE); ec->tag->state = st; ruby_longjmp(ec->tag->buf, 1); } @@ -167,7 +169,7 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st) [ISO/IEC 9899:1999] 7.13.1.1 */ #define EC_EXEC_TAG() \ - (ruby_setjmp(_tag.buf) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0)) + (UNLIKELY(ruby_setjmp(_tag.buf)) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0)) #define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st) |