Java and inlining

Discussion in 'Java' started by Aaron Fude, Dec 17, 2004.

  1. Aaron Fude

    Aaron Fude Guest

    Hi,

    Is there a good article to read about the inlining of functions in Java. For
    example, how inefficient would it be to write double sum(double x) { return
    Math.sin(x) + Math.cos(x); }

    Thanks!

    Aaron Fude
    Aaron Fude, Dec 17, 2004
    #1
    1. Advertising

  2. Aaron Fude

    Chris Smith Guest

    Aaron Fude <> wrote:
    > Is there a good article to read about the inlining of functions in Java. For
    > example, how inefficient would it be to write double sum(double x) { return
    > Math.sin(x) + Math.cos(x); }


    I don't know of a good article to read. In practice, I wouldn't worry
    about it. If your code is performing poorly, there are certainly bigger
    concerns. A profiler will tell you more.

    If you're just curious, though, then read on. My comments from here on
    apply to the Sun JVM for various platforms; other virtual machines --
    and especially those on small J2ME platforms such as mobile phones --
    may differ considerably. Inlining is performed by the JIT compiler at
    runtime, and can be applied very widely in modern virtual machines.
    Inlining will be most widely applied to methods that are declared as
    private, static, or final, or are in final classes. However,
    conditional inlining is also performed on polymorphics methods when
    possible. The latter optimization is one of the benefits of adaptive
    optimizations like the JVM does over static optimization of other
    languages.

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Dec 17, 2004
    #2
    1. Advertising

  3. Aaron Fude

    Aaron Fude Guest

    "Chris Smith" <> wrote in message
    news:...
    > Aaron Fude <> wrote:
    >> Is there a good article to read about the inlining of functions in Java.
    >> For
    >> example, how inefficient would it be to write double sum(double x) {
    >> return
    >> Math.sin(x) + Math.cos(x); }

    >
    > I don't know of a good article to read. In practice, I wouldn't worry
    > about it. If your code is performing poorly, there are certainly bigger
    > concerns. A profiler will tell you more.
    >
    > If you're just curious, though, then read on. My comments from here on
    > apply to the Sun JVM for various platforms; other virtual machines --
    > and especially those on small J2ME platforms such as mobile phones --
    > may differ considerably. Inlining is performed by the JIT compiler at
    > runtime, and can be applied very widely in modern virtual machines.
    > Inlining will be most widely applied to methods that are declared as
    > private, static, or final, or are in final classes. However,
    > conditional inlining is also performed on polymorphics methods when
    > possible. The latter optimization is one of the benefits of adaptive
    > optimizations like the JVM does over static optimization of other
    > languages.
    >
    > --
    > www.designacourse.com
    > The Easiest Way To Train Anyone... Anywhere.
    >
    > Chris Smith - Lead Software Developer/Technical Trainer
    > MindIQ Corporation


    Actually, thowing in "final" speeded up the code tremendously.
    Interesting... I also used to think that "final" makes little difference,
    but the difference turned out to be tremendous is this case!
    Aaron Fude, Dec 17, 2004
    #3
  4. Aaron Fude

    Skip Guest

    > Actually, thowing in "final" speeded up the code tremendously.
    > Interesting... I also used to think that "final" makes little difference,
    > but the difference turned out to be tremendous is this case!


    Which VM? On the most recent VMs (Suns 1.4 / 1.5) it shouldn't really
    matter.
    Skip, Dec 17, 2004
    #4
  5. Aaron Fude

    Aaron Fude Guest

    "Skip" <> wrote in message
    news:41c367d2$0$775$...
    >> Actually, thowing in "final" speeded up the code tremendously.
    >> Interesting... I also used to think that "final" makes little difference,
    >> but the difference turned out to be tremendous is this case!

    >
    > Which VM? On the most recent VMs (Suns 1.4 / 1.5) it shouldn't really
    > matter.
    >
    >


    1.4.2
    Aaron Fude, Dec 18, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ronald Fischer
    Replies:
    3
    Views:
    564
    Roedy Green
    Jul 20, 2004
  2. David Rubin
    Replies:
    8
    Views:
    486
    David Rubin
    Jan 15, 2004
  3. Mat Booth

    Function Pointers and Inlining

    Mat Booth, Mar 22, 2005, in forum: C++
    Replies:
    8
    Views:
    359
    Rolf Magnus
    Mar 22, 2005
  4. jimmy
    Replies:
    3
    Views:
    381
    John Carson
    May 17, 2005
  5. Replies:
    5
    Views:
    454
Loading...

Share This Page