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

ruby-changes:46669

From: normal <ko1@a...>
Date: Fri, 19 May 2017 15:00:58 +0900 (JST)
Subject: [ruby-changes:46669] normal:r58784 (trunk): method.h: pack rb_method_definition_t struct

normal	2017-05-19 15:00:53 +0900 (Fri, 19 May 2017)

  New Revision: 58784

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

  Log:
    method.h: pack rb_method_definition_t struct
    
    We only have 12 method types, so 4 bits is enough for
    rb_method_type_t.
    
    Size reductions:
    
    - x86-64     48 => 40 bytes
    - x86        28 => 24 bytes
    
    * method.h (enum method_optimized_type): split out for CPP
      (struct rb_method_definition struct): pack on unaligned systems
      (rb_method_definition_t): split typedef to help ctags
      [ruby-core:81236] [Feature #13494]

  Modified files:
    trunk/method.h
Index: method.h
===================================================================
--- method.h	(revision 58783)
+++ method.h	(revision 58784)
@@ -144,10 +144,16 @@ typedef struct rb_method_refined_struct https://github.com/ruby/ruby/blob/trunk/method.h#L144
     const VALUE owner;
 } rb_method_refined_t;
 
-typedef struct rb_method_definition_struct {
-    rb_method_type_t type :  8; /* method type */
-    int alias_count       : 28;
-    int complemented_count: 28;
+enum method_optimized_type {
+    OPTIMIZED_METHOD_TYPE_SEND,
+    OPTIMIZED_METHOD_TYPE_CALL,
+    OPTIMIZED_METHOD_TYPE__MAX
+};
+
+PACKED_STRUCT_UNALIGNED(struct rb_method_definition_struct {
+    rb_method_type_t type :  4; /* method type */
+    int alias_count : 28;
+    int complemented_count : 28;
 
     union {
 	rb_method_iseq_t iseq;
@@ -157,16 +163,13 @@ typedef struct rb_method_definition_stru https://github.com/ruby/ruby/blob/trunk/method.h#L163
 	rb_method_refined_t refined;
 
 	const VALUE proc;                 /* should be marked */
-	enum method_optimized_type {
-	    OPTIMIZED_METHOD_TYPE_SEND,
-	    OPTIMIZED_METHOD_TYPE_CALL,
-
-	    OPTIMIZED_METHOD_TYPE__MAX
-	} optimize_type;
+	enum method_optimized_type optimize_type;
     } body;
 
     ID original_id;
-} rb_method_definition_t;
+});
+
+typedef struct rb_method_definition_struct rb_method_definition_t;
 
 #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
 #define UNDEFINED_REFINED_METHOD_P(def) \

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

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