2 * Copyright (C) 2008 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "Executable.h"
24 #include "JSFunction.h"
25 #include "PrototypeFunction.h"
29 void HashTable::createTable(JSGlobalData* globalData) const
32 int linkIndex = compactHashSizeMask + 1;
33 HashEntry* entries = new HashEntry[compactSize];
34 for (int i = 0; i < compactSize; ++i)
36 for (int i = 0; values[i].key; ++i) {
37 StringImpl* identifier = Identifier::add(globalData, values[i].key).leakRef();
38 int hashIndex = identifier->existingHash() & compactHashSizeMask;
39 HashEntry* entry = &entries[hashIndex];
42 while (entry->next()) {
43 entry = entry->next();
45 ASSERT(linkIndex < compactSize);
46 entry->setNext(&entries[linkIndex++]);
47 entry = entry->next();
50 entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2
59 void HashTable::deleteTable() const
62 int max = compactSize;
63 for (int i = 0; i != max; ++i) {
64 if (StringImpl* key = table[i].key())
72 void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
74 ASSERT(thisObj->structure()->anonymousSlotCount() > 0);
75 ASSERT(thisObj->getAnonymousValue(0).isCell() && asObject(thisObj->getAnonymousValue(0).asCell())->isGlobalObject());
76 ASSERT(entry->attributes() & Function);
77 JSValue* location = thisObj->getDirectLocation(propertyName);
80 NativeFunctionWrapper* function;
81 JSGlobalObject* globalObject = asGlobalObject(thisObj->getAnonymousValue(0).asCell());
82 #if ENABLE(JIT) && ENABLE(JIT_OPTIMIZE_NATIVE_CALL)
83 if (entry->generator())
84 function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
87 function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
89 thisObj->putDirectFunction(propertyName, function, entry->attributes());
90 location = thisObj->getDirectLocation(propertyName);
93 slot.setValueSlot(thisObj, location, thisObj->offsetForLocation(location));