Closed Bug 884649 Opened 11 years ago Closed 11 years ago

Remove jsdhash.{h,cpp}

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

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

References

Details

Attachments

(2 files, 1 obsolete file)

JSDHash is no longer used within SpiderMonkey;  it's only used in XPConnect.  I
suggest we move it into js/xpconnect/, to reduce its exposure. 

There's precedent for this:  I moved jshash.{h,cpp} from js/src/ to js/jsd/ in
bug 647367, and that left a fresh minty flavour in everybody's mouths.
I suppose we could rename the files to xpchash.{h,cpp} and the types to
XPCHash*, but it doesn't seem worth the effort.
Attachment #764529 - Flags: review?(luke)
Attachment #764529 - Flags: review?(bobbyholley+bmo)
I wrote some patches to convert these to normal browser hash tables, but I deemed them unreviewable as they were large and tedious. ;)  That was in bug 781589.
(In reply to Andrew McCreight [:mccr8] from comment #2)
> I wrote some patches to convert these to normal browser hash tables, but I
> deemed them unreviewable as they were large and tedious. ;)  That was in bug
> 781589.

From a quick look those patches look ok to me...

That does give me another idea, though:  convert all those xpconnect JSDHashes to PLDHashes and remove jsdhash.{h,cpp} altogether!
Yeah, that would probably be easier to do than convert them to more "modern" hash tables...
Attachment #764529 - Attachment is obsolete: true
Attachment #764529 - Flags: review?(luke)
Attachment #764529 - Flags: review?(bobbyholley+bmo)
Summary: Move jsdhash.{h,cpp} from js/src/ to js/xpconnect/src/, to reduce its exposure → Remove jsdhash.{h,cpp}
This is mostly trivial, just replacing "JS" with "PL" in lots of places.

The one exception is that JSDHashMatchEntry's return type is JSBool, but
PLDHashMatchEntry's is bool.  So I had to modify a few Match() methods
accordingly.  This was easy;  they were already returning true/false rather
than JS_TRUE/JS_FALSE.
Attachment #764554 - Flags: review?(bobbyholley+bmo)
Now even mintier!
Attachment #764556 - Flags: review?(luke)
Comment on attachment 764556 [details] [diff] [review]
(part 2) - Remove jsdhash.{h,cpp}.

weeeeee
Attachment #764556 - Flags: review?(luke) → review+
Comment on attachment 764554 [details] [diff] [review]
(part 1) - Used PLDHash instead of JSDHash in xpconnect.

I know next to nothing about hash tables. But from comment 2, it sounds like Andrew does! :-)
Attachment #764554 - Flags: review?(bobbyholley+bmo) → review?(continuation)
Comment on attachment 764554 [details] [diff] [review]
(part 1) - Used PLDHash instead of JSDHash in xpconnect.

Review of attachment 764554 [details] [diff] [review]:
-----------------------------------------------------------------

thanks

::: js/xpconnect/src/XPCMaps.cpp
@@ +274,5 @@
>  {
>      size_t n = 0;
>      n += mallocSizeOf(this);
>      // The second arg is NULL because this is a "shallow" measurement of the map.
> +    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, NULL, mallocSizeOf) : 0;

nullptr please

::: js/xpconnect/src/xpcprivate.h
@@ +85,5 @@
>  #include <stdarg.h>
>  #include <math.h>
>  #include "xpcpublic.h"
>  #include "jsapi.h"
> +#include "pldhash.h"

please move this after jsprf to preserve some kind of local alphabetical ordering
Attachment #764554 - Flags: review?(continuation) → review+
I know next to next to nothing about hash tables, but this should be okay, assuming PLDhash and JSDhash haven't diverged too much.
> I know next to next to nothing

I see what you did there.
https://hg.mozilla.org/mozilla-central/rev/65e7eb47b5a2
https://hg.mozilla.org/mozilla-central/rev/5900380df45d
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Depends on: 902062
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: