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

Using lambda to optimize GraphKit::compute_stack_effects()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 21
    • hotspot
    • None
    • b03
    • generic
    • generic

      compute_stack_effects() is called in add_safepoint_edges(). In debug build, C2 invokes it for almost all bytecodes in Parse::do_one_block().

      There are 2 places that we can optimize it.

      1. rsize is not used by many bytecodes. we could use a lambda to wrap it up. only evaluate the lambda on demand.

      here is the code snippet.
          BasicType rtype = T_ILLEGAL;
          int rsize = 0;

          if (code != Bytecodes::_illegal) {
           depth = Bytecodes::depth(code); // checkcast=0, athrow=-1
           rtype = Bytecodes::result_type(code); // checkcast=P, athrow=V
           if (rtype < T_CONFLICT)
             rsize = type2size[rtype];
          }

      it requires 2 loads and 2 comparisons every time. We will skip the computation if it is not in use and 2 loads and 1 comparison when it's used.

      2. we could leverage assertion to skip computation.
      if asserts that resize is -depth, we could use it directly
           assert(rsize == -depth, "");
           inputs = rsize;

            xliu Xin Liu
            xliu Xin Liu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: