From: Armin R. <ar...@us...> - 2003-02-10 17:09:47
|
Update of /cvsroot/psyco/psyco/c In directory sc8-pr-cvs1:/tmp/cvs-serv15455 Modified Files: dispatcher.c mergepoints.c processor.c vcompiler.h Log Message: more bug fixes Index: dispatcher.c =================================================================== RCS file: /cvsroot/psyco/psyco/c/dispatcher.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** dispatcher.c 4 Feb 2003 20:17:24 -0000 1.28 --- dispatcher.c 10 Feb 2003 17:09:33 -0000 1.29 *************** *** 542,546 **** SHRINK_CODE_BUFFER(codebuf, code, "respawned"); /* make sure DETECT_RESPAWN() succeeded */ ! extra_assert(codebuf->snapshot.fz_respawned_from == rs->respawn_from); /* fix the jump to point to 'codebuf->codestart' */ --- 542,546 ---- SHRINK_CODE_BUFFER(codebuf, code, "respawned"); /* make sure DETECT_RESPAWN() succeeded */ ! psyco_assert(codebuf->snapshot.fz_respawned_from == rs->respawn_from); /* fix the jump to point to 'codebuf->codestart' */ *************** *** 1405,1408 **** --- 1405,1409 ---- struct dmove_s { PsycoObject* po; + int original_stack_depth; char* usages; /* buffer: array of vinfo_t*, see ORIGINAL_VINFO() below */ int usages_size; *************** *** 1429,1432 **** --- 1430,1434 ---- /* overwriting the small buffer, start a new (regular) one */ codebuf = psyco_new_code_buffer(NULL, NULL, &dm->code_limit); + codebuf->snapshot.fz_stuff.fz_stack_depth = dm->original_stack_depth; /* the new buffer should be at least as large as the old one */ codesize = code - dm->code_origin; *************** *** 1627,1630 **** --- 1629,1633 ---- dm.po = po; + dm.original_stack_depth = po->stack_depth; dm.code_origin = code; dm.code_limit = po->codelimit == NULL ? code : po->codelimit; *************** *** 1681,1689 **** if (from_tos < REG_TOTAL*sizeof(void*)) { ! char* target = pops + (from_tos / sizeof(void*)); ! if (*target == -1) ! *target = i; else ! *target = -2; } } --- 1684,1692 ---- if (from_tos < REG_TOTAL*sizeof(void*)) { ! char* ptarget = pops + (from_tos / sizeof(void*)); ! if (*ptarget == -1) ! *ptarget = i; else ! *ptarget = -2; } } Index: mergepoints.c =================================================================== RCS file: /cvsroot/psyco/psyco/c/mergepoints.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mergepoints.c 4 Feb 2003 20:17:26 -0000 1.18 --- mergepoints.c 10 Feb 2003 17:09:34 -0000 1.19 *************** *** 4,7 **** --- 4,12 ---- #include "Python/pycinternal.h" + /* set to 1 to compute the detailed control flow + which allows for early variable deletion */ + #define FULL_CONTROL_FLOW 1 + #define DUMP_CONTROL_FLOW 0 + /***************************************************************/ *************** *** 289,303 **** } ! #if 0 ! static void set_exc_handler(struct instrnode_s* nodes, ! struct instrnode_s* target) ! { ! while (nodes < target) ! { ! nodes->next3 = target; ! nodes++; ! } ! } ! #endif /* how many variables fit in the 'int' bitfield of instrnode_s */ --- 294,300 ---- } ! ! /***************************************************************/ ! #if FULL_CONTROL_FLOW /* how many variables fit in the 'int' bitfield of instrnode_s */ *************** *** 342,358 **** } - #if 0 - inline void clear_var_uses(struct instrnode_s* instrnodes, - struct instrnode_s* node) - { - while (node > instrnodes) - { - node--; - node -= node->back; /* skip back argument */ - node->storemask = 0; - } - } - #endif - inline void mark_var_uses(struct instrnode_s* instrnodes, struct instrnode_s* node, --- 339,342 ---- *************** *** 421,443 **** } - #if 0 - inline void propagate_stores(struct instrnode_s* instrnodes, - struct instrnode_s* node) - { - while (node > instrnodes) - { - node--; - node -= node->back; /* skip back argument */ - if (node->opcode == STORE_FAST) - if (node->next1) - { - forward_propagate(node->next1, node->storemask); - if (node->next2) - forward_propagate(node->next2, node->storemask); - } - } - } - #endif - inline void find_unused_vars(struct instrnode_s* instrnodes, struct instrnode_s* node, --- 405,408 ---- *************** *** 483,487 **** } ! #if 0 /* debugging dump */ { --- 448,452 ---- } ! #if DUMP_CONTROL_FLOW /* debugging dump */ { *************** *** 510,513 **** --- 475,482 ---- } + #endif /* FULL_CONTROL_FLOW */ + /***************************************************************/ + + DEFINEFN PyObject* psyco_build_merge_points(PyCodeObject* co) *************** *** 563,570 **** for (btop = iblock; btop--; ) { ! if (i0 >= blockstack[btop].b_handler) ! iblock = btop; /* pop block */ ! else if (blockstack[btop].b_type == SETUP_EXCEPT || ! blockstack[btop].b_type == SETUP_FINALLY) { /* control flow may jump to the b_handler at any time */ instrnodes[i0].next3 = instrnodes + blockstack[btop].b_handler; --- 532,537 ---- for (btop = iblock; btop--; ) { ! if (blockstack[btop].b_type == SETUP_EXCEPT || ! blockstack[btop].b_type == SETUP_FINALLY) { /* control flow may jump to the b_handler at any time */ instrnodes[i0].next3 = instrnodes + blockstack[btop].b_handler; *************** *** 581,585 **** case SETUP_FINALLY: mp_flags |= MP_FLAGS_HAS_FINALLY; break; } - psyco_assert(iblock == 0 || oparg <= blockstack[iblock-1].b_handler); psyco_assert(iblock < CO_MAXBLOCKS); blockstack[iblock].b_type = op; --- 548,551 ---- *************** *** 588,591 **** --- 554,562 ---- break; + case POP_BLOCK: + psyco_assert(iblock > 0); + iblock--; + break; + case BREAK_LOOP: /* break the innermost loop */ *************** *** 596,605 **** } while (blockstack[btop].b_type != SETUP_LOOP && blockstack[btop].b_type != SETUP_FINALLY); ! if (blockstack[btop].b_type == SETUP_LOOP) ! { /* jump to the loop bottom */ ! instrnodes[i0].next3 = instrnodes + blockstack[btop].b_handler; ! } ! else { /* argh, this gets messy */ valid_controlflow = 0; } --- 567,575 ---- } while (blockstack[btop].b_type != SETUP_LOOP && blockstack[btop].b_type != SETUP_FINALLY); ! /* jump to the loop bottom or finally handler */ ! instrnodes[i0].next3 = instrnodes + blockstack[btop].b_handler; ! if (blockstack[btop].b_type != SETUP_LOOP) { /* argh, this gets messy */ + /* because END_FINALLY will then jump to the loop bottom */ valid_controlflow = 0; } *************** *** 619,622 **** --- 589,593 ---- else { /* argh, this gets messy */ + instrnodes[i0].next3 = instrnodes + blockstack[btop].b_handler; valid_controlflow = 0; } *************** *** 624,627 **** --- 595,600 ---- } } + if (iblock != 0) + valid_controlflow = 0; /* ?? */ /* control flow analysis */ *************** *** 724,729 **** --- 697,704 ---- extra_assert(mp - (mergepoint_t*) PyString_AS_STRING(s) == count); mp->bytecode_position = mp_flags; + #if FULL_CONTROL_FLOW if (valid_controlflow) analyse_variables(instrnodes, instrnodes+length, co); + #endif PyMem_FREE(instrnodes); return s; Index: processor.c =================================================================== RCS file: /cvsroot/psyco/psyco/c/processor.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** processor.c 4 Feb 2003 20:17:27 -0000 1.22 --- processor.c 10 Feb 2003 17:09:34 -0000 1.23 *************** *** 2112,2116 **** condition_code_t result; ! if (v1->source == v2->source) goto same_source; --- 2112,2116 ---- condition_code_t result; ! if (vinfo_known_equal(v1, v2)) goto same_source; *************** *** 2118,2122 **** return CC_ERROR; ! if (v1->source == v2->source) { same_source: --- 2118,2122 ---- return CC_ERROR; ! if (vinfo_known_equal(v1, v2)) { same_source: Index: vcompiler.h =================================================================== RCS file: /cvsroot/psyco/psyco/c/vcompiler.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** vcompiler.h 4 Feb 2003 20:17:29 -0000 1.14 --- vcompiler.h 10 Feb 2003 17:09:39 -0000 1.15 *************** *** 304,307 **** --- 304,312 ---- } + inline bool vinfo_known_equal(vinfo_t* v, vinfo_t* w) { + return (v->source == w->source && + (v == w || !is_virtualtime(v->source))); + } + /* sub-array (see also psyco_get_field()&co.) */ inline void vinfo_array_grow(vinfo_t* vi, int ncount) { |