diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-28 06:21:46 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-28 06:21:46 +0000 |
| commit | 2f286496fd612f93d1459f8bc1d70af1b386b3be (patch) | |
| tree | ddf952542b46d0c180ed6200fcdb7b3e00036b32 /include/ruby/ruby.h | |
| parent | 5cd0f7449c5eb0879bc74a0db30c513991b6df15 (diff) | |
| download | ruby-2f286496fd612f93d1459f8bc1d70af1b386b3be.tar.gz ruby-2f286496fd612f93d1459f8bc1d70af1b386b3be.tar.xz ruby-2f286496fd612f93d1459f8bc1d70af1b386b3be.zip | |
* include/ruby/intern.h: export rb_ivar_foreach.
* include/ruby/ruby.h: modify struct RObject and RClass for optimizing
T_OBJECT space. [ruby-dev:31853]
(ROBJECT_LEN, ROBJECT_PTR)
(RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_SUPER, RCLASS_IV_INDEX_TBL)
(RMODULE_IV_TBL, RMODULE_M_TBL, RMODULE_SUPER): abstract accessor
defined.
* variable.c: support the modified RObject and RClass.
* object.c: ditto.
* class.c: ditto.
* gc.c: ditto.
* marshal.c: ditto.
* eval_method.ci: use the abstract accessor.
* insns.def: ditto.
* proc.c: ditto.
* struct.c: ditto.
* eval.c: ditto.
* error.c: ditto.
* vm.c: ditto.
* insnhelper.ci: ditto.
* ext/digest/digest.c: ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/ruby.h')
| -rw-r--r-- | include/ruby/ruby.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 5ccf24673..4939609e3 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -402,10 +402,26 @@ struct RBasic { VALUE klass; }; +#define ROBJECT_EMBED_LEN_MAX 3 struct RObject { struct RBasic basic; - struct st_table *iv_tbl; + union { + struct { + long len; + VALUE *ptr; + } heap; + VALUE ary[ROBJECT_EMBED_LEN_MAX]; + } as; }; +#define ROBJECT_EMBED FL_USER1 +#define ROBJECT_LEN(o) \ + ((RBASIC(o)->flags & ROBJECT_EMBED) ? \ + ROBJECT_EMBED_LEN_MAX : \ + ROBJECT(o)->as.heap.len) +#define ROBJECT_PTR(o) \ + ((RBASIC(o)->flags & ROBJECT_EMBED) ? \ + ROBJECT(o)->as.ary : \ + ROBJECT(o)->as.heap.ptr) struct RValues { struct RBasic basic; @@ -414,12 +430,24 @@ struct RValues { VALUE v3; }; +typedef struct { + struct st_table *iv_tbl; + VALUE super; +} rb_classext_t; + struct RClass { struct RBasic basic; - struct st_table *iv_tbl; + rb_classext_t *ptr; struct st_table *m_tbl; - VALUE super; + struct st_table *iv_index_tbl; }; +#define RCLASS_IV_TBL(c) (RCLASS(c)->ptr->iv_tbl) +#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl) +#define RCLASS_SUPER(c) (RCLASS(c)->ptr->super) +#define RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl) +#define RMODULE_IV_TBL(m) RCLASS_IV_TBL(m) +#define RMODULE_M_TBL(m) RCLASS_M_TBL(m) +#define RMODULE_SUPER(m) RCLASS_SUPER(m) struct RFloat { struct RBasic basic; |
