equal
deleted
inserted
replaced
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 } |