Hello,

thank you for your answer.

First I will change the WeakMap.

If I change the typedef for ObjectValueMap, I have to remove also the
default value for the HashPolicy of the WeakMap (jsweakmap.h), I'm right?

template <class Key, class Value,  class HashPolicy = DefaultHasher<Key> >
class WeakMap : public HashMap<Key, Value, HashPolicy,
RuntimeAllocPolicy>, public WeakMapBase

Have I to implement more than one template, if I want to distinguish
between JSObject and the other types?
I want only change the behaviour for JSObject and JSObject*, because
only this types can be a Proxy type.

In the HashTable.h are three implementations:

  * a generic one for pointer types
  * a generic one for Class Types
  * one for double Types

Can I implement something like this:

template <class Key>
struct WeakMapHasher : DefaultHasher
{
...
}

template <>
struct WeakMapHasher<JSObject> : DefaultHasher<JSObject>
{
...
}

template <>
struct WeakMapHasher<JSObject*> : DefaultHasher<JSObject*>
{
...
}

And change the implementation of hash() and match()?

Thanks a lot
Andreas

Am 19.12.2013 19:58, schrieb Jason Orendorff:
> On 12/19/13 3:21 AM, Andreas Schlegel wrote:
>> Hello Jason,
>>
>> for comparing "transparent" proxies I have to change some things for
>> WeakMap Map and Set.
>>
>> I should compare the key from a transparent Proxy with its object, e.g.
>> for getting the value .
>>
>> I found the lookup is in the HashTable.h in the Folder JS/public may I
>> change something there, or are this includes from somewhere?
>>
> (adding the list)
>
> Don't change js/public/HashTable.h.
>
> For Map and Set, you have to change hash() and match() methods in
> builtin/MapObject.h and .cpp.
>
> For WeakMap, I think you need to modify js/src/vm/WeakMapObject.h. You
> need to add a struct that is a hash policy (as defined in comments in
> js/public/HashTable.h) and implements hash() and match() correctly for
> your purpose. Then change this line:
>
>     typedef WeakMap<EncapsulatedPtrObject, RelocatableValue> ObjectValueMap;
>
> to pass your new hash policy as the third parameter. (The default
> HashPolicy has hash() and match() methods based on pointer equality. You
> must provide an explicit hash policy to override that.)
>
> -j
>
>

_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to