[前][次][番号順一覧][スレッド一覧]

ruby-changes:39977

From: ko1 <ko1@a...>
Date: Tue, 6 Oct 2015 18:50:04 +0900 (JST)
Subject: [ruby-changes:39977] ko1:r52058 (trunk): * method.h: remove METHOD_ENTRY_SAFE(me) and related code

ko1	2015-10-06 18:49:53 +0900 (Tue, 06 Oct 2015)

  New Revision: 52058

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52058

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/method.h
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
    trunk/vm_method.c
Index: method.h
===================================================================
--- method.h	(revision 52057)
+++ method.h	(revision 52058)
@@ -63,7 +63,6 @@ typedef struct rb_callable_method_entry_ https://github.com/ruby/ruby/blob/trunk/method.h#L63
 
 #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_SAFE(me)  (int)                   (((me)->flags & (IMEMO_FL_USER3 | IMEMO_FL_USER4)) >> (IMEMO_FL_USHIFT+3))
 
 static inline void
 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 https://github.com/ruby/ruby/blob/trunk/method.h#L77
     me->flags = (me->flags & ~(IMEMO_FL_USER2                 )) | (basic << IMEMO_FL_USHIFT+2);
 }
 static inline void
-METHOD_ENTRY_SAFE_SET(rb_method_entry_t *me, unsigned int safe)
-{
-    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)
+METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
 {
     VM_ASSERT((int)visi >= 0 && visi <= 3);
     VM_ASSERT(basic <= 1);
-    VM_ASSERT(safe <= 1);
     me->flags =
       (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
 METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52057)
+++ ChangeLog	(revision 52058)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct  6 18:47:45 2015  Koichi Sasada  <ko1@a...>
+
+	* 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@r...>
 
 	* include/ruby/ruby.h: turn function macros into inline functions,
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 52057)
+++ vm_eval.c	(revision 52058)
@@ -601,10 +601,6 @@ rb_method_call_status(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L601
 		    return MISSING_PROTECTED;
 		}
 	    }
-
-	    if (METHOD_ENTRY_SAFE(me) > th->safe_level) {
-		rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE, rb_id2str(me->called_id));
-	    }
 	}
     }
 
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 52057)
+++ vm_method.c	(revision 52058)
@@ -369,7 +369,7 @@ rb_method_entry_t * https://github.com/ruby/ruby/blob/trunk/vm_method.c#L369
 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);
-    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);
     return me;
 }
@@ -604,7 +604,6 @@ method_entry_set(VALUE klass, ID mid, co https://github.com/ruby/ruby/blob/trunk/vm_method.c#L604
 {
     rb_method_entry_t *newme = rb_method_entry_make(klass, mid, defined_class, visi,
 						    me->def->type, method_definition_addref(me->def), 0, NULL);
-    METHOD_ENTRY_SAFE_SET(newme, METHOD_ENTRY_SAFE(me));
     method_added(klass, mid);
     return newme;
 }
@@ -1504,7 +1503,6 @@ rb_alias(VALUE klass, ID alias_name, ID https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1503
 
 	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;
-	METHOD_ENTRY_SAFE_SET(alias_me, METHOD_ENTRY_SAFE(orig_me));
     }
     else {
 	rb_method_entry_t *alias_me;
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 52057)
+++ vm_insnhelper.c	(revision 52058)
@@ -2114,13 +2114,11 @@ vm_call_method0(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2114
     VM_ASSERT(callable_method_entry_p(cc->me));
 
     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));
 	    return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
 	}
 	else {
-	    int safe;
-
 	    if (!(ci->flag & VM_CALL_FCALL) && (METHOD_ENTRY_VISI(cc->me) == METHOD_VISI_PRIVATE)) {
 		enum method_missing_reason stat = MISSING_PRIVATE;
 		if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
@@ -2139,9 +2137,6 @@ vm_call_method0(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2137
 		    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 {
 		return vm_call_method_each_type(th, cfp, calling, ci, cc, enable_fastpath);
 	    }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]