2 * Copyright (C) 2008, 2012 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 "Operations.h"
29 void HashTable::createTable(VM
* vm
) 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(vm
, 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
, values
[i
].intrinsic
);
55 void HashTable::deleteTable() const
58 int max
= compactSize
;
59 for (int i
= 0; i
!= max
; ++i
) {
60 if (StringImpl
* key
= table
[i
].key())
68 bool setUpStaticFunctionSlot(ExecState
* exec
, const HashEntry
* entry
, JSObject
* thisObj
, PropertyName propertyName
, PropertySlot
& slot
)
70 ASSERT(thisObj
->globalObject());
71 ASSERT(entry
->attributes() & Function
);
72 PropertyOffset offset
= thisObj
->getDirectOffset(exec
->vm(), propertyName
);
74 if (!isValidOffset(offset
)) {
75 // If a property is ever deleted from an object with a static table, then we reify
76 // all static functions at that time - after this we shouldn't be re-adding anything.
77 if (thisObj
->staticFunctionsReified())
80 thisObj
->putDirectNativeFunction(
81 exec
, thisObj
->globalObject(), propertyName
, entry
->functionLength(),
82 entry
->function(), entry
->intrinsic(), entry
->attributes());
83 offset
= thisObj
->getDirectOffset(exec
->vm(), propertyName
);
84 ASSERT(isValidOffset(offset
));
87 slot
.setValue(thisObj
, thisObj
->getDirect(offset
), offset
);