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"
28
void HashTable::createTable(JSGlobalData* globalData) const
31
int linkIndex = compactHashSizeMask + 1;
32
HashEntry* entries = new HashEntry[compactSize];
33
for (int i = 0; i < compactSize; ++i)
35
for (int i = 0; values[i].key; ++i) {
36
StringImpl* identifier = Identifier::add(globalData, values[i].key).leakRef();
37
int hashIndex = identifier->existingHash() & compactHashSizeMask;
38
HashEntry* entry = &entries[hashIndex];
41
while (entry->next()) {
42
entry = entry->next();
44
ASSERT(linkIndex < compactSize);
45
entry->setNext(&entries[linkIndex++]);
46
entry = entry->next();
49
entry->initialize(identifier, values[i].attributes, values[i].value1, values[i].value2, values[i].intrinsic);
54
void HashTable::deleteTable() const
57
int max = compactSize;
58
for (int i = 0; i != max; ++i) {
59
if (StringImpl* key = table[i].key())
67
bool setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
69
ASSERT(thisObj->globalObject());
70
ASSERT(entry->attributes() & Function);
71
WriteBarrierBase<Unknown>* location = thisObj->getDirectLocation(exec->globalData(), propertyName);
74
// If a property is ever deleted from an object with a static table, then we reify
75
// all static functions at that time - after this we shouldn't be re-adding anything.
76
if (thisObj->staticFunctionsReified())
79
StringImpl* name = propertyName.publicName();
82
JSFunction* function = JSFunction::create(exec, thisObj->globalObject(), entry->functionLength(), name, entry->function(), entry->intrinsic());
83
thisObj->putDirect(exec->globalData(), propertyName, function, entry->attributes());
84
location = thisObj->getDirectLocation(exec->globalData(), propertyName);
87
slot.setValue(thisObj, location->get(), thisObj->offsetForLocation(location));