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

improve StackValue API

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • 14
    • hotspot

      The StackValue API treats all primitive values as intptr_t which means users of the API need to do a bunch of ugly casting when getting/setting primitive j<type> values from/to a StackValue:

      jint StackValueCollection::int_at(int slot) const {
        intptr_t val = at(slot)->get_int();
        jint ival = *((jint*) (&val));
        return ival;
      }

      void StackValueCollection::set_int_at(int slot, jint value) {
        intptr_t val;
        *((jint*) (&val)) = value;
        at(slot)->set_int(val);
      }

      More examples:
      https://github.com/openjdk/jdk/blob/6bab0f539fba8fb441697846347597b4a0ade428/src/hotspot/share/runtime/deoptimization.cpp#L905
      https://github.com/openjdk/jdk/blob/6bab0f539fba8fb441697846347597b4a0ade428/src/hotspot/share/runtime/deoptimization.cpp#L897

      This casting to/from intptr_t could be behind the StackValue API and instead there would be `j<type> get_j<type>()` and `void set_j<type>(j<type> value)` methods instread of the raw `intptr_t get_int` and `void set_int(intptr_t value)` methods.

            Unassigned Unassigned
            dnsimon Douglas Simon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: