Re: [Question] Could the max code size check be optional?
"Eugene Kuleshov" (via asm Mailing List) <[email protected]> Wed, 17 Mar 2021 16:02:43 -0400
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CADFjdoWfO2+e0Mmg+dJBNUg5xONamyrDVocXeU+zrGmgRDWrqQ@mail.gmail.com> |
This is a multi-part message in MIME format... ------------=_1616011379-16935-23 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hmm... I thought there was an Analyzer somewhere that could calculate these max values or if your transformation is built on top of the LocalVariableSorter that could also do the update of the max values. regards, Eugene On Wed, Mar 17, 2021 at 2:27 PM Manuel Carrasco <[email protected]> wrote: >> >> It is possible, you would just have to write it yourself - or it could p= erhaps be included in asm-commons. A similar thing already exists (Analyzer= Adapter) but I think it only works with bytecode that has updated stackfram= es - I assume if you are not updating the maxLocals and maxStack you are al= so not updating frames. > > > Thanks x4e. > > Yes, you're correct I'm not creating/updating the frames. I'm creating ja= va bytecode from scratch. > >> If your pipeline has some optimizer in the middle, perhaps you can >> write your generated bytecode into a MethodNode first, then run your >> optimizer over a MethodNode and only then send it to the MethodWriter > > > Thanks Eugene. > > Yes, this is the case. However, my optimization requires a MethodNode whi= ch has its max local/stack and stack map frames computed. Basically, becaus= e I'm using a SourceInterpreter to compute SourceValues: > >> Analyzer<SourceValue> analyzer =3D new Analyzer<>(new SourceInterpreter(= )); > > > I've noticed that in order to execute, it requires the MethodNode to have= at least the max local/stack correctly set. That's why I tried to work aro= und it by calling the MethodWriter in the middle. > > Cheers, > Manuel. > > El mi=C3=A9, 17 mar 2021 a las 14:53, Eugene Kuleshov (<[email protected]= om>) escribi=C3=B3: >> >> Manuel, >> >> If your pipeline has some optimizer in the middle, perhaps you can >> write your generated bytecode into a MethodNode first, then run your >> optimizer over a MethodNode and only then send it to the MethodWriter >> >> regards, >> Eugene >> >> >> On Wed, Mar 17, 2021 at 7:10 AM Manuel Carrasco <[email protected]> wrote: >> > >> > Hi, >> > >> > How are you? >> > >> > I noticed that the MethodWriter currently (184aaa9f0ec4c233872087a3c4d= 2d96a3c204ac6) throws an exception when the method size exceeds the maximum= allowed by the JVM. The intent is clear to me, the library wants to emit J= ava bytecode that is legal in terms of the specification. My question is, c= ould we make this check optional and true by default? >> > >> > In case that you want to perform an optimization to shrink your code, = you may require to have the max stack and local as well as the stack map fr= ames available. So, you execute the ClassWriter to compute them, but it wil= l crash as soon the MethodWriter verifies the maximum code size. >> > >> > The current implementation is limiting user optimizations on their cod= e in case it has already exceeded the maximum limit. At least, it is not al= lowing them to compute the max stack and local as well as the map stack fra= mes. >> > >> > I tested commenting the check and emitting the code. It didn't crash, = and I could optimize it, so it can be executed by the JVM. >> > >> > Considering all this, I'd like to know if you consider reasonable to m= ake the max code size check optional. Perhaps, I'm missing some other techn= ical reason that could make this impossible. >> > >> > Thanks in advance! >> > >> > Cheers, >> > Manuel. >> > >> > >> > -- >> > You receive this message as a subscriber of the [email protected] mailing li= st. >> > To unsubscribe: mailto:[email protected] >> > For general help: mailto:[email protected]?subject=3Dhelp >> > OW2 mailing lists service home page: http://www.ow2.org/wws > > > -- > 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 ------------=_1616011379-16935-23 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 ------------=_1616011379-16935-23--