2006-12-31 18:02:22 +03:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
blockinlining.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-10 07:06:15 +04:00
|
|
|
#include "ruby/ruby.h"
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
#include "vm_core.h"
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
static VALUE
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_special_block(rb_iseq_t *iseq, void *builder)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
#if OPT_BLOCKINLINING
|
|
|
|
VALUE parent = Qfalse;
|
|
|
|
VALUE iseqval;
|
|
|
|
|
|
|
|
if (iseq->argc > 1 || iseq->arg_simple == 0) {
|
|
|
|
/* argument check */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->cached_special_block_builder) {
|
|
|
|
if (iseq->cached_special_block_builder == builder) {
|
|
|
|
return iseq->cached_special_block;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->cached_special_block_builder = (void *)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->parent_iseq) {
|
|
|
|
parent = iseq->parent_iseq->self;
|
|
|
|
}
|
2007-02-25 04:34:33 +03:00
|
|
|
iseqval = rb_iseq_new_with_bopt(iseq->node, iseq->name, iseq->filename,
|
2006-12-31 18:02:22 +03:00
|
|
|
parent, iseq->type,
|
|
|
|
GC_GUARDED_PTR(builder));
|
|
|
|
if (0) {
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-07 04:25:05 +03:00
|
|
|
printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
iseq->cached_special_block = iseqval;
|
|
|
|
iseq->cached_special_block_builder = builder;
|
|
|
|
return iseqval;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_block(NODE * head, NODE * tail)
|
|
|
|
{
|
|
|
|
head = NEW_BLOCK(head);
|
|
|
|
tail = NEW_BLOCK(tail);
|
|
|
|
head->nd_next = tail;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_ary(NODE * head, NODE * tail)
|
|
|
|
{
|
|
|
|
head = NEW_ARRAY(head);
|
|
|
|
head->nd_next = tail;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_assign(NODE * lnode, NODE * rhs)
|
|
|
|
{
|
|
|
|
switch (nd_type(lnode)) {
|
|
|
|
case NODE_LASGN:{
|
|
|
|
return NEW_NODE(NODE_LASGN, lnode->nd_vid, rhs, lnode->nd_cnt);
|
|
|
|
/* NEW_LASGN(lnode->nd_vid, rhs); */
|
|
|
|
}
|
|
|
|
case NODE_GASGN:{
|
|
|
|
return NEW_GASGN(lnode->nd_vid, rhs);
|
|
|
|
}
|
|
|
|
case NODE_DASGN:{
|
|
|
|
return NEW_DASGN(lnode->nd_vid, rhs);
|
|
|
|
}
|
|
|
|
case NODE_ATTRASGN:{
|
|
|
|
NODE *args = 0;
|
|
|
|
if (lnode->nd_args) {
|
|
|
|
args = NEW_ARRAY(lnode->nd_args->nd_head);
|
|
|
|
args->nd_next = NEW_ARRAY(rhs);
|
|
|
|
args->nd_alen = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
args = NEW_ARRAY(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NEW_ATTRASGN(lnode->nd_recv,
|
|
|
|
lnode->nd_mid,
|
|
|
|
args);
|
|
|
|
}
|
|
|
|
default:
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-07 04:25:05 +03:00
|
|
|
rb_bug("unimplemented (block inlining): %s", ruby_node_name(nd_type(lnode)));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
build_Integer_times_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
/* Special Block for Integer#times
|
|
|
|
{|e, _self|
|
|
|
|
_e = e
|
|
|
|
while(e < _self)
|
|
|
|
e = _e
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_e = _e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
{|e, _self|
|
|
|
|
while(e < _self)
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
e = e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _self;
|
|
|
|
CONST_ID(_self, "#_self");
|
2006-12-31 18:02:22 +03:00
|
|
|
if (iseq->argc == 0) {
|
2008-06-09 13:25:32 +04:00
|
|
|
ID e;
|
|
|
|
CONST_ID(e, "#e");
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(param_vars, ID2SYM(e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc += 2;
|
|
|
|
|
|
|
|
node =
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(e), idLT, new_ary(NEW_DVAR(_self), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(e), idSucc, 0))),
|
|
|
|
Qundef);
|
|
|
|
}
|
|
|
|
else {
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _e;
|
2006-12-31 18:02:22 +03:00
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(_e, "#_e");
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_e));
|
|
|
|
iseq->argc++;
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_e, NEW_DVAR(e)),
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(_e), idLT,
|
|
|
|
new_ary(NEW_DVAR(_self), 0)),
|
|
|
|
new_block(assign,
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_e,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR(_e),
|
|
|
|
idSucc, 0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
invoke_Integer_times_special_block(VALUE num)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 09:37:46 +03:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
if (orig_block && BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
VALUE tsiseqval = iseq_special_block(orig_block->iseq,
|
|
|
|
build_Integer_times_node);
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE argv[2], val;
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 18:02:22 +03:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = INT2FIX(0);
|
|
|
|
argv[1] = num;
|
* eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added. Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
blockinlining.c: fix for above changes. and do some refactoring.
this changes improve rb_yield() performance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 21:50:17 +04:00
|
|
|
val = rb_yield_values(2, argv);
|
2006-12-31 18:02:22 +03:00
|
|
|
if (val == Qundef) {
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
build_Range_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE param_vars, VALUE local_vars, ID mid)
|
|
|
|
{
|
|
|
|
/* Special Block for Range#each
|
|
|
|
{|e, _last|
|
|
|
|
_e = e
|
|
|
|
while _e < _last
|
|
|
|
e = _e
|
|
|
|
next_point:
|
|
|
|
BODY
|
|
|
|
redo_point:
|
|
|
|
_e = _e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
{|e, _last|
|
|
|
|
while e < _last
|
|
|
|
BODY
|
|
|
|
redo_point:
|
|
|
|
e = e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _last;
|
|
|
|
CONST_ID(_last, "#_last");
|
2006-12-31 18:02:22 +03:00
|
|
|
if (iseq->argc == 0) {
|
2008-06-09 13:25:32 +04:00
|
|
|
ID e;
|
|
|
|
CONST_ID(e, "#e");
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(param_vars, ID2SYM(e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_last));
|
|
|
|
iseq->argc += 2;
|
|
|
|
|
|
|
|
node =
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(e), mid, new_ary(NEW_DVAR(_last), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(e), idSucc, 0))),
|
|
|
|
Qundef);
|
|
|
|
}
|
|
|
|
else {
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _e;
|
2006-12-31 18:02:22 +03:00
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(_e, "#_e");
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(param_vars, ID2SYM(_last));
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_e));
|
|
|
|
iseq->argc++;
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_e, NEW_DVAR(e)),
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(_e), mid,
|
|
|
|
new_ary(NEW_DVAR(_last), 0)),
|
|
|
|
new_block(assign,
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_e,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR(_e),
|
|
|
|
idSucc, 0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
build_Range_each_node_LE(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
return build_Range_each_node(iseq, node, lnode,
|
|
|
|
param_vars, local_vars, idLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
build_Range_each_node_LT(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
return build_Range_each_node(iseq, node, lnode,
|
|
|
|
param_vars, local_vars, idLT);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
invoke_Range_each_special_block(VALUE range,
|
|
|
|
VALUE beg, VALUE end, int excl)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 09:37:46 +03:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
|
|
|
void *builder =
|
|
|
|
excl ? build_Range_each_node_LT : build_Range_each_node_LE;
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
VALUE tsiseqval = iseq_special_block(orig_block->iseq, builder);
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE argv[2];
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
|
|
|
VALUE val;
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 18:02:22 +03:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = beg;
|
|
|
|
argv[1] = end;
|
* eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added. Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
blockinlining.c: fix for above changes. and do some refactoring.
this changes improve rb_yield() performance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 21:50:17 +04:00
|
|
|
val = rb_yield_values(2, argv);
|
2006-12-31 18:02:22 +03:00
|
|
|
if (val == Qundef) {
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NODE *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
build_Array_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
/* Special block for Array#each
|
|
|
|
ary.each{|e|
|
|
|
|
BODY
|
|
|
|
}
|
|
|
|
=>
|
|
|
|
{|e, _self|
|
|
|
|
_i = 0
|
|
|
|
while _i < _self.length
|
|
|
|
e = _self[_i]
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_i = _i.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
ary.each{
|
|
|
|
BODY
|
|
|
|
}
|
|
|
|
=>
|
|
|
|
{|_i, _self|
|
|
|
|
_i = 0
|
|
|
|
while _i < _self.length
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_i = _i.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _self, _i;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(_self, "#_self");
|
|
|
|
CONST_ID(_i, "#_i");
|
2006-12-31 18:02:22 +03:00
|
|
|
if (iseq->argc == 0) {
|
2008-06-09 13:25:32 +04:00
|
|
|
ID _e;
|
|
|
|
CONST_ID(_e, "#_e");
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(param_vars, ID2SYM(_e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc += 2;
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_i));
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
|
|
|
|
new_ary(NEW_CALL
|
|
|
|
(NEW_DVAR(_self), idLength,
|
|
|
|
0), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_i,
|
|
|
|
NEW_CALL(NEW_DVAR(_i),
|
|
|
|
idSucc, 0))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc++;
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_i));
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(_self), idAREF,
|
|
|
|
new_ary(NEW_DVAR(_i), 0)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode,
|
|
|
|
NEW_CALL(NEW_DVAR(_self), idAREF,
|
|
|
|
new_ary(NEW_DVAR(_i), 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
|
|
|
|
new_ary(NEW_CALL
|
|
|
|
(NEW_DVAR(_self), idLength,
|
|
|
|
0), 0)), new_block(assign,
|
|
|
|
new_block
|
|
|
|
(NEW_OPTBLOCK
|
|
|
|
(node),
|
|
|
|
NEW_DASGN
|
|
|
|
(_i,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR
|
|
|
|
(_i),
|
|
|
|
idSucc,
|
|
|
|
0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
invoke_Array_each_special_block(VALUE ary)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 09:37:46 +03:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
VALUE tsiseqval = iseq_special_block(orig_block->iseq,
|
|
|
|
build_Array_each_node);
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE argv[2];
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
|
|
|
VALUE val;
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 18:02:22 +03:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = 0;
|
|
|
|
argv[1] = ary;
|
* eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added. Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
blockinlining.c: fix for above changes. and do some refactoring.
this changes improve rb_yield() performance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 21:50:17 +04:00
|
|
|
val = rb_yield_values(2, argv);
|
2006-12-31 18:02:22 +03:00
|
|
|
if (val == Qundef) {
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|