Track whether local variables are initialized in the compiler. #223
Replies: 3 comments 4 replies
-
What if (We might have to do something like not using quickened code if a frame has ever been traced, but that doesn't seem too bad.)
Eh, we could stick these in a list on the frame somewhere and have it cleared when the frame exits, if we decided to go this route. It seems a bit heavy, but I personally view memory leaks as serious bugs (second only to interpreter crashes and incorrect behavior). |
Beta Was this translation helpful? Give feedback.
-
Specializing won't help either as a callee could turn on tracing. |
Beta Was this translation helpful? Give feedback.
-
To solve the debugging issues, if tracing/debuggers are enabled (or when a local is set) we could go through and swap all these opcodes to regular |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a simple dataflow analysis. For each load or store of a local variable we can track if the variable is initialized.
We can then use that information to specialize
LOAD_FAST
andSTORE_FAST
accordingly.Consider
x = y
. The compiler can (in most cases) determine whetherx
andy
are initialized.Suppose we have two new instructions.
LOAD_EVEN_FASTER
andSTORE_EVEN_FASTER
which do not check for NULLness (feel free to mentally substitute more sensible names).LOAD_EVEN_FASTER
assumes that the variable is not NULL, so can avoid the NULL check.STORE_EVEN_FASTER
assumes that the variable is NULL, so avoids the read and the NULL check.E.g.
would be compiled as:
We might also want
CLEAR_THEN_STORE_FAST
for when we are storing to a local that we know to be non NULL.One problem is that a debugger can potentially set or delete variables.
None
STORE_EVEN_FASTER
would not decrement its reference. I can think of no reliable way to avoid a memory leak here, but I think that a very rare refleak in the debugger is probably worth it.Beta Was this translation helpful? Give feedback.
All reactions