diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/Lookup.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/runtime/Lookup.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Lookup.cpp | 83 |
1 files changed, 32 insertions, 51 deletions
diff --git a/Source/JavaScriptCore/runtime/Lookup.cpp b/Source/JavaScriptCore/runtime/Lookup.cpp index a806dd052..f40740e35 100644 --- a/Source/JavaScriptCore/runtime/Lookup.cpp +++ b/Source/JavaScriptCore/runtime/Lookup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2012, 2015-2016 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,73 +20,54 @@ #include "config.h" #include "Lookup.h" -#include "Executable.h" +#include "GetterSetter.h" #include "JSFunction.h" -#include "Operations.h" +#include "JSCInlines.h" namespace JSC { -void HashTable::createTable(VM& vm) const +void reifyStaticAccessor(VM& vm, const HashTableValue& value, JSObject& thisObject, PropertyName propertyName) { - 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); + JSGlobalObject* globalObject = thisObject.globalObject(); + GetterSetter* accessor = GetterSetter::create(vm, globalObject); + if (value.accessorGetter()) { + String getterName = tryMakeString(ASCIILiteral("get "), String(*propertyName.publicName())); + if (!getterName) + return; + accessor->setGetter(vm, globalObject, value.attributes() & Builtin + ? JSFunction::createBuiltinFunction(vm, value.builtinAccessorGetterGenerator()(vm), globalObject, getterName) + : JSFunction::create(vm, globalObject, 0, getterName, value.accessorGetter())); } - table = entries; + thisObject.putDirectNonIndexAccessor(vm, propertyName, accessor, attributesForStructure(value.attributes())); } -void HashTable::deleteTable() const +bool setUpStaticFunctionSlot(VM& vm, const HashTableValue* entry, JSObject* thisObject, PropertyName propertyName, PropertySlot& slot) { - 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() & Function); - VM& vm = exec->vm(); + ASSERT(thisObject->globalObject()); + ASSERT(entry->attributes() & BuiltinOrFunctionOrAccessorOrLazyProperty); unsigned attributes; - PropertyOffset offset = thisObj->getDirectOffset(vm, propertyName, attributes); + bool isAccessor = entry->attributes() & Accessor; + PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName, attributes); if (!isValidOffset(offset)) { // If a property is ever deleted from an object with a static table, then we reify // all static functions at that time - after this we shouldn't be re-adding anything. - if (thisObj->staticFunctionsReified()) + if (thisObject->staticPropertiesReified()) return false; - - thisObj->putDirectNativeFunction( - vm, thisObj->globalObject(), propertyName, entry->functionLength(), - entry->function(), entry->intrinsic(), entry->attributes()); - offset = thisObj->getDirectOffset(vm, propertyName, attributes); - ASSERT(isValidOffset(offset)); + + reifyStaticProperty(vm, propertyName, *entry, *thisObject); + + offset = thisObject->getDirectOffset(vm, propertyName, attributes); + if (!isValidOffset(offset)) { + dataLog("Static hashtable initialiation for ", propertyName, " did not produce a property.\n"); + RELEASE_ASSERT_NOT_REACHED(); + } } - slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset); + if (isAccessor) + slot.setCacheableGetterSlot(thisObject, attributes, jsCast<GetterSetter*>(thisObject->getDirect(offset)), offset); + else + slot.setValue(thisObject, attributes, thisObject->getDirect(offset), offset); return true; } |