I just figured out how I can have better memory management and such for stack and
locals. That would be splitting them up and then counting the maximum number of
kinds of primitive types appear at any given time. So basically for locals and the
stack, they will refer to individual indexes according to their primitive type. So
for example say a method has only a single
long value but the rest are
Instead of just having every single local/stack variable be a union of every type,
which on 64-bit systems would consume 64-bits each, even if not used... it would
instead just consume the minimum needed. I honestly think this would be better.
It would also handle long types and reference types. So basically the translator
would keep track of this and refer to everything by its type instead.
So with regards to the variable code limits that I have in place, I could de-duplicate it within an entire ROM by using some CMake and also preprocessor magic accordingly. Additionally, I want to also de-duplicate method code so that if two methods do happen to be the same and one already exists, then it is considered the same method.
Another optimization I could do for duplicates, is for a given code instead of using the entire class's constant pool I only select indexes that are actually used so that way I do not need to consider unused things... this could lead to more matches.