Re: [webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-19 Thread Stephen Lin
On Wed, Sep 19, 2012 at 1:32 AM, Geoffrey Garen gga...@apple.com wrote:

  Thanks! So is PropertyMapHashTable for properties that have been defined
 by the user, or is it not that simple?

 Yes.

  Apologies. Basically, does the implementation of object property access
 in the JIT codebase also use strings which have been made unique
 identifiers in the same way as in the runtime stack? (i.e. can they be
 assumed equal iff they have the same address).

 Yes -- typically, though, if the JIT needs to do a hash lookup, it will
 pass an Identifier to a C++ helper function.


Thanks! Do you mind pointing me to where this happens in the code? (passing
an Identifer to a C++ helper?)


 Geoff

 Stephen
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-19 Thread Geoffrey Garen
 Thanks! Do you mind pointing me to where this happens in the code? (passing 
 an Identifer to a C++ helper?)

Here's an example function called by the JIT, from DFGOperations.cpp:

void DFG_OPERATION operationPutByIdNonStrict(ExecState* exec, EncodedJSValue 
encodedValue, JSCell* base, Identifier* propertyName)
{
JSGlobalData* globalData = exec-globalData();
NativeCallFrameTracer tracer(globalData, exec);

PutPropertySlot slot(false);
base-methodTable()-put(base, exec, *propertyName, 
JSValue::decode(encodedValue), slot);
}

Geoff
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev


[webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-18 Thread Stephen Lin
Hi,

I just started working with webkit (specificially JSC) and am trying to
learn the codebase. I hope someone can bear with me enough to help me with
some questions:

1. I notice there are at least two implementations of hash tables in
JavaScriptCore/runtime, in Lookup.h and PropertyMapHashTable.h. Which, if
either, is used in, say, the normal case of accessing the properties of a
DOM element, like window.location, etc.? And assuming it's one or the
other, what's the main use case of the other one?

2. Also, it looks like string keys in Lookup.h are always Identifiers,
meaning (I think) that they are guaranteed to be single unique entries in
the identifierTable of a JSGlobalData object. Because of this
preprocessing, string equality in the hash table implementation can be
tested just by comparing addresses. Is there any reason
why PropertyMapHashTable.h does not (as far as I can tell) do the same
thing?

3. Does the JIT side of the codebase use unique string identifiers like
Lookup.h does, or is that a whole different ballgame?

Thanks very much in advance for help!
Stephen
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-18 Thread Geoffrey Garen
Hi Stephen.

 1. I notice there are at least two implementations of hash tables in 
 JavaScriptCore/runtime, in Lookup.h and PropertyMapHashTable.h. Which, if 
 either, is used in, say, the normal case of accessing the properties of a DOM 
 element, like window.location, etc.? And assuming it's one or the other, 
 what's the main use case of the other one?

window.location uses Lookup.h. Lookup.h contains hash table logic for static 
properties compiled into the binary.

 2. Also, it looks like string keys in Lookup.h are always Identifiers, 
 meaning (I think) that they are guaranteed to be single unique entries in the 
 identifierTable of a JSGlobalData object. Because of this preprocessing, 
 string equality in the hash table implementation can be tested just by 
 comparing addresses. Is there any reason why PropertyMapHashTable.h does not 
 (as far as I can tell) do the same thing?

It does.

inline PropertyTable::find_iterator PropertyTable::find(const KeyType key)
{
ASSERT(key);
ASSERT(key-isIdentifier() || key-isEmptyUnique());
unsigned hash = key-existingHash();

 3. Does the JIT side of the codebase use unique string identifiers like 
 Lookup.h does, or is that a whole different ballgame?

Can you be more specific?

Geoff
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-18 Thread Stephen Lin
On Wed, Sep 19, 2012 at 1:12 AM, Geoffrey Garen gga...@apple.com wrote:

 Hi Stephen.

  1. I notice there are at least two implementations of hash tables in
 JavaScriptCore/runtime, in Lookup.h and PropertyMapHashTable.h. Which, if
 either, is used in, say, the normal case of accessing the properties of a
 DOM element, like window.location, etc.? And assuming it's one or the
 other, what's the main use case of the other one?

 window.location uses Lookup.h. Lookup.h contains hash table logic for
 static properties compiled into the binary.


Thanks! So is PropertyMapHashTable for properties that have been defined by
the user, or is it not that simple?


  2. Also, it looks like string keys in Lookup.h are always Identifiers,
 meaning (I think) that they are guaranteed to be single unique entries in
 the identifierTable of a JSGlobalData object. Because of this
 preprocessing, string equality in the hash table implementation can be
 tested just by comparing addresses. Is there any reason why
 PropertyMapHashTable.h does not (as far as I can tell) do the same thing?

 It does.

 inline PropertyTable::find_iterator PropertyTable::find(const KeyType key)
 {
 ASSERT(key);
 ASSERT(key-isIdentifier() || key-isEmptyUnique());
 unsigned hash = key-existingHash();




My mistake: the second assert seems to not be there in QtWebKit-2.2.0, the
version I'm looking through, but I reading further I realized that keys are
also assumed to be unique identifiers with the comparison below.

if (key == table()[entryIndex - 1].key)
return std::make_pair(table()[entryIndex - 1], hash 
m_indexMask);

(The way the types resolve, the key comparison is done on address rather
than value, as I assumed the first time I read it)


  3. Does the JIT side of the codebase use unique string identifiers like
 Lookup.h does, or is that a whole different ballgame?


 Can you be more specific?


Apologies. Basically, does the implementation of object property access in
the JIT codebase also use strings which have been made unique identifiers
in the same way as in the runtime stack? (i.e. can they be assumed equal
iff they have the same address). I can't seem to find any code that does
it, but I am new to the whole tree.


 Geoff


Thanks!
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev


Re: [webkit-dev] Hash tables and unique string identifiers in JavaScriptCore

2012-09-18 Thread Geoffrey Garen
 Thanks! So is PropertyMapHashTable for properties that have been defined by 
 the user, or is it not that simple? 

Yes.

 Apologies. Basically, does the implementation of object property access in 
 the JIT codebase also use strings which have been made unique identifiers in 
 the same way as in the runtime stack? (i.e. can they be assumed equal iff 
 they have the same address).

Yes -- typically, though, if the JIT needs to do a hash lookup, it will pass an 
Identifier to a C++ helper function.

Geoff

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-dev