--- gforth/prims2x.fs 2001/02/27 10:30:02 1.85 +++ gforth/prims2x.fs 2001/02/27 21:17:10 1.86 @@ -585,8 +585,15 @@ s" IP" save-mem w s" error don't use # o : stores ( -- ) prim prim-effect-out prim prim-effect-out-end @ ['] store map-items ; +: output-super-end ( -- ) + prim prim-c-code 2@ s" SET_IP" search if + ." SUPER_END;" cr + endif + 2drop ; + : output-c-tail ( -- ) \ the final part of the generated C code + output-super-end ." NEXT_P1;" cr stores fill-tos @@ -661,6 +668,17 @@ s" IP" save-mem w s" error don't use # o ." ip += " inst-stream stack-in @ 1+ 0 .r ." ;" cr ." } else " ; +: output-profile ( -- ) + \ generate code for postprocessing the VM block profile stuff + ." if (*ip == VM_INST(" function-number @ 0 .r ." )) {" cr + ." add_inst(b, " quote prim prim-name 2@ type quote ." );" cr + ." ip += " inst-stream stack-in @ 1+ 0 .r ." ;" cr + prim prim-c-code 2@ s" SET_IP" search nip nip + prim prim-c-code 2@ s" SUPER_END" search nip nip or if + ." return;" cr + endif + ." } else " cr ; + : gen-arg-parm { item -- } item item-stack @ inst-stream = if ." , " item item-type @ type-c-name 2@ type space @@ -901,6 +919,8 @@ s" IP" save-mem w s" error don't use # o : process-combined ( -- ) combined combined-prims num-combined @ cells combinations ['] constant insert-wordlist + combined-prims num-combined @ 1- th ( last-part ) + @ prim-c-code 2@ prim prim-c-code 2! \ used by output-super-end prim compute-effects prim init-effects output-combined perform ;