Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8232173

Migrate StackTraceElement be an inline class


    • Type: Enhancement
    • Status: New
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: repo-valhalla
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:


      StackTraceElement may benefit from being converted to an inline class. There might be some space savings and locality of reference.

      Additional comments:
      StackTraceElement is a good candidate to be an inline type and we probably need good benchmark to determine if flattenability helps the use cases.

      Throwable is performance-sensitive when filling the backtrace (which is in VM-internal compact form). Throwable::stackTrace is an StackTraceElement array that is lazily filled and accessed sequentially typically when printing the stack trace for example logging. It would save the footprint when flattened.

      On the other hand, StackFrameInfo has a StackTraceElement field that is not initialized until the filename or line number is queried. For that case, I think StackFrameInfo wants it to be non-flattened to save the footprint.


      The runtime code filling in the stack information currently assumes
      StackTraceElement is an identity class, and it uses two properties
      that inline types don’t have:
         - the code mutates StackTraceElement instances
         - the code assumes StackTraceElements are stored in an object array (non-flattened)

      Changing the code to use a flattened array of inline type is possible,
      but it would require some refactoring of the code.

      The main modification would be to have the VM to allocate the flattened
      array and directly write information in fields of flattened elements. This
      way, the VM would have the guarantee that the array is not shared, and can
      be safely mutated before being made visible to Java code.




            • Assignee:
              rriggs Roger Riggs
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: