<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">There are a number of FIXME
comments in the code that remind us that we haven't made a
decision of what to do about dead labels, which are labels that
are not assigned a point in the element stream. <br>
<br>
Sometimes a dead label is an outright error, such as:<br>
<br>
.withCode(b -> { Label lab = Label.of();<br>
b.branch(GOTO, lab);<br>
});<br>
<br>
You can't jump to a location that is not defined. But sometimes
a label can get accidentally snipped out, and yet still show up
in LVT, LVTT, or the exception table. For example, suppose we
have some code:<br>
<br>
start();<br>
try { // X<br>
int x;<br>
<br>
blah();<br>
} // Y<br>
catch (FooException f) { <br>
// Z<br>
blahblah(); <br>
// W<br>
}<br>
// Q<br>
end();<br>
moo();<br>
<br>
When we traverse this, we will get something like:<br>
<br>
exceptionCatch(X, Y, Z, W, FooException)<br>
</font></font><font size="4"><font face="monospace"><font size="4"><font face="monospace"><font size="4"><font face="monospace">
local("x", X, Y)<br>
</font></font></font></font> invoke start<br>
label(X)<br>
invoke blah<br>
label(y)<br>
goto Q<br>
label(Z)<br>
invoke blahblah <br>
label(W)<br>
label(Q)<br>
invoke end<br>
invoke moo<br>
<br>
If the user decides to transform this such that anything between
"begin" and "end" are removed, we could get this stream:<br>
<br>
</font></font><font size="4"><font face="monospace"><font size="4"><font face="monospace"><font size="4"><font face="monospace">
exceptionCatch(X, Y, Z, W, FooException)<br>
</font></font><font size="4"><font face="monospace"><font size="4"><font face="monospace"><font size="4"><font face="monospace">
</font></font></font></font></font></font>
local("x", X, Y)<br>
invoke start<br>
invoke end<br>
invoke moo<br>
</font></font><br>
and the labels in the exception table / local metadata are
dead. This really isn't the user's fault, especially as we send
the metadata up front. (One reason for this is that early
rounds sending it in order had a measurable performance cost; we
should re-measure that. But also, its not always obvious that
there is a "right" time, or that it would be immune to such
transforms.) <br>
<br>
Separate from whether we should try to reorder the elements to
reduce the error surface, we have two choices for how to deal
with dead labels in metadata:<br>
<br>
- try to sanitize the metadata. If we find an exception table
/ LVT / LVTT entry with dead labels, just drop it, and write the
class out. <br>
- fail fast. If we find an entry with data labels, throw. <br>
<br>
(I am hoping that there is a reasonable answer that is not "make
it an option to do either.")<br>
<br>
<br>
<br>
<br>
</font></font>
</body>
</html>