dumping ground for random patches and texts
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 1/2] hoist out rb_call_info_kw_arg_bytes to inline function
Date: Wed, 12 Aug 2015 12:14:23 +0000	[thread overview]
Message-ID: <1439381664-24104-1-git-send-email-e@80x24.org> (raw)

* vm_core.h (rb_call_info_kw_arg_bytes): extract from below
* compile.c (iseq_build_callinfo_from_hash): use above

This will be use for implementing iseq_memsize
---
 compile.c | 2 +-
 vm_core.h | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/compile.c b/compile.c
index 637f56f..26ee3b2 100644
--- a/compile.c
+++ b/compile.c
@@ -5917,7 +5917,7 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op)
 	if (!NIL_P(vkw_arg)) {
 	    int i;
 	    int len = RARRAY_LENINT(vkw_arg);
-	    size_t n = sizeof(rb_call_info_kw_arg_t) + sizeof(VALUE) * (len - 1);
+	    size_t n = rb_call_info_kw_arg_bytes(len);
 
 	    kw_arg = xmalloc(n);
 	    kw_arg->keyword_len = len;
diff --git a/vm_core.h b/vm_core.h
index a032daa..6745837 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -180,6 +180,12 @@ typedef struct rb_call_info_kw_arg_struct {
     VALUE keywords[1];
 } rb_call_info_kw_arg_t;
 
+static inline size_t
+rb_call_info_kw_arg_bytes(int keyword_len)
+{
+    return sizeof(rb_call_info_kw_arg_t) + sizeof(VALUE) * (keyword_len - 1);
+}
+
 enum method_missing_reason {
     MISSING_NOENTRY   = 0x00,
     MISSING_PRIVATE   = 0x01,
-- 
EW


             reply	other threads:[~2015-08-12 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 12:14 Eric Wong [this message]
2015-08-12 12:14 ` [PATCH 2/2] iseq.c (iseq_memsize): reimplement for wrapper Eric Wong

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=1439381664-24104-1-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).