Closed Bug 1176160 Opened 9 years ago Closed 9 years ago

Remove PL_DHashTableEnumerate() use from rdf/

Categories

(Core Graveyard :: RDF, defect)

defect
Not set
normal

Tracking

(firefox42 fixed)

RESOLVED FIXED
mozilla42
Tracking Status
firefox42 --- fixed

People

(Reporter: n.nethercote, Assigned: n.nethercote)

References

Details

Attachments

(3 files)

Because PLDHashTable::Iterator is much nicer than PL_DHashTableEnumerate().
I've preserved the existing behaviour, which is that if NS_RDF_STOP_VISIT
occurs in the inner loop, we break out of the inner loop and continue the outer
loop. But it's possible that the intended behaviour is to break out of both
loops, as happens if NS_FAILED() is true. (This latter behaviour would actually
be easier to implement because the |inner_end| label could be removed.)
Attachment #8624613 - Flags: review?(axel)
Comment on attachment 8624612 [details] [diff] [review]
(part 1) - Remove simple uses of PL_DHashTableEnumerator() from rdf/

Sorry for the lag, mountains in my way. Patches like this are really better for :bs to review, redirecting.
Attachment #8624612 - Flags: review?(axel) → review?(benjamin)
Attachment #8624613 - Flags: review?(axel) → review?(benjamin)
Attachment #8624614 - Flags: review?(axel) → review?(benjamin)
Attachment #8624612 - Flags: review?(benjamin) → review+
Comment on attachment 8624613 [details] [diff] [review]
(part 2) - Remove uses of PL_DHashTableEnumerator() involving VisitorClosure from rdf/

oh god this is so awful. Arbitrary visitor code on the stack while enumerating a hashtable :-(

But you're not making it worse, and I'm hoping to just rm -rf rdf/ one of these days anyway.
Attachment #8624613 - Flags: review?(benjamin) → review+
Comment on attachment 8624614 [details] [diff] [review]
(part 3) - Remove uses of PL_DHashTableEnumerator() from SweepForwardArcsEntries()

Is this possibly safe? SweepForwardArcsEntries seems to call itself recursively while iterating over a hashtable, which ought to invalidate the iterator, no?
Flags: needinfo?(n.nethercote)
Thank you for the fast reviews.

(In reply to Benjamin Smedberg  [:bsmedberg] from comment #6)
> Comment on attachment 8624614 [details] [diff] [review]
> (part 3) - Remove uses of PL_DHashTableEnumerator() from
> SweepForwardArcsEntries()
> 
> Is this possibly safe? SweepForwardArcsEntries seems to call itself
> recursively while iterating over a hashtable, which ought to invalidate the
> iterator, no?

First of all, I've tried very hard to simply preserve the existing behaviour. I've done a lot of enuerate-to-iterator conversions now so I'm confident I've done so here as well :)

Addressing your concern more directly... AIUI, there is a hash table, each element of which can contain a hash table, but it can only go one level deep, as shown by this comment:

> Stuff in sub-hashes must be swept recursively (max depth: 1)

(Indeed, my "part 2" patch modifies other code that handles this data structure via a nested loop rather than via recursion, so the "must be" in this comment isn't strictly true.)

More importantly, a new iterator is used for each sub-table, so there should be no invalidation issues.

Basically it's a just a N-ary tree with one or two levels and a new iterator is used for each node.
Flags: needinfo?(n.nethercote)
Also, I've done a try push that looked fine: https://treeherder.mozilla.org/#/jobs?repo=try&revision=811e0f45d012.
Keywords: leave-open
Still one patch to go.
Attachment #8624614 - Flags: review?(benjamin) → review+
Keywords: leave-open
https://hg.mozilla.org/mozilla-central/rev/2a11da784c65
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: