2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
yarvcore.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: 04/01/01 01:17:22 JST
|
|
|
|
|
|
|
|
Copyright (C) 2004-2006 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include "ruby.h"
|
|
|
|
#include "node.h"
|
|
|
|
|
|
|
|
#include "yarvcore.h"
|
|
|
|
#include "gc.h"
|
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
VALUE rb_cVM;
|
2007-02-05 07:21:01 -05:00
|
|
|
VALUE rb_cThread;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
VALUE symIFUNC;
|
|
|
|
VALUE symCFUNC;
|
|
|
|
|
|
|
|
ID idPLUS;
|
|
|
|
ID idMINUS;
|
|
|
|
ID idMULT;
|
|
|
|
ID idDIV;
|
|
|
|
ID idMOD;
|
|
|
|
ID idLT;
|
|
|
|
ID idLTLT;
|
|
|
|
ID idLE;
|
|
|
|
ID idEq;
|
|
|
|
ID idEqq;
|
|
|
|
ID idBackquote;
|
|
|
|
ID idEqTilde;
|
|
|
|
ID idThrowState;
|
|
|
|
ID idAREF;
|
|
|
|
ID idASET;
|
|
|
|
ID idIntern;
|
|
|
|
ID idMethodMissing;
|
|
|
|
ID idLength;
|
|
|
|
ID idLambda;
|
|
|
|
ID idGets;
|
|
|
|
ID idSucc;
|
|
|
|
ID idEach;
|
|
|
|
ID idRangeEachLT;
|
|
|
|
ID idRangeEachLE;
|
|
|
|
ID idArrayEach;
|
|
|
|
ID idTimes;
|
|
|
|
ID idEnd;
|
|
|
|
ID idBitblt;
|
|
|
|
ID idAnswer;
|
|
|
|
ID idSvarPlaceholder;
|
2007-01-05 19:24:59 -05:00
|
|
|
ID idSend;
|
|
|
|
ID id__send__;
|
|
|
|
ID id__send;
|
|
|
|
ID idFuncall;
|
|
|
|
ID id__send_bang;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
/* from Ruby 1.9 eval.c */
|
|
|
|
#ifdef HAVE_STDARG_PROTOTYPES
|
|
|
|
#include <stdarg.h>
|
|
|
|
#define va_init_list(a,b) va_start(a,b)
|
|
|
|
#else
|
|
|
|
#include <varargs.h>
|
|
|
|
#define va_init_list(a,b) va_start(a)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/************/
|
|
|
|
/* YARVCore */
|
|
|
|
/************/
|
|
|
|
|
2007-02-26 17:51:33 -05:00
|
|
|
rb_thread_t *ruby_current_thread = 0;
|
|
|
|
rb_vm_t *ruby_current_vm = 0;
|
|
|
|
static VALUE ruby_vm_list = Qnil;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
RUBY_EXTERN int ruby_nerrs;
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
compile_string(VALUE str, VALUE file, VALUE line)
|
|
|
|
{
|
|
|
|
NODE *node;
|
|
|
|
node = rb_compile_string(StringValueCStr(file), str, NUM2INT(line));
|
|
|
|
|
|
|
|
if (ruby_nerrs > 0) {
|
|
|
|
ruby_nerrs = 0;
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
rb_exc_raise(GET_THREAD()->errinfo); /* TODO: check err */
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
yarvcore_eval_iseq(VALUE iseq)
|
|
|
|
{
|
* 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 14:00:03 -05:00
|
|
|
return rb_thread_eval(GET_THREAD(), iseq);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* 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 01:37:46 -05:00
|
|
|
th_compile_from_node(rb_thread_t *th, NODE * node, VALUE file)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
VALUE iseq;
|
|
|
|
if (th->base_block) {
|
* 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-06 20:25:05 -05:00
|
|
|
iseq = rb_iseq_new(node,
|
2006-12-31 10:02:22 -05:00
|
|
|
th->base_block->iseq->name,
|
|
|
|
file,
|
|
|
|
th->base_block->iseq->self,
|
|
|
|
ISEQ_TYPE_EVAL);
|
|
|
|
}
|
|
|
|
else {
|
* 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-06 20:25:05 -05:00
|
|
|
iseq = rb_iseq_new(node, rb_str_new2("<main>"), file,
|
2006-12-31 10:02:22 -05:00
|
|
|
Qfalse, ISEQ_TYPE_TOP);
|
|
|
|
}
|
|
|
|
return iseq;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* 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 01:37:46 -05:00
|
|
|
th_compile(rb_thread_t *th, VALUE str, VALUE file, VALUE line)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
NODE *node = (NODE *) compile_string(str, file, line);
|
|
|
|
return th_compile_from_node(th, (NODE *) node, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
yarvcore_eval_parsed(NODE *node, VALUE file)
|
|
|
|
{
|
|
|
|
VALUE iseq = th_compile_from_node(GET_THREAD(), node, file);
|
|
|
|
return yarvcore_eval_iseq(iseq);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line)
|
|
|
|
{
|
|
|
|
NODE *node;
|
|
|
|
node = compile_string(str, file, line);
|
|
|
|
return yarvcore_eval_parsed(node, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******/
|
|
|
|
/* VM */
|
|
|
|
/******/
|
|
|
|
|
|
|
|
void native_thread_cleanup(void *);
|
|
|
|
|
|
|
|
static void
|
|
|
|
vm_free(void *ptr)
|
|
|
|
{
|
|
|
|
FREE_REPORT_ENTER("vm");
|
|
|
|
if (ptr) {
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vmobj = ptr;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
st_free_table(vmobj->living_threads);
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
/* TODO: MultiVM Instance */
|
|
|
|
/* VM object should not be cleaned by GC */
|
|
|
|
/* ruby_xfree(ptr); */
|
2007-02-26 17:51:33 -05:00
|
|
|
/* ruby_current_vm = 0; */
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
FREE_REPORT_LEAVE("vm");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vm_mark_each_thread_func(st_data_t key, st_data_t value, st_data_t dummy)
|
|
|
|
{
|
|
|
|
VALUE thval = (VALUE)key;
|
|
|
|
rb_gc_mark(thval);
|
|
|
|
return ST_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vm_mark(void *ptr)
|
|
|
|
{
|
|
|
|
MARK_REPORT_ENTER("vm");
|
|
|
|
GC_INFO("-------------------------------------------------\n");
|
|
|
|
if (ptr) {
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vm = ptr;
|
2006-12-31 10:02:22 -05:00
|
|
|
if (vm->living_threads) {
|
|
|
|
st_foreach(vm->living_threads, vm_mark_each_thread_func, 0);
|
|
|
|
}
|
|
|
|
MARK_UNLESS_NULL(vm->thgroup_default);
|
|
|
|
MARK_UNLESS_NULL(vm->mark_object_ary);
|
2007-02-05 07:21:01 -05:00
|
|
|
MARK_UNLESS_NULL(vm->last_status);
|
2007-02-13 21:19:02 -05:00
|
|
|
MARK_UNLESS_NULL(vm->loaded_features);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
2007-02-13 21:19:02 -05:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
MARK_REPORT_LEAVE("vm");
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
vm_alloc(VALUE klass)
|
|
|
|
{
|
|
|
|
VALUE volatile obj;
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vm;
|
|
|
|
obj = Data_Make_Struct(klass, rb_vm_t, vm_mark, vm_free, vm);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
vm->self = obj;
|
|
|
|
vm->mark_object_ary = rb_ary_new();
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
* 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 14:00:03 -05:00
|
|
|
vm_init2(rb_vm_t *vm)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
* 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 14:00:03 -05:00
|
|
|
MEMZERO(vm, rb_vm_t, 1);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********/
|
|
|
|
/* Thread */
|
|
|
|
/**********/
|
|
|
|
|
|
|
|
static void
|
|
|
|
thread_free(void *ptr)
|
|
|
|
{
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
2006-12-31 10:02:22 -05:00
|
|
|
FREE_REPORT_ENTER("thread");
|
|
|
|
|
|
|
|
if (ptr) {
|
|
|
|
th = ptr;
|
|
|
|
FREE_UNLESS_NULL(th->stack);
|
|
|
|
FREE_UNLESS_NULL(th->top_local_tbl);
|
|
|
|
|
|
|
|
if (th->local_storage) {
|
|
|
|
st_free_table(th->local_storage);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if USE_VALUE_CACHE
|
|
|
|
{
|
|
|
|
VALUE *ptr = th->value_cache_ptr;
|
|
|
|
while (*ptr) {
|
|
|
|
VALUE v = *ptr;
|
|
|
|
RBASIC(v)->flags = 0;
|
|
|
|
RBASIC(v)->klass = 0;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (th->vm->main_thread == th) {
|
|
|
|
GC_INFO("main thread\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ruby_xfree(ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FREE_REPORT_LEAVE("thread");
|
|
|
|
}
|
|
|
|
|
* 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 01:37:46 -05:00
|
|
|
void yarv_machine_stack_mark(rb_thread_t *th);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
thread_mark(void *ptr)
|
|
|
|
{
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th = NULL;
|
2006-12-31 10:02:22 -05:00
|
|
|
MARK_REPORT_ENTER("thread");
|
|
|
|
if (ptr) {
|
|
|
|
th = ptr;
|
|
|
|
if (th->stack) {
|
|
|
|
VALUE *p = th->stack;
|
|
|
|
VALUE *sp = th->cfp->sp;
|
* 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 14:00:03 -05:00
|
|
|
rb_control_frame_t *cfp = th->cfp;
|
|
|
|
rb_control_frame_t *limit_cfp =
|
2006-12-31 10:02:22 -05:00
|
|
|
(void *)(th->stack + th->stack_size);
|
|
|
|
|
|
|
|
while (p < sp) {
|
|
|
|
rb_gc_mark(*p++);
|
|
|
|
}
|
|
|
|
while (cfp != limit_cfp) {
|
|
|
|
rb_gc_mark(cfp->proc);
|
* 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 14:00:03 -05:00
|
|
|
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark ruby objects */
|
|
|
|
MARK_UNLESS_NULL(th->first_proc);
|
|
|
|
MARK_UNLESS_NULL(th->first_args);
|
|
|
|
|
|
|
|
MARK_UNLESS_NULL(th->thgroup);
|
|
|
|
MARK_UNLESS_NULL(th->value);
|
|
|
|
MARK_UNLESS_NULL(th->errinfo);
|
|
|
|
MARK_UNLESS_NULL(th->local_svar);
|
2007-02-25 11:29:26 -05:00
|
|
|
MARK_UNLESS_NULL(th->top_self);
|
|
|
|
MARK_UNLESS_NULL(th->top_wrapper);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
rb_mark_tbl(th->local_storage);
|
|
|
|
|
|
|
|
if (GET_THREAD() != th &&
|
|
|
|
th->machine_stack_start && th->machine_stack_end) {
|
|
|
|
yarv_machine_stack_mark(th);
|
|
|
|
rb_gc_mark_locations((VALUE *)&th->machine_regs,
|
|
|
|
(VALUE *)(&th->machine_regs) +
|
|
|
|
sizeof(th->machine_regs) / sizeof(VALUE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MARK_UNLESS_NULL(th->stat_insn_usage);
|
|
|
|
MARK_REPORT_LEAVE("thread");
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
thread_alloc(VALUE klass)
|
|
|
|
{
|
|
|
|
VALUE volatile obj;
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
|
|
|
obj = Data_Make_Struct(klass, rb_thread_t,
|
2006-12-31 10:02:22 -05:00
|
|
|
thread_mark, thread_free, th);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
* 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 01:37:46 -05:00
|
|
|
th_init2(rb_thread_t *th)
|
2006-12-31 10:02:22 -05: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 01:37:46 -05:00
|
|
|
MEMZERO(th, rb_thread_t, 1);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
/* allocate thread stack */
|
* 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 14:00:03 -05:00
|
|
|
th->stack = ALLOC_N(VALUE, RUBY_VM_THREAD_STACK_SIZE);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
* 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 14:00:03 -05:00
|
|
|
th->stack_size = RUBY_VM_THREAD_STACK_SIZE;
|
2006-12-31 10:02:22 -05:00
|
|
|
th->cfp = (void *)(th->stack + th->stack_size);
|
|
|
|
th->cfp--;
|
|
|
|
|
|
|
|
th->cfp->pc = 0;
|
|
|
|
th->cfp->sp = th->stack;
|
|
|
|
th->cfp->bp = 0;
|
|
|
|
th->cfp->lfp = th->stack;
|
|
|
|
th->cfp->dfp = th->stack;
|
|
|
|
th->cfp->self = Qnil;
|
|
|
|
th->cfp->magic = 0;
|
|
|
|
th->cfp->iseq = 0;
|
|
|
|
th->cfp->proc = 0;
|
|
|
|
th->cfp->block_iseq = 0;
|
2007-02-05 07:21:01 -05:00
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
th->status = THREAD_RUNNABLE;
|
|
|
|
th->errinfo = Qnil;
|
|
|
|
|
|
|
|
#if USE_VALUE_CACHE
|
|
|
|
th->value_cache_ptr = &th->value_cache[0];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
* 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 01:37:46 -05:00
|
|
|
th_init(rb_thread_t *th)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
th_init2(th);
|
|
|
|
}
|
|
|
|
|
2007-02-25 11:29:26 -05:00
|
|
|
extern VALUE ruby_top_self;
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
static VALUE
|
|
|
|
thread_init(VALUE self)
|
|
|
|
{
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vm = GET_THREAD()->vm;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetThreadPtr(self, th);
|
|
|
|
|
|
|
|
th_init(th);
|
|
|
|
th->self = self;
|
|
|
|
th->vm = vm;
|
2007-02-25 11:29:26 -05:00
|
|
|
|
|
|
|
th->top_wrapper = 0;
|
|
|
|
th->top_self = ruby_top_self;
|
2006-12-31 10:02:22 -05:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
* 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 14:00:03 -05:00
|
|
|
rb_thread_alloc(VALUE klass)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
VALUE self = thread_alloc(klass);
|
|
|
|
thread_init(self);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************/
|
|
|
|
|
|
|
|
VALUE insns_name_array(void);
|
|
|
|
extern VALUE *rb_gc_stack_start;
|
|
|
|
|
2007-02-19 11:30:02 -05:00
|
|
|
static VALUE
|
2006-12-31 10:02:22 -05:00
|
|
|
sdr(void)
|
|
|
|
{
|
|
|
|
yarv_bug();
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
nsdr(void)
|
|
|
|
{
|
|
|
|
VALUE ary = rb_ary_new();
|
|
|
|
#if HAVE_BACKTRACE
|
|
|
|
#include <execinfo.h>
|
|
|
|
#define MAX_NATIVE_TRACE 1024
|
|
|
|
static void *trace[MAX_NATIVE_TRACE];
|
|
|
|
int n = backtrace(trace, MAX_NATIVE_TRACE);
|
|
|
|
char **syms = backtrace_symbols(trace, n);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (syms == 0) {
|
|
|
|
rb_memerror();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
rb_ary_push(ary, rb_str_new2(syms[i]));
|
|
|
|
}
|
|
|
|
free(syms);
|
|
|
|
#endif
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
|
* 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-06 20:25:05 -05:00
|
|
|
static char *yarv_options = ""
|
2006-12-31 10:02:22 -05:00
|
|
|
#if OPT_DIRECT_THREADED_CODE
|
|
|
|
"[direct threaded code] "
|
|
|
|
#elif OPT_TOKEN_THREADED_CODE
|
|
|
|
"[token threaded code] "
|
|
|
|
#elif OPT_CALL_THREADED_CODE
|
|
|
|
"[call threaded code] "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if OPT_BASIC_OPERATIONS
|
|
|
|
"[optimize basic operation] "
|
|
|
|
#endif
|
|
|
|
#if OPT_STACK_CACHING
|
|
|
|
"[stack caching] "
|
|
|
|
#endif
|
|
|
|
#if OPT_OPERANDS_UNIFICATION
|
|
|
|
"[operands unification] "
|
|
|
|
#endif
|
|
|
|
#if OPT_INSTRUCTIONS_UNIFICATION
|
|
|
|
"[instructions unification] "
|
|
|
|
#endif
|
|
|
|
#if OPT_INLINE_METHOD_CACHE
|
|
|
|
"[inline method cache] "
|
|
|
|
#endif
|
|
|
|
#if OPT_BLOCKINLINING
|
|
|
|
"[block inlining] "
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
* 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-06 20:25:05 -05:00
|
|
|
void yarv_init_redefined_flag(void);
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
void
|
2007-02-05 07:21:01 -05:00
|
|
|
Init_VM(void)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
2007-01-17 03:48:52 -05:00
|
|
|
/* ::VM */
|
|
|
|
rb_cVM = rb_define_class("VM", rb_cObject);
|
|
|
|
rb_undef_alloc_func(rb_cVM);
|
* 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 14:00:03 -05:00
|
|
|
|
|
|
|
/* Env */
|
|
|
|
rb_cEnv = rb_define_class_under(rb_cVM, "Env", rb_cObject);
|
|
|
|
rb_undef_alloc_func(rb_cEnv);
|
|
|
|
|
2007-02-05 07:21:01 -05:00
|
|
|
/* ::Thread */
|
|
|
|
rb_cThread = rb_define_class("Thread", rb_cObject);
|
|
|
|
rb_undef_alloc_func(rb_cThread);
|
|
|
|
rb_define_method(rb_cThread, "initialize", thread_init, 0);
|
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
/* ::VM::USAGE_ANALISYS_* */
|
|
|
|
rb_define_const(rb_cVM, "USAGE_ANALISYS_INSN", rb_hash_new());
|
|
|
|
rb_define_const(rb_cVM, "USAGE_ANALISYS_REGS", rb_hash_new());
|
|
|
|
rb_define_const(rb_cVM, "USAGE_ANALISYS_INSN_BIGRAM", rb_hash_new());
|
|
|
|
rb_define_const(rb_cVM, "OPTS", rb_str_new2(yarv_options));
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
/* ::VM::InsnNameArray */
|
|
|
|
rb_define_const(rb_cVM, "InsnNameArray", insns_name_array());
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
/* ::VM::eval() */
|
|
|
|
rb_define_singleton_method(rb_cVM, "eval", yarvcore_eval, 3);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2007-02-05 07:21:01 -05:00
|
|
|
/* debug functions ::VM::SDR(), ::VM::NSDR() */
|
2007-01-17 03:48:52 -05:00
|
|
|
rb_define_singleton_method(rb_cVM, "SDR", sdr, 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-06 20:25:05 -05:00
|
|
|
rb_define_singleton_method(rb_cVM, "NSDR", nsdr, 0);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
/* Symbols */
|
2006-12-31 10:02:22 -05:00
|
|
|
symIFUNC = ID2SYM(rb_intern("<IFUNC>"));
|
|
|
|
symCFUNC = ID2SYM(rb_intern("<CFUNC>"));
|
|
|
|
|
2007-01-17 03:48:52 -05:00
|
|
|
/* IDs */
|
2006-12-31 10:02:22 -05:00
|
|
|
idPLUS = rb_intern("+");
|
|
|
|
idMINUS = rb_intern("-");
|
|
|
|
idMULT = rb_intern("*");
|
|
|
|
idDIV = rb_intern("/");
|
|
|
|
idMOD = rb_intern("%");
|
|
|
|
idLT = rb_intern("<");
|
|
|
|
idLTLT = rb_intern("<<");
|
|
|
|
idLE = rb_intern("<=");
|
|
|
|
idEq = rb_intern("==");
|
|
|
|
idEqq = rb_intern("===");
|
|
|
|
idBackquote = rb_intern("`");
|
|
|
|
idEqTilde = rb_intern("=~");
|
|
|
|
|
|
|
|
idAREF = rb_intern("[]");
|
|
|
|
idASET = rb_intern("[]=");
|
|
|
|
|
|
|
|
idEach = rb_intern("each");
|
|
|
|
idTimes = rb_intern("times");
|
|
|
|
idLength = rb_intern("length");
|
|
|
|
idLambda = rb_intern("lambda");
|
|
|
|
idIntern = rb_intern("intern");
|
|
|
|
idGets = rb_intern("gets");
|
|
|
|
idSucc = rb_intern("succ");
|
|
|
|
idEnd = rb_intern("end");
|
|
|
|
idRangeEachLT = rb_intern("Range#each#LT");
|
|
|
|
idRangeEachLE = rb_intern("Range#each#LE");
|
|
|
|
idArrayEach = rb_intern("Array#each");
|
|
|
|
idMethodMissing = rb_intern("method_missing");
|
|
|
|
|
|
|
|
idThrowState = rb_intern("#__ThrowState__");
|
|
|
|
|
|
|
|
idBitblt = rb_intern("bitblt");
|
|
|
|
idAnswer = rb_intern("the_answer_to_life_the_universe_and_everything");
|
|
|
|
idSvarPlaceholder = rb_intern("#svar");
|
|
|
|
|
2007-01-05 19:24:59 -05:00
|
|
|
idSend = rb_intern("send");
|
|
|
|
id__send__ = rb_intern("__send__");
|
|
|
|
id__send = rb_intern("__send");
|
|
|
|
idFuncall = rb_intern("funcall");
|
|
|
|
id__send_bang = rb_intern("__send!");
|
|
|
|
|
2007-02-05 07:21:01 -05:00
|
|
|
/* VM bootstrap: phase 2 */
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
/* create vm object */
|
2007-01-17 03:48:52 -05:00
|
|
|
VALUE vmval = vm_alloc(rb_cVM);
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE thval;
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vm;
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th;
|
2007-02-13 21:19:02 -05:00
|
|
|
|
2007-02-26 17:51:33 -05:00
|
|
|
vm = ruby_current_vm;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
xfree(RDATA(vmval)->data);
|
|
|
|
RDATA(vmval)->data = vm;
|
|
|
|
vm->self = vmval;
|
|
|
|
|
|
|
|
/* create main 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 14:00:03 -05:00
|
|
|
thval = rb_thread_alloc(rb_cThread);
|
2006-12-31 10:02:22 -05:00
|
|
|
GetThreadPtr(thval, th);
|
|
|
|
|
|
|
|
vm->main_thread = th;
|
|
|
|
vm->running_thread = th;
|
|
|
|
GET_THREAD()->vm = vm;
|
|
|
|
thread_free(GET_THREAD());
|
|
|
|
th->vm = vm;
|
* 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 14:00:03 -05:00
|
|
|
rb_thread_set_current(th);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
th->machine_stack_start = rb_gc_stack_start;
|
|
|
|
vm->living_threads = st_init_numtable();
|
|
|
|
st_insert(vm->living_threads, th->self, (st_data_t) th->thread_id);
|
|
|
|
}
|
|
|
|
yarv_init_redefined_flag();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Init_yarv(void)
|
|
|
|
{
|
2007-01-17 03:48:52 -05:00
|
|
|
/* VM bootstrap: phase 1 */
|
* 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 14:00:03 -05:00
|
|
|
rb_vm_t *vm = ALLOC(rb_vm_t);
|
* 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 01:37:46 -05:00
|
|
|
rb_thread_t *th = ALLOC(rb_thread_t);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
vm_init2(vm);
|
2007-02-26 17:51:33 -05:00
|
|
|
ruby_current_vm = vm;
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
th_init2(th);
|
|
|
|
th->vm = vm;
|
|
|
|
th->machine_stack_start = rb_gc_stack_start;
|
* 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 14:00:03 -05:00
|
|
|
rb_thread_set_current_raw(th);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
2007-02-05 07:21:01 -05:00
|
|
|
|