diff options
Diffstat (limited to 'vm_core.h')
-rw-r--r-- | vm_core.h | 77 |
1 files changed, 25 insertions, 52 deletions
@@ -946,79 +946,52 @@ typedef void *rb_jmpbuf_t[5]; Therefore, we allocates the buffer on the heap on such environments. */ -typedef struct _rb_vm_tag_jmpbuf { - struct _rb_vm_tag_jmpbuf *next; - rb_jmpbuf_t buf; -} *rb_vm_tag_jmpbuf_t; +typedef rb_jmpbuf_t *rb_vm_tag_jmpbuf_t; -#define RB_VM_TAG_JMPBUF_GET(jmpbuf) ((jmpbuf)->buf) -#else -typedef rb_jmpbuf_t rb_vm_tag_jmpbuf_t; - -#define RB_VM_TAG_JMPBUF_GET(jmpbuf) (jmpbuf) -#endif - -/* - the members which are written in EC_PUSH_TAG() should be placed at - the beginning and the end, so that entire region is accessible. -*/ -struct rb_vm_tag { - VALUE tag; - VALUE retval; - rb_vm_tag_jmpbuf_t buf; - struct rb_vm_tag *prev; - enum ruby_tag_type state; - unsigned int lock_rec; -}; - -#if defined(__wasm__) && !defined(__EMSCRIPTEN__) -static inline void -_rb_vm_tag_jmpbuf_deinit_internal(rb_vm_tag_jmpbuf_t jmpbuf) -{ - rb_vm_tag_jmpbuf_t buf = jmpbuf; - while (buf != NULL) { - rb_vm_tag_jmpbuf_t next = buf->next; - ruby_xfree(buf); - buf = next; - } -} +#define RB_VM_TAG_JMPBUF_GET(buf) (*buf) static inline void -rb_vm_tag_jmpbuf_init(struct rb_vm_tag *tag) +rb_vm_tag_jmpbuf_init(rb_vm_tag_jmpbuf_t *jmpbuf) { - if (tag->prev != NULL && tag->prev->buf->next != NULL) { - _rb_vm_tag_jmpbuf_deinit_internal(tag->prev->buf->next); - tag->prev->buf->next = NULL; - } - tag->buf = ruby_xmalloc(sizeof *tag->buf); - tag->buf->next = NULL; - if (tag->prev != NULL) { - tag->prev->buf->next = tag->buf; - } + *jmpbuf = ruby_xmalloc(sizeof(rb_jmpbuf_t)); } static inline void -rb_vm_tag_jmpbuf_deinit(struct rb_vm_tag *tag) +rb_vm_tag_jmpbuf_deinit(const rb_vm_tag_jmpbuf_t *jmpbuf) { - if (tag->prev != NULL) { - tag->prev->buf->next = NULL; - } - _rb_vm_tag_jmpbuf_deinit_internal(tag->buf); + ruby_xfree(*jmpbuf); } #else +typedef rb_jmpbuf_t rb_vm_tag_jmpbuf_t; + +#define RB_VM_TAG_JMPBUF_GET(buf) (buf) + static inline void -rb_vm_tag_jmpbuf_init(struct rb_vm_tag *tag) +rb_vm_tag_jmpbuf_init(rb_vm_tag_jmpbuf_t *jmpbuf) { // no-op } static inline void -rb_vm_tag_jmpbuf_deinit(struct rb_vm_tag *tag) +rb_vm_tag_jmpbuf_deinit(const rb_vm_tag_jmpbuf_t *jmpbuf) { // no-op } #endif +/* + the members which are written in EC_PUSH_TAG() should be placed at + the beginning and the end, so that entire region is accessible. +*/ +struct rb_vm_tag { + VALUE tag; + VALUE retval; + rb_vm_tag_jmpbuf_t buf; + struct rb_vm_tag *prev; + enum ruby_tag_type state; + unsigned int lock_rec; +}; + STATIC_ASSERT(rb_vm_tag_buf_offset, offsetof(struct rb_vm_tag, buf) > 0); STATIC_ASSERT(rb_vm_tag_buf_end, offsetof(struct rb_vm_tag, buf) + sizeof(rb_vm_tag_jmpbuf_t) < |