Re: AdviceAdapter extends LocalVariablesSorter

"Eugene Kuleshov" (via asm Mailing List) <[email protected]> Thu, 18 Feb 2021 10:51:48 -0500
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CADFjdoWPeyGM7TjOp6+arqktZ_qOQ7My5e3Az=txjcKQ_Mayfw@mail.gmail.com>
This is a multi-part message in MIME format...

------------=_1613663523-2761-10
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Eirik,

  Great stuff.
  I haven't looked at your changes yet and it has been about a decade
since I touched that code. :)

  Some history. I might be the one responsible for AdviceAdapter back then.
  It was based on the AOSD'07 talk:
  http://modularity.info/conference/2007/program/industry/I5-UsingASMFramew=
ork.pdf

  The thought was that transformations you'd need to implement in the
AdviceAdapter will likely
require to introduce local variable slots anyways. So, it was
extending the variable sorter to
inherit that capability.
  A basic example would be an around-like advice that implements something =
like:

long start =3D System.nanoTime();
try {
   ... method body
} finally {
  System.err.println("method name " + (System.nanoTime() - start));
}

  Not sure if something like that is covered by any tests now

  regards,
  Eugene



On Thu, Feb 18, 2021 at 9:57 AM Eirik Bj=C3=B8rsn=C3=B8s <[email protected]> wrot=
e:
>>
>> Alternatively, could the bulk of the AdviceAdapter logic be extracted in=
to a reusable class which could be reused from alternative adapter classes =
which do not extend LVS?
>
>
> I did an experiment to see if I could untangle the goodness of AdviceAdap=
ter from GeneralAdapter/LVS inheritance chain:
>
> https://gitlab.ow2.org/eirbjo/asm/-/commit/8c5f53e3ac321b24c8c5d401fa7468=
826b380808
>
> The main idea is to do the following:
>
> 1) Copy AdviceAdapter to a new class AdviceVisitor
> 2) Update AdviceVisitor to extend MethodVisitor (instead of GeneralAdapte=
r)
> 3) Remove all existing methods from AdviceAdapter (except the abstract on=
MethodEnter/onMethodExit)
> 4) In the AdviceAdapter constructor, inject an AdviceBridge into the dele=
gation chain.
> 5) Let the AdviceBrige chain forward onMethodEnter/onMethodExit calls fro=
m AdviceVisitor -> AdviceAdapter.
>
> This has the effect of introducing a compressed-frame compatible AdviceVi=
sitor while keeping the AdviceAdapter class binary compatible.
>
> All ASM tests pass, so existing AdviceAdapter behaviour seems to be prese=
rved.
>
> Here's the updated AdviceAdapter class:
>
> https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa746882=
6b380808/asm-commons/src/main/java/org/objectweb/asm/commons/AdviceAdapter.=
java
>
> And here's the new AdviceVisitor class:
>
> https://gitlab.ow2.org/eirbjo/asm/-/blob/8c5f53e3ac321b24c8c5d401fa746882=
6b380808/asm-commons/src/main/java/org/objectweb/asm/commons/AdviceVisitor.=
java
>
> Eirik.
>
>
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=3Dhelp
> OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1613663523-2761-10
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1613663523-2761-10--