dumping ground for random patches and texts
 help / color / mirror / Atom feed
* [PATCH 1/2] iseq.c (rb_iseq_mark): reduce NULL checks
@ 2015-08-13 21:40 Eric Wong
  2015-08-13 21:40 ` [PATCH 2/2] iseq: move iseq->body->mark_ary to iseq->mark_ary Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2015-08-13 21:40 UTC (permalink / raw)
  To: spew

iseq_location_setup always sets path, label and base_label fields,
and the only caller of iseq_location_setup (prepare_iseq_build) will
always pass non-nil `name' and `path' arguments.
---
 iseq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/iseq.c b/iseq.c
index e9b84a1..9b32c0a 100644
--- a/iseq.c
+++ b/iseq.c
@@ -108,9 +108,9 @@ rb_iseq_mark(const rb_iseq_t *iseq)
 	const struct rb_iseq_constant_body *body = iseq->body;
 
 	RUBY_MARK_UNLESS_NULL(body->mark_ary);
-	RUBY_MARK_UNLESS_NULL(body->location.label);
-	RUBY_MARK_UNLESS_NULL(body->location.base_label);
-	RUBY_MARK_UNLESS_NULL(body->location.path);
+	rb_gc_mark(body->location.label);
+	rb_gc_mark(body->location.base_label);
+	rb_gc_mark(body->location.path);
 	RUBY_MARK_UNLESS_NULL(body->location.absolute_path);
     }
 
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] iseq: move iseq->body->mark_ary to iseq->mark_ary
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2015-08-13 21:40 UTC (permalink / raw)
  To: spew

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-13 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-13 21:40 [PATCH 1/2] iseq.c (rb_iseq_mark): reduce NULL checks Eric Wong
2015-08-13 21:40 ` [PATCH 2/2] iseq: move iseq->body->mark_ary to iseq->mark_ary Eric Wong

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).