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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f623428d1a
commit
b5d5cce11b
@ -540,7 +540,7 @@ class RubyVM
|
|||||||
@insns.dup.each{|insn|
|
@insns.dup.each{|insn|
|
||||||
body = <<-EOS
|
body = <<-EOS
|
||||||
vm_trace(ec, GET_CFP(), GET_PC());
|
vm_trace(ec, GET_CFP(), GET_PC());
|
||||||
goto start_of_#{insn.name};
|
DISPATCH_ORIGINAL_INSN(#{insn.name});
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
trace_insn = Instruction.new(name = "trace_#{insn.name}",
|
trace_insn = Instruction.new(name = "trace_#{insn.name}",
|
||||||
@ -884,7 +884,7 @@ class RubyVM
|
|||||||
end
|
end
|
||||||
|
|
||||||
def make_header insn
|
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}"
|
commit "INSN_ENTRY(#{insn.name}){#{label}"
|
||||||
make_header_prepare_stack insn
|
make_header_prepare_stack insn
|
||||||
commit "{"
|
commit "{"
|
||||||
|
12
vm_exec.h
12
vm_exec.h
@ -66,6 +66,9 @@ error !
|
|||||||
|
|
||||||
#define NEXT_INSN() return reg_cfp;
|
#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
|
#elif OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
|
||||||
/* threaded code with gcc */
|
/* threaded code with gcc */
|
||||||
@ -95,10 +98,8 @@ error !
|
|||||||
#else
|
#else
|
||||||
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
#define DISPATCH_ARCH_DEPEND_WAY(addr) \
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**********************************/
|
/**********************************/
|
||||||
#if OPT_DIRECT_THREADED_CODE
|
#if OPT_DIRECT_THREADED_CODE
|
||||||
|
|
||||||
@ -134,6 +135,9 @@ error !
|
|||||||
|
|
||||||
#define NEXT_INSN() TC_DISPATCH(__NEXT_INSN__)
|
#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 */
|
#else /* no threaded code */
|
||||||
/* most common method */
|
/* most common method */
|
||||||
@ -145,7 +149,6 @@ case BIN(insn):
|
|||||||
DEBUG_END_INSN(); \
|
DEBUG_END_INSN(); \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#define INSN_DISPATCH() \
|
#define INSN_DISPATCH() \
|
||||||
while (1) { \
|
while (1) { \
|
||||||
switch (GET_CURRENT_INSN()) {
|
switch (GET_CURRENT_INSN()) {
|
||||||
@ -159,6 +162,9 @@ default: \
|
|||||||
|
|
||||||
#define NEXT_INSN() goto first
|
#define NEXT_INSN() goto first
|
||||||
|
|
||||||
|
#define START_OF_ORIGINAL_INSN(x) start_of_##x:
|
||||||
|
#define DISPATCH_ORIGINAL_INSN(x) goto start_of_##x;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
|
#define VM_SP_CNT(ec, sp) ((sp) - (ec)->vm_stack)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user