Project

General

Profile

Actions

Feature #490

closed

relayouting struct RNode

Added by yugui (Yuki Sonoda) over 15 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
[ruby-dev:35947]

Description

=begin
Yuguiです。

「第7回RHGの逆襲」(http://qwik.jp/rhg-strikes-back/78.html )の結果とし
て、RNode::nd_fileは誰も利用していないことが分かりました。

よって、RNodeのレイアウトにおいてポインタ長だけ空間が余っています。添付
のパッチでは、とりあえずこの空間をvoid *reservedとして、YARVに残っている
無駄なNULL pointer代入を削除してみました。

さて、この空間を何らかの形で有益に活用したいと思います。関係者に聞いてみ
たところでは次のような案が出てきました。

  1. 行番号に使う
    行番号のMAXが15bit増えます。現状では32bit環境でも2**17あるので現実的に
    特に困ることはないと思いますが、もう少し増えても悪くはないかもしれません。

  2. RNodeを4分木にする
    ASTの分岐の数を増やします。笹田さんによれば、これで楽になるケースが少
    しはあるとのことです。

どのようにしたら良いか、ご意見をいただければと思います。

--
Yugui
http://yugui.jp
私は私をDumpする

diff --git a/include/ruby/node.h b/include/ruby/node.h
index d83f550..6621ac1 100644
--- a/include/ruby/node.h
+++ b/include/ruby/node.h
@@ -242,7 +242,7 @@ enum node_type {

typedef struct RNode {
unsigned long flags;

  • char *nd_file;
  • void *reserved;
    union {
    struct RNode *node;
    ID id;
    diff --git a/iseq.c b/iseq.c
    index b964176..9de648b 100644
    --- a/iseq.c
    +++ b/iseq.c
    @@ -118,12 +118,10 @@ set_relation(rb_iseq_t iseq, const VALUE parent)
    if (type == ISEQ_TYPE_TOP) {
    /
    toplevel is private */
    iseq->cref_stack = NEW_BLOCK(th->top_wrapper ? th->top_wrapper : rb_cObject);
  • iseq->cref_stack->nd_file = 0;
    iseq->cref_stack->nd_visi = NOEX_PRIVATE;
    }
    else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
    iseq->cref_stack = NEW_BLOCK(0); /* place holder */

  • iseq->cref_stack->nd_file = 0;
    }
    else if (RTEST(parent)) {
    rb_iseq_t *piseq;
    diff --git a/vm.c b/vm.c
    index 730d89c..b1b67d8 100644
    --- a/vm.c
    +++ b/vm.c
    @@ -748,7 +748,6 @@ vm_cref_push(rb_thread_t *th, VALUE klass, int noex)
    {
    rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->cfp);
    NODE *cref = NEW_BLOCK(klass);

  • cref->nd_file = 0;
    cref->nd_visi = noex;

    if (cfp) {
    =end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0