m_attributes = attributes;
m_u.store.value1 = v1;
m_u.store.value2 = v2;
- m_u.function.intrinsic = intrinsic;
+ m_intrinsic = intrinsic;
m_next = 0;
}
Intrinsic intrinsic() const
{
ASSERT(m_attributes & Function);
- return m_u.function.intrinsic;
+ return m_intrinsic;
}
NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; }
private:
StringImpl* m_key;
unsigned char m_attributes; // JSObject attributes
+ Intrinsic m_intrinsic;
union {
struct {
struct {
NativeFunction functionValue;
intptr_t length; // number of arguments for function
- Intrinsic intrinsic;
} function;
struct {
GetFunction get;
const HashTableValue* values; // Fixed values generated by script.
mutable const HashEntry* table; // Table allocated at runtime.
- ALWAYS_INLINE void initializeIfNeeded(JSGlobalData* globalData) const
+ ALWAYS_INLINE HashTable copy() const
+ {
+ // Don't copy dynamic table since it's thread specific.
+ HashTable result = { compactSize, compactHashSizeMask, values, 0 };
+ return result;
+ }
+
+ ALWAYS_INLINE void initializeIfNeeded(VM* vm) const
{
if (!table)
- createTable(globalData);
+ createTable(vm);
}
ALWAYS_INLINE void initializeIfNeeded(ExecState* exec) const
{
if (!table)
- createTable(&exec->globalData());
+ createTable(&exec->vm());
}
JS_EXPORT_PRIVATE void deleteTable() const;
// Find an entry in the table, and return the entry.
- ALWAYS_INLINE const HashEntry* entry(JSGlobalData* globalData, const Identifier& identifier) const
+ ALWAYS_INLINE const HashEntry* entry(VM* vm, PropertyName identifier) const
{
- initializeIfNeeded(globalData);
+ initializeIfNeeded(vm);
return entry(identifier);
}
- ALWAYS_INLINE const HashEntry* entry(ExecState* exec, const Identifier& identifier) const
+ ALWAYS_INLINE const HashEntry* entry(ExecState* exec, PropertyName identifier) const
{
initializeIfNeeded(exec);
return entry(identifier);
int m_position;
};
- ConstIterator begin(JSGlobalData& globalData) const
+ ConstIterator begin(VM& vm) const
{
- initializeIfNeeded(&globalData);
+ initializeIfNeeded(&vm);
return ConstIterator(this, 0);
}
- ConstIterator end(JSGlobalData& globalData) const
+ ConstIterator end(VM& vm) const
{
- initializeIfNeeded(&globalData);
+ initializeIfNeeded(&vm);
return ConstIterator(this, compactSize);
}
private:
- ALWAYS_INLINE const HashEntry* entry(const Identifier& identifier) const
+ ALWAYS_INLINE const HashEntry* entry(PropertyName propertyName) const
{
+ StringImpl* impl = propertyName.publicName();
+ if (!impl)
+ return 0;
+
ASSERT(table);
- const HashEntry* entry = &table[identifier.impl()->existingHash() & compactHashSizeMask];
+ const HashEntry* entry = &table[impl->existingHash() & compactHashSizeMask];
if (!entry->key())
return 0;
do {
- if (entry->key() == identifier.impl())
+ if (entry->key() == impl)
return entry;
entry = entry->next();
} while (entry);
}
// Convert the hash table keys to identifiers.
- JS_EXPORT_PRIVATE void createTable(JSGlobalData*) const;
+ JS_EXPORT_PRIVATE void createTable(VM*) const;
};
- JS_EXPORT_PRIVATE bool setUpStaticFunctionSlot(ExecState*, const HashEntry*, JSObject* thisObject, const Identifier& propertyName, PropertySlot&);
+ JS_EXPORT_PRIVATE bool setUpStaticFunctionSlot(ExecState*, const HashEntry*, JSObject* thisObject, PropertyName, PropertySlot&);
/**
* This method does it all (looking in the hashtable, checking for function
* unknown property).
*/
template <class ThisImp, class ParentImp>
- inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
+ inline bool getStaticPropertySlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
{
const HashEntry* entry = table->entry(exec, propertyName);
}
template <class ThisImp, class ParentImp>
- inline bool getStaticPropertyDescriptor(ExecState* exec, const HashTable* table, ThisImp* thisObj, const Identifier& propertyName, PropertyDescriptor& descriptor)
+ inline bool getStaticPropertyDescriptor(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertyDescriptor& descriptor)
{
const HashEntry* entry = table->entry(exec, propertyName);
* a dummy getValueProperty.
*/
template <class ParentImp>
- inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
+ inline bool getStaticFunctionSlot(ExecState* exec, const HashTable* table, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
{
if (ParentImp::getOwnPropertySlot(thisObj, exec, propertyName, slot))
return true;
* a dummy getValueProperty.
*/
template <class ParentImp>
- inline bool getStaticFunctionDescriptor(ExecState* exec, const HashTable* table, JSObject* thisObj, const Identifier& propertyName, PropertyDescriptor& descriptor)
+ inline bool getStaticFunctionDescriptor(ExecState* exec, const HashTable* table, JSObject* thisObj, PropertyName propertyName, PropertyDescriptor& descriptor)
{
if (ParentImp::getOwnPropertyDescriptor(static_cast<ParentImp*>(thisObj), exec, propertyName, descriptor))
return true;
* Using this instead of getStaticPropertySlot removes the need for a FuncImp class.
*/
template <class ThisImp, class ParentImp>
- inline bool getStaticValueSlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, const Identifier& propertyName, PropertySlot& slot)
+ inline bool getStaticValueSlot(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertySlot& slot)
{
const HashEntry* entry = table->entry(exec, propertyName);
* Using this instead of getStaticPropertyDescriptor removes the need for a FuncImp class.
*/
template <class ThisImp, class ParentImp>
- inline bool getStaticValueDescriptor(ExecState* exec, const HashTable* table, ThisImp* thisObj, const Identifier& propertyName, PropertyDescriptor& descriptor)
+ inline bool getStaticValueDescriptor(ExecState* exec, const HashTable* table, ThisImp* thisObj, PropertyName propertyName, PropertyDescriptor& descriptor)
{
const HashEntry* entry = table->entry(exec, propertyName);
return true;
}
+ template <class ThisImp>
+ inline void putEntry(ExecState* exec, const HashEntry* entry, PropertyName propertyName, JSValue value, ThisImp* thisObj, bool shouldThrow = false)
+ {
+ // If this is a function put it as an override property.
+ if (entry->attributes() & Function)
+ thisObj->putDirect(exec->vm(), propertyName, value);
+ else if (!(entry->attributes() & ReadOnly))
+ entry->propertyPutter()(exec, thisObj, value);
+ else if (shouldThrow)
+ throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
+ }
+
/**
* This one is for "put".
* It looks up a hash entry for the property to be set. If an entry
* is found it sets the value and returns true, else it returns false.
*/
template <class ThisImp>
- inline bool lookupPut(ExecState* exec, const Identifier& propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, bool shouldThrow = false)
+ inline bool lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, bool shouldThrow = false)
{
const HashEntry* entry = table->entry(exec, propertyName);
if (!entry)
return false;
- // If this is a function put it as an override property.
- if (entry->attributes() & Function)
- thisObj->putDirect(exec->globalData(), propertyName, value);
- else if (!(entry->attributes() & ReadOnly))
- entry->propertyPutter()(exec, thisObj, value);
- else if (shouldThrow)
- throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
-
+ putEntry<ThisImp>(exec, entry, propertyName, value, thisObj, shouldThrow);
return true;
}
* then it calls put() on the ParentImp class.
*/
template <class ThisImp, class ParentImp>
- inline void lookupPut(ExecState* exec, const Identifier& propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, PutPropertySlot& slot)
+ inline void lookupPut(ExecState* exec, PropertyName propertyName, JSValue value, const HashTable* table, ThisImp* thisObj, PutPropertySlot& slot)
{
if (!lookupPut<ThisImp>(exec, propertyName, value, table, thisObj, slot.isStrictMode()))
ParentImp::put(thisObj, exec, propertyName, value, slot); // not found: forward to parent