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

ruby-changes:54383

From: shyouhei <ko1@a...>
Date: Fri, 28 Dec 2018 10:06:11 +0900 (JST)
Subject: [ruby-changes:54383] shyouhei:r66597 (trunk): vm_insnhelper.c: delete unused macros

shyouhei	2018-12-28 10:06:04 +0900 (Fri, 28 Dec 2018)

  New Revision: 66597

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

  Log:
    vm_insnhelper.c: delete unused macros
    
    - FIXNUM_2_P: moved to vm_insnhelper.c because that is the only
      place this macro is used.
    
    - FLONUM_2_P: ditto.
    
    - FLOAT_HEAP_P: not used anywhere.
    
    - FLOAT_INSTANCE_P: ditto.
    
    - GET_TOS: ditto.
    
    - USE_IC_FOR_SPECIALIZED_METHOD: ditto.
    
    - rb_obj_hidden_p: ditto.
    
    - REG_A: ditto.
    
    - REG_B: ditto.
    
    - GET_CONST_INLINE_CACHE: ditto.
    
    - vm_regan_regtype: moved inside of VM_COLLECT_USAGE_DETAILS
      because that os the only place this enum is used.
    
    - vm_regan_acttype: ditto.
    
    - GET_GLOBAL: used only once.  Removed with replacing that usage.
    
    - SET_GLOBAL: ditto.
    
    - rb_method_definition_create: declaration moved to
      vm_insnhelper.c because that is the only place this declaration
      makes sense.
    
    - rb_method_definition_set: ditto.
    
    - rb_method_definition_eq: ditto.
    
    - rb_make_no_method_exception: ditto.

  Modified files:
    trunk/insns.def
    trunk/vm_insnhelper.c
    trunk/vm_insnhelper.h
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 66596)
+++ vm_insnhelper.c	(revision 66597)
@@ -19,6 +19,12 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L19
 #include "ruby/config.h"
 #include "debug_counter.h"
 
+extern rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
+extern void rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts);
+extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
+extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
+                                         int argc, const VALUE *argv, int priv);
+
 /* control stack frame */
 
 static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
@@ -1385,6 +1391,35 @@ opt_equal_fallback(VALUE recv, VALUE obj https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1391
 #define BUILTIN_CLASS_P(x, k) (!SPECIAL_CONST_P(x) && RBASIC_CLASS(x) == k)
 #define EQ_UNREDEFINED_P(t) BASIC_OP_UNREDEFINED_P(BOP_EQ, t##_REDEFINED_OP_FLAG)
 
+static bool
+FIXNUM_2_P(VALUE a, VALUE b)
+{
+    /* FIXNUM_P(a) && FIXNUM_P(b)
+     * == ((a & 1) && (b & 1))
+     * == a & b & 1 */
+    SIGNED_VALUE x = a;
+    SIGNED_VALUE y = b;
+    SIGNED_VALUE z = x & y & 1;
+    return z == 1;
+}
+
+static bool
+FLONUM_2_P(VALUE a, VALUE b)
+{
+#ifdef USE_FLONUM
+    /* FLONUM_P(a) && FLONUM_P(b)
+     * == ((a & 3) == 2) && ((b & 3) == 2)
+     * == ! ((a ^ 2) | (b ^ 2) & 3)
+     */
+    SIGNED_VALUE x = a;
+    SIGNED_VALUE y = b;
+    SIGNED_VALUE z = ((x ^ 2) | (y ^ 2)) & 3;
+    return !z;
+#else
+    return false;
+#endif
+}
+
 /* 1: compare by identity, 0: not applicable, -1: redefined */
 static inline int
 comparable_by_identity(VALUE recv, VALUE obj)
@@ -1619,6 +1654,19 @@ rb_simple_iseq_p(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1654
 	   iseq->body->param.flags.has_block == FALSE;
 }
 
+static void
+CALLER_SETUP_ARG(struct rb_control_frame_struct *restrict cfp,
+                 struct rb_calling_info *restrict calling,
+                 const struct rb_call_info *restrict ci)
+{
+    if (UNLIKELY(IS_ARGS_SPLAT(ci))) {
+        vm_caller_setup_arg_splat(cfp, calling);
+    }
+    if (UNLIKELY(IS_ARGS_KEYWORD(ci))) {
+        vm_caller_setup_arg_kw(cfp, calling, ci);
+    }
+}
+
 static inline int
 vm_callee_setup_arg(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
 		    const rb_iseq_t *iseq, VALUE *argv, int param_size, int local_size)
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 66596)
+++ vm_insnhelper.h	(revision 66597)
@@ -36,25 +36,12 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L36
 /* deal with stack                                        */
 /**********************************************************/
 
-static inline int
-rb_obj_hidden_p(VALUE obj)
-{
-    if (SPECIAL_CONST_P(obj)) {
-        return FALSE;
-    }
-    else {
-        return RBASIC_CLASS(obj) ? FALSE : TRUE;
-    }
-}
-
 #define PUSH(x) (SET_SV(x), INC_SP(1))
 #define TOPN(n) (*(GET_SP()-(n)-1))
 #define POPN(n) (DEC_SP(n))
 #define POP()   (DEC_SP(1))
 #define STACK_ADDR_FROM_TOP(n) (GET_SP()-(n))
 
-#define GET_TOS()  (tos)	/* dummy */
-
 /**********************************************************/
 /* deal with registers                                    */
 /**********************************************************/
@@ -68,9 +55,7 @@ rb_obj_hidden_p(VALUE obj) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L55
     VM_REG_CFP = ec->cfp; \
 } while (0)
 
-#define REG_A   reg_a
-#define REG_B   reg_b
-
+#if VM_COLLECT_USAGE_DETAILS
 enum vm_regan_regtype {
     VM_REGAN_PC = 0,
     VM_REGAN_SP = 1,
@@ -84,7 +69,6 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L69
     VM_REGAN_ACT_SET = 1
 };
 
-#if VM_COLLECT_USAGE_DETAILS
 #define COLLECT_USAGE_REGISTER_HELPER(a, b, v) \
   (COLLECT_USAGE_REGISTER((VM_REGAN_##a), (VM_REGAN_ACT_##b)), (v))
 #else
@@ -122,11 +106,6 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L106
 
 #define GET_PREV_EP(ep)                ((VALUE *)((ep)[VM_ENV_DATA_INDEX_SPECVAL] & ~0x03))
 
-#define GET_GLOBAL(entry)       rb_gvar_get((struct rb_global_entry*)(entry))
-#define SET_GLOBAL(entry, val)  rb_gvar_set((struct rb_global_entry*)(entry), (val))
-
-#define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 2))
-
 /**********************************************************/
 /* deal with values                                       */
 /**********************************************************/
@@ -175,20 +154,6 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L154
 /* others                                                 */
 /**********************************************************/
 
-/* optimize insn */
-#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
-#if USE_FLONUM
-#define FLONUM_2_P(a, b) (((((a)^2) | ((b)^2)) & 3) == 0) /* (FLONUM_P(a) && FLONUM_P(b)) */
-#else
-#define FLONUM_2_P(a, b) 0
-#endif
-#define FLOAT_HEAP_P(x) (!SPECIAL_CONST_P(x) && RBASIC_CLASS(x) == rb_cFloat)
-#define FLOAT_INSTANCE_P(x) (FLONUM_P(x) || FLOAT_HEAP_P(x))
-
-#ifndef USE_IC_FOR_SPECIALIZED_METHOD
-#define USE_IC_FOR_SPECIALIZED_METHOD 1
-#endif
-
 #ifndef MJIT_HEADER
 #define CALL_SIMPLE_METHOD() do { \
     rb_snum_t x = leaf ? INSN_ATTR(width) : 0; \
@@ -205,13 +170,6 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L170
 #define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state)
 #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state)
 
-extern rb_method_definition_t *rb_method_definition_create(rb_method_type_t type, ID mid);
-extern void rb_method_definition_set(const rb_method_entry_t *me, rb_method_definition_t *def, void *opts);
-extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_definition_t *d2);
-
-extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
-					 int argc, const VALUE *argv, int priv);
-
 static inline struct vm_throw_data *
 THROW_DATA_NEW(VALUE val, const rb_control_frame_t *cf, VALUE st)
 {
@@ -272,9 +230,4 @@ THROW_DATA_CONSUMED_SET(struct vm_throw_ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L230
 #define IS_ARGS_SPLAT(ci)   ((ci)->flag & VM_CALL_ARGS_SPLAT)
 #define IS_ARGS_KEYWORD(ci) ((ci)->flag & VM_CALL_KWARG)
 
-#define CALLER_SETUP_ARG(cfp, calling, ci) do { \
-    if (UNLIKELY(IS_ARGS_SPLAT(ci))) vm_caller_setup_arg_splat((cfp), (calling)); \
-    if (UNLIKELY(IS_ARGS_KEYWORD(ci))) vm_caller_setup_arg_kw((cfp), (calling), (ci)); \
-} while (0)
-
 #endif /* RUBY_INSNHELPER_H */
Index: insns.def
===================================================================
--- insns.def	(revision 66596)
+++ insns.def	(revision 66597)
@@ -290,7 +290,8 @@ getglobal https://github.com/ruby/ruby/blob/trunk/insns.def#L290
 (VALUE val)
 // attr bool leaf = leafness_of_getglobal(entry);
 {
-    val = GET_GLOBAL((VALUE)entry);
+    struct rb_global_entry *gentry = (void *)entry;
+    val = rb_gvar_get(gentry);
 }
 
 /* set global variable id as val. */
@@ -301,7 +302,8 @@ setglobal https://github.com/ruby/ruby/blob/trunk/insns.def#L302
 ()
 // attr bool leaf = leafness_of_setglobal(entry);
 {
-    SET_GLOBAL((VALUE)entry, val);
+    struct rb_global_entry *gentry = (void *)entry;
+    rb_gvar_set(gentry, val);
 }
 
 /**********************************************************/

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

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