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

ruby-changes:7944

From: ko1 <ko1@a...>
Date: Tue, 23 Sep 2008 09:21:07 +0900 (JST)
Subject: [ruby-changes:7944] Ruby:r19466 (trunk): * common.mk: clean up

ko1	2008-09-23 09:20:28 +0900 (Tue, 23 Sep 2008)

  New Revision: 19466

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

  Log:
    * common.mk: clean up
      - remove blockinlining.$(OBJEXT) to built
      - make ENCODING_H_INCLDUES variable (include/ruby/encoding.h)
      - make VM_CORE_H_INCLUDES variable (vm_core.h)
      - simplify rules.
      - make depends rule to output depend status using gcc -MM.
    * include/ruby/mvm.h, include/ruby/vm.h: rename mvm.h to vm.h.
    * include/ruby.h: ditto.
    * load.c: add inclusion explicitly.
    * enumerator.c, object.c, parse.y, thread.c, vm_dump.c:
      remove useless inclusion.
    * eval_intern.h: cleanup inclusion.
    * vm_core.h: rb_thread_t should be defined in this file.
    * vm_evalbody.c, vm_exec.c: rename vm_evalbody.c to vm_exec.c.
    * vm.h, vm_exec.h: rename vm.h to vm_exec.h.
    * insnhelper.h, vm_insnhelper.h: rename insnhelper.h to vm_insnhelper.h.
    * vm.c, vm_insnhelper.c, vm_insnhelper.h:
      - rename vm_eval() to vm_exec_core().
      - rename vm_eval_body() to vm_exec().
      - cleanup include order.
    * vm_method.c: fix comment.

  Added files:
    trunk/include/ruby/vm.h
    trunk/vm_exec.c
    trunk/vm_exec.h
    trunk/vm_insnhelper.h
  Removed files:
    trunk/include/ruby/mvm.h
    trunk/insnhelper.h
    trunk/vm.h
    trunk/vm_evalbody.c
  Modified files:
    trunk/ChangeLog
    trunk/common.mk
    trunk/enumerator.c
    trunk/eval_intern.h
    trunk/include/ruby.h
    trunk/load.c
    trunk/object.c
    trunk/parse.y
    trunk/thread.c
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_dump.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
    trunk/vm_method.c

