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

Fix handling of trap count overflow in Parse::Parse()

XMLWordPrintable

    • b18
    • generic
    • generic

      Currently Parse::Parse() has the following code to initialize its trap counts:

        // Accumulate deoptimization counts.
        // (The range_check and store_check counts are checked elsewhere.)
        ciMethodData* md = method()->method_data();
        for (uint reason = 0; reason < md->trap_reason_limit(); reason++) {
          uint md_count = md->trap_count(reason);
          if (md_count != 0) {
            if (md_count == md->trap_count_limit())
              md_count += md->overflow_trap_count();

      The intention of this code is to also take into account the `overflow_trap_count()` for trap reasons which have overflowed.

      But the code is wrong, because `md->trap_count(reason)` will return `(uint)-1` if an overflow happened and `md->trap_count_limit()` will return `(jubyte)-1` (i.e. 0xff) so the condition `md_count == md->trap_count_limit()` will never be true if an overflow happened.

      Instead the code should be something like:

            if (md_count == (uint)-1) {
              md_count = md->trap_count_limit() + md->overflow_trap_count();

            bstafford Brian Stafford
            simonis Volker Simonis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: