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

Clean up JVM code that compares 'this' to NULL

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 12
    • hotspot

      Comparisons of 'this' to NULL are bogus because the compiler is free to elide these tests. Since (this == NULL) can never be true; applying an ordinary member function to NULL invokes undefined behavior.

      Here are the places in the JVM that compare 'this' to NULL (based in part on email from Matthias Baesken):

      jdk/src/hotspot/share/adlc/formssel.cpp

      1727bool Opcode::print_opcode(FILE *fp, Opcode::opcode_type desired_opcode) {
      1728 // Default values previously provided by MachNode::primary()...
      1729 const char *description = NULL;
      1730 const char *value = NULL;
      1731 // Check if user provided any opcode definitions
      1732 if( this != NULL ) {


      3417void MatchNode::count_instr_names( Dict &names ) {
      3418 if( this == NULL ) return;


      jdk/src/hotspot/share/opto/chaitin.cpp

      2147char *PhaseChaitin::dump_register( const Node *n, char *buf ) const {
      2148 if( this == NULL ) { // Not got anything?
      2149 sprintf(buf,"N%d",n->_idx); // Then use Node index
      2150 } else if( _node_regs ) {


      jdk/src/hotspot/share/asm/codeBuffer.cpp

      1241void CodeBuffer::print() {
      1242 if (this == NULL) {
      1243 tty->print_cr("NULL CodeBuffer pointer");


      jdk/src/hotspot/share/libadt/set.cpp

      58char *Set::setstr() const
      59{
      60 if( this == NULL ) return os::strdup("{no set}");

            Unassigned Unassigned
            hseigel Harold Seigel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: