mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* method.h: remove METHOD_ENTRY_SAFE(me) and related code
because $SAFE = 3 and 4 is not available. Now, $SAFE is not checked on method dispatch at all. * vm_eval.c, vm_insnhelper.c, vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa4de7328d
commit
72cf24c813
5 changed files with 12 additions and 23 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Oct 6 18:47:45 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* method.h: remove METHOD_ENTRY_SAFE(me) and related code
|
||||||
|
because $SAFE = 3 and 4 is not available.
|
||||||
|
Now, $SAFE is not checked on method dispatch at all.
|
||||||
|
|
||||||
|
* vm_eval.c, vm_insnhelper.c, vm_method.c: ditto.
|
||||||
|
|
||||||
Tue Oct 6 13:56:14 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Oct 6 13:56:14 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* include/ruby/ruby.h: turn function macros into inline functions,
|
* include/ruby/ruby.h: turn function macros into inline functions,
|
||||||
|
|
12
method.h
12
method.h
|
@ -63,7 +63,6 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e
|
||||||
|
|
||||||
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
||||||
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
||||||
#define METHOD_ENTRY_SAFE(me) (int) (((me)->flags & (IMEMO_FL_USER3 | IMEMO_FL_USER4)) >> (IMEMO_FL_USHIFT+3))
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
||||||
|
@ -78,20 +77,13 @@ METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
|
||||||
me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << IMEMO_FL_USHIFT+2);
|
me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << IMEMO_FL_USHIFT+2);
|
||||||
}
|
}
|
||||||
static inline void
|
static inline void
|
||||||
METHOD_ENTRY_SAFE_SET(rb_method_entry_t *me, unsigned int safe)
|
METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
|
||||||
{
|
|
||||||
VM_ASSERT(safe <= 1);
|
|
||||||
me->flags = (me->flags & ~(IMEMO_FL_USER3 | IMEMO_FL_USER4)) | (safe << IMEMO_FL_USHIFT+3);
|
|
||||||
}
|
|
||||||
static inline void
|
|
||||||
METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic, unsigned int safe)
|
|
||||||
{
|
{
|
||||||
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
||||||
VM_ASSERT(basic <= 1);
|
VM_ASSERT(basic <= 1);
|
||||||
VM_ASSERT(safe <= 1);
|
|
||||||
me->flags =
|
me->flags =
|
||||||
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3|IMEMO_FL_USER4)) |
|
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3|IMEMO_FL_USER4)) |
|
||||||
((visi << IMEMO_FL_USHIFT+0) | (basic << (IMEMO_FL_USHIFT+2)) | (safe << IMEMO_FL_USHIFT+3));
|
((visi << IMEMO_FL_USHIFT+0) | (basic << (IMEMO_FL_USHIFT+2)));
|
||||||
}
|
}
|
||||||
static inline void
|
static inline void
|
||||||
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
||||||
|
|
|
@ -601,10 +601,6 @@ rb_method_call_status(rb_thread_t *th, const rb_callable_method_entry_t *me, cal
|
||||||
return MISSING_PROTECTED;
|
return MISSING_PROTECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (METHOD_ENTRY_SAFE(me) > th->safe_level) {
|
|
||||||
rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE, rb_id2str(me->called_id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2114,13 +2114,11 @@ vm_call_method0(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
|
||||||
VM_ASSERT(callable_method_entry_p(cc->me));
|
VM_ASSERT(callable_method_entry_p(cc->me));
|
||||||
|
|
||||||
if (cc->me != NULL) {
|
if (cc->me != NULL) {
|
||||||
if (LIKELY(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PUBLIC && METHOD_ENTRY_SAFE(cc->me) == 0)) {
|
if (LIKELY(METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PUBLIC)) {
|
||||||
VM_ASSERT(callable_method_entry_p(cc->me));
|
VM_ASSERT(callable_method_entry_p(cc->me));
|
||||||
return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
|
return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int safe;
|
|
||||||
|
|
||||||
if (!(ci->flag & VM_CALL_FCALL) && (METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PRIVATE)) {
|
if (!(ci->flag & VM_CALL_FCALL) && (METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PRIVATE)) {
|
||||||
enum method_missing_reason stat = MISSING_PRIVATE;
|
enum method_missing_reason stat = MISSING_PRIVATE;
|
||||||
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
||||||
|
@ -2139,9 +2137,6 @@ vm_call_method0(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
|
||||||
return vm_call_method_each_type(th, cfp, calling, ci, cc, FALSE);
|
return vm_call_method_each_type(th, cfp, calling, ci, cc, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((safe = METHOD_ENTRY_SAFE(cc->me)) > th->safe_level && safe > 2) {
|
|
||||||
rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE, rb_id2str(ci->mid));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
|
return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ rb_method_entry_t *
|
||||||
rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def)
|
rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def)
|
||||||
{
|
{
|
||||||
rb_method_entry_t *me = rb_method_entry_alloc(called_id, klass, filter_defined_class(klass), def);
|
rb_method_entry_t *me = rb_method_entry_alloc(called_id, klass, filter_defined_class(klass), def);
|
||||||
METHOD_ENTRY_FLAGS_SET(me, visi, ruby_running ? FALSE : TRUE, rb_safe_level());
|
METHOD_ENTRY_FLAGS_SET(me, visi, ruby_running ? FALSE : TRUE);
|
||||||
if (def != NULL) method_definition_reset(me);
|
if (def != NULL) method_definition_reset(me);
|
||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,6 @@ method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *me,
|
||||||
{
|
{
|
||||||
rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi,
|
rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi,
|
||||||
me->def->type, method_definition_addref(me->def), 0, NULL);
|
me->def->type, method_definition_addref(me->def), 0, NULL);
|
||||||
METHOD_ENTRY_SAFE_SET(newme, METHOD_ENTRY_SAFE(me));
|
|
||||||
method_added(klass, mid);
|
method_added(klass, mid);
|
||||||
return newme;
|
return newme;
|
||||||
}
|
}
|
||||||
|
@ -1504,7 +1503,6 @@ rb_alias(VALUE klass, ID alias_name, ID original_name)
|
||||||
|
|
||||||
alias_me = rb_add_method(target_klass, alias_name, VM_METHOD_TYPE_ALIAS, (void *)rb_method_entry_clone(orig_me), visi);
|
alias_me = rb_add_method(target_klass, alias_name, VM_METHOD_TYPE_ALIAS, (void *)rb_method_entry_clone(orig_me), visi);
|
||||||
alias_me->def->original_id = orig_me->called_id;
|
alias_me->def->original_id = orig_me->called_id;
|
||||||
METHOD_ENTRY_SAFE_SET(alias_me, METHOD_ENTRY_SAFE(orig_me));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_method_entry_t *alias_me;
|
rb_method_entry_t *alias_me;
|
||||||
|
|
Loading…
Reference in a new issue