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

ThreadCritical lock can be avoided in LazyClassPathEntry::resolve_entry() method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • generic
    • generic

      Taking ThreadCritical lock is not necessary while compare-and-swap can do the work.

      original:
        new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, CHECK_NULL);
        {
          ThreadCritical tc;
          if (_resolved_entry == NULL) {
            _resolved_entry = new_entry;
            return new_entry;
          }
        }

      with CAS

        new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, CHECK_NULL);
        if (Atomic::cmpxchg_ptr(NULL, &_resolved_entry, new_entry) == NULL) {
          return new_entry;
        }




            zgu Zhengyu Gu
            zgu Zhengyu Gu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: