source: webkit/trunk/JavaScriptCore/kjs/lookup.cpp@ 31147

Last change on this file since 31147 was 31147, checked in by Darin Adler, 17 years ago

JavaScriptCore:

2008-03-18 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • Speed up JavaScript built-in properties by changing the hash table to take advantage of the identifier objects

5% speedup for Acid3 test 26

  • JavaScriptCore.exp: Updated.
  • kjs/create_hash_table: Compute size of hash table large enough so that there are no collisions, but don't generate the hash table.
  • kjs/identifier.h: Made the add function that returns a PassRefPtr public.
  • kjs/lexer.cpp: (KJS::Lexer::lex): Updated for change to HashTable interface.
  • kjs/lookup.cpp: (KJS::HashTable::changeKeysToIdentifiers): Added. Finds the identifier for each property so the equality comparision can be done with pointer comparision.
  • kjs/lookup.h: Made the key be a union of char* with UString::Rep* so it can hold identifiers. Added a keysAreIdentifiers flag to the HashTable. Changed the Lookup functions to be member functions of HashTable instead.
  • kjs/object.cpp: (KJS::JSObject::deleteProperty): Update for change to HashTable. (KJS::JSObject::findPropertyHashEntry): Ditto. (KJS::JSObject::getPropertyAttributes): Ditto. (KJS::JSObject::getPropertyNames): Ditto.

WebCore:

2008-03-18 Darin Adler <Darin Adler>

Reviewed by Maciej.

  • Speed up JavaScript built-in properties by changing the hash table to take advantage of the identifier objects

5% speedup for Acid3 test 26

  • bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::getOwnPropertySlot): Update for change to HashTable. (WebCore::JSDOMWindowBase::put): Ditto.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::customGetOwnPropertySlot): Ditto.
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::JSHTMLInputElementBase::getOwnPropertySlot): Ditto.
  • bindings/js/JSHistoryCustom.cpp: (WebCore::JSHistory::customGetOwnPropertySlot): Ditto.
  • bindings/js/JSLocation.cpp: (WebCore::JSLocation::customGetOwnPropertySlot): Ditto. (WebCore::JSLocation::put): Ditto.
  • bindings/js/kjs_binding.cpp: (WebCore::nonCachingStaticFunctionGetter): Ditto.
  • bindings/scripts/CodeGeneratorJS.pm: Same changes as in the create_hash_table script.
  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/*
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 *
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.
8 *
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.
13 *
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
17 *
18 */
19
20#include "config.h"
21#include "lookup.h"
22
23namespace KJS {
24
25void HashTable::createTable() const
26{
27 ASSERT(!table);
28 HashEntry* entries = new HashEntry[hashSizeMask + 1];
29 for (int i = 0; i <= hashSizeMask; ++i)
30 entries[i].key = 0;
31 for (int i = 0; values[i].key; ++i) {
32 UString::Rep* identifier = Identifier::add(values[i].key).releaseRef();
33 int hashIndex = identifier->computedHash() & hashSizeMask;
34 ASSERT(!entries[hashIndex].key);
35 entries[hashIndex].key = identifier;
36 entries[hashIndex].integerValue = values[i].value;
37 entries[hashIndex].attributes = values[i].attributes;
38 entries[hashIndex].length = values[i].length;
39 }
40 table = entries;
41}
42
43}
Note: See TracBrowser for help on using the repository browser.