Part of the advantage of the structs Per is talking about is this: Structs may be passed as arguments and used as locals elementwise, with no allocation on the stack. Think of it as guaranteed escape analysis, or guaranteed unboxing.
-- John On May 28, 2010, at 3:24 AM, Kresten Krab Thorup wrote: > > > On May 27, 1:17 am, Per Bothner <p...@bothner.com> wrote: >> This is another example of where structs would be helpful. That would >> allow: >> >> struct Integer { >> int ivalue; >> int[] iwords; >> >> } > .... >> >> Kawa basically does this using a regular class gnu.math.Integer, >> and "small" Integers pre-allocated. That is one reason Kawa's >> arbitrary-precision handling is (mostly) noticeably faster than BigInteger. >> (Some of that could be achieved by further tweaking BigInteger.) > > 1: I'm intrigued. How much does this give you? > > I can see that you avoid a virtual call for all math operators where > you can determine the integer-ness of operands; so it does not have to > choose between SmallInt and BigInt objects. But it comes at the > overhead of an extra word per integer. > > Integer arithmetic (most notably X+1, X-1, and X==<constant>) used in > loops is currently a noticeable performance issue in Erjang (when > comparing to the normal erlang implementation using tags). In many > such cases, I could avoid a virtual call and that does sound > appealing. > > 2: What is the motivation in Kawa to make your own bignum > implementation. Why not just have > > class KawaInteger { > int ival; > BigInteger bval; > > ... > } > > i.e., fall back on the standard bignum implementation? > > > Kresten > > -- > You received this message because you are subscribed to the Google Groups > "JVM Languages" group. > To post to this group, send email to jvm-langua...@googlegroups.com. > To unsubscribe from this group, send email to > jvm-languages+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/jvm-languages?hl=en. > -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to jvm-langua...@googlegroups.com. To unsubscribe from this group, send email to jvm-languages+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.