src/hotspot/share/services/mallocSiteTable.cpp
changeset 59252 623722a6aeb9
parent 53685 df83034c9275
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
   126     MallocSiteHashtableEntry* entry = new_entry(key, flags);
   126     MallocSiteHashtableEntry* entry = new_entry(key, flags);
   127     // OOM check
   127     // OOM check
   128     if (entry == NULL) return NULL;
   128     if (entry == NULL) return NULL;
   129 
   129 
   130     // swap in the head
   130     // swap in the head
   131     if (Atomic::replace_if_null(entry, &_table[index])) {
   131     if (Atomic::replace_if_null(&_table[index], entry)) {
   132       return entry->data();
   132       return entry->data();
   133     }
   133     }
   134 
   134 
   135     delete entry;
   135     delete entry;
   136   }
   136   }
   227 
   227 
   228   // make counter negative to block out shared locks
   228   // make counter negative to block out shared locks
   229   do {
   229   do {
   230     val = *_lock;
   230     val = *_lock;
   231     target = _MAGIC_ + *_lock;
   231     target = _MAGIC_ + *_lock;
   232   } while (Atomic::cmpxchg(target, _lock, val) != val);
   232   } while (Atomic::cmpxchg(_lock, val, target) != val);
   233 
   233 
   234   // wait for all readers to exit
   234   // wait for all readers to exit
   235   while (*_lock != _MAGIC_) {
   235   while (*_lock != _MAGIC_) {
   236 #ifdef _WINDOWS
   236 #ifdef _WINDOWS
   237     os::naked_short_sleep(1);
   237     os::naked_short_sleep(1);
   241   }
   241   }
   242   _lock_state = ExclusiveLock;
   242   _lock_state = ExclusiveLock;
   243 }
   243 }
   244 
   244 
   245 bool MallocSiteHashtableEntry::atomic_insert(MallocSiteHashtableEntry* entry) {
   245 bool MallocSiteHashtableEntry::atomic_insert(MallocSiteHashtableEntry* entry) {
   246   return Atomic::replace_if_null(entry, &_next);
   246   return Atomic::replace_if_null(&_next, entry);
   247 }
   247 }