Changeset 31147 in webkit for trunk/JavaScriptCore/kjs/lexer.cpp


Ignore:
Timestamp:
Mar 18, 2008, 9:23:21 PM (17 years ago)
Author:
Darin Adler
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r30942 r31147  
    524524#endif
    525525
    526   if (state != Identifier && eatNextIdentifier)
     526  if (state != Identifier)
    527527    eatNextIdentifier = false;
    528528
     
    537537    break;
    538538  case Other:
    539     if(token == '}' || token == ';') {
     539    if (token == '}' || token == ';')
    540540      delimited = true;
     541    break;
     542  case Identifier:
     543    // Apply anonymous-function hack below (eat the identifier).
     544    if (eatNextIdentifier) {
     545      eatNextIdentifier = false;
     546      token = lex();
     547      break;
    541548    }
     549    kjsyylval.ident = makeIdentifier(m_buffer16);
     550    token = IDENT;
    542551    break;
    543552  case IdentifierOrKeyword:
    544     if ((token = Lookup::find(&mainTable, m_buffer16.data(), m_buffer16.size())) < 0) {
    545   case Identifier:
    546       // Lookup for keyword failed, means this is an identifier
    547       // Apply anonymous-function hack below (eat the identifier)
    548       if (eatNextIdentifier) {
    549         eatNextIdentifier = false;
    550         token = lex();
    551         break;
    552       }
    553       kjsyylval.ident = makeIdentifier(m_buffer16);
     553    kjsyylval.ident = makeIdentifier(m_buffer16);
     554    if ((token = mainTable.value(*kjsyylval.ident)) < 0) {
     555      // Lookup for keyword failed, means this is an identifier.
    554556      token = IDENT;
    555557      break;
    556558    }
    557 
    558     eatNextIdentifier = false;
    559     // Hack for "f = function somename() { ... }", too hard to get into the grammar
    560     if (token == FUNCTION && lastToken == '=' )
    561       eatNextIdentifier = true;
    562 
    563     if (token == CONTINUE || token == BREAK ||
    564         token == RETURN || token == THROW)
     559    // Hack for "f = function somename() { ... }"; too hard to get into the grammar.
     560    eatNextIdentifier = token == FUNCTION && lastToken == '=';
     561    if (token == CONTINUE || token == BREAK || token == RETURN || token == THROW)
    565562      restrKeyword = true;
    566563    break;
Note: See TracChangeset for help on using the changeset viewer.