From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6315 166.70.0.0/16 X-Spam-Status: No, score=-1.8 required=3.0 tests=AWL,BAYES_00,RCVD_IN_XBL, RDNS_NONE shortcircuit=no autolearn=no version=3.3.2 X-Original-To: spew@80x24.org Received: from 80x24.org (unknown [166.70.181.109]) by dcvr.yhbt.net (Postfix) with ESMTP id CD2811F48C for ; Thu, 13 Aug 2015 21:40:41 +0000 (UTC) From: Eric Wong 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 Message-Id: <1439502034-1546-2-git-send-email-e@80x24.org> In-Reply-To: <1439502034-1546-1-git-send-email-e@80x24.org> References: <1439502034-1546-1-git-send-email-e@80x24.org> List-Id: 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