mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* insnhelper.h, vm.h: some refactoring.
remove useless comments, etc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a69ad4df1
commit
061cce6d6f
3 changed files with 25 additions and 32 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Jul 1 03:25:53 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* insnhelper.h, vm.h: some refactoring.
|
||||
remove useless comments, etc.
|
||||
|
||||
Sun Jul 1 03:02:29 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* yarvcore.h: some refactoring on rb_iseq_t.
|
||||
|
|
46
insnhelper.h
46
insnhelper.h
|
@ -16,11 +16,6 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "vm.h"
|
||||
|
||||
|
||||
/*
|
||||
* deal with control frame pointer
|
||||
*/
|
||||
|
||||
/**********************************************************/
|
||||
/* deal with stack */
|
||||
/**********************************************************/
|
||||
|
@ -54,8 +49,7 @@
|
|||
#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
|
||||
(USAGE_ANALYSIS_REGISTER(a, b), (v))
|
||||
#else
|
||||
#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) \
|
||||
(v)
|
||||
#define USAGE_ANALYSIS_REGISTER_HELPER(a, b, v) (v)
|
||||
#endif
|
||||
|
||||
/* PC */
|
||||
|
@ -66,13 +60,10 @@
|
|||
#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))
|
||||
|
@ -95,7 +86,6 @@
|
|||
#define GET_ISEQ() (GET_CFP()->iseq)
|
||||
#define CLEAR_ENV(env) (GET_ENV_CTRL(env)->is_orphan = Qundef)
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* deal with variables */
|
||||
/**********************************************************/
|
||||
|
@ -112,28 +102,31 @@
|
|||
|
||||
#define GET_SELF() (USAGE_ANALYSIS_REGISTER_HELPER(5, 0, GET_CFP()->self))
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* deal with control flow 2: method/iterator */
|
||||
/**********************************************************/
|
||||
|
||||
#define COPY_CREF(c1, c2) { \
|
||||
#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)
|
||||
|
||||
/* block */
|
||||
#define GET_BLOCK_PTR() \
|
||||
((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0])))
|
||||
|
||||
#define CHECK_STACK_OVERFLOW(cfp, margin) do \
|
||||
if (((VALUE *)(cfp)->sp) + (margin) >= ((VALUE *)cfp)) { \
|
||||
rb_exc_raise(sysstack_error); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/**********************************************************/
|
||||
/* deal with control flow 3: exception */
|
||||
/**********************************************************/
|
||||
|
@ -148,17 +141,6 @@ while (0)
|
|||
#define BASIC_OP_UNREDEFINED_P(op) ((ruby_vm_redefined_flag & (op)) == 0)
|
||||
#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
|
||||
|
||||
#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 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)); \
|
||||
|
|
6
vm.h
6
vm.h
|
@ -220,6 +220,12 @@ default: \
|
|||
((rb_control_frame_t *)(th->stack + th->stack_size) - (rb_control_frame_t *)(cfp))
|
||||
#define VM_SP_CNT(th, sp) ((sp) - (th)->stack)
|
||||
|
||||
#define CHECK_STACK_OVERFLOW(cfp, margin) do \
|
||||
if (((VALUE *)(cfp)->sp) + (margin) >= ((VALUE *)cfp)) { \
|
||||
rb_exc_raise(sysstack_error); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/*
|
||||
env{
|
||||
env[0] // special (block or prev env)
|
||||
|
|
Loading…
Reference in a new issue