Nicholas Clark wrote: > On Fri, Oct 11, 2002 at 05:01:49PM -0400, Dan Sugalski wrote: > >>At 9:02 PM +0100 10/11/02, Nicholas Clark wrote: >> > >>>I would like to kill all generated variants of all the 3 argument opcodes >>>where both input arguments are constants. They truly are superfluous.
>>Where both operands are ints or nums, I think it's a good idea. I'm >>less sure in the case where there's a PMC or string involved, as >>there may be some assumption of runtime behaviour (in the case of >>constant PMCs that might have some methods overloaded) or strings >>where the compiler is expecting runtime conversion to happen before >>whatever gets done. Ok, we need 2 + 3 args PMC ops becaus of overloading. > I think I agree with this reasoning. I was really thinking of the ints > as being easiest to bump off, providing we can be sure that things will > consistently for bytecode compile on a 32 bit parrot, but run by a 64 > bit parrot (or likewise for different length floating point) By preprocessing ints and nums, we would move overflow/precision issues from the running machine to the compiling machine. But the issue itself would remain. So we could end up with: add_i_ic add_n_nc add_i_i_i add_n_n_n add_i_i_ic add_n_n_nc add_i_ic_i add_n_nc_n where the latter could be tossed, when the assebler/imcc swaps arguments. This saves 6 opcodes for each <add> and <mul> and ~2 opcodes for each <sub>, <div> and <mod>. <sub> with constants could be rewritten to <add>. Saving a total of ~20 ops. Some 2 operand bitwise operations are there some not - there is no consistency - I would remove the to operand bitwise integer ops. > More free speedup. I had this crazier idea - experiment with splitting > every parrot function out into its own object file, and see what happens > with permuting the order of all of them. I have s small shell script (attached), which generates opcode coverage for all PBC files in the parrot tree: total ops 866 ops types 177 op usage stat 540 op-list-all 161 op-list-s So only ~2/3 opcodes are currently used/tested (ops types/op-list-s are ops short names w/o variants). To run the script do: make test cd languages/perl6 make perl6 --test cd - make disassemble ./op-stat > But I think I need a lot of tuits, and a decent way of doing permutations > with genetic algorithms. (I've got access to a fast machine, but it will > have to stop smoking perl5 for the duration). This would keep the machine busy for some time ;-) Interesting idea. > Nicholas Clark leo
#!/bin/sh DIS=disassemble [ -e .op-list1 ] && rm .op-list1 [ -e op-list-all ] && rm op-list-all [ -e op-list-s ] && rm op-list-s find . -name '*.pbc' -fprint /dev/stderr -exec $DIS {} \; | sed -e's/^[[:blank:]]*L[0-9]*://' | \ sed -e's/^[[:blank:]]+//' | cut -d\ -f1 >> .op-list1 sort < .op-list1 | uniq -c | sort -rg > op-list-all sort < .op-list1 | sed -e's/_.*//' | uniq -c | sort -rg > op-list-s echo T=`grep NAME lib/Parrot/OpLib/core.pm | wc -l` S=`grep NAME lib/Parrot/OpLib/core.pm | sort | uniq | wc -l` echo total ops $T echo ops types $S echo op usage stat wc -l op-list* | head -2