summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/Lookup.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-05-30 12:48:17 +0200
commit881da28418d380042aa95a97f0cbd42560a64f7c (patch)
treea794dff3274695e99c651902dde93d934ea7a5af /Source/JavaScriptCore/runtime/Lookup.cpp
parent7e104c57a70fdf551bb3d22a5d637cdcbc69dbea (diff)
parent0fcedcd17cc00d3dd44c718b3cb36c1033319671 (diff)
downloadqtwebkit-881da28418d380042aa95a97f0cbd42560a64f7c.tar.gz
Merge 'wip/next' into dev
Change-Id: Iff9ee5e23bb326c4371ec8ed81d56f2f05d680e9
Diffstat (limited to 'Source/JavaScriptCore/runtime/Lookup.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/Lookup.cpp83
1 files changed, 37 insertions, 46 deletions
diff --git a/Source/JavaScriptCore/runtime/Lookup.cpp b/Source/JavaScriptCore/runtime/Lookup.cpp
index 030aef5a5..dcee6ba58 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 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
@@ -21,70 +21,61 @@
#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& thisObj, 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 = thisObj.globalObject();
+ GetterSetter* accessor = GetterSetter::create(vm, globalObject);
+ if (value.accessorGetter()) {
+ String getterName = WTF::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;
+ thisObj.putDirectNonIndexAccessor(vm, propertyName, accessor, attributesForStructure(value.attributes()));
}
-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)
+bool setUpStaticFunctionSlot(ExecState* exec, const HashTableValue* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
{
ASSERT(thisObj->globalObject());
- ASSERT(entry->attributes() & Function);
- PropertyOffset offset = thisObj->getDirectOffset(exec->vm(), propertyName);
+ ASSERT(entry->attributes() & BuiltinOrFunctionOrAccessor);
+ VM& vm = exec->vm();
+ unsigned attributes;
+ bool isAccessor = entry->attributes() & Accessor;
+ PropertyOffset offset = thisObj->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())
return false;
-
- thisObj->putDirectNativeFunction(
- exec, thisObj->globalObject(), propertyName, entry->functionLength(),
- entry->function(), entry->intrinsic(), entry->attributes());
- offset = thisObj->getDirectOffset(exec->vm(), propertyName);
+
+ if (entry->attributes() & Builtin)
+ thisObj->putDirectBuiltinFunction(vm, thisObj->globalObject(), propertyName, entry->builtinGenerator()(vm), attributesForStructure(entry->attributes()));
+ else if (entry->attributes() & Function) {
+ thisObj->putDirectNativeFunction(
+ vm, thisObj->globalObject(), propertyName, entry->functionLength(),
+ entry->function(), entry->intrinsic(), attributesForStructure(entry->attributes()));
+ } else {
+ ASSERT(isAccessor);
+ reifyStaticAccessor(vm, *entry, *thisObj, propertyName);
+ }
+
+ offset = thisObj->getDirectOffset(vm, propertyName, attributes);
ASSERT(isValidOffset(offset));
}
- slot.setValue(thisObj, thisObj->getDirect(offset), offset);
+ if (isAccessor)
+ slot.setCacheableGetterSlot(thisObj, attributes, jsCast<GetterSetter*>(thisObj->getDirect(offset)), offset);
+ else
+ slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset);
return true;
}