How many locals?

BlitzMax Forums/BlitzMax Programming/How many locals?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

what's going into the cache (say, the 512k dreamore mentinoed) ? the actual vars, or only a reference to those vars?
It depends. The data cache stores variables (actual data from memory) the instruction cache stores decoded opcodes for expensive operations. You'll rarely actually have 512K of data cache available at any given time. Also note that a value stored in the cache will take up more space than a value stored in memory.

e.g. does a local array of 2*512*512 bytes cost me 512k or 4 bytes?
It costs you a lot more. Depending on the cache used it would probably cost you 3 bytes of cache to store a 1 byte value (1 for the value, 2 for the address/association).

It's good to know that 16 registers is about a reasonable minimum.
All local variables are allocated on the stack, thus there is no way to allocate them directly as registers, particularly since this would limit the compilers ability to optimize and rearrange opcodes. Remember, some processors still only have 4 general purpose registers, and the runtime is going to need at least one at any time, which in a best case scenario means that you can have three variables in play at any given time, before you need to switch in and out of registers.