diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-07-03 16:56:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-03 16:56:44 +0900 |
commit | a0f12a0258e4020bd657ee80b7d8f22bd33ea223 (patch) | |
tree | f6ebafa85cba2bddddc090f8d3c3b74c2c9f374b /internal | |
parent | 8655c2e69041cc812d30c2e951a8ac9ea7a60c47 (diff) | |
download | ruby-a0f12a0258e4020bd657ee80b7d8f22bd33ea223.tar.gz |
Use ID instead of GENTRY for gvars. (#3278)
Use ID instead of GENTRY for gvars.
Global variables are compiled into GENTRY (a pointer to struct
rb_global_entry). This patch replace this GENTRY to ID and
make the code simple.
We need to search GENTRY from ID every time (st_lookup), so
additional overhead will be introduced.
However, the performance of accessing global variables is not
important now a day and this simplicity helps Ractor development.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/variable.h | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/internal/variable.h b/internal/variable.h index f0b7b215a4..6ed728076e 100644 --- a/internal/variable.h +++ b/internal/variable.h @@ -19,13 +19,6 @@ #define ROBJECT_TRANSIENT_FLAG FL_USER13 -struct rb_global_variable; /* defined in variable.c */ - -struct rb_global_entry { - struct rb_global_variable *var; - ID id; -}; - /* variable.c */ void rb_gc_mark_global_tbl(void); void rb_gc_update_global_tbl(void); @@ -36,9 +29,8 @@ VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef); void rb_autoload_str(VALUE mod, ID id, VALUE file); VALUE rb_autoload_at_p(VALUE, ID, int); NORETURN(VALUE rb_mod_const_missing(VALUE,VALUE)); -rb_gvar_getter_t *rb_gvar_getter_function_of(const struct rb_global_entry *); -rb_gvar_setter_t *rb_gvar_setter_function_of(const struct rb_global_entry *); -bool rb_gvar_is_traced(const struct rb_global_entry *); +rb_gvar_getter_t *rb_gvar_getter_function_of(ID); +rb_gvar_setter_t *rb_gvar_setter_function_of(ID); void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_); static inline bool ROBJ_TRANSIENT_P(VALUE obj); static inline void ROBJ_TRANSIENT_SET(VALUE obj); @@ -55,11 +47,9 @@ void rb_deprecate_constant(VALUE mod, const char *name); RUBY_SYMBOL_EXPORT_END MJIT_SYMBOL_EXPORT_BEGIN -struct rb_global_entry *rb_global_entry(ID); -VALUE rb_gvar_get(struct rb_global_entry *); -VALUE rb_gvar_set(struct rb_global_entry *, VALUE); -VALUE rb_gvar_defined(struct rb_global_entry *); -struct st_table *rb_ivar_generic_ivtbl(void); +VALUE rb_gvar_get(ID); +VALUE rb_gvar_set(ID, VALUE); +VALUE rb_gvar_defined(ID); void rb_const_warn_if_deprecated(const rb_const_entry_t *, VALUE, ID); MJIT_SYMBOL_EXPORT_END |