зеркало из https://github.com/github/ruby.git
RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)
Don't abuse struct RString to hold arbitrary memory region. Raw pointer should just suffice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
433a4e66a2
Коммит
75d5cf55de
|
@ -8929,7 +8929,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
|
|||
dump_body.ci_entries = ibf_dump_ci_entries(dump, iseq);
|
||||
dump_body.cc_entries = NULL;
|
||||
dump_body.variable.coverage = Qnil;
|
||||
dump_body.variable.original_iseq = Qnil;
|
||||
dump_body.variable.original_iseq = NULL;
|
||||
|
||||
IBF_W_ALIGN(struct rb_iseq_constant_body);
|
||||
return IBF_WV(dump_body);
|
||||
|
|
1
iseq.c
1
iseq.c
|
@ -222,7 +222,6 @@ rb_iseq_mark(const rb_iseq_t *iseq)
|
|||
}
|
||||
|
||||
rb_gc_mark(body->variable.coverage);
|
||||
rb_gc_mark(body->variable.original_iseq);
|
||||
rb_gc_mark(body->location.label);
|
||||
rb_gc_mark(body->location.base_label);
|
||||
rb_gc_mark(body->location.pathobj);
|
||||
|
|
15
iseq.h
15
iseq.h
|
@ -46,23 +46,24 @@ ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
|
|||
static inline VALUE *
|
||||
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
|
||||
{
|
||||
VALUE str = iseq->body->variable.original_iseq;
|
||||
if (RTEST(str)) return (VALUE *)RSTRING_PTR(str);
|
||||
return NULL;
|
||||
return iseq->body->variable.original_iseq;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
|
||||
{
|
||||
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil);
|
||||
void *ptr = iseq->body->variable.original_iseq;
|
||||
iseq->body->variable.original_iseq = NULL;
|
||||
if (ptr) {
|
||||
ruby_xfree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static inline VALUE *
|
||||
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
|
||||
{
|
||||
VALUE str = rb_str_tmp_new(size * sizeof(VALUE));
|
||||
RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, str);
|
||||
return (VALUE *)RSTRING_PTR(str);
|
||||
return iseq->body->variable.original_iseq =
|
||||
ruby_xmalloc2(sizeof(VALUE), size);
|
||||
}
|
||||
|
||||
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
|
||||
|
|
|
@ -420,7 +420,7 @@ struct rb_iseq_constant_body {
|
|||
struct {
|
||||
rb_snum_t flip_count;
|
||||
VALUE coverage;
|
||||
VALUE original_iseq;
|
||||
VALUE *original_iseq;
|
||||
} variable;
|
||||
|
||||
unsigned int local_table_size;
|
||||
|
|
Загрузка…
Ссылка в новой задаче