From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 2/2] iseq: move iseq->body->mark_ary to iseq->mark_ary
Date: Thu, 13 Aug 2015 21:40:34 +0000 [thread overview]
Message-ID: <1439502034-1546-2-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1439502034-1546-1-git-send-email-e@80x24.org>
Having an unused dummy field is ugly and wasteful. mark_ary was
chosen here since it is often touched at a different point in
execution (GC) than during normal execution of the iseq code.
The GC performance impact is is probably tiny especially given
RGenGC, and rb_location_t still resides in the body for marking
(however on a different cache-line than mark_ary was).
Overall, this should not make a real difference today since
most malloc is 2-word aligned, but it should allow us more room to
make future modifications to rb_iseq_constant_body without using
more space.
---
iseq.c | 13 +++++++------
vm_core.h | 3 +--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/iseq.c b/iseq.c
index 9b32c0a..38bd84d 100644
--- a/iseq.c
+++ b/iseq.c
@@ -104,10 +104,11 @@ rb_iseq_mark(const rb_iseq_t *iseq)
RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(iseq->body->location.path));
+ RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
+
if (iseq->body) {
const struct rb_iseq_constant_body *body = iseq->body;
- RUBY_MARK_UNLESS_NULL(body->mark_ary);
rb_gc_mark(body->location.label);
rb_gc_mark(body->location.base_label);
rb_gc_mark(body->location.path);
@@ -259,11 +260,11 @@ set_relation(rb_iseq_t *iseq, const rb_iseq_t *piseq)
void
rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj)
{
- if (!RTEST(iseq->body->mark_ary)) {
- RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, rb_ary_tmp_new(3));
- RBASIC_CLEAR_CLASS(iseq->body->mark_ary);
+ if (!RTEST(iseq->mark_ary)) {
+ RB_OBJ_WRITE(iseq, &iseq->mark_ary, rb_ary_tmp_new(3));
+ RBASIC_CLEAR_CLASS(iseq->mark_ary);
}
- rb_ary_push(iseq->body->mark_ary, obj);
+ rb_ary_push(iseq->mark_ary, obj);
}
static VALUE
@@ -282,7 +283,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
if (iseq != iseq->body->local_iseq) {
RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
}
- RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, 0);
+ RB_OBJ_WRITE(iseq, &iseq->mark_ary, 0);
iseq->compile_data = ZALLOC(struct iseq_compile_data);
RB_OBJ_WRITE(iseq, &iseq->compile_data->err_info, Qnil);
diff --git a/vm_core.h b/vm_core.h
index a032daa..1e52da6 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -343,7 +343,6 @@ struct rb_iseq_constant_body {
union iseq_inline_storage_entry *is_entries;
rb_call_info_t *callinfo_entries;
- const VALUE mark_ary; /* Array: includes operands which should be GC marked */
unsigned int local_table_size;
unsigned int is_size;
@@ -368,7 +367,7 @@ struct rb_iseq_struct {
struct iseq_compile_data *compile_data; /* used at compile time */
struct rb_iseq_constant_body *body;
struct rb_iseq_variable_body *variable_body;
- VALUE dummy2;
+ const VALUE mark_ary; /* Array: includes operands which should be GC marked */
};
enum ruby_special_exceptions {
--
EW
prev parent reply other threads:[~2015-08-13 21:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 21:40 [PATCH 1/2] iseq.c (rb_iseq_mark): reduce NULL checks Eric Wong
2015-08-13 21:40 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439502034-1546-2-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).