cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Stupp (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CASSANDRA-12343) Make 'static final boolean' easier to optimize for Hotspot
Date Fri, 29 Jul 2016 16:03:21 GMT
Robert Stupp created CASSANDRA-12343:
----------------------------------------

             Summary: Make 'static final boolean' easier to optimize for Hotspot
                 Key: CASSANDRA-12343
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12343
             Project: Cassandra
          Issue Type: Improvement
            Reporter: Robert Stupp
            Assignee: Robert Stupp
            Priority: Trivial
             Fix For: 3.x


Hotspot is able to optimize condition checks on `static final` fields. But the compiler can
only optimize if the referenced "constant" is the first condition to check. (If I understood
the optimization in Hotspot correctly.)

I.e. the first {{if}} block can be "eliminated" whereas the second cannot:
{code}
class Foo {
  static final boolean CONST = /* some fragment evaluating to false */;
  
  public void doSomeStuff(boolean param) {

    if (!CONST) {
      // this code block can be eliminated
    }

    if (!CONST && param) {
      // this code block can be eliminated
    }

    if (param && !CONST) {
      // this code block cannot be eliminated due to some compiler logic
    }
    
  }
}
{code}

Linked patch changes the order in some {{if}} statements and migrates a few methods to static
final fields.

||trunk|[branch|https://github.com/apache/cassandra/compare/trunk...snazy:boolean-hotspot]|[testall|http://cassci.datastax.com/view/Dev/view/snazy/job/snazy-boolean-hotspot-testall/lastSuccessfulBuild/]|[dtest|http://cassci.datastax.com/view/Dev/view/snazy/job/snazy-boolean-hotspot-dtest/lastSuccessfulBuild/]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message