Index: insnhelper.h
===================================================================
--- insnhelper.h	(revision 19465)
+++ insnhelper.h	(revision 19466)
@@ -1,148 +0,0 @@
-/**********************************************************************
-
-  insnhelper.h - helper macros to implement each instructions
-
-  $Author$
-  created at: 04/01/01 15:50:34 JST
-
-  Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#ifndef RUBY_INSNHELPER_H
-#define RUBY_INSNHELPER_H
-
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "eval_intern.h"
-#include "vm_core.h"
-#include "vm.h"
-
-/**********************************************************/
-/* deal with stack                                        */
-/**********************************************************/
-
-#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                                    */
-/**********************************************************/
-
-#define REG_CFP (reg_cfp)
-#define REG_PC  (REG_CFP->pc)
-#define REG_SP  (REG_CFP->sp)
-#define REG_LFP (REG_CFP->lfp)
-#define REG_DFP (REG_CFP->dfp)
-
-#define RESTORE_REGS() do { \
-  REG_CFP = th->cfp; \
-} while (0)
-
-#define REG_A   reg_a
-#define REG_B   reg_b
-
-#ifdef COLLECT_USAGE_ANALYSIS
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
-  (USAGE_ANALYSIS_REGISTER(a, b), (v))
-#else
-#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) (v)
-#endif
-
-/* PC */
-#define GET_PC()           (USAGE_ANALYSIS_REGISTER_HELPER(0, 0, REG_PC))
-#define SET_PC(x)          (REG_PC = (USAGE_ANALYSIS_REGISTER_HELPER(0, 1, x)))
-#define GET_CURRENT_INSN() (*GET_PC())
-#define GET_OPERAND(n)     (GET_PC()[(n)])
-#define ADD_PC(n)          (SET_PC(REG_PC + (n)))
-
-#define GET_PC_COUNT()     (REG_PC - GET_ISEQ()->iseq_encoded)
-#define JUMP(dst)          (REG_PC += (dst))
-
-/* FP */
-#define GET_CFP()  (USAGE_ANALYSIS_REGISTER_HELPER(2, 0, REG_CFP))
-#define GET_LFP()  (USAGE_ANALYSIS_REGISTER_HELPER(3, 0, REG_LFP))
-#define SET_LFP(x) (REG_LFP = (USAGE_ANALYSIS_REGISTER_HELPER(3, 1, (x))))
-#define GET_DFP()  (USAGE_ANALYSIS_REGISTER_HELPER(4, 0, REG_DFP))
-#define SET_DFP(x) (REG_DFP = (USAGE_ANALYSIS_REGISTER_HELPER(4, 1, (x))))
-
-/* SP */
-#define GET_SP()   (USAGE_ANALYSIS_REGISTER_HELPER(1, 0, REG_SP))
-#define SET_SP(x)  (REG_SP  = (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define INC_SP(x)  (REG_SP += (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define DEC_SP(x)  (REG_SP -= (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
-#define SET_SV(x)  (*GET_SP() = (x))
-  /* set current stack value as x */
-
-#define GET_SP_COUNT() (REG_SP - th->stack)
-
-/* instruction sequence C struct */
-#define GET_ISEQ() (GET_CFP()->iseq)
-
-/**********************************************************/
-/* deal with variables                                    */
-/**********************************************************/
-
-#define GET_PREV_DFP(dfp)                ((VALUE *)((dfp)[0] & ~0x03))
-
-#define GET_GLOBAL(entry)       rb_gvar_get((struct global_entry*)entry)
-#define SET_GLOBAL(entry, val)  rb_gvar_set((struct global_entry*)entry, val)
-
-#define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 1))
-
-/**********************************************************/
-/* deal with values                                       */
-/**********************************************************/
-
-#define GET_SELF() (USAGE_ANALYSIS_REGISTER_HELPER(5, 0, GET_CFP()->self))
-
-/**********************************************************/
-/* deal with control flow 2: method/iterator              */
-/**********************************************************/
-
-#define COPY_CREF(c1, c2) do {  \
-  NODE *__tmp_c2 = (c2); \
-  c1->nd_clss = __tmp_c2->nd_clss; \
-  c1->nd_visi = __tmp_c2->nd_visi; \
-  c1->nd_next = __tmp_c2->nd_next; \
-} while (0)
-
-#define CALL_METHOD(num, blockptr, flag, id, mn, recv, klass) do { \
-    VALUE v = vm_call_method(th, GET_CFP(), num, blockptr, flag, id, mn, recv, klass); \
-    if (v == Qundef) { \
-	RESTORE_REGS(); \
-	NEXT_INSN(); \
-    } \
-    else { \
-	val = v; \
-    } \
-} while (0)
-
-#define GET_BLOCK_PTR() \
-  ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0])))
-
-/**********************************************************/
-/* deal with control flow 3: exception                    */
-/**********************************************************/
-
-
-/**********************************************************/
-/* others                                                 */
-/**********************************************************/
-
-/* optimize insn */
-#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
-#define BASIC_OP_UNREDEFINED_P(op) ((ruby_vm_redefined_flag & (op)) == 0)
-#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
-
-#define CALL_SIMPLE_METHOD(num, id, recv) do { \
-    VALUE klass = CLASS_OF(recv); \
-    CALL_METHOD(num, 0, 0, id, rb_method_node(klass, id), recv, CLASS_OF(recv)); \
-} while (0)
-
-#endif /* RUBY_INSNHELPER_H */
Index: vm_evalbody.c
===================================================================
--- vm_evalbody.c	(revision 19465)
+++ vm_evalbody.c	(revision 19466)
@@ -1,148 +0,0 @@
-/* -*-c-*- */
-/**********************************************************************
-
-  vm_evalbody.c -
-
-  $Author$
-
-  Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include <math.h>
-
-#if VMDEBUG > 0
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-
-#elif __GNUC__ && __x86_64__
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
-
-#elif __GNUC__ && __i386__
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg)
-
-#else
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-#endif
-/* #define DECL_SC_REG(r, reg) VALUE reg_##r */
-
-#if !OPT_CALL_THREADED_CODE
-static VALUE
-vm_eval(rb_thread_t *th, VALUE initial)
-{
-
-#if OPT_STACK_CACHING
-#if 0
-#elif __GNUC__ && __x86_64
-    DECL_SC_REG(VALUE, a, "12");
-    DECL_SC_REG(VALUE, b, "13");
-#else
-    register VALUE reg_a;
-    register VALUE reg_b;
-#endif
-#endif
-
-#if __GNUC__ && __i386__
-    DECL_SC_REG(VALUE *, pc, "di");
-    DECL_SC_REG(rb_control_frame_t *, cfp, "si");
-#define USE_MACHINE_REGS 1
-
-#elif __GNUC__ && __x86_64__
-    DECL_SC_REG(VALUE *, pc, "14");
-    DECL_SC_REG(rb_control_frame_t *, cfp, "15");
-#define USE_MACHINE_REGS 1
-
-#else
-    register rb_control_frame_t *reg_cfp;
-    VALUE *reg_pc;
-#endif
-
-#if USE_MACHINE_REGS
-
-#undef  RESTORE_REGS
-#define RESTORE_REGS() \
-{ \
-  REG_CFP = th->cfp; \
-  reg_pc  = reg_cfp->pc; \
-}
-
-#undef  REG_PC
-#define REG_PC reg_pc
-#undef  GET_PC
-#define GET_PC() (reg_pc)
-#undef  SET_PC
-#define SET_PC(x) (reg_cfp->pc = REG_PC = (x))
-#endif
-
-#if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
-#include "vmtc.inc"
-    if (th == 0) {
-#if OPT_STACK_CACHING
-	finish_insn_seq[0] = (VALUE)&&LABEL (finish_SC_ax_ax);
-#else
-	finish_insn_seq[0] = (VALUE)&&LABEL (finish);
-#endif
-	return (VALUE)insns_address_table;
-    }
-#endif
-    reg_cfp = th->cfp;
-    reg_pc = reg_cfp->pc;
-
-#if OPT_STACK_CACHING
-    reg_a = initial;
-    reg_b = 0;
-#endif
-
-  first:
-    INSN_DISPATCH();
-/*****************/
- #include "vm.inc"
-/*****************/
-    END_INSNS_DISPATCH();
-
-    /* unreachable */
-    rb_bug("vm_eval: unreachable");
-    goto first;
-}
-
-#else
-
-#include "vm.inc"
-#include "vmtc.inc"
-
-const void *const *
-get_insns_address_table()
-{
-    return insns_address_table;
-}
-
-VALUE
-vm_eval(rb_thread_t *th, VALUE initial)
-{
-    register rb_control_frame_t *reg_cfp = th->cfp;
-    VALUE ret;
-
-    while (*GET_PC()) {
-	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);
-
-	if (reg_cfp == 0) {
-	    VALUE err = th->errinfo;
-	    th->errinfo = Qnil;
-	    return err;
-	}
-    }
-
-    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_FINISH) {
-	rb_bug("cfp consistency error");
-    }
-
-    ret = *(th->cfp->sp-1); /* pop */
-    th->cfp++; /* pop cf */
-    return ret;
-}
-#endif
-
-const void **
-vm_get_insns_address_table(void)
-{
-    return (const void **)vm_eval(0, 0);
-}
Index: vm.h
===================================================================
--- vm.h	(revision 19465)
+++ vm.h	(revision 19466)
@@ -1,257 +0,0 @@
-/**********************************************************************
-
-  vm.h -
-
-  $Author$
-  created at: 04/01/01 16:56:59 JST
-
-  Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#ifndef RUBY_VM_H
-#define RUBY_VM_H
-
-typedef long OFFSET;
-typedef unsigned long lindex_t;
-typedef unsigned long dindex_t;
-typedef rb_num_t GENTRY;
-typedef rb_iseq_t *ISEQ;
-
-extern VALUE rb_cEnv;
-extern VALUE ruby_vm_global_state_version;
-extern VALUE ruby_vm_redefined_flag;
-
-
-/**
- * VM Debug Level
- *
- * debug level:
- *  0: no debug output
- *  1: show instruction name
- *  2: show stack frame when control stack frame is changed
- *  3: show stack status
- *  4: show register
- *  5:
- * 10: gc check
- */
-
-
-#ifndef VMDEBUG
-#define VMDEBUG 0
-#endif
-
-#if 0
-#undef  VMDEBUG
-#define VMDEBUG 3
-#endif
-
-#ifdef  COLLECT_USAGE_ANALYSIS
-#define USAGE_ANALYSIS_INSN(insn)           vm_analysis_insn(insn)
-#define USAGE_ANALYSIS_OPERAND(insn, n, op) vm_analysis_operand(insn, n, (VALUE)op)
-#define USAGE_ANALYSIS_REGISTER(reg, s)     vm_analysis_register(reg, s)
-#else
-#define USAGE_ANALYSIS_INSN(insn)		/* none */
-#define USAGE_ANALYSIS_OPERAND(insn, n, op)	/* none */
-#define USAGE_ANALYSIS_REGISTER(reg, s)		/* none */
-#endif
-
-#ifdef __GCC__
-/* TODO: machine dependent prefetch instruction */
-#define PREFETCH(pc)
-#else
-#define PREFETCH(pc)
-#endif
-
-#if VMDEBUG > 0
-#define debugs printf
-#define DEBUG_ENTER_INSN(insn) \
-  debug_print_pre(th, GET_CFP());
-
-#if OPT_STACK_CACHING
-#define SC_REGS() , reg_a, reg_b
-#else
-#define SC_REGS()
-#endif
-
-#define DEBUG_END_INSN() \
-  debug_print_post(th, GET_CFP() SC_REGS());
-
-#else
-
-#define debugs
-#define DEBUG_ENTER_INSN(insn)
-#define DEBUG_END_INSN()
-#endif
-
-#define throwdebug if(0)printf
-/* #define throwdebug printf */
-
-#define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
-
-
-/************************************************/
-#if   DISPATCH_XXX
-error !
-/************************************************/
-#elif OPT_CALL_THREADED_CODE
-
-#define LABEL(x)  insn_func_##x
-#define ELABEL(x)
-#define LABEL_PTR(x) &LABEL(x)
-
-#define INSN_ENTRY(insn) \
-  static rb_control_frame_t * \
-    FUNC_FASTCALL(LABEL(insn))(rb_thread_t *th, rb_control_frame_t *reg_cfp) {
-
-#define END_INSN(insn) return reg_cfp;}
-
-#define NEXT_INSN() return reg_cfp;
-
-/************************************************/
-#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
-/* threaded code with gcc */
-
-#define LABEL(x)  INSN_LABEL_##x
-#define ELABEL(x) INSN_ELABEL_##x
-#define LABEL_PTR(x) &&LABEL(x)
-
-#define INSN_ENTRY_SIG(insn)
-
-
-#define INSN_DISPATCH_SIG(insn)
-
-#define INSN_ENTRY(insn) \
-  LABEL(insn): \
-  INSN_ENTRY_SIG(insn); \
-
-/* dispather */
-#if __GNUC__ && (__i386__ || __x86_64__) && __GNUC__ == 3
-#define DISPATCH_ARCH_DEPEND_WAY(addr) \
-  asm volatile("jmp *%0;\t# -- inseted by vm.h\t[length = 2]" : : "r" (addr))
-
-#else
-#define DISPATCH_ARCH_DEPEND_WAY(addr) \
-				/* do nothing */
-
-#endif
-
-
-/**********************************/
-#if OPT_DIRECT_THREADED_CODE
-
-/* for GCC 3.4.x */
-#define TC_DISPATCH(insn) \
-  INSN_DISPATCH_SIG(insn); \
-  goto *GET_CURRENT_INSN(); \
-  ;
-
-#else
-/* token threade code */
-
-#define TC_DISPATCH(insn)  \
-  DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
-  INSN_DISPATCH_SIG(insn); \
-  goto *insns_address_table[GET_CURRENT_INSN()]; \
-  rb_bug("tc error");
-
-
-#endif /* DISPATCH_DIRECT_THREADED_CODE */
-
-#define END_INSN(insn)      \
-  DEBUG_END_INSN();         \
-  TC_DISPATCH(insn);        \
-
-#define INSN_DISPATCH()     \
-  TC_DISPATCH(__START__)    \
-  {
-
-#define END_INSNS_DISPATCH()    \
-      rb_bug("unknown insn: %ld", GET_CURRENT_INSN());   \
-  }   /* end of while loop */   \
-
-#define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
-
-/************************************************/
-#else /* no threaded code */
-/* most common method */
-
-#define INSN_ENTRY(insn) \
-case BIN(insn):
-
-#define END_INSN(insn)                        \
-  DEBUG_END_INSN();                           \
-  break;
-
-
-#define INSN_DISPATCH()         \
-  while(1){                     \
-    switch(GET_CURRENT_INSN()){
-
-#define END_INSNS_DISPATCH()    \
-default:                        \
-  SDR(); \
-      rb_bug("unknown insn: %ld", GET_CURRENT_INSN());   \
-    } /* end of switch */       \
-  }   /* end of while loop */   \
-
-#define NEXT_INSN() goto first
-
-#endif
-
-
-/************************************************/
-/************************************************/
-
-#define VM_CFP_CNT(th, cfp) \
-  ((rb_control_frame_t *)(th->stack + th->stack_size) - (rb_control_frame_t *)(cfp))
-#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
-
-/*
-  env{
-    env[0] // special (block or prev env)
-    env[1] // env object
-    env[2] // prev env val
-  };
- */
-
-#define ENV_IN_HEAP_P(th, env)  \
-  (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
-#define ENV_VAL(env)        ((env)[1])
-
-#if OPT_CALL_THREADED_CODE
-#define THROW_EXCEPTION(exc) do { \
-    th->errinfo = (VALUE)(exc); \
-    return 0; \
-} while (0)
-#else
-#define THROW_EXCEPTION(exc) return (VALUE)(exc)
-#endif
-
-#define SCREG(r) (reg_##r)
-
-/* VM state version */
-
-#define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
-#define INC_VM_STATE_VERSION() \
-  (ruby_vm_global_state_version = (ruby_vm_global_state_version+1) & 0x8fffffff)
-
-#define BOP_PLUS     0x01
-#define BOP_MINUS    0x02
-#define BOP_MULT     0x04
-#define BOP_DIV      0x08
-#define BOP_MOD      0x10
-#define BOP_EQ       0x20
-#define BOP_LT       0x40
-#define BOP_LE       0x80
-#define BOP_LTLT    0x100
-#define BOP_AREF    0x200
-#define BOP_ASET    0x400
-#define BOP_LENGTH  0x800
-#define BOP_SUCC   0x1000
-#define BOP_GT     0x2000
-#define BOP_GE     0x4000
-#define BOP_NOT    0x8000
-#define BOP_NEQ   0x10000
-
-#endif /* RUBY_VM_H */
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 19465)
+++ eval_intern.h	(revision 19466)
@@ -2,6 +2,8 @@
 #ifndef RUBY_EVAL_INTERN_H
 #define RUBY_EVAL_INTERN_H
 
+#include "vm_core.h"
+
 #define PASS_PASSED_BLOCK_TH(th) do { \
     (th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
     (th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
@@ -12,11 +14,6 @@
     PASS_PASSED_BLOCK_TH(__th__); \
 } while (0)
 
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "ruby/util.h"
-#include "vm_core.h"
-
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -30,9 +27,6 @@
 #include <stdio.h>
 #include <setjmp.h>
 
-#include "ruby/st.h"
-#include "dln.h"
-
 #ifdef __APPLE__
 #include <crt_externs.h>
 #endif
Index: include/ruby/mvm.h
===================================================================
--- include/ruby/mvm.h	(revision 19465)
+++ include/ruby/mvm.h	(revision 19466)
@@ -1,21 +0,0 @@
-/**********************************************************************
-
-  ruby/mvm.h -
-
-  $Author$
-  created at: Sat May 31 15:17:36 2008
-
-  Copyright (C) 2008 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_MVM_H
-#define RUBY_MVM_H 1
-
-typedef struct rb_vm_struct rb_vm_t;
-typedef struct rb_thread_struct rb_thread_t;
-
-VALUE *ruby_vm_verbose_ptr(rb_vm_t *);
-VALUE *ruby_vm_debug_ptr(rb_vm_t *);
-
-#endif /* RUBY_MVM_H */
Index: include/ruby/vm.h
===================================================================
--- include/ruby/vm.h	(revision 0)
+++ include/ruby/vm.h	(revision 19466)
@@ -0,0 +1,17 @@
+/**********************************************************************
+
+  ruby/vm.h -
+
+  $Author$
+  created at: Sat May 31 15:17:36 2008
+
+  Copyright (C) 2008 Yukihiro Matsumoto
+
+**********************************************************************/
+
+#ifndef RUBY_MVM_H
+#define RUBY_MVM_H 1
+
+typedef struct rb_vm_struct rb_vm_t;
+
+#endif /* RUBY_MVM_H */

Property changes on: include/ruby/vm.h
___________________________________________________________________
Name: svn:eol-style
   + LF
Name: svn:keywords
   + Author Id Revision

Index: include/ruby.h
===================================================================
--- include/ruby.h	(revision 19465)
+++ include/ruby.h	(revision 19466)
@@ -31,9 +31,5 @@
 #endif
 
 #include "ruby/ruby.h"
-#if RUBY_VM
-#include "ruby/mvm.h"
-#endif
 
-extern void ruby_set_debug_option(const char *);
 #endif /* RUBY_H */
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19465)
+++ ChangeLog	(revision 19466)
@@ -1,3 +1,38 @@
+Tue Sep 23 09:20:00 2008  Koichi Sasada  <ko1@a...>
+
+	* common.mk: clean up
+	  - remove blockinlining.$(OBJEXT) to built
+	  - make ENCODING_H_INCLDUES variable (include/ruby/encoding.h)
+	  - make VM_CORE_H_INCLUDES variable (vm_core.h)
+	  - simplify rules.
+	  - make depends rule to output depend status using gcc -MM.
+
+	* include/ruby/mvm.h, include/ruby/vm.h: rename mvm.h to vm.h.
+
+	* include/ruby.h: ditto.
+
+	* load.c: add inclusion explicitly.
+
+	* enumerator.c, object.c, parse.y, thread.c, vm_dump.c:
+	  remove useless inclusion.
+
+	* eval_intern.h: cleanup inclusion.
+
+	* vm_core.h: rb_thread_t should be defined in this file.
+
+	* vm_evalbody.c, vm_exec.c: rename vm_evalbody.c to vm_exec.c.
+
+	* vm.h, vm_exec.h: rename vm.h to vm_exec.h.
+
+	* insnhelper.h, vm_insnhelper.h: rename insnhelper.h to vm_insnhelper.h.
+
+	* vm.c, vm_insnhelper.c, vm_insnhelper.h:
+	  - rename vm_eval() to vm_exec_core().
+	  - rename vm_eval_body() to vm_exec().
+	  - cleanup include order.
+
+	* vm_method.c: fix comment.
+
 Tue Sep 23 09:01:15 2008  Yusuke Endoh  <mame@t...>
 
 	* lib/pathname.rb (each_filename): return Enumerator if no block
Index: enumerator.c
===================================================================
--- enumerator.c	(revision 19465)
+++ enumerator.c	(revision 19466)
@@ -13,7 +13,6 @@
 ************************************************/
 
 #include "ruby/ruby.h"
-#include "debug.h"
 
 /*
  * Document-class: Enumerator
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 19465)
+++ vm_core.h	(revision 19466)
@@ -17,7 +17,7 @@
 #include <setjmp.h>
 
 #include "ruby/ruby.h"
-#include "ruby/mvm.h"
+#include "ruby/vm.h"
 #include "ruby/st.h"
 #include "ruby/node.h"
 
@@ -402,7 +402,7 @@
 
 struct rb_mutex_struct;
 
-struct rb_thread_struct
+typedef struct rb_thread_struct
 {
     VALUE self;
     rb_vm_t *vm;
@@ -501,7 +501,7 @@
     /* misc */
     int method_missing_reason;
     int abort_on_exception;
-};
+} rb_thread_t;
 
 /* iseq.c */
 VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
Index: object.c
===================================================================
--- object.c	(revision 19465)
+++ object.c	(revision 19466)
@@ -14,7 +14,6 @@
 #include "ruby/ruby.h"
 #include "ruby/st.h"
 #include "ruby/util.h"
-#include "debug.h"
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
Index: load.c
===================================================================
--- load.c	(revision 19465)
+++ load.c	(revision 19466)
@@ -2,6 +2,9 @@
  * load methods from eval.c
  */
 
+#include "ruby/ruby.h"
+#include "ruby/util.h"
+#include "dln.h"
 #include "eval_intern.h"
 
 VALUE ruby_dln_librefs;
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 19465)
+++ vm_eval.c	(revision 19466)
@@ -11,19 +11,13 @@
 
 **********************************************************************/
 
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "ruby/st.h"
-
-#include "vm_method.c"
-
 static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
 static inline VALUE rb_vm_set_finish_env(rb_thread_t * th);
 static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref);
 static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
 static inline VALUE vm_backtrace(rb_thread_t *th, int lev);
 static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex);
-static VALUE vm_eval_body(rb_thread_t *th);
+static VALUE vm_exec(rb_thread_t *th);
 static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
 
 static inline VALUE
@@ -58,7 +52,7 @@
 	}
 
 	vm_setup_method(th, reg_cfp, argc, blockptr, 0, iseqval, recv, klass);
-	val = vm_eval_body(th);
+	val = vm_exec(th);
 	break;
       }
       case NODE_CFUNC: {
@@ -740,7 +734,7 @@
 
 	/* kick */
 	CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
-	result = vm_eval_body(th);
+	result = vm_exec(th);
     }
     POP_TAG();
     th->mild_compile_error = mild_compile_error;
