Menu

#2 Simplify .catch directive

open
nobody
None
5
2009-10-23
2009-10-23
Alexei
No

The current format of the .catch directive uses 3 labels:
.catch <classname> from <offset1> to <offset2> using <offset3>

The proposal is to allow omit one or even two offsets omitted, using the position of the directive as a label.
Thus, following code

first:
...
second:
catch java/lang/IncompatibleClassChangeError from first to second using catcher
catcher:
ireturn

can be compacted to:

first:
...
second:
catch java/lang/IncompatibleClassChangeError from first to second
ireturn

and even to:

first:
catch java/lang/IncompatibleClassChangeError from first
ireturn

Alternative style with .catch at the start of the quarded region can also be expressed:

catch java/lang/IncompatibleClassChangeError from first to second using catcher
first:
...
second:
catcher:
ireturn

can be compacted to:

catch java/lang/IncompatibleClassChangeError second using catcher
...
second:
catcher:
ireturn

and even to:

catch java/lang/IncompatibleClassChangeError using catcher
,,,
catcher:
ireturn

So the rule is:
if one offset is omitted, then it is taken from the offset of the directive
if offset2 and offset3 are omitted, then offset2=offset2=offset of the directive
if offset1 and offset2 are omitted, then offset1=offset of the directive and offset2=offset3
Both offset1 and offset3 cannot be omitted.

Discussion


Log in to post a comment.