From: Armin R. <ar...@us...> - 2003-09-03 19:58:01
|
Update of /cvsroot/psyco/psyco/c/Python In directory sc8-pr-cvs1:/tmp/cvs-serv20170/c/Python Modified Files: frames.c frames.h pycompiler.c pycompiler.h pyver.h Log Message: the virtual machine is up and running! Index: frames.c =================================================================== RCS file: /cvsroot/psyco/psyco/c/Python/frames.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** frames.c 18 May 2003 22:26:47 -0000 1.8 --- frames.c 3 Sep 2003 19:57:57 -0000 1.9 *************** *** 53,57 **** po->stack_depth = INITIAL_STACK_DEPTH; po->vlocals.count = INDEX_LOC_LOCALS_PLUS + extras; ! po->last_used_reg = REG_LOOP_START; po->pr.auto_recursion = AUTO_RECURSION(recursion); --- 53,57 ---- po->stack_depth = INITIAL_STACK_DEPTH; po->vlocals.count = INDEX_LOC_LOCALS_PLUS + extras; ! INIT_PROCESSOR_PSYCOOBJECT(po); po->pr.auto_recursion = AUTO_RECURSION(recursion); *************** *** 75,80 **** free vars */ /* arguments get borrowed references */ ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); v = vinfo_new(rsrc); } --- 75,79 ---- free vars */ /* arguments get borrowed references */ ! rsrc = RunTime_NewStack(po->stack_depth, false, false); v = vinfo_new(rsrc); } *************** *** 97,102 **** /* set up the CALL return address */ po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); LOC_CONTINUATION = vinfo_new(rsrc); psyco_assert_coherent(po); --- 96,100 ---- /* set up the CALL return address */ po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, false, false); LOC_CONTINUATION = vinfo_new(rsrc); psyco_assert_coherent(po); *************** *** 134,138 **** po->stack_depth = INITIAL_STACK_DEPTH; po->vlocals.count = INDEX_LOC_LOCALS_PLUS + extras; ! po->last_used_reg = REG_LOOP_START; po->pr.auto_recursion = AUTO_RECURSION(recursion); --- 132,136 ---- po->stack_depth = INITIAL_STACK_DEPTH; po->vlocals.count = INDEX_LOC_LOCALS_PLUS + extras; ! INIT_PROCESSOR_PSYCOOBJECT(po); po->pr.auto_recursion = AUTO_RECURSION(recursion); *************** *** 154,159 **** po->stack_depth += sizeof(long); /* borrowed references from the frame object */ ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); v = vinfo_new(rsrc); LOC_LOCALS_PLUS[--i] = v; --- 152,156 ---- po->stack_depth += sizeof(long); /* borrowed references from the frame object */ ! rsrc = RunTime_NewStack(po->stack_depth, false, false); v = vinfo_new(rsrc); LOC_LOCALS_PLUS[--i] = v; *************** *** 170,175 **** if (co->co_flags & CO_VARKEYWORDS) { po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); v = vinfo_new(rsrc); /* known to be a dict */ --- 167,171 ---- if (co->co_flags & CO_VARKEYWORDS) { po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, false, false); v = vinfo_new(rsrc); /* known to be a dict */ *************** *** 183,188 **** if (co->co_flags & CO_VARARGS) { po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); v = vinfo_new(rsrc); /* known to be a tuple */ --- 179,183 ---- if (co->co_flags & CO_VARARGS) { po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, false, false); v = vinfo_new(rsrc); /* known to be a tuple */ *************** *** 198,203 **** po->stack_depth += sizeof(long); /* arguments get borrowed references */ ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); v = vinfo_new(rsrc); LOC_LOCALS_PLUS[--i] = v; --- 193,197 ---- po->stack_depth += sizeof(long); /* arguments get borrowed references */ ! rsrc = RunTime_NewStack(po->stack_depth, false, false); v = vinfo_new(rsrc); LOC_LOCALS_PLUS[--i] = v; *************** *** 213,218 **** /* set up the CALL return address */ po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, REG_NONE, ! false, false); LOC_CONTINUATION = vinfo_new(rsrc); return (PyObject*) po; --- 207,211 ---- /* set up the CALL return address */ po->stack_depth += sizeof(long); ! rsrc = RunTime_NewStack(po->stack_depth, false, false); LOC_CONTINUATION = vinfo_new(rsrc); return (PyObject*) po; *************** *** 295,299 **** Py_INCREF(codebuf); result = psyco_processor_run((CodeBufferObject*) codebuf, ! initial_stack, &finfo); Py_DECREF(codebuf); psyco_trash_object(NULL); /* free any trashed object now */ --- 288,292 ---- Py_INCREF(codebuf); result = psyco_processor_run((CodeBufferObject*) codebuf, ! initial_stack, &finfo, tdict); Py_DECREF(codebuf); psyco_trash_object(NULL); /* free any trashed object now */ *************** *** 406,410 **** --- 399,405 ---- p = current; current += inlining + 1; + #if NEED_STACK_FRAME_HACK p->link_stack_depth = -inlining; + #endif p->co = callee->pr.co; sglobals = callee->vlocals.items[INDEX_LOC_GLOBALS]->source; *************** *** 527,532 **** --- 522,529 ---- p->next = revlist; revlist = p; + #if NEED_STACK_FRAME_HACK if ((*f1)->link_stack_depth == 0) break; /* stack top is an inline frame */ + #endif } Index: frames.h =================================================================== RCS file: /cvsroot/psyco/psyco/c/Python/frames.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** frames.h 18 May 2003 22:26:47 -0000 1.4 --- frames.h 3 Sep 2003 19:57:57 -0000 1.5 *************** *** 9,12 **** --- 9,13 ---- #include "../psyco.h" #include "../cstruct.h" + #include <idispatcher.h> #include "pyver.h" #include <compile.h> *************** *** 53,67 **** EXTERNFN PyObject* psyco_get_globals(void); ! EXTERNFN PyObject* psyco_get_locals(void); /* this one implemented in psyco.c */ /* to keep a trace of the Psyco stack frames */ struct stack_frame_info_s { int link_stack_depth; /* -1 if there is an inline frame following */ PyCodeObject* co; PyObject* globals; /* NULL if not compile-time */ }; inline stack_frame_info_t* finfo_last(stack_frame_info_t* finfo) { if (finfo->link_stack_depth < 0) finfo -= finfo->link_stack_depth; return finfo; } --- 54,72 ---- EXTERNFN PyObject* psyco_get_globals(void); ! /* PyObject* psyco_get_locals(void); this one implemented in psyco.c */ /* to keep a trace of the Psyco stack frames */ struct stack_frame_info_s { + #if NEED_STACK_FRAME_HACK int link_stack_depth; /* -1 if there is an inline frame following */ + #endif PyCodeObject* co; PyObject* globals; /* NULL if not compile-time */ }; inline stack_frame_info_t* finfo_last(stack_frame_info_t* finfo) { + #if NEED_STACK_FRAME_HACK if (finfo->link_stack_depth < 0) finfo -= finfo->link_stack_depth; + #endif return finfo; } Index: pycompiler.c =================================================================== RCS file: /cvsroot/psyco/psyco/c/Python/pycompiler.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** pycompiler.c 31 Jul 2003 17:13:04 -0000 1.46 --- pycompiler.c 3 Sep 2003 19:57:57 -0000 1.47 *************** *** 5,8 **** --- 5,9 ---- #include "../codemanager.h" #include "../psyfunc.h" + #include "../pycodegen.h" #include "../Objects/pabstract.h" *************** *** 20,24 **** #define KNOWN_VAR(type, varname, loc) \ ! type varname = (type)(KNOWN_SOURCE(loc)->value) #ifdef FOR_ITER --- 21,25 ---- #define KNOWN_VAR(type, varname, loc) \ ! type varname = (type)(CompileTime_Get(loc->source)->value) #ifdef FOR_ITER *************** *** 1055,1060 **** XXX psyco_compile_code() */ ! extra_assert(target != code); ! JUMP_TO(target); /* code a jump from the original code */ Py_DECREF(cg->varname); --- 1056,1061 ---- XXX psyco_compile_code() */ ! /* code a jump from the original code */ ! dictitem_update_jump(code, target); Py_DECREF(cg->varname); *************** *** 1143,1147 **** PsycoObject* po1 = po; changed_global_t* cg; - code_t* macrocode; code_t* newcodelimit; result = ep->me_value; --- 1144,1147 ---- *************** *** 1150,1156 **** a proxy which we prepare now */ onchangebuf = psyco_new_code_buffer(NULL, NULL, &newcodelimit); ! po = dictitem_check_change(po, (code_t*) onchangebuf->codestart, ! globals, ep); ! macrocode = po->code; /* make the new 'po' point to the proxy buffer */ po->code = (code_t*) onchangebuf->codestart; --- 1150,1156 ---- a proxy which we prepare now */ onchangebuf = psyco_new_code_buffer(NULL, NULL, &newcodelimit); ! dictitem_check_change(po, (code_t*) onchangebuf->codestart, ! globals, ep); ! po = PsycoObject_Duplicate(po); /* make the new 'po' point to the proxy buffer */ po->code = (code_t*) onchangebuf->codestart; *************** *** 1163,1167 **** cg->varname = key; Py_INCREF(key); cg->previousvalue = result; Py_INCREF(result); ! cg->originalmacrocode = macrocode; SHRINK_CODE_BUFFER(onchangebuf, (code_t*)(cg+1), "load_global"); --- 1163,1167 ---- cg->varname = key; Py_INCREF(key); cg->previousvalue = result; Py_INCREF(result); ! cg->originalmacrocode = po1->code; SHRINK_CODE_BUFFER(onchangebuf, (code_t*)(cg+1), "load_global"); *************** *** 2100,2103 **** --- 2100,2106 ---- psyco_assert_coherent(po); /* this test is expensive */ + /* are we potentially running out of stack space? */ + CHECK_STACK_SPACE(); + /* save 'next_instr' and 'respawn_cnt' */ SAVE_NEXT_INSTR(next_instr); /* could be optimized, not needed in the *************** *** 3096,3100 **** extra_assert(mp == psyco_next_merge_point(po->pr.merge_points, next_instr)); ! /* are we running out of space in the current code buffer? */ if ((po->codelimit - po->code) < BUFFER_MARGIN) { --- 3099,3103 ---- extra_assert(mp == psyco_next_merge_point(po->pr.merge_points, next_instr)); ! /* are we running out of space in the current code buffer? */ if ((po->codelimit - po->code) < BUFFER_MARGIN) { Index: pycompiler.h =================================================================== RCS file: /cvsroot/psyco/psyco/c/Python/pycompiler.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pycompiler.h 18 May 2003 22:26:47 -0000 1.18 --- pycompiler.h 3 Sep 2003 19:57:57 -0000 1.19 *************** *** 219,224 **** return psyco_vi_One(); } ! else ! return psyco_generic_call(po, PyErr_Occurred, CfReturnNormal, ""); } --- 219,238 ---- return psyco_vi_One(); } ! else { ! /* normal call would be: ! return psyco_generic_call(po, PyErr_Occurred, ! CfReturnNormal, ""); ! but we inline the check done in PyErr_Occurred(). */ ! vinfo_t* vaddr = vinfo_new(CompileTime_New( ! (long)(&_PyThreadState_Current))); ! vinfo_t* vtstate = psyco_memory_read(po, vaddr, 0, ! NULL, 2, false); ! vinfo_decref(vaddr, po); ! vinfo_t* vcurexc = psyco_memory_read(po, vtstate, ! offsetof(PyThreadState, curexc_type), ! NULL, 2, false); ! vinfo_decref(vtstate, po); ! return vcurexc; ! } } Index: pyver.h =================================================================== RCS file: /cvsroot/psyco/psyco/c/Python/pyver.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pyver.h 19 Aug 2003 10:13:01 -0000 1.7 --- pyver.h 3 Sep 2003 19:57:57 -0000 1.8 *************** *** 9,13 **** #include <Python.h> ! #define PSYCO_VERSION_HEX 0x010100f0 /* 1.1 */ #define HAVE_PYTHON_SUPPORT (PY_VERSION_HEX>=0x02020200) /* 2.2.2 */ --- 9,13 ---- #include <Python.h> ! #define PSYCO_VERSION_HEX 0x010200a0 /* 1.2a */ #define HAVE_PYTHON_SUPPORT (PY_VERSION_HEX>=0x02020200) /* 2.2.2 */ |