Index: thread.c
===================================================================
--- thread.c	(revision 19465)
+++ thread.c	(revision 19466)
@@ -45,7 +45,6 @@
 /* for model 2 */
 
 #include "eval_intern.h"
-#include "vm.h"
 #include "gc.h"
 
 #ifndef USE_NATIVE_THREAD_PRIORITY
Index: common.mk
===================================================================
--- common.mk	(revision 19465)
+++ common.mk	(revision 19466)
@@ -71,7 +71,6 @@
 		util.$(OBJEXT) \
 		variable.$(OBJEXT) \
 		version.$(OBJEXT) \
-		blockinlining.$(OBJEXT) \
 		compile.$(OBJEXT) \
 		debug.$(OBJEXT) \
 		iseq.$(OBJEXT) \
@@ -435,232 +434,133 @@
 
 ###
 
-RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \
-		  {$(VPATH)}intern.h {$(VPATH)}missing.h
-ID_H_INCLUDES = {$(VPATH)}id.h {$(VPATH)}parse.h
+RUBY_H_INCLUDES    = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \
+		     {$(VPATH)}intern.h {$(VPATH)}missing.h {$(VPATH)}st.h
+ENCODING_H_INCLDUES= {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
+ID_H_INCLUDES      = {$(VPATH)}id.h {$(VPATH)}parse.h
+VM_CORE_H_INCLUDES = {$(VPATH)}vm_core.h {$(VPATH)}vm_opts.h \
+	             {$(VPATH)}vm.h {$(VPATH)}thread_$(THREAD_MODEL).h \
+		     {$(VPATH)}node.h $(ID_H_INCLUDES)
 
-array.$(OBJEXT): {$(VPATH)}array.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}util.h
-bignum.$(OBJEXT): {$(VPATH)}bignum.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
-class.$(OBJEXT): {$(VPATH)}class.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h {$(VPATH)}id.h \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.h \
-  {$(VPATH)}parse.y
-compar.$(OBJEXT): {$(VPATH)}compar.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
-complex.$(OBJEXT): {$(VPATH)}complex.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}mvm.h
-dir.$(OBJEXT): {$(VPATH)}dir.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}util.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
-dln.$(OBJEXT): {$(VPATH)}dln.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}dln.h
+array.$(OBJEXT): {$(VPATH)}array.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
+bignum.$(OBJEXT): {$(VPATH)}bignum.c $(RUBY_H_INCLUDES)
+class.$(OBJEXT): {$(VPATH)}class.c $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES)
+compar.$(OBJEXT): {$(VPATH)}compar.c $(RUBY_H_INCLUDES)
+complex.$(OBJEXT): {$(VPATH)}complex.c $(RUBY_H_INCLUDES)
+dir.$(OBJEXT): {$(VPATH)}dir.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
+  $(ENCODING_H_INCLDUES)
+dln.$(OBJEXT): {$(VPATH)}dln.c {$(VPATH)}dln.h $(RUBY_H_INCLUDES)
 dmydln.$(OBJEXT): {$(VPATH)}dmydln.c dln.$(OBJEXT)
 dmyext.$(OBJEXT): {$(VPATH)}dmyext.c
-dmyencoding.$(OBJEXT): {$(VPATH)}dmyencoding.c {$(VPATH)}encoding.c \
-  $(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}encoding.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}regenc.h {$(VPATH)}util.h
+dmyencoding.$(OBJEXT): {$(VPATH)}dmyencoding.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}regenc.h {$(VPATH)}util.h $(ENCODING_H_INCLDUES)
 encoding.$(OBJEXT): {$(VPATH)}encoding.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}regenc.h {$(VPATH)}util.h
-enum.$(OBJEXT): {$(VPATH)}enum.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
+  $(ENCODING_H_INCLDUES) {$(VPATH)}regenc.h {$(VPATH)}util.h
+enum.$(OBJEXT): {$(VPATH)}enum.c $(RUBY_H_INCLUDES) \
   {$(VPATH)}node.h {$(VPATH)}util.h
 enumerator.$(OBJEXT): {$(VPATH)}enumerator.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}debug.h {$(VPATH)}node.h
-error.$(OBJEXT): {$(VPATH)}error.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
+  {$(VPATH)}node.h
+error.$(OBJEXT): {$(VPATH)}error.c $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES)
 eval.$(OBJEXT): {$(VPATH)}eval.c {$(VPATH)}eval_intern.h \
-  $(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
-  {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h \
-  {$(VPATH)}dln.h {$(VPATH)}eval_error.c {$(VPATH)}eval_safe.c \
-  {$(VPATH)}eval_jump.c {$(VPATH)}mvm.h {$(VPATH)}parse.y
+  $(RUBY_H_INCLUDES) {$(VPATH)}util.h $(VM_CORE_H_INCLUDES) \
+  {$(VPATH)}eval_error.c {$(VPATH)}eval_safe.c {$(VPATH)}eval_jump.c
 load.$(OBJEXT): {$(VPATH)}load.c {$(VPATH)}eval_intern.h \
-  $(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
-  {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h \
-  {$(VPATH)}dln.h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}io.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}util.h {$(VPATH)}dln.h
-gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}re.h {$(VPATH)}regex.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}io.h {$(VPATH)}encoding.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
-  $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}gc.h \
-  {$(VPATH)}eval_intern.h {$(VPATH)}util.h {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y {$(VPATH)}dln.h
-hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) $(ID_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}util.h \
-  {$(VPATH)}eval_intern.h {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}mvm.h {$(VPATH)}debug.h {$(VPATH)}vm_opts.h {$(VPATH)}parse.y \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}dln.h
-inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
-io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}io.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}util.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h {$(VPATH)}id.h \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}node.h \
-  {$(VPATH)}parse.h {$(VPATH)}parse.y
-main.$(OBJEXT): {$(VPATH)}main.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}mvm.h
-marshal.$(OBJEXT): {$(VPATH)}marshal.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}io.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}util.h
-math.$(OBJEXT): {$(VPATH)}math.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
-numeric.$(OBJEXT): {$(VPATH)}numeric.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
-object.$(OBJEXT): {$(VPATH)}object.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}util.h {$(VPATH)}debug.h {$(VPATH)}node.h
-pack.$(OBJEXT): {$(VPATH)}pack.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
+  {$(VPATH)}util.h $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES)
+file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
+  $(ENCODING_H_INCLDUES) {$(VPATH)}util.h {$(VPATH)}dln.h
+gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}re.h {$(VPATH)}regex.h \
+  $(ENCODING_H_INCLDUES) $(VM_CORE_H_INCLUDES) \
+  {$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h
+hash.$(OBJEXT): {$(VPATH)}hash.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
+  {$(VPATH)}eval_intern.h $(VM_CORE_H_INCLUDES)
+inits.$(OBJEXT): {$(VPATH)}inits.c $(RUBY_H_INCLUDES)
+io.$(OBJEXT): {$(VPATH)}io.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
+  {$(VPATH)}util.h $(VM_CORE_H_INCLUDES) $(ENCODING_H_INCLDUES)
+main.$(OBJEXT): {$(VPATH)}main.c $(RUBY_H_INCLUDES) {$(VPATH)}vm.h
+marshal.$(OBJEXT): {$(VPATH)}marshal.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}io.h $(ENCODING_H_INCLDUES) {$(VPATH)}util.h
+math.$(OBJEXT): {$(VPATH)}math.c $(RUBY_H_INCLUDES)
+numeric.$(OBJEXT): {$(VPATH)}numeric.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLDUES)
+object.$(OBJEXT): {$(VPATH)}object.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
+pack.$(OBJEXT): {$(VPATH)}pack.c $(RUBY_H_INCLUDES)
 parse.$(OBJEXT): {$(VPATH)}parse.c {$(VPATH)}parse.y $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}encoding.h \
-  {$(VPATH)}oniguruma.h $(ID_H_INCLUDES) {$(VPATH)}regenc.h \
+  {$(VPATH)}node.h $(ENCODING_H_INCLDUES) $(ID_H_INCLUDES) {$(VPATH)}regenc.h \
   {$(VPATH)}regex.h {$(VPATH)}util.h {$(VPATH)}lex.c {$(VPATH)}keywords \
-  {$(VPATH)}debug.h {$(VPATH)}id.c
-proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
-  $(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
-  {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h \
-  {$(VPATH)}dln.h {$(VPATH)}gc.h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-process.$(OBJEXT): {$(VPATH)}process.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}util.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}io.h {$(VPATH)}encoding.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}mvm.h {$(VPATH)}parse.y {$(VPATH)}dln.h
-random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
-range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
-rational.$(OBJEXT): {$(VPATH)}rational.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}mvm.h
-re.$(OBJEXT): {$(VPATH)}re.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}encoding.h {$(VPATH)}util.h {$(VPATH)}regint.h \
-  {$(VPATH)}regenc.h
-regcomp.$(OBJEXT): {$(VPATH)}regcomp.c {$(VPATH)}regparse.h \
-  {$(VPATH)}regint.h {$(VPATH)}config.h {$(VPATH)}defines.h \
-  {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
-regenc.$(OBJEXT): {$(VPATH)}regenc.c {$(VPATH)}regint.h \
-  {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}regenc.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
+  {$(VPATH)}id.c
+proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h  {$(VPATH)}util.h \
+  $(RUBY_H_INCLUDES) {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES)
+process.$(OBJEXT): {$(VPATH)}process.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}util.h {$(VPATH)}io.h $(ENCODING_H_INCLDUES) \
+  {$(VPATH)}dln.h $(VM_CORE_H_INCLUDES)
+random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES)
+range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLDUES)
+rational.$(OBJEXT): {$(VPATH)}rational.c $(RUBY_H_INCLUDES)
+re.$(OBJEXT): {$(VPATH)}re.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}re.h {$(VPATH)}regex.h $(ENCODING_H_INCLDUES) \
+  {$(VPATH)}util.h {$(VPATH)}regint.h {$(VPATH)}regenc.h
+regcomp.$(OBJEXT): {$(VPATH)}regcomp.c {$(VPATH)}regparse.h {$(VPATH)}regint.h \
+  {$(VPATH)}regenc.h $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
+regenc.$(OBJEXT): {$(VPATH)}regenc.c {$(VPATH)}regint.h {$(VPATH)}regenc.h \
+  $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
 regerror.$(OBJEXT): {$(VPATH)}regerror.c {$(VPATH)}regint.h \
-  {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}regenc.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
+  {$(VPATH)}regenc.h $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
 regexec.$(OBJEXT): {$(VPATH)}regexec.c {$(VPATH)}regint.h \
-  {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}regenc.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
+  {$(VPATH)}regenc.h $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
 regparse.$(OBJEXT): {$(VPATH)}regparse.c {$(VPATH)}regparse.h \
-  {$(VPATH)}regint.h {$(VPATH)}config.h {$(VPATH)}defines.h \
-  {$(VPATH)}regenc.h {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
+  {$(VPATH)}regint.h {$(VPATH)}regenc.h $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
 regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c {$(VPATH)}regint.h \
-  {$(VPATH)}config.h {$(VPATH)}defines.h {$(VPATH)}regenc.h \
-  {$(VPATH)}oniguruma.h {$(VPATH)}st.h {$(VPATH)}ruby.h \
-  {$(VPATH)}missing.h {$(VPATH)}intern.h
-ruby.$(OBJEXT): {$(VPATH)}ruby.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
-  $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}dln.h \
-  {$(VPATH)}mvm.h {$(VPATH)}parse.y
-signal.$(OBJEXT): {$(VPATH)}signal.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}encoding.h {$(VPATH)}vsnprintf.c
+  {$(VPATH)}regenc.h $(ENCODING_H_INCLDUES) $(RUBY_H_INCLUDES)
+ruby.$(OBJEXT): {$(VPATH)}ruby.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \
+  $(ENCODING_H_INCLDUES) {$(VPATH)}eval_intern.h \
+  $(VM_CORE_H_INCLUDES) {$(VPATH)}dln.h
+signal.$(OBJEXT): {$(VPATH)}signal.c $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES)
+sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
+  {$(VPATH)}regex.h {$(VPATH)}vsnprintf.c $(ENCODING_H_INCLDUES)
 st.$(OBJEXT): {$(VPATH)}st.c {$(VPATH)}config.h {$(VPATH)}defines.h \
   {$(VPATH)}st.h
-strftime.$(OBJEXT): {$(VPATH)}strftime.c {$(VPATH)}config.h \
-  {$(VPATH)}ruby.h {$(VPATH)}defines.h {$(VPATH)}missing.h \
-  {$(VPATH)}intern.h {$(VPATH)}st.h
-string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}re.h {$(VPATH)}regex.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}encoding.h
-struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
+strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLDUES)
+string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) \
+  {$(VPATH)}re.h {$(VPATH)}regex.h $(ENCODING_H_INCLDUES)
+struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES)
 thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \
-  $(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
-  {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h \
-  {$(VPATH)}dln.h {$(VPATH)}vm.h {$(VPATH)}gc.h \
-  {$(VPATH)}thread_$(THREAD_MODEL).c {$(VPATH)}mvm.h {$(VPATH)}parse.y
+  $(RUBY_H_INCLUDES) {$(VPATH)}util.h {$(VPATH)}gc.h $(VM_CORE_H_INCLUDES)
 transcode.$(OBJEXT): {$(VPATH)}transcode.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}transcode_data.h
-cont.$(OBJEXT): {$(VPATH)}cont.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}gc.h \
-  {$(VPATH)}eval_intern.h {$(VPATH)}util.h {$(VPATH)}dln.h {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y
-time.$(OBJEXT): {$(VPATH)}time.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h
-util.$(OBJEXT): {$(VPATH)}util.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}util.h
+  $(ENCODING_H_INCLDUES) {$(VPATH)}transcode_data.h
+cont.$(OBJEXT): {$(VPATH)}cont.c $(RUBY_H_INCLUDES) \
+  $(VM_CORE_H_INCLUDES) {$(VPATH)}gc.h {$(VPATH)}eval_intern.h
+time.$(OBJEXT): {$(VPATH)}time.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLDUES)
+util.$(OBJEXT): {$(VPATH)}util.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h
 variable.$(OBJEXT): {$(VPATH)}variable.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h
-version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
+  {$(VPATH)}node.h {$(VPATH)}util.h
+version.$(OBJEXT): {$(VPATH)}version.c $(RUBY_H_INCLUDES) \
   {$(VPATH)}version.h $(srcdir)/revision.h
 
-compile.$(OBJEXT): {$(VPATH)}compile.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}compile.h \
-  {$(VPATH)}insns.inc {$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc \
-  {$(VPATH)}mvm.h {$(VPATH)}parse.y
-iseq.$(OBJEXT): {$(VPATH)}iseq.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}gc.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}insns.inc \
-  {$(VPATH)}insns_info.inc {$(VPATH)}node_name.inc {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y
-vm.$(OBJEXT): {$(VPATH)}vm.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h \
-  {$(VPATH)}gc.h {$(VPATH)}insnhelper.h {$(VPATH)}eval_intern.h \
-  {$(VPATH)}util.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}dln.h {$(VPATH)}vm.h \
-  {$(VPATH)}vm_insnhelper.c {$(VPATH)}insns.inc {$(VPATH)}vm_evalbody.c \
-  {$(VPATH)}vmtc.inc {$(VPATH)}vm.inc {$(VPATH)}insns.def \
-  {$(VPATH)}vm_method.c {$(VPATH)}vm_eval.c {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y
-vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}vm.h {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y
-debug.$(OBJEXT): {$(VPATH)}debug.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h {$(VPATH)}debug.h \
-  {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) {$(VPATH)}thread_$(THREAD_MODEL).h \
-  {$(VPATH)}util.h {$(VPATH)}eval_intern.h {$(VPATH)}mvm.h \
-  {$(VPATH)}parse.y {$(VPATH)}dln.h
-blockinlining.$(OBJEXT): {$(VPATH)}blockinlining.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}vm_core.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-id.$(OBJEXT): {$(VPATH)}id.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h $(ID_H_INCLUDES)
+compile.$(OBJEXT): {$(VPATH)}compile.c {$(VPATH)}compile.h \
+  $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
+  {$(VPATH)}insns.inc {$(VPATH)}insns_info.inc {$(VPATH)}optinsn.inc
+iseq.$(OBJEXT): {$(VPATH)}iseq.c {$(VPATH)}gc.h \
+  $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
+  {$(VPATH)}insns.inc {$(VPATH)}insns_info.inc {$(VPATH)}node_name.inc
+vm.$(OBJEXT): {$(VPATH)}vm.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLDUES) \
+  {$(VPATH)}gc.h {$(VPATH)}eval_intern.h  $(VM_CORE_H_INCLUDES) \
+  {$(VPATH)}vm_method.c {$(VPATH)}vm_eval.c \
+  {$(VPATH)}vm_insnhelper.c {$(VPATH)}vm_insnhelper.h \
+  {$(VPATH)}vm_exec.c {$(VPATH)}vm_exec.h \
+  {$(VPATH)}insns.def {$(VPATH)}vmtc.inc {$(VPATH)}vm.inc {$(VPATH)}insns.inc
+vm_dump.$(OBJEXT): {$(VPATH)}vm_dump.c $(RUBY_H_INCLUDES) \
+  $(VM_CORE_H_INCLUDES)
+debug.$(OBJEXT): {$(VPATH)}debug.c $(RUBY_H_INCLUDES) $(ENCODING_H_INCLDUES) \
+  $(VM_CORE_H_INCLUDES) {$(VPATH)}eval_intern.h
+id.$(OBJEXT): {$(VPATH)}id.c $(RUBY_H_INCLUDES) $(ID_H_INCLUDES)
 miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}vm_core.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-prelude.$(OBJEXT): {$(VPATH)}prelude.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h \
-  {$(VPATH)}vm_core.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
-golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}vm_core.h {$(VPATH)}node.h \
-  {$(VPATH)}debug.h {$(VPATH)}vm_opts.h $(ID_H_INCLUDES) \
-  {$(VPATH)}thread_$(THREAD_MODEL).h {$(VPATH)}mvm.h {$(VPATH)}parse.y
+  $(VM_CORE_H_INCLUDES)
+prelude.$(OBJEXT): {$(VPATH)}prelude.c $(RUBY_H_INCLUDES) \
+  $(VM_CORE_H_INCLUDES)
+golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c $(RUBY_H_INCLUDES)\
+   $(VM_CORE_H_INCLUDES)
 goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c $(RUBY_H_INCLUDES) \
-  {$(VPATH)}st.h {$(VPATH)}mvm.h
+  {$(VPATH)}vm.h
 
 ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h {$(VPATH)}config.h \
   {$(VPATH)}defines.h {$(VPATH)}oniguruma.h
@@ -812,6 +712,12 @@
 	@$(VCS) up "$(srcdir)"
 	-@$(MAKE) $(MFLAGS) REVISION_FORCE=PHONY "$(srcdir)/revision.h"
 
+depends: PHONY
+	gcc $(XCFLAGS) -MM $(srcdir)/*.c > depends.txt
+
+vm_test.o: vm_test.c $(RUBY_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
+  vm_exec.c vm_insnhelper.c vm_insnhelper.h
+
 help: PHONY
 	@echo "                Makefile of Ruby"
 	@echo ""
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 19465)
+++ vm_method.c	(revision 19466)
@@ -1,6 +1,5 @@
-/* -*-c-*- */
 /*
- * This file is included by vm_eval.c
+ * This file is included by vm.h
  */
 
 #define CACHE_SIZE 0x800
Index: parse.y
===================================================================
--- parse.y	(revision 19465)
+++ parse.y	(revision 19466)
@@ -8725,7 +8725,6 @@
     return buf;
 }
 
-#include "debug.h"
 static int
 arg_var_gen(struct parser_params *parser, ID id)
 {
Index: vm_exec.c
===================================================================
--- vm_exec.c	(revision 0)
+++ vm_exec.c	(revision 19466)
@@ -0,0 +1,156 @@
+/* -*-c-*- */
+/**********************************************************************
+
+  vm_evalbody.c -
+
+  $Author$
+
+  Copyright (C) 2004-2007 Koichi Sasada
+
+**********************************************************************/
+
+#include <math.h>
+
+#if VMDEBUG > 0
+#define DECL_SC_REG(type, r, reg) register type reg_##r
+
+#elif __GNUC__ && __x86_64__
+#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
+
+#elif __GNUC__ && __i386__
+#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg)
+
+#else
+#define DECL_SC_REG(type, r, reg) register type reg_##r
+#endif
+/* #define DECL_SC_REG(r, reg) VALUE reg_##r */
+
+#if OPT_STACK_CACHING
+static VALUE finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
+#elif OPT_CALL_THREADED_CODE
+static VALUE const finish_insn_seq[1] = { 0 };
+#else
+static VALUE finish_insn_seq[1] = { BIN(finish) };
+#endif
+
+#if !OPT_CALL_THREADED_CODE
+static VALUE
+vm_exec_core(rb_thread_t *th, VALUE initial)
+{
+
+#if OPT_STACK_CACHING
+#if 0
+#elif __GNUC__ && __x86_64
+    DECL_SC_REG(VALUE, a, "12");
+    DECL_SC_REG(VALUE, b, "13");
+#else
+    register VALUE reg_a;
+    register VALUE reg_b;
+#endif
+#endif
+
+#if __GNUC__ && __i386__
+    DECL_SC_REG(VALUE *, pc, "di");
+    DECL_SC_REG(rb_control_frame_t *, cfp, "si");
+#define USE_MACHINE_REGS 1
+
+#elif __GNUC__ && __x86_64__
+    DECL_SC_REG(VALUE *, pc, "14");
+    DECL_SC_REG(rb_control_frame_t *, cfp, "15");
+#define USE_MACHINE_REGS 1
+
+#else
+    register rb_control_frame_t *reg_cfp;
+    VALUE *reg_pc;
+#endif
+
+#if USE_MACHINE_REGS
+
+#undef  RESTORE_REGS
+#define RESTORE_REGS() \
+{ \
+  REG_CFP = th->cfp; \
+  reg_pc  = reg_cfp->pc; \
+}
+
+#undef  REG_PC
+#define REG_PC reg_pc
+#undef  GET_PC
+#define GET_PC() (reg_pc)
+#undef  SET_PC
+#define SET_PC(x) (reg_cfp->pc = REG_PC = (x))
+#endif
+
+#if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
+#include "vmtc.inc"
+    if (th == 0) {
+#if OPT_STACK_CACHING
+	finish_insn_seq[0] = (VALUE)&&LABEL (finish_SC_ax_ax);
+#else
+	finish_insn_seq[0] = (VALUE)&&LABEL (finish);
+#endif
+	return (VALUE)insns_address_table;
+    }
+#endif
+    reg_cfp = th->cfp;
+    reg_pc = reg_cfp->pc;
+
+#if OPT_STACK_CACHING
+    reg_a = initial;
+    reg_b = 0;
+#endif
+
+  first:
+    INSN_DISPATCH();
+/*****************/
+ #include "vm.inc"
+/*****************/
+    END_INSNS_DISPATCH();
+
+    /* unreachable */
+    rb_bug("vm_eval: unreachable");
+    goto first;
+}
+
+const void **
+vm_get_insns_address_table(void)
+{
+    return (const void **)vm_exec_core(0, 0);
+}
+
+#else
+
+#include "vm.inc"
+#include "vmtc.inc"
+
+const void *const *
+vm_get_insns_address_table(void)
+{
+    return insns_address_table;
+}
+
+static VALUE
+vm_exec_core(rb_thread_t *th, VALUE initial)
+{
+    register rb_control_frame_t *reg_cfp = th->cfp;
+    VALUE ret;
+
+    while (*GET_PC()) {
+	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);
+
+	if (reg_cfp == 0) {
+	    VALUE err = th->errinfo;
+	    th->errinfo = Qnil;
+	    return err;
+	}
+    }
+
+    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_FINISH) {
+	rb_bug("cfp consistency error");
+    }
+
+    ret = *(th->cfp->sp-1); /* pop */
+    th->cfp++; /* pop cf */
+    return ret;
+}
+#endif

Property changes on: vm_exec.c
___________________________________________________________________
Name: svn:eol-style
   + LF
Name: svn:keywords
   + Author Date Id Revision

Index: vm_exec.h
===================================================================
--- vm_exec.h	(revision 0)
+++ vm_exec.h	(revision 19466)
@@ -0,0 +1,187 @@
+/**********************************************************************
+
+  vm.h -
+
+  $Author$
+  created at: 04/01/01 16:56:59 JST
+
+  Copyright (C) 2004-2007 Koichi Sasada
+
+**********************************************************************/
+
+#ifndef RUBY_VM_H
+#define RUBY_VM_H
+
+typedef long OFFSET;
+typedef unsigned long lindex_t;
+typedef unsigned long dindex_t;
+typedef rb_num_t GENTRY;
+typedef rb_iseq_t *ISEQ;
+
+#ifdef  COLLECT_USAGE_ANALYSIS
+#define USAGE_ANALYSIS_INSN(insn)           vm_analysis_insn(insn)
+#define USAGE_ANALYSIS_OPERAND(insn, n, op) vm_analysis_operand(insn, n, (VALUE)op)
+#define USAGE_ANALYSIS_REGISTER(reg, s)     vm_analysis_register(reg, s)
+#else
+#define USAGE_ANALYSIS_INSN(insn)		/* none */
+#define USAGE_ANALYSIS_OPERAND(insn, n, op)	/* none */
+#define USAGE_ANALYSIS_REGISTER(reg, s)		/* none */
+#endif
+
+#ifdef __GCC__
+/* TODO: machine dependent prefetch instruction */
+#define PREFETCH(pc)
+#else
+#define PREFETCH(pc)
+#endif
+
+#if VMDEBUG > 0
+#define debugs printf
+#define DEBUG_ENTER_INSN(insn) \
+  debug_print_pre(th, GET_CFP());
+
+#if OPT_STACK_CACHING
+#define SC_REGS() , reg_a, reg_b
+#else
+#define SC_REGS()
+#endif
+
+#define DEBUG_END_INSN() \
+  debug_print_post(th, GET_CFP() SC_REGS());
+
+#else
+
+#define debugs
+#define DEBUG_ENTER_INSN(insn)
+#define DEBUG_END_INSN()
+#endif
+
+#define throwdebug if(0)printf
+/* #define throwdebug printf */
+
+#define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
+
+
+/************************************************/
+#if   DISPATCH_XXX
+error !
+/************************************************/
+#elif OPT_CALL_THREADED_CODE
+
+#define LABEL(x)  insn_func_##x
+#define ELABEL(x)
+#define LABEL_PTR(x) &LABEL(x)
+
+#define INSN_ENTRY(insn) \
+  static rb_control_frame_t * \
+    FUNC_FASTCALL(LABEL(insn))(rb_thread_t *th, rb_control_frame_t *reg_cfp) {
+
+#define END_INSN(insn) return reg_cfp;}
+
+#define NEXT_INSN() return reg_cfp;
+
+/************************************************/
+#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
+/* threaded code with gcc */
+
+#define LABEL(x)  INSN_LABEL_##x
+#define ELABEL(x) INSN_ELABEL_##x
+#define LABEL_PTR(x) &&LABEL(x)
+
+#define INSN_ENTRY_SIG(insn)
+
+
+#define INSN_DISPATCH_SIG(insn)
+
+#define INSN_ENTRY(insn) \
+  LABEL(insn): \
+  INSN_ENTRY_SIG(insn); \
+
+/* dispather */
+#if __GNUC__ && (__i386__ || __x86_64__) && __GNUC__ == 3
+#define DISPATCH_ARCH_DEPEND_WAY(addr) \
+  asm volatile("jmp *%0;\t# -- inseted by vm.h\t[length = 2]" : : "r" (addr))
+
+#else
+#define DISPATCH_ARCH_DEPEND_WAY(addr) \
+				/* do nothing */
+
+#endif
+
+
+/**********************************/
+#if OPT_DIRECT_THREADED_CODE
+
+/* for GCC 3.4.x */
+#define TC_DISPATCH(insn) \
+  INSN_DISPATCH_SIG(insn); \
+  goto *GET_CURRENT_INSN(); \
+  ;
+
+#else
+/* token threade code */
+
+#define TC_DISPATCH(insn)  \
+  DISPATCH_ARCH_DEPEND_WAY(insns_address_table[GET_CURRENT_INSN()]); \
+  INSN_DISPATCH_SIG(insn); \
+  goto *insns_address_table[GET_CURRENT_INSN()]; \
+  rb_bug("tc error");
+
+
+#endif /* DISPATCH_DIRECT_THREADED_CODE */
+
+#define END_INSN(insn)      \
+  DEBUG_END_INSN();         \
+  TC_DISPATCH(insn);        \
+
+#define INSN_DISPATCH()     \
+  TC_DISPATCH(__START__)    \
+  {
+
+#define END_INSNS_DISPATCH()    \
+      rb_bug("unknown insn: %ld", GET_CURRENT_INSN());   \
+  }   /* end of while loop */   \
+
+#define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
+
+/************************************************/
+#else /* no threaded code */
+/* most common method */
+
+#define INSN_ENTRY(insn) \
+case BIN(insn):
+
+#define END_INSN(insn)                        \
+  DEBUG_END_INSN();                           \
+  break;
+
+
+#define INSN_DISPATCH()         \
+  while(1){                     \
+    switch(GET_CURRENT_INSN()){
+
+#define END_INSNS_DISPATCH()    \
+default:                        \
+  SDR(); \
+      rb_bug("unknown insn: %ld", GET_CURRENT_INSN());   \
+    } /* end of switch */       \
+  }   /* end of while loop */   \
+
+#define NEXT_INSN() goto first
+
+#endif
+
+#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
+
+#if OPT_CALL_THREADED_CODE
+#define THROW_EXCEPTION(exc) do { \
+    th->errinfo = (VALUE)(exc); \
+    return 0; \
+} while (0)
+#else
+#define THROW_EXCEPTION(exc) return (VALUE)(exc)
+#endif
+
+#define SCREG(r) (reg_##r)
+
+#endif /* RUBY_VM_H */

Property changes on: vm_exec.h
___________________________________________________________________
Name: svn:eol-style
   + LF
Name: svn:keywords
   + Author Date Id Revision

Index: vm.c
===================================================================
--- vm.c	(revision 19465)
+++ vm.c	(revision 19466)
@@ -12,10 +12,17 @@
 #include "ruby/node.h"
 #include "ruby/st.h"
 #include "ruby/encoding.h"
+
 #include "gc.h"
+#include "vm_core.h"
+#include "eval_intern.h"
 
-#include "insnhelper.h"
+#include "vm_insnhelper.h"
 #include "vm_insnhelper.c"
+#include "vm_exec.h"
+#include "vm_exec.c"
+
+#include "vm_method.c"
 #include "vm_eval.c"
 
 #define BUFSIZE 0x100
@@ -27,6 +34,8 @@
 VALUE rb_mRubyVMFrozenCore;
 
 VALUE ruby_vm_global_state_version = 1;
+VALUE ruby_vm_redefined_flag = 0;
+
 rb_thread_t *ruby_current_thread = 0;
 rb_vm_t *ruby_current_vm = 0;
 
@@ -34,14 +43,6 @@
 void vm_analysis_register(int reg, int isset);
 void vm_analysis_insn(int insn);
 
-#if OPT_STACK_CACHING
-static VALUE finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
-#elif OPT_CALL_THREADED_CODE
-static VALUE const finish_insn_seq[1] = { 0 };
-#else
-static VALUE finish_insn_seq[1] = { BIN(finish) };
-#endif
-
 void
 rb_vm_change_state(void)
 {
@@ -132,6 +133,18 @@
 
 /* Env */
 
+/*
+  env{
+    env[0] // special (block or prev env)
+    env[1] // env object
+    env[2] // prev env val
+  };
+ */
+
+#define ENV_IN_HEAP_P(th, env)  \
+  (!((th)->stack < (env) && (env) < ((th)->stack + (th)->stack_size)))
+#define ENV_VAL(env)        ((env)[1])
+
 static void
 env_free(void * const ptr)
 {
@@ -471,7 +484,7 @@
 	    th->cfp->dfp[-1] = (VALUE)cref;
 	}
 
-	return vm_eval_body(th);
+	return vm_exec(th);
     }
     else {
 	return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr);
@@ -743,37 +756,6 @@
 }
 #endif
 
-static NODE *
-vm_cref_push(rb_thread_t *th, VALUE klass, int noex)
-{
-    rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->cfp);
-    NODE *cref = NEW_BLOCK(klass);
-    cref->nd_file = 0;
-    cref->nd_visi = noex;
-
-    if (cfp) {
-	cref->nd_next = vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp);
-    }
-
-    return cref;
-}
-
-static inline VALUE
-vm_get_cbase(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
-{
-    NODE *cref = vm_get_cref(iseq, lfp, dfp);
-    VALUE klass = Qundef;
-
-    while (cref) {
-	if ((klass = cref->nd_clss) != 0) {
-	    break;
-	}
-	cref = cref->nd_next;
-    }
-
-    return klass;
-}
-
 VALUE
 rb_vm_cbase(void)
 {
@@ -887,7 +869,6 @@
 
 /* optimization: redefine management */
 
-VALUE ruby_vm_redefined_flag = 0;
 static st_table *vm_opt_method_table = 0;
 
 static void
@@ -944,8 +925,6 @@
 
 /* evaluator body */
 
-#include "vm_evalbody.c"
-
 /*                  finish
   VMe (h1)          finish
     VM              finish F1 F2
@@ -1048,7 +1027,7 @@
 
 
 static VALUE
-vm_eval_body(rb_thread_t *th)
+vm_exec(rb_thread_t *th)
 {
     int state;
     VALUE result, err;
@@ -1059,7 +1038,7 @@
     _tag.retval = Qnil;
     if ((state = EXEC_TAG()) == 0) {
       vm_loop_start:
-	result = vm_eval(th, initial);
+	result = vm_exec_core(th, initial);
 	if ((state = th->state) != 0) {
 	    err = result;
 	    th->state = 0;
@@ -1264,7 +1243,7 @@
     if (!rb_const_defined(rb_cObject, rb_intern("TOPLEVEL_BINDING"))) {
 	rb_define_global_const("TOPLEVEL_BINDING", rb_binding_new());
     }
-    val = vm_eval_body(th);
+    val = vm_exec(th);
     tmp = iseqval; /* prohibit tail call optimization */
     return val;
 }
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 19465)
+++ vm_dump.c	(revision 19466)
@@ -11,12 +11,13 @@
 
 #include "ruby/ruby.h"
 #include "ruby/node.h"
-
 #include "vm_core.h"
-#include "vm.h"
 
 #define MAX_POSBUF 128
 
+#define VM_CFP_CNT(th, cfp) \
+  ((rb_control_frame_t *)(th->stack + th->stack_size) - (rb_control_frame_t *)(cfp))
+
 static void
 control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
 {
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 19465)
+++ vm_insnhelper.c	(revision 19466)
@@ -10,12 +10,10 @@
 
 /* finish iseq array */
 #include "insns.inc"
-
 #include <math.h>
 
 /* control stack frame */
 
-
 #ifndef INLINE
 #define INLINE inline
 #endif
@@ -967,7 +965,37 @@
     return cref;
 }
 
+static NODE *
+vm_cref_push(rb_thread_t *th, VALUE klass, int noex)
+{
+    rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->cfp);
+    NODE *cref = NEW_BLOCK(klass);
+    cref->nd_file = 0;
+    cref->nd_visi = noex;
 
+    if (cfp) {
+	cref->nd_next = vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp);
+    }
+
+    return cref;
+}
+
+static inline VALUE
+vm_get_cbase(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
+{
+    NODE *cref = vm_get_cref(iseq, lfp, dfp);
+    VALUE klass = Qundef;
+
+    while (cref) {
+	if ((klass = cref->nd_clss) != 0) {
+	    break;
+	}
+	cref = cref->nd_next;
+    }
+
+    return klass;
+}
+
 static inline void
 vm_check_if_namespace(VALUE klass)
 {
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 0)
+++ vm_insnhelper.h	(revision 19466)
@@ -0,0 +1,191 @@
+/**********************************************************************
+
+  insnhelper.h - helper macros to implement each instructions
+
+  $Author$
+  created at: 04/01/01 15:50:34 JST
+
+  Copyright (C) 2004-2007 Koichi Sasada
+
+**********************************************************************/
+
+#ifndef RUBY_INSNHELPER_H
+#define RUBY_INSNHELPER_H
+
+/**
+ * VM Debug Level
+ *
+ * debug level:
+ *  0: no debug output
+ *  1: show instruction name
+ *  2: show stack frame when control stack frame is changed
+ *  3: show stack status
+ *  4: show register
+ *  5:
+ * 10: gc check
+ */
+
+#ifndef VMDEBUG
+#define VMDEBUG 0
+#endif
+
+#if 0
+#undef  VMDEBUG
+#define VMDEBUG 3
+#endif
+
+/* VM state version */
+
+extern VALUE ruby_vm_global_state_version;
+extern VALUE ruby_vm_redefined_flag;
+
+#define GET_VM_STATE_VERSION() (ruby_vm_global_state_version)
+#define INC_VM_STATE_VERSION() \
+  (ruby_vm_global_state_version = (ruby_vm_global_state_version+1) & 0x8fffffff)
+
+#define BOP_PLUS     0x01
+#define BOP_MINUS    0x02
+#define BOP_MULT     0x04
+#define BOP_DIV      0x08
+#define BOP_MOD      0x10
+#define BOP_EQ       0x20
+#define BOP_LT       0x40
+#define BOP_LE       0x80
+#define BOP_LTLT    0x100
+#define BOP_AREF    0x200
+#define BOP_ASET    0x400
+#define BOP_LENGTH  0x800
+#define BOP_SUCC   0x1000
+#define BOP_GT     0x2000
+#define BOP_GE     0x4000
+#define BOP_NOT    0x8000
+#define BOP_NEQ   0x10000
+
+/**********************************************************/
+/* deal with stack                                        */
+/**********************************************************/
+
+#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                                    */
+/**********************************************************/
+
+#define REG_CFP (reg_cfp)
+#define REG_PC  (REG_CFP->pc)
+#define REG_SP  (REG_CFP->sp)
+#define REG_LFP (REG_CFP->lfp)
+#define REG_DFP (REG_CFP->dfp)
+
+#define RESTORE_REGS() do { \
+  REG_CFP = th->cfp; \
+} while (0)
+
+#define REG_A   reg_a
+#define REG_B   reg_b
+
+#ifdef COLLECT_USAGE_ANALYSIS
+#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
+  (USAGE_ANALYSIS_REGISTER(a, b), (v))
+#else
+#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) (v)
+#endif
+
+/* PC */
+#define GET_PC()           (USAGE_ANALYSIS_REGISTER_HELPER(0, 0, REG_PC))
+#define SET_PC(x)          (REG_PC = (USAGE_ANALYSIS_REGISTER_HELPER(0, 1, x)))
+#define GET_CURRENT_INSN() (*GET_PC())
+#define GET_OPERAND(n)     (GET_PC()[(n)])
+#define ADD_PC(n)          (SET_PC(REG_PC + (n)))
+
+#define GET_PC_COUNT()     (REG_PC - GET_ISEQ()->iseq_encoded)
+#define JUMP(dst)          (REG_PC += (dst))
+
+/* FP */
+#define GET_CFP()  (USAGE_ANALYSIS_REGISTER_HELPER(2, 0, REG_CFP))
+#define GET_LFP()  (USAGE_ANALYSIS_REGISTER_HELPER(3, 0, REG_LFP))
+#define SET_LFP(x) (REG_LFP = (USAGE_ANALYSIS_REGISTER_HELPER(3, 1, (x))))
+#define GET_DFP()  (USAGE_ANALYSIS_REGISTER_HELPER(4, 0, REG_DFP))
+#define SET_DFP(x) (REG_DFP = (USAGE_ANALYSIS_REGISTER_HELPER(4, 1, (x))))
+
+/* SP */
+#define GET_SP()   (USAGE_ANALYSIS_REGISTER_HELPER(1, 0, REG_SP))
+#define SET_SP(x)  (REG_SP  = (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
+#define INC_SP(x)  (REG_SP += (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
+#define DEC_SP(x)  (REG_SP -= (USAGE_ANALYSIS_REGISTER_HELPER(1, 1, (x))))
+#define SET_SV(x)  (*GET_SP() = (x))
+  /* set current stack value as x */
+
+#define GET_SP_COUNT() (REG_SP - th->stack)
+
+/* instruction sequence C struct */
+#define GET_ISEQ() (GET_CFP()->iseq)
+
+/**********************************************************/
+/* deal with variables                                    */
+/**********************************************************/
+
+#define GET_PREV_DFP(dfp)                ((VALUE *)((dfp)[0] & ~0x03))
+
+#define GET_GLOBAL(entry)       rb_gvar_get((struct global_entry*)entry)
+#define SET_GLOBAL(entry, val)  rb_gvar_set((struct global_entry*)entry, val)
+
+#define GET_CONST_INLINE_CACHE(dst) ((IC) * (GET_PC() + (dst) + 1))
+
+/**********************************************************/
+/* deal with values                                       */
+/**********************************************************/
+
+#define GET_SELF() (USAGE_ANALYSIS_REGISTER_HELPER(5, 0, GET_CFP()->self))
+
+/**********************************************************/
+/* deal with control flow 2: method/iterator              */
+/**********************************************************/
+
+#define COPY_CREF(c1, c2) do {  \
+  NODE *__tmp_c2 = (c2); \
+  c1->nd_clss = __tmp_c2->nd_clss; \
+  c1->nd_visi = __tmp_c2->nd_visi; \
+  c1->nd_next = __tmp_c2->nd_next; \
+} while (0)
+
+#define CALL_METHOD(num, blockptr, flag, id, mn, recv, klass) do { \
+    VALUE v = vm_call_method(th, GET_CFP(), num, blockptr, flag, id, mn, recv, klass); \
+    if (v == Qundef) { \
+	RESTORE_REGS(); \
+	NEXT_INSN(); \
+    } \
+    else { \
+	val = v; \
+    } \
+} while (0)
+
+#define GET_BLOCK_PTR() \
+  ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0])))
+
+/**********************************************************/
+/* deal with control flow 3: exception                    */
+/**********************************************************/
+
+
+/**********************************************************/
+/* others                                                 */
+/**********************************************************/
+
+/* optimize insn */
+#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
+#define BASIC_OP_UNREDEFINED_P(op) ((ruby_vm_redefined_flag & (op)) == 0)
+#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
+
+#define CALL_SIMPLE_METHOD(num, id, recv) do { \
+    VALUE klass = CLASS_OF(recv); \
+    CALL_METHOD(num, 0, 0, id, rb_method_node(klass, id), recv, CLASS_OF(recv)); \
+} while (0)
+
+#endif /* RUBY_INSNHELPER_H */

Property changes on: vm_insnhelper.h
___________________________________________________________________
Name: svn:eol-style
   + LF
Name: svn:keywords
   + Author Date Id Revision


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

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