Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add NEWOBJ_EDEN macro.

  • Loading branch information...
commit 085c09f9dbddea6203bbefc3bd1fa04b231d8793 1 parent aa7d928
Evan Weaver authored
View
2  enum.c
@@ -748,7 +748,7 @@ sort_by_i(i, ary)
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
}
- memo = rb_node_newnode(NODE_MEMO, v, i, 0);
+ memo = NEW_NODE_EDEN(NODE_MEMO, v, i, 0);
rb_ary_push(ary, (VALUE)memo);
return Qnil;
}
View
2  eval.c
@@ -5688,7 +5688,7 @@ rb_protect(proc, data, state)
int status;
PUSH_TAG(PROT_EMPTY);
- cont_protect = (VALUE)rb_node_newnode(NODE_MEMO, cont_protect, 0, 0);
+ cont_protect = (VALUE)NEW_NODE_EDEN(NODE_MEMO, cont_protect, 0, 0);
if ((status = EXEC_TAG()) == 0) {
result = (*proc)(data);
}
View
4 gc.c
@@ -1167,7 +1167,7 @@ pop_freelist(heaps_space_t* heaps_space)
}
VALUE
-rb_newobj()
+rb_newobj_eden(int type)
{
VALUE obj;
@@ -1215,7 +1215,7 @@ rb_newobj_longlife(int type)
VALUE obj;
if (longlife_disabled == Qtrue || longlife_temp_disable == Qtrue)
- return rb_newobj();
+ return rb_newobj_eden(type);
if (during_gc)
rb_bug("object allocation during garbage collection phase");
View
10 node.h
@@ -231,8 +231,12 @@ extern NODE *ruby_top_cref;
#define nd_tag u1.id
#define nd_tval u2.value
+// Default node allocator
#define NEW_NODE(t,a0,a1,a2) rb_node_newnode_longlife((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
-#define NEW_NODE_SHORTLIFE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
+
+// Specific node allocators
+#define NEW_NODE_EDEN(t,a0,a1,a2) rb_node_newnode_eden((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
+#define NEW_NODE_LONGLIFE(t,a0,a1,a2) rb_node_newnode_longlife((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
#define NEW_METHOD(n,x) NEW_NODE(NODE_METHOD,x,n,0)
#define NEW_FBODY(n,i,o) NEW_NODE(NODE_FBODY,n,i,o)
@@ -241,7 +245,7 @@ extern NODE *ruby_top_cref;
#define NEW_CFUNC(f,c) NEW_NODE(NODE_CFUNC,f,c,0)
/* IFUNC nodes are created whenever an enumeration runs; see rb_iterate(). For
this reason, they're allocated in ordinary heap. */
-#define NEW_IFUNC(f,c) NEW_NODE_SHORTLIFE(NODE_IFUNC,f,c,0)
+#define NEW_IFUNC(f,c) NEW_NODE_EDEN(NODE_IFUNC,f,c,0)
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
#define NEW_SCOPE(b) NEW_NODE(NODE_SCOPE,local_tbl(),0,(b))
#define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
@@ -351,7 +355,7 @@ NODE *rb_compile_string _((const char*, VALUE, int));
NODE *rb_compile_file _((const char*, VALUE, int));
void rb_add_method _((VALUE, ID, NODE *, int));
-NODE *rb_node_newnode _((enum node_type,VALUE,VALUE,VALUE));
+NODE *rb_node_newnode_eden _((enum node_type,VALUE,VALUE,VALUE));
NODE *rb_node_newnode_longlife _((enum node_type,VALUE,VALUE,VALUE));
NODE* rb_method_node _((VALUE klass, ID id));
View
20 parse.y
@@ -3197,7 +3197,7 @@ tokadd_string(func, term, paren, nest)
}
#define NEW_STRTERM(func, term, paren) \
- rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
+ NEW_NODE_EDEN(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
static int
parse_string(quote)
@@ -3303,7 +3303,7 @@ heredoc_identifier()
tokfix();
len = lex_p - lex_pbeg;
lex_p = lex_pend;
- lex_strterm = rb_node_newnode(NODE_HEREDOC,
+ lex_strterm = NEW_NODE_EDEN(NODE_HEREDOC,
rb_str_new(tok(), toklen()), /* nd_lit */
len, /* nd_nth */
lex_lastline); /* nd_orig */
@@ -4585,11 +4585,11 @@ yylex()
}
NODE*
-rb_node_newnode(type, a0, a1, a2)
+rb_node_newnode_eden(type, a0, a1, a2)
enum node_type type;
VALUE a0, a1, a2;
{
- NODE *n = (NODE*)rb_newobj();
+ NODE *n = (NODE*)rb_newobj_eden(type);
n->flags |= T_NODE;
nd_set_type(n, type);
@@ -6302,15 +6302,15 @@ symbols_i(key, value, ary)
/*
* call-seq:
* Symbol.all_symbols => array
- *
+ *
* Returns an array of all the symbols currently in Ruby's symbol
* table.
- *
+ *
* Symbol.all_symbols.size #=> 903
* Symbol.all_symbols[1,20] #=> [:floor, :ARGV, :Binding, :symlink,
- * :chown, :EOFError, :$;, :String,
- * :LOCK_SH, :"setuid?", :$<,
- * :default_proc, :compact, :extend,
+ * :chown, :EOFError, :$;, :String,
+ * :LOCK_SH, :"setuid?", :$<,
+ * :default_proc, :compact, :extend,
* :Tms, :getwd, :$=, :ThreadGroup,
* :wait2, :$>]
*/
@@ -6425,7 +6425,7 @@ rb_lastline_set(val)
#ifdef YYMALLOC
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
-#define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser_heap, 0)
+#define NEWHEAP() NEW_NODE_EDEN(NODE_ALLOCA, 0, (VALUE)parser_heap, 0)
#define ADD2HEAP(n, c, p) ((parser_heap = (n))->u1.node = (p), \
(n)->u3.cnt = (c), (p))
View
16 ruby.h
@@ -307,11 +307,17 @@ char *rb_str2cstr _((VALUE,long*));
RSTRING(x)->ptr[0]:(char)(NUM2INT(x)&0xff))
#define CHR2FIX(x) INT2FIX((long)((x)&0xff))
-VALUE rb_newobj _((void));
VALUE rb_newobj_longlife _((int));
+VALUE rb_newobj_eden _((int));
void rb_register_newobj _((int));
-#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj()
+// Default allocator
+#define NEWOBJ(obj,type) type *obj = (type*)rb_newobj_eden(-1)
+
+// Specific allocators
+#define NEWOBJ_LONGLIFE(obj,type) type *obj = (type*)rb_newobj_longlife(-1)
+#define NEWOBJ_EDEN(obj,type) type *obj = (type*)rb_newobj_eden(-1)
+
#define OBJSETUP(obj,c,t) do {\
rb_register_newobj(t);\
RBASIC(obj)->flags = (t);\
@@ -481,9 +487,9 @@ struct RBignum {
#define FL_FINALIZE (1<<7)
#define FL_TAINT (1<<8)
#define FL_EXIVAR (1<<9)
-#define FL_FREEZE (1<<10)
-#define FL_REMEMBERED_SET (1<<11)
-#define FL_LONGLIFE (1<<12)
+#define FL_FREEZE (1<<10)
+#define FL_REMEMBERED_SET (1<<11)
+#define FL_LONGLIFE (1<<12)
#define FL_USHIFT 13
View
2  variable.c
@@ -1332,7 +1332,7 @@ rb_autoload(mod, id, file)
fn = rb_str_new2(file);
FL_UNSET(fn, FL_TAINT);
OBJ_FREEZE(fn);
- st_insert(tbl, id, (st_data_t)rb_node_newnode(NODE_MEMO, fn, ruby_safe_level, 0));
+ st_insert(tbl, id, (st_data_t)NEW_NODE_EDEN(NODE_MEMO, fn, ruby_safe_level, 0));
}
static NODE*
Please sign in to comment.
Something went wrong with that request. Please try again.