Closed rgrig closed 12 years ago
@yoff: Any idea? I'd like something that correctly handles any valid bytecode, not just bytecode that looks generated by a compiler. The option we have now is to use the infrastructure in Barista to track how the stack looks at the return point. But, I'd like a simple solution.
@yoff: Any idea? I'd like something that correctly handles any valid bytecode, not just bytecode that looks generated by a compiler. The option we have now is to use the infrastructure in Barista to track how the stack looks at the return point. But, I'd like a simple solution. Does storing the value in a local variable work? i.e. using astore in the beginning and aload just before return?
That should be easier. Thanks!
This is now waiting on https://github.com/rgrig/barista/issues/14
This is now not waiting anymore. :)
Indeed, I saw you got the high level locals in, that is really nice! :-)
I want
x = new A(y)
to be treated by topl essentially the same asx = A.make(y)
. To offer this illusion some trickery is needed while instrumenting the bytecode, because static methods and constructors are compiled to different things. In this example the static method takesy
as an argument and returnsx
. But, the constructor takes two argumentsx
andy
and returns nothing. Right now the instrumentation emits an eventcall
with the value ofy
and an eventreturn
with no value, so the returned value is not accessible. (In fact, it leads to a crash of the checker.)Note: The
call
event does not sendx
on purpose. One reason is that I want to emulate the static method behavior. Another reason, more serious, is thatx
can't be put in an array of objects before it is initialized. (Well, some JVM versions are forgiving, but others do conform to the spec.)How to simulate a
return
that carriesx
? (Note: At the point werereturn
is reachedx
must be initialized, if the input bytecode is valid.) Initiallyx
is in register 0, but there is no guarantee that it still is (although for code generated by normal compilers it probably is). One idea is to push it on the stack in the beginning and then take it of the stack just beforereturn
to build up the event. Alas, there is no guarantee that in the original bytecode the stack is empty whenreturn
is reached.Is there a simple solution to send a
return
event with valuex
?