RFR: 8256453: C2: Reduce State footprint

Claes Redestad redestad at openjdk.java.net
Tue Nov 17 11:33:14 UTC 2020


State objects are pretty heavy-weight. On linux-x64 sizeof(State) = 2344

Much of this is due to the two 32-bit int arrays _cost and _rule.

The number of rules vary by platform, but seem to hover around 1k. A 16-bit integer seem more than enough to map all rules, so making _rule an uint16_t array saves significant space.

Also it seems we can fold the _valid bit vector into _rule and reduce the size even further. This also considerably simplify the common validity checks, which more than makes up for needing to initialize more memory when setting up the State object.

Those two optimizations reduce sizeof(State) down to 1736. Profiling compilations show a tiny win overall and instrumenting some simple compilations I see a sharp decline in Arena::grow events caused by ResourceObj allocation in Matcher::match_tree and Matcher::Label_Root

-------------

Commit messages:
 - Fix 'comparison is always true' build issue on newer compiler
 - More cleanup
 - Clean up State::dump
 - Add sanity assertion
 - Clean up
 - Merge branch 'master' into state_opts
 - Merge branch 'master' into state_opts
 - Merge _rule and _valid, encapsulate _rule and _cost, simplify DFA productions
 - Merge branch 'master' into state_opts
 - uint16_t _rule

Changes: https://git.openjdk.java.net/jdk/pull/1253/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1253&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8256453
  Stats: 111 lines in 3 files changed: 18 ins; 37 del; 56 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1253.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1253/head:pull/1253

PR: https://git.openjdk.java.net/jdk/pull/1253


More information about the hotspot-compiler-dev mailing list