[Ups-cvs] ups/ups ci_compile_expr.c,1.2,1.3
Brought to you by:
ianedwards
From: Tom H. <th...@us...> - 2005-03-15 15:43:25
|
Update of /cvsroot/ups/ups/ups In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31491 Modified Files: ci_compile_expr.c Log Message: Round to the size of a stack word when working out how much stack space is needed instead of assuming the stack uses four byte words. Also use CALL_L instead of CALL_B for direct calls so we can cope with returning more than 255 bytes. Index: ci_compile_expr.c =================================================================== RCS file: /cvsroot/ups/ups/ups/ci_compile_expr.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ci_compile_expr.c 25 Feb 2005 10:31:02 -0000 1.2 --- ci_compile_expr.c 15 Mar 2005 15:43:15 -0000 1.3 *************** *** 887,891 **** /* DUBIOUS: we round the type size up to a multiple ! * of four (the size of a stack slot). * This means we copy some extra bytes. * If we had memory protection at byte rather --- 887,891 ---- /* DUBIOUS: we round the type size up to a multiple ! * of four or eight (the size of a stack slot). * This means we copy some extra bytes. * If we had memory protection at byte rather *************** *** 893,903 **** */ nbytes = ci_typesize(expr->ex_lexinfo, type); ! if ((nbytes % 4) != 0) ! nbytes += 4 - nbytes % 4; if (expr->ex_exprtype == ET_FUNC_CALL) { ci_code_opcode(tx, OC_RESERVE_BYTES); ci_code_long(tx, nbytes); ! tx->tx_sp += nbytes + 4; ci_compile_expression(tx, expr, EC_ADDRESS); ci_code_opcode(tx, OC_POP); /* lose address */ --- 893,903 ---- */ nbytes = ci_typesize(expr->ex_lexinfo, type); ! if ((nbytes % sizeof(stackword_t)) != 0) ! nbytes += sizeof(stackword_t) - nbytes % sizeof(stackword_t); if (expr->ex_exprtype == ET_FUNC_CALL) { ci_code_opcode(tx, OC_RESERVE_BYTES); ci_code_long(tx, nbytes); ! tx->tx_sp += nbytes + sizeof(stackword_t); ci_compile_expression(tx, expr, EC_ADDRESS); ci_code_opcode(tx, OC_POP); /* lose address */ *************** *** 914,920 **** ci_code_long(tx, nbytes); ! tx->tx_sp += nbytes - 4; } ! excess_slots += nbytes / 4 - 1; } else { --- 914,920 ---- ci_code_long(tx, nbytes); ! tx->tx_sp += nbytes - sizeof(stackword_t); } ! excess_slots += nbytes / sizeof(stackword_t) - 1; } else { *************** *** 963,973 **** ci_panic("args botch in cfc"); ! if (is_direct_call) ! ci_code_generic_opcode(tx, OC_CALL_B, (stackword_t)func_index); else { ci_compile_expression(tx, fce->fce_func, EC_VALUE); ci_code_opcode(tx, OC_CALL_INDIRECT); } - ci_code_byte(tx, nargs + excess_slots); #if WANT_TYPE_PUSHED --- 963,975 ---- ci_panic("args botch in cfc"); ! if (is_direct_call) { ! ci_code_generic_opcode(tx, OC_CALL_L, (stackword_t)func_index); ! ci_code_long(tx, nargs + excess_slots); ! } else { ci_compile_expression(tx, fce->fce_func, EC_VALUE); ci_code_opcode(tx, OC_CALL_INDIRECT); + ci_code_byte(tx, nargs + excess_slots); } #if WANT_TYPE_PUSHED |