From b9ab998effdcffdd1a2202c2ab31b4c907b72d4a Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 29 Oct 2015 07:26:44 +0000 Subject: * gc.c: introduce rb_wb_unprotected_newobj_of() and rb_wb_protected_newobj_of(), pass the WB_PROTECTED information explicitly. * internal.h: use introduced functions by NEWOBJ_OF(). `flag' is immediate value, so that C compilers can solve them at compile time. * include/ruby/ruby.h: add a commnent about that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- internal.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'internal.h') diff --git a/internal.h b/internal.h index a21f1512e0..30d4952734 100644 --- a/internal.h +++ b/internal.h @@ -814,6 +814,18 @@ void ruby_sized_xfree(void *x, size_t size); void rb_gc_resurrect(VALUE ptr); +VALUE rb_wb_protected_newobj_of(VALUE, VALUE); +VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE); + +/* optimized version of NEWOBJ() */ +#undef NEWOBJF_OF +#undef RB_NEWOBJ_OF +#define RB_NEWOBJ_OF(obj,type,klass,flags) \ + type *(obj) = (type*)(((flags) & FL_WB_PROTECTED) ? \ + rb_wb_protected_newobj_of(klass, (flags) & ~FL_WB_PROTECTED) : \ + rb_wb_unprotected_newobj_of(klass, flags)) +#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags) + /* hash.c */ struct st_table *rb_hash_tbl_raw(VALUE hash); VALUE rb_hash_has_key(VALUE hash, VALUE key); -- cgit v1.2.3