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

Suspicious calls to MacroAssembler::null_check(Register, offset)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 15
    • hotspot
    • b17
    • x86

      In several places in HotSpot, the method MacroAssembler::null_check(Register, offset) is called in a way that never produces any null check in the assembly code.

      null_check(Register, offset) calls needs_explicit_null_check(offset) to determine if it must emit a null check in the assembly code or not.

      needs_explicit_null_check(offset) returns true only if the offset is negative or bigger than the os page size.

      In the following cases:

      MethodHandles::generate_method_handle_dispatch, line 353: __ null_check(receiver_reg, oopDesc::klass_offset_in_bytes());
      TemplateTable::index_check_without_pop, line 752: __ null_check(array, arrayOopDesc::length_offset_in_bytes());
      TemplateTable::invokevirtual_helper, line 3739: __ null_check(recv, oopDesc::klass_offset_in_bytes());
      TemplateTable::invokeinterface, line 3832: __ null_check(rcx, oopDesc::klass_offset_in_bytes());
      TemplateTable::invokeinterface, line 3855: __ null_check(rcx, oopDesc::klass_offset_in_bytes());
      TemplateTable::arraylength, line 4171: __ null_check(rax, arrayOopDesc::length_offset_in_bytes());

      the offset being passed is the offset of a field in the header of Java object or a Java array. In both cases, the offset is always positive and smaller than an os page size.

      Either null checks are not required in those cases, and there's no point in calling the null_check() method, or null checks are required and the null_check() method is not called correctly.

      Note that when the offset argument is omitted, its default value is -1, and the null_check() method produces a null check instruction.

            matsaave Matias Saavedra Silva
            fparain Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: