Lucas Dixon wrote:
Some answers to my own questions...
saves only 1MB, despite the fact that I have many deeply nested functors in my code. Changing the max inline depth also seems to have pretty much no change on the size of generated code.... so now I still wonder how I got 20MB of compiled code, but at least its not 200 :)
I'd be interested to know why this is so large, and whether this is really code or some other data.
I'm surprised that shareCommonData was so effective as I had almost only functions... does shareCommonData share functions that are the same? (David: I think I remember you telling me it did not - but I can't remember why...?)
No, it doesn't. The reason is that, on the i386 at least, code segments contain PC-relative calls and jumps. That means that two pieces of code that look the same may well be calling different functions and so can't be merged and equally two pieces that actually call the same function wouldn't appear to be the same.
I was thinking about calling PolyML.shareCommonData on every defined value - would this do more than on PolyML.rootFunction ? or does polyml already ignore unused functions?
PolyML.shareCommonData detects any sharing between values that are reachable from its argument. PolyML.rootFunction is the function that is called when Poly/ML starts up and includes references to the global name space. So calling PolyML.shareCommonData PolyML.rootFunction will detect all the possible sharing within declarations you have made. Crucially, it detects sharing within the data structures the compiler uses to represent type-information so it reduces the space needed to store information about structures, signatures and functors.
Calling PolyML.shareCommonData again on particular values won't help. If something is completely unreachable then it will be thrown away by the garbage-collector.
What happens to exceptions which are raise after PolyML.Compiler.forgetXXX where the exception would normally contain type-names ? are they also forgotten?
it appears that the data associated with exceptions is simply not printed.
Exception packets contain an identifier for the exception and the name of the exception but do not otherwise contain any type information. When an exception is raised the printing mechanism searches in the global name-space to see if the exception has been declared there or in a global structure. If it finds a matching identifier it uses the type-information to print the arguments to the exception otherwise it just prints the name.
Regards, David