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

Replace "int which" with "int cp_index" in constantPool

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 22
    • 21
    • hotspot
    • b09

      See:
      https://github.com/openjdk/jdk/blob/8a70664e5248cd6b9d63951729e93bf73eff004c/src/hotspot/share/oops/constantPool.hpp

      Many of the APIs take an "int which" parameter to represent an index that is NOT an index to the constant pool. (These are "derived indices". See JDK-8307309)

      However, we have a large number of function that do take constant pool indices. E.g.

        void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); }
        void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); }
        u1* tag_addr_at(int which) const { return tags()->adr_at(which); }

        intptr_t* obj_at_addr(int which) const {
          assert(is_within_bounds(which), "index out of bounds");
          return (intptr_t*) &base()[which];
        }

        jint* int_at_addr(int which) const {
          assert(is_within_bounds(which), "index out of bounds");
          return (jint*) &base()[which];
        }

      These should be renamed from "which" to "cp_index" to distinguish them from the derived indices.

      Also, in constantPool.cpp and various of other files, callers of these function use different local variables like i, index, etc. These should also be renamed to cp_index to improve readability.

            matsaave Matias Saavedra Silva
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: