aboutsummaryrefslogtreecommitdiffstats
path: root/include/ruby
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-28 06:21:46 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-28 06:21:46 +0000
commit5c0e68c39c3fc7717311826549a30d1615eb2007 (patch)
treeddf952542b46d0c180ed6200fcdb7b3e00036b32 /include/ruby
parent041fbcbf50993925b2d61fbfca4d16b766d8ea5d (diff)
downloadruby-5c0e68c39c3fc7717311826549a30d1615eb2007.tar.gz
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@13543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/intern.h1
-rw-r--r--include/ruby/ruby.h34
2 files changed, 32 insertions, 3 deletions
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index d9443f5788..1b453d1f30 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -583,6 +583,7 @@ void rb_free_generic_ivar(VALUE);
VALUE rb_ivar_get(VALUE, ID);
VALUE rb_ivar_set(VALUE, ID, VALUE);
VALUE rb_ivar_defined(VALUE, ID);
+void rb_ivar_foreach(VALUE, int (*)(ANYARGS), st_data_t);
VALUE rb_iv_set(VALUE, const char*, VALUE);
VALUE rb_iv_get(VALUE, const char*);
VALUE rb_attr_get(VALUE, ID);
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 5ccf246734..4939609e31 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;