mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c: rename iseq_translate_direct_threaded_code()
to iseq_translate_threaded_code(). * eval_intern.h, yarvcore.h: mv EXEC_EVENT_HOOK() and exec_event_hooks() to yarvcore.h. * insnhelper.ci, vm.c: mv yarv_finish_insn_seq to vm.c. * insns.def (opt_call_c_function): fix to use RESTORE_REGS(). * iseq.c (rb_iseq_build_for_ruby2cext): fix to allocate iseq. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0a75feb94a
commit
ee457d92c2
8 changed files with 71 additions and 49 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Mon Jul 2 21:45:53 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* compile.c: rename iseq_translate_direct_threaded_code()
|
||||
to iseq_translate_threaded_code().
|
||||
|
||||
* eval_intern.h, yarvcore.h: mv EXEC_EVENT_HOOK() and
|
||||
exec_event_hooks() to yarvcore.h.
|
||||
|
||||
* insnhelper.ci, vm.c: mv yarv_finish_insn_seq to vm.c.
|
||||
|
||||
* insns.def (opt_call_c_function): fix to use RESTORE_REGS().
|
||||
|
||||
* iseq.c (rb_iseq_build_for_ruby2cext): fix to allocate iseq.
|
||||
|
||||
Mon Jul 2 11:59:34 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* insns.def (defineclass): suppress a warning.
|
||||
|
|
|
@ -218,8 +218,8 @@ rb_iseq_compile(VALUE self, NODE *node)
|
|||
|
||||
VALUE vm_eval(void *);
|
||||
|
||||
static int
|
||||
iseq_translate_direct_threaded_code(rb_iseq_t *iseq)
|
||||
int
|
||||
iseq_translate_threaded_code(rb_iseq_t *iseq)
|
||||
{
|
||||
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
|
||||
|
||||
|
@ -690,8 +690,8 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
|||
debugs("[compile step 4.3 (set_optargs_table)] \n");
|
||||
set_optargs_table(iseq);
|
||||
|
||||
debugs("[compile step 5 (iseq_translate_direct_threaded_code)] \n");
|
||||
iseq_translate_direct_threaded_code(iseq);
|
||||
debugs("[compile step 5 (iseq_translate_threaded_code)] \n");
|
||||
iseq_translate_threaded_code(iseq);
|
||||
|
||||
if (CPDEBUG > 1) {
|
||||
VALUE str = ruby_iseq_disasm(iseq->self);
|
||||
|
|
|
@ -227,39 +227,8 @@ VALUE rb_obj_is_proc(VALUE);
|
|||
void rb_vm_check_redefinition_opt_method(NODE *node);
|
||||
VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, rb_block_t *blockptr, VALUE filename);
|
||||
void rb_thread_terminate_all(void);
|
||||
|
||||
VALUE rb_vm_set_eval_stack(rb_thread_t *, VALUE iseq);
|
||||
void rb_vm_set_eval_stack(rb_thread_t *, VALUE iseq);
|
||||
|
||||
#define ruby_cbase() vm_get_cbase(GET_THREAD())
|
||||
|
||||
|
||||
/* tracer */
|
||||
static void inline
|
||||
exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
|
||||
{
|
||||
while (hook) {
|
||||
if (flag & hook->flag) {
|
||||
(*hook->func)(flag, hook->data, self, id, klass);
|
||||
}
|
||||
hook = hook->next;
|
||||
}
|
||||
}
|
||||
|
||||
#define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
|
||||
rb_event_flag_t wait_event__ = th->event_flags; \
|
||||
if (UNLIKELY(wait_event__)) { \
|
||||
if (wait_event__ & (flag | RUBY_EVENT_VM)) { \
|
||||
VALUE self__ = (self), klass__ = (klass); \
|
||||
ID id__ = (id); \
|
||||
if (wait_event__ & flag) { \
|
||||
exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \
|
||||
} \
|
||||
if (wait_event__ & RUBY_EVENT_VM) { \
|
||||
exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#endif /* EVAL_INTERN_H_INCLUDED */
|
||||
|
|
|
@ -14,14 +14,6 @@
|
|||
|
||||
#include "insns.inc"
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
static VALUE yarv_finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
|
||||
#elif OPT_CALL_THREADED_CODE
|
||||
static VALUE const yarv_finish_insn_seq[1] = { 0 };
|
||||
#else
|
||||
static VALUE yarv_finish_insn_seq[1] = { BIN(finish) };
|
||||
#endif
|
||||
|
||||
/* control stack frame */
|
||||
|
||||
static inline rb_control_frame_t *
|
||||
|
|
|
@ -379,11 +379,11 @@ putobject
|
|||
|
||||
DEFINE_INSN
|
||||
putstring
|
||||
(VALUE val)
|
||||
(VALUE str)
|
||||
()
|
||||
(VALUE val)
|
||||
{
|
||||
val = rb_str_new3(val);
|
||||
val = rb_str_new3(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2337,6 +2337,7 @@ opt_call_c_function
|
|||
()
|
||||
{
|
||||
rb_insn_func_t funcptr = (rb_insn_func_t) func;
|
||||
|
||||
reg_cfp = (funcptr)(th, reg_cfp);
|
||||
|
||||
if (reg_cfp == 0) {
|
||||
|
@ -2345,6 +2346,7 @@ opt_call_c_function
|
|||
THROW_EXCEPTION(err);
|
||||
}
|
||||
|
||||
RESTORE_REGS();
|
||||
NEXT_INSN();
|
||||
}
|
||||
|
||||
|
|
10
iseq.c
10
iseq.c
|
@ -1372,6 +1372,7 @@ rb_iseq_build_for_ruby2cext(
|
|||
const char *name,
|
||||
const char *filename)
|
||||
{
|
||||
int i;
|
||||
VALUE iseqval = iseq_alloc(rb_cISeq);
|
||||
rb_iseq_t *iseq;
|
||||
GetISeqPtr(iseqval, iseq);
|
||||
|
@ -1382,6 +1383,15 @@ rb_iseq_build_for_ruby2cext(
|
|||
iseq->filename = rb_str_new2(filename);
|
||||
iseq->mark_ary = rb_ary_new();
|
||||
|
||||
iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);
|
||||
|
||||
for (i=0; i<iseq->iseq_size; i+=2) {
|
||||
iseq->iseq[i] = BIN(opt_call_c_function);
|
||||
iseq->iseq[i+1] = (VALUE)func;
|
||||
}
|
||||
|
||||
iseq_translate_threaded_code(iseq);
|
||||
|
||||
#define ALLOC_AND_COPY(dst, src, type, size) do { \
|
||||
if (size) { \
|
||||
(dst) = ALLOC_N(type, (size)); \
|
||||
|
|
13
vm.c
13
vm.c
|
@ -38,6 +38,14 @@ static NODE *lfp_set_special_cref(VALUE *lfp, NODE * cref);
|
|||
|
||||
static inline int block_proc_is_lambda(VALUE procval);
|
||||
|
||||
#if OPT_STACK_CACHING
|
||||
static VALUE yarv_finish_insn_seq[1] = { BIN(finish_SC_ax_ax) };
|
||||
#elif OPT_CALL_THREADED_CODE
|
||||
static VALUE const yarv_finish_insn_seq[1] = { 0 };
|
||||
#else
|
||||
static VALUE yarv_finish_insn_seq[1] = { BIN(finish) };
|
||||
#endif
|
||||
|
||||
void
|
||||
rb_vm_change_state(void)
|
||||
{
|
||||
|
@ -56,7 +64,7 @@ rb_vm_set_finish_env(rb_thread_t *th)
|
|||
return Qtrue;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
rb_vm_set_top_stack(rb_thread_t *th, VALUE iseqval)
|
||||
{
|
||||
rb_iseq_t *iseq;
|
||||
|
@ -74,7 +82,7 @@ rb_vm_set_top_stack(rb_thread_t *th, VALUE iseqval)
|
|||
th->cfp->sp, 0, iseq->local_size);
|
||||
}
|
||||
|
||||
VALUE
|
||||
void
|
||||
rb_vm_set_eval_stack(rb_thread_t *th, VALUE iseqval)
|
||||
{
|
||||
rb_iseq_t *iseq;
|
||||
|
@ -86,7 +94,6 @@ rb_vm_set_eval_stack(rb_thread_t *th, VALUE iseqval)
|
|||
vm_push_frame(th, iseq, FRAME_MAGIC_EVAL, block->self,
|
||||
GC_GUARDED_PTR(block->dfp), iseq->iseq_encoded,
|
||||
th->cfp->sp, block->lfp, iseq->local_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Env */
|
||||
|
|
28
yarvcore.h
28
yarvcore.h
|
@ -719,4 +719,32 @@ void rb_thread_execute_interrupts(rb_thread_t *);
|
|||
#define RUBY_VM_CHECK_INTS() \
|
||||
RUBY_VM_CHECK_INTS_TH(GET_THREAD())
|
||||
|
||||
/* tracer */
|
||||
static void inline
|
||||
exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
|
||||
{
|
||||
while (hook) {
|
||||
if (flag & hook->flag) {
|
||||
(*hook->func)(flag, hook->data, self, id, klass);
|
||||
}
|
||||
hook = hook->next;
|
||||
}
|
||||
}
|
||||
|
||||
#define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
|
||||
rb_event_flag_t wait_event__ = th->event_flags; \
|
||||
if (UNLIKELY(wait_event__)) { \
|
||||
if (wait_event__ & (flag | RUBY_EVENT_VM)) { \
|
||||
VALUE self__ = (self), klass__ = (klass); \
|
||||
ID id__ = (id); \
|
||||
if (wait_event__ & flag) { \
|
||||
exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \
|
||||
} \
|
||||
if (wait_event__ & RUBY_EVENT_VM) { \
|
||||
exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* _YARVCORE_H_INCLUDED_ */
|
||||
|
|
Loading…
Reference in a new issue