[armedbear-devel] Understanding JVM code

dmiles@users.sourceforge.net logicmoo at gmail.com
Tue Mar 9 11:22:29 UTC 2010


On Tue, Mar 9, 2010 at 3:17 AM, Mark Evenson <evenson at panix.com> wrote:
>
> On Mar 9, 2010, at 11:56 AM, Alessio Stalla wrote:
> […]
>>> What I don't understand is how the *A* binding is restored at all.  But ABCL executes this code correctly, restoring *A* to the string "initial" after an execution of FOO.  But as you see in the code, the SETF is executed in line 26, then the return value is discarded via pop, then the return value is put on the stack in line 30, and then the method returns via ARETURN.  None of the exception handlers which invoke resetSpecialBindings at the end of the the code (lines 34-39, 40-45) are executed at all.  So how does the special variable get reset?  Is there something happening in the autoloaded that intercepts with a proxy that resets things?
>>
>> Are you sure those are both exception handlers, and there's not a
>> finally block instead? I don't know how those constructs translate to
>> bytecode, but if I had to implement special variables in Java, I would
>> use try-finally to restore them.
>>
>
> Exception handlers are listed in a table (which is in the javap output but I didn't list in the post):
>
>  Exception table:
>   from   to  target type
>    15    34    34   any

 any = finally block

>
> This exception table instructs the JVM that from index 15 to 33 (the "to" is exclusive), on any exception, start executing the code at index 34.  The code from 40-45 isn't executed at all as far as I can tell.  What *would* make sense would be that something was inserting a JSR instruction to the main method with the return set to index 40, but as far as I understand the JVM this isn't possible.

 But yes.. I am used to seeing at least a JSR to call  34

>
> As far as I understand it [finally doesn't have JVM primitives][1] to support it:  its implemented in terms of the exception handlers with JSR and GOTOs to handle the specific cases.

So definately confusing

>
> [1]: http://java.sun.com/docs/books/jvms/second_edition/html/Compiling.doc.html#13789
>
> --
> "A screaming comes across the sky.  It has happened before, but there is nothing to compare to it now."
>
>
>
>
>
> _______________________________________________
> armedbear-devel mailing list
> armedbear-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>




More information about the armedbear-devel mailing list