Yao Qi wrote:
>
> top--> +--------+
> | long |
long is two entries. This is the real problem, as swap wont work as
intended. (Not a popular piece of byte code design, but presumably a bit
easier for interpreters on 32-bit systems.)
> +--------+
> | Object |
> +--------+
> | ... |
>
> we want to transform this stack layout to this, shown as follows,
>
>
> top--> +--------+
> | Object |
> +--------+
> | long |
> +--------+
> | Object |
> +--------+
> | Object |
> +--------+
> | ... |
So you have
...., C, B, A
where A and B are the long and C the reference, and you want
...., C, C, B, A, C
The trick is to use dup_x and then discard unwanted values.
So
...., C, B, A
dup2_x1
...., B, A, C, B, A
pop2
...., B, A, C
dup_x2
...., C, B, A, C
dup_x2
...., C, C, B, A, C
I think. (And make sure you set the max frame size appropriately.)
If you are writing code from scratch, then local variables are very
useful. Probably not so convenient for instrumentation.
Tom Hawtin


|