Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 659327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:01:55+00:00 2026-05-13T23:01:55+00:00

Using the stock Sun 1.6 compiler and JRE/JIT, is it a good idea to

  • 0

Using the stock Sun 1.6 compiler and JRE/JIT, is it a good idea to use the sort of extensive unroll exemplified by Duff’s Device to unroll a loop? Or does it end up as code obfuscation with no performance benefit?

The Java profiling tools I’ve used are less informative about line-by-line CPU usage than, say, valgrind, so I was looking to augment measurement with other people’s experience.

Note that, of course, you can’t exactly code Duff’s Device, but you can do the basic unroll, and that’s what I’m wondering about.

        short stateType = data.getShort(ptr);
        switch (stateType) {

        case SEARCH_TYPE_DISPATCH + 16:
            if (c > data.getChar(ptr + (3 << 16) - 4)) {
                ptr += 3 << 16;
            }
        case SEARCH_TYPE_DISPATCH + 15:
            if (c > data.getChar(ptr + (3 << 15) - 4)) {
                ptr += 3 << 15;
            }
         ...

down through many other values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:01:55+00:00Added an answer on May 13, 2026 at 11:01 pm

    It doesn’t much matter whether it’s a good idea (it’s not), because it won’t compile.

    EDIT: This is mentioned explicitly in the JLS:

    A trick known as Duff’s device can be used in C or C++ to unroll the loop, but this is not valid code in the Java programming language:

    Or, more bluntly (from the same section):

    Great C hack, Tom, but it’s not valid here.

    EDIT: To answer your more (too) general question, usually no. You should generally rely on the JIT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible (by using the stock c# TreeView) to have Multiline TreeNodes? Also,
Im trying to download share data from a stock exchange using python. The problem
hi i am using the two panes chart http://www.highcharts.com/stock/demo/candlestick-and-volume i then put a plodBands
I'm using the following piece of code to pull a stock price from yahoo
I've been using the Google Finance API to successfully gather some stock info. The
I am attempting to upload the stock Blink sketch using the Arduino IDE in
I've got a stock Debian Etch system, using Exim4. The domains are mostly local
I'm using RichFaces per a client requirement, but the markup it (and the stock
I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol
I am trying to allocate memory using sun.misc.Unsafe.allocateMemory() and access it in native code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.