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

ruby-changes:49001

From: ko1 <ko1@a...>
Date: Tue, 12 Dec 2017 01:07:24 +0900 (JST)
Subject: [ruby-changes:49001] ko1:r61120 (trunk): vm_exec.h: introduce macros for abstarction.

ko1	2017-12-12 01:07:21 +0900 (Tue, 12 Dec 2017)

  New Revision: 61120

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

  Log:
    vm_exec.h: introduce macros for abstarction.
    
    * vm_exec.h: declare two macros
      * START_OF_ORIGINAL_INSN()
      * DISPATCH_ORIGINAL_INSN()
      instead of inserting label and goto lines.
      For OPT_CALL_THREADED_CODE, first macro is empty and second macro
      is simply call the original insn function.
    
    * tool/instruction.rb: use above macros.

  Modified files:
    trunk/tool/instruction.rb
    trunk/vm_exec.h
Index: vm_exec.h
===================================================================
--- vm_exec.h	(revision 61119)
+++ vm_exec.h	(revision 61120)
@@ -66,6 +66,9 @@ error ! https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L66
 
 #define NEXT_INSN() return reg_cfp;
 
+#define START_OF_ORIGINAL_INSN(x) /* ignore */
+#define DISPATCH_ORIGINAL_INSN(x) return LABEL(x)(ec, reg_cfp);
+
 /************************************************/
 #elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
 /* threaded code with gcc */
@@ -95,10 +98,8 @@ error ! https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L98
 #else
 #define DISPATCH_ARCH_DEPEND_WAY(addr) \
 				/* do nothing */
-
 #endif
 
-
 /**********************************/
 #if OPT_DIRECT_THREADED_CODE
 
@@ -134,6 +135,9 @@ error ! https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L135
 
 #define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
 
+#define START_OF_ORIGINAL_INSN(x) start_of_##x:
+#define DISPATCH_ORIGINAL_INSN(x) goto  start_of_##x;
+
 /************************************************/
 #else /* no threaded code */
 /* most common method */
@@ -145,7 +149,6 @@ case BIN(insn): https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L149
   DEBUG_END_INSN();                           \
   break;
 
-
 #define INSN_DISPATCH()         \
   while (1) {			\
     switch (GET_CURRENT_INSN()) {
@@ -159,6 +162,9 @@ default:                        \ https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L162
 
 #define NEXT_INSN() goto first
 
+#define START_OF_ORIGINAL_INSN(x) start_of_##x:
+#define DISPATCH_ORIGINAL_INSN(x) goto  start_of_##x;
+
 #endif
 
 #define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
Index: tool/instruction.rb
===================================================================
--- tool/instruction.rb	(revision 61119)
+++ tool/instruction.rb	(revision 61120)
@@ -540,7 +540,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L540
       @insns.dup.each{|insn|
         body = <<-EOS
         vm_trace(ec, GET_CFP(), GET_PC());
-        goto start_of_#{insn.name};
+        DISPATCH_ORIGINAL_INSN(#{insn.name});
         EOS
 
         trace_insn = Instruction.new(name = "trace_#{insn.name}",
@@ -884,7 +884,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L884
     end
 
     def make_header insn
-      label = insn.trace ? '' : "start_of_#{insn.name}:;"
+      label = insn.trace ? '' : "START_OF_ORIGINAL_INSN(#{insn.name});"
       commit "INSN_ENTRY(#{insn.name}){#{label}"
       make_header_prepare_stack insn
       commit "{"

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

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