diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/Lookup.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/Lookup.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Lookup.cpp | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/Source/JavaScriptCore/runtime/Lookup.cpp b/Source/JavaScriptCore/runtime/Lookup.cpp index 7df15b486..a806dd052 100644 --- a/Source/JavaScriptCore/runtime/Lookup.cpp +++ b/Source/JavaScriptCore/runtime/Lookup.cpp @@ -21,32 +21,56 @@ #include "Lookup.h" #include "Executable.h" -#include "GetterSetter.h" #include "JSFunction.h" -#include "JSCInlines.h" +#include "Operations.h" namespace JSC { -void reifyStaticAccessor(VM& vm, const HashTableValue& value, JSObject& thisObj, PropertyName propertyName) +void HashTable::createTable(VM& vm) const { - JSGlobalObject* globalObject = thisObj.globalObject(); - GetterSetter* accessor = GetterSetter::create(vm, globalObject); - if (value.accessorGetter()) { - RefPtr<StringImpl> getterName = WTF::tryMakeString(ASCIILiteral("get "), String(*propertyName.publicName())); - if (!getterName) - return; - accessor->setGetter(vm, globalObject, JSFunction::create(vm, globalObject, 0, *getterName, value.accessorGetter())); + ASSERT(!table); + int linkIndex = compactHashSizeMask + 1; + HashEntry* entries = new HashEntry[compactSize]; + for (int i = 0; i < compactSize; ++i) + entries[i].setKey(0); + for (int i = 0; values[i].key; ++i) { + StringImpl* identifier = Identifier::add(&vm, values[i].key).leakRef(); + int hashIndex = identifier->existingHash() & compactHashSizeMask; + HashEntry* entry = &entries[hashIndex]; + + if (entry->key()) { + while (entry->next()) { + entry = entry->next(); + } + ASSERT(linkIndex < compactSize); + entry->setNext(&entries[linkIndex++]); + entry = entry->next(); + } + + entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2, values[i].intrinsic); } - thisObj.putDirectNonIndexAccessor(vm, propertyName, accessor, value.attributes()); + table = entries; } -bool setUpStaticFunctionSlot(ExecState* exec, const HashTableValue* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot) +void HashTable::deleteTable() const +{ + if (table) { + int max = compactSize; + for (int i = 0; i != max; ++i) { + if (StringImpl* key = table[i].key()) + key->deref(); + } + delete [] table; + table = 0; + } +} + +bool setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot) { ASSERT(thisObj->globalObject()); - ASSERT(entry->attributes() & BuiltinOrFunctionOrAccessor); + ASSERT(entry->attributes() & Function); VM& vm = exec->vm(); unsigned attributes; - bool isAccessor = entry->attributes() & Accessor; PropertyOffset offset = thisObj->getDirectOffset(vm, propertyName, attributes); if (!isValidOffset(offset)) { @@ -54,26 +78,15 @@ bool setUpStaticFunctionSlot(ExecState* exec, const HashTableValue* entry, JSObj // all static functions at that time - after this we shouldn't be re-adding anything. if (thisObj->staticFunctionsReified()) return false; - - if (entry->attributes() & Builtin) - thisObj->putDirectBuiltinFunction(vm, thisObj->globalObject(), propertyName, entry->builtinGenerator()(vm), entry->attributes()); - else if (entry->attributes() & Function) { - thisObj->putDirectNativeFunction( - vm, thisObj->globalObject(), propertyName, entry->functionLength(), - entry->function(), entry->intrinsic(), entry->attributes()); - } else { - ASSERT(isAccessor); - reifyStaticAccessor(vm, *entry, *thisObj, propertyName); - } - + + thisObj->putDirectNativeFunction( + vm, thisObj->globalObject(), propertyName, entry->functionLength(), + entry->function(), entry->intrinsic(), entry->attributes()); offset = thisObj->getDirectOffset(vm, propertyName, attributes); ASSERT(isValidOffset(offset)); } - if (isAccessor) - slot.setCacheableGetterSlot(thisObj, attributes, jsCast<GetterSetter*>(thisObj->getDirect(offset)), offset); - else - slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset); + slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset); return true; } |