diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-11 23:13:01 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-11 23:13:01 +0000 |
commit | 08f3cfb5859332c0f7a9a574dc64a2a002c50354 (patch) | |
tree | 9b88e32745288764702ef3685d3b10b5b1d175a8 /internal.h | |
parent | 287b046fab9fc07f228977de7e0dc087f29d2516 (diff) |
* internal.h: use T_IMEMO to represent `struct MEMO' value.
memo->v1 and memo->v2 is WB protected values.
So use MEMO_V1/V2_SET() macros to set these values.
memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
value), so use gc_mark_maybe() in gc.c to mark it.
Rename NEW_MEMO() to MEMO_NEW().
Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
(I'm not sure it is working correctly...)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/internal.h b/internal.h index 0ac09bceeb..c7ee731622 100644 --- a/internal.h +++ b/internal.h @@ -530,11 +530,12 @@ struct RIMemo { }; enum imemo_type { - imemo_none, - imemo_cref, - imemo_svar, - imemo_throw_data, - imemo_ifunc, + imemo_none = 0, + imemo_cref = 1, + imemo_svar = 2, + imemo_throw_data = 3, + imemo_ifunc = 4, + imemo_memo = 5, imemo_mask = 0x07 }; @@ -544,8 +545,6 @@ imemo_type(VALUE imemo) return (RBASIC(imemo)->flags >> FL_USHIFT) & imemo_mask; } -VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0); - /* CREF */ typedef struct rb_cref_struct { @@ -595,17 +594,26 @@ struct vm_ifunc { struct MEMO { VALUE flags; VALUE reserved; - VALUE v1; - VALUE v2; + const VALUE v1; + const VALUE v2; union { long cnt; long state; - VALUE value; + const VALUE value; VALUE (*func)(ANYARGS); } u3; }; +#define MEMO_V1_SET(m, v) RB_OBJ_WRITE((memo), &(memo)->v1, (v)) +#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((memo), &(memo)->v2, (v)) + #define MEMO_CAST(m) ((struct MEMO *)m) +#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0)) + +#define type_roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y)) +#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value)) +#define NEW_MEMO_FOR(type, value) \ + ((value) = rb_ary_tmp_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value)) struct vtm; /* defined by timev.h */ @@ -1267,6 +1275,8 @@ size_t rb_obj_memsize_of(VALUE); size_t rb_obj_gc_flags(VALUE, ID[], size_t); void rb_gc_mark_values(long n, const VALUE *values); +VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0); + RUBY_SYMBOL_EXPORT_END #if defined(__cplusplus) |