Changeset 36977 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 26, 2008, 7:36:15 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-09-26 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Patch for https://bugs.webkit.org/show_bug.cgi?id=21152
Speedup static property get/put

Convert getting/setting static property values to use static functions
instead of storing an integer and switching in getValueProperty/putValueProperty.

  • kjs/JSObject.cpp: (JSC::JSObject::deleteProperty): (JSC::JSObject::getPropertyAttributes):
  • kjs/MathObject.cpp: (JSC::MathObject::getOwnPropertySlot):
  • kjs/NumberConstructor.cpp: (JSC::numberConstructorNaNValue): (JSC::numberConstructorNegInfinity): (JSC::numberConstructorPosInfinity): (JSC::numberConstructorMaxValue): (JSC::numberConstructorMinValue):
  • kjs/PropertySlot.h: (JSC::PropertySlot::):
  • kjs/RegExpConstructor.cpp: (JSC::regExpConstructorDollar1): (JSC::regExpConstructorDollar2): (JSC::regExpConstructorDollar3): (JSC::regExpConstructorDollar4): (JSC::regExpConstructorDollar5): (JSC::regExpConstructorDollar6): (JSC::regExpConstructorDollar7): (JSC::regExpConstructorDollar8): (JSC::regExpConstructorDollar9): (JSC::regExpConstructorInput): (JSC::regExpConstructorMultiline): (JSC::regExpConstructorLastMatch): (JSC::regExpConstructorLastParen): (JSC::regExpConstructorLeftContext): (JSC::regExpConstructorRightContext): (JSC::setRegExpConstructorInput): (JSC::setRegExpConstructorMultiline): (JSC::RegExpConstructor::setInput): (JSC::RegExpConstructor::setMultiline): (JSC::RegExpConstructor::multiline):
  • kjs/RegExpConstructor.h:
  • kjs/RegExpObject.cpp: (JSC::regExpObjectGlobal): (JSC::regExpObjectIgnoreCase): (JSC::regExpObjectMultiline): (JSC::regExpObjectSource): (JSC::regExpObjectLastIndex): (JSC::setRegExpObjectLastIndex):
  • kjs/RegExpObject.h: (JSC::RegExpObject::setLastIndex): (JSC::RegExpObject::lastIndex): (JSC::RegExpObject::RegExpObjectData::RegExpObjectData):
  • kjs/StructureID.cpp: (JSC::StructureID::getEnumerablePropertyNames):
  • kjs/create_hash_table:
  • kjs/lexer.cpp: (JSC::Lexer::lex):
  • kjs/lookup.cpp: (JSC::HashTable::createTable): (JSC::HashTable::deleteTable): (JSC::setUpStaticFunctionSlot):
  • kjs/lookup.h: (JSC::HashEntry::initialize): (JSC::HashEntry::setKey): (JSC::HashEntry::key): (JSC::HashEntry::attributes): (JSC::HashEntry::function): (JSC::HashEntry::functionLength): (JSC::HashEntry::propertyGetter): (JSC::HashEntry::propertyPutter): (JSC::HashEntry::lexerValue): (JSC::HashEntry::): (JSC::HashTable::entry): (JSC::getStaticPropertySlot): (JSC::getStaticValueSlot): (JSC::lookupPut):

WebCore:

2008-09-26 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Patch for https://bugs.webkit.org/show_bug.cgi?id=21152
Speedup static property get/put

  • DerivedSources.make:
  • GNUmakefile.am:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMBinding.cpp:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::getDOMConstructor): (WebCore::jsDOMWindowBaseCrypto): (WebCore::jsDOMWindowBaseEvent): (WebCore::jsDOMWindowBaseImage): (WebCore::jsDOMWindowBaseMessageChannel): (WebCore::jsDOMWindowBaseOption): (WebCore::jsDOMWindowBaseXMLHttpRequest): (WebCore::jsDOMWindowBaseAudio): (WebCore::jsDOMWindowBaseXSLTProcessor): (WebCore::jsDOMWindowBaseOnabort): (WebCore::jsDOMWindowBaseOnblur): (WebCore::jsDOMWindowBaseOnchange): (WebCore::jsDOMWindowBaseOnclick): (WebCore::jsDOMWindowBaseOndblclick): (WebCore::jsDOMWindowBaseOnerror): (WebCore::jsDOMWindowBaseOnfocus): (WebCore::jsDOMWindowBaseOnkeydown): (WebCore::jsDOMWindowBaseOnkeypress): (WebCore::jsDOMWindowBaseOnkeyup): (WebCore::jsDOMWindowBaseOnload): (WebCore::jsDOMWindowBaseOnmousedown): (WebCore::jsDOMWindowBaseOnmousemove): (WebCore::jsDOMWindowBaseOnmouseout): (WebCore::jsDOMWindowBaseOnmouseover): (WebCore::jsDOMWindowBaseOnmouseup): (WebCore::jsDOMWindowBaseOnMouseWheel): (WebCore::jsDOMWindowBaseOnreset): (WebCore::jsDOMWindowBaseOnresize): (WebCore::jsDOMWindowBaseOnscroll): (WebCore::jsDOMWindowBaseOnsearch): (WebCore::jsDOMWindowBaseOnselect): (WebCore::jsDOMWindowBaseOnsubmit): (WebCore::jsDOMWindowBaseOnbeforeunload): (WebCore::jsDOMWindowBaseOnunload): (WebCore::jsDOMWindowBaseOnWebKitAnimationStart): (WebCore::jsDOMWindowBaseOnWebKitAnimationIteration): (WebCore::jsDOMWindowBaseOnWebKitAnimationEnd): (WebCore::jsDOMWindowBaseOnWebKitTransitionEnd): (WebCore::JSDOMWindowBase::getOwnPropertySlot): (WebCore::JSDOMWindowBase::put): (WebCore::setJSDOMWindowBaseOnabort): (WebCore::setJSDOMWindowBaseOnblur): (WebCore::setJSDOMWindowBaseOnchange): (WebCore::setJSDOMWindowBaseOnclick): (WebCore::setJSDOMWindowBaseOndblclick): (WebCore::setJSDOMWindowBaseOnerror): (WebCore::setJSDOMWindowBaseOnfocus): (WebCore::setJSDOMWindowBaseOnkeydown): (WebCore::setJSDOMWindowBaseOnkeypress): (WebCore::setJSDOMWindowBaseOnkeyup): (WebCore::setJSDOMWindowBaseOnload): (WebCore::setJSDOMWindowBaseOnmousedown): (WebCore::setJSDOMWindowBaseOnmousemove): (WebCore::setJSDOMWindowBaseOnmouseout): (WebCore::setJSDOMWindowBaseOnmouseover): (WebCore::setJSDOMWindowBaseOnmouseup): (WebCore::setJSDOMWindowBaseOnMouseWheel): (WebCore::setJSDOMWindowBaseOnreset): (WebCore::setJSDOMWindowBaseOnresize): (WebCore::setJSDOMWindowBaseOnscroll): (WebCore::setJSDOMWindowBaseOnsearch): (WebCore::setJSDOMWindowBaseOnselect): (WebCore::setJSDOMWindowBaseOnsubmit): (WebCore::setJSDOMWindowBaseOnbeforeunload): (WebCore::setJSDOMWindowBaseOnunload): (WebCore::setJSDOMWindowBaseOnWebKitAnimationStart): (WebCore::setJSDOMWindowBaseOnWebKitAnimationIteration): (WebCore::setJSDOMWindowBaseOnWebKitAnimationEnd): (WebCore::setJSDOMWindowBaseOnWebKitTransitionEnd): (WebCore::setJSDOMWindowBaseEvent): (WebCore::setJSDOMWindowBaseAudio): (WebCore::setJSDOMWindowBaseImage): (WebCore::setJSDOMWindowBaseMessageChannel): (WebCore::setJSDOMWindowBaseOption): (WebCore::setJSDOMWindowBaseXMLHttpRequest): (WebCore::setJSDOMWindowBaseXSLTProcessor):
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::nonCachingStaticCloseFunctionGetter): (WebCore::nonCachingStaticBlurFunctionGetter): (WebCore::nonCachingStaticFocusFunctionGetter): (WebCore::nonCachingStaticPostMessageFunctionGetter):
  • bindings/js/JSDOMWindowCustom.h: (WebCore::JSDOMWindow::customGetOwnPropertySlot):
  • bindings/js/JSEventTargetBase.cpp:
  • bindings/js/JSEventTargetBase.h: (WebCore::JSEventTargetBasePrototype::getOwnPropertySlot): (WebCore::JSEventTargetBasePrototype::classInfo):
  • bindings/js/JSEventTargetNode.cpp: (WebCore::): (WebCore::JSEventTargetNode::getOwnPropertySlot): (WebCore::JSEventTargetNode::put):
  • bindings/js/JSEventTargetNode.h: (WebCore::JSEventTargetNode::classInfo): (WebCore::JSEventTargetNode::prototypeClassName):
  • bindings/js/JSEventTargetSVGElementInstance.cpp: (WebCore::): (WebCore::JSEventTargetSVGElementInstance::getOwnPropertySlot): (WebCore::JSEventTargetSVGElementInstance::put):
  • bindings/js/JSEventTargetSVGElementInstance.h: (WebCore::JSEventTargetSVGElementInstance::classInfo): (WebCore::JSEventTargetSVGElementInstance::prototypeClassName):
  • bindings/js/JSHTMLInputElementCustom.cpp: (WebCore::JSHTMLInputElement::customGetOwnPropertySlot):
  • bindings/js/JSHistoryCustom.cpp: (WebCore::nonCachingStaticBackFunctionGetter): (WebCore::nonCachingStaticForwardFunctionGetter): (WebCore::nonCachingStaticGoFunctionGetter): (WebCore::JSHistory::customGetOwnPropertySlot):
  • bindings/js/JSLocationCustom.cpp: (WebCore::nonCachingStaticReplaceFunctionGetter): (WebCore::nonCachingStaticReloadFunctionGetter): (WebCore::nonCachingStaticAssignFunctionGetter): (WebCore::JSLocation::customGetOwnPropertySlot): (WebCore::JSLocation::customPut):
  • bindings/scripts/CodeGeneratorJS.pm:
Location:
trunk/JavaScriptCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36976 r36977  
     12008-09-26  Sam Weinig  <[email protected]>
     2
     3        Reviewed by Darin Adler.
     4
     5        Patch for https://bugs.webkit.org/show_bug.cgi?id=21152
     6        Speedup static property get/put
     7
     8        Convert getting/setting static property values to use static functions
     9        instead of storing an integer and switching in getValueProperty/putValueProperty.
     10
     11        * kjs/JSObject.cpp:
     12        (JSC::JSObject::deleteProperty):
     13        (JSC::JSObject::getPropertyAttributes):
     14        * kjs/MathObject.cpp:
     15        (JSC::MathObject::getOwnPropertySlot):
     16        * kjs/NumberConstructor.cpp:
     17        (JSC::numberConstructorNaNValue):
     18        (JSC::numberConstructorNegInfinity):
     19        (JSC::numberConstructorPosInfinity):
     20        (JSC::numberConstructorMaxValue):
     21        (JSC::numberConstructorMinValue):
     22        * kjs/PropertySlot.h:
     23        (JSC::PropertySlot::):
     24        * kjs/RegExpConstructor.cpp:
     25        (JSC::regExpConstructorDollar1):
     26        (JSC::regExpConstructorDollar2):
     27        (JSC::regExpConstructorDollar3):
     28        (JSC::regExpConstructorDollar4):
     29        (JSC::regExpConstructorDollar5):
     30        (JSC::regExpConstructorDollar6):
     31        (JSC::regExpConstructorDollar7):
     32        (JSC::regExpConstructorDollar8):
     33        (JSC::regExpConstructorDollar9):
     34        (JSC::regExpConstructorInput):
     35        (JSC::regExpConstructorMultiline):
     36        (JSC::regExpConstructorLastMatch):
     37        (JSC::regExpConstructorLastParen):
     38        (JSC::regExpConstructorLeftContext):
     39        (JSC::regExpConstructorRightContext):
     40        (JSC::setRegExpConstructorInput):
     41        (JSC::setRegExpConstructorMultiline):
     42        (JSC::RegExpConstructor::setInput):
     43        (JSC::RegExpConstructor::setMultiline):
     44        (JSC::RegExpConstructor::multiline):
     45        * kjs/RegExpConstructor.h:
     46        * kjs/RegExpObject.cpp:
     47        (JSC::regExpObjectGlobal):
     48        (JSC::regExpObjectIgnoreCase):
     49        (JSC::regExpObjectMultiline):
     50        (JSC::regExpObjectSource):
     51        (JSC::regExpObjectLastIndex):
     52        (JSC::setRegExpObjectLastIndex):
     53        * kjs/RegExpObject.h:
     54        (JSC::RegExpObject::setLastIndex):
     55        (JSC::RegExpObject::lastIndex):
     56        (JSC::RegExpObject::RegExpObjectData::RegExpObjectData):
     57        * kjs/StructureID.cpp:
     58        (JSC::StructureID::getEnumerablePropertyNames):
     59        * kjs/create_hash_table:
     60        * kjs/lexer.cpp:
     61        (JSC::Lexer::lex):
     62        * kjs/lookup.cpp:
     63        (JSC::HashTable::createTable):
     64        (JSC::HashTable::deleteTable):
     65        (JSC::setUpStaticFunctionSlot):
     66        * kjs/lookup.h:
     67        (JSC::HashEntry::initialize):
     68        (JSC::HashEntry::setKey):
     69        (JSC::HashEntry::key):
     70        (JSC::HashEntry::attributes):
     71        (JSC::HashEntry::function):
     72        (JSC::HashEntry::functionLength):
     73        (JSC::HashEntry::propertyGetter):
     74        (JSC::HashEntry::propertyPutter):
     75        (JSC::HashEntry::lexerValue):
     76        (JSC::HashEntry::):
     77        (JSC::HashTable::entry):
     78        (JSC::getStaticPropertySlot):
     79        (JSC::getStaticValueSlot):
     80        (JSC::lookupPut):
     81
    1822008-09-26  Gavin Barraclough  <[email protected]>
    283
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r36766 r36977  
    210210    // Look in the static hashtable of properties
    211211    const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
    212     if (entry && entry->attributes & DontDelete)
     212    if (entry && entry->attributes() & DontDelete)
    213213        return false; // this builtin property can't be deleted
    214214
     
    419419    const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
    420420    if (entry) {
    421         attributes = entry->attributes;
     421        attributes = entry->attributes();
    422422        return true;
    423423    }
  • trunk/JavaScriptCore/kjs/MathObject.cpp

    r36726 r36977  
    106106        return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    107107
    108     ASSERT(entry->attributes & Function);
     108    ASSERT(entry->attributes() & Function);
    109109    setUpStaticFunctionSlot(exec, entry, this, propertyName, slot);
    110110    return true;
  • trunk/JavaScriptCore/kjs/NumberConstructor.cpp

    r36726 r36977  
    2222#include "config.h"
    2323#include "NumberConstructor.h"
    24 #include "NumberConstructor.lut.h"
    2524
    2625#include "NumberObject.h"
     
    3130ASSERT_CLASS_FITS_IN_CELL(NumberConstructor);
    3231
     32static JSValue* numberConstructorNaNValue(ExecState*, const Identifier&, const PropertySlot&);
     33static JSValue* numberConstructorNegInfinity(ExecState*, const Identifier&, const PropertySlot&);
     34static JSValue* numberConstructorPosInfinity(ExecState*, const Identifier&, const PropertySlot&);
     35static JSValue* numberConstructorMaxValue(ExecState*, const Identifier&, const PropertySlot&);
     36static JSValue* numberConstructorMinValue(ExecState*, const Identifier&, const PropertySlot&);
     37
     38} // namespace JSC
     39
     40#include "NumberConstructor.lut.h"
     41
     42namespace JSC {
     43
    3344const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable };
    3445
    35 /* Source for NumberObject.lut.h
     46/* Source for NumberConstructor.lut.h
    3647@begin numberTable
    37   NaN                   NumberConstructor::NaNValue       DontEnum|DontDelete|ReadOnly
    38   NEGATIVE_INFINITY     NumberConstructor::NegInfinity    DontEnum|DontDelete|ReadOnly
    39   POSITIVE_INFINITY     NumberConstructor::PosInfinity    DontEnum|DontDelete|ReadOnly
    40   MAX_VALUE             NumberConstructor::MaxValue       DontEnum|DontDelete|ReadOnly
    41   MIN_VALUE             NumberConstructor::MinValue       DontEnum|DontDelete|ReadOnly
     48   NaN                   numberConstructorNaNValue       DontEnum|DontDelete|ReadOnly
     49   NEGATIVE_INFINITY     numberConstructorNegInfinity    DontEnum|DontDelete|ReadOnly
     50   POSITIVE_INFINITY     numberConstructorPosInfinity    DontEnum|DontDelete|ReadOnly
     51   MAX_VALUE             numberConstructorMaxValue       DontEnum|DontDelete|ReadOnly
     52   MIN_VALUE             numberConstructorMinValue       DontEnum|DontDelete|ReadOnly
    4253@end
    4354*/
     55
    4456NumberConstructor::NumberConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NumberPrototype* numberPrototype)
    4557    : InternalFunction(exec, structure, Identifier(exec, numberPrototype->info.className))
     
    5769}
    5870
    59 JSValue* NumberConstructor::getValueProperty(ExecState* exec, int token) const
     71JSValue* numberConstructorNaNValue(ExecState* exec, const Identifier&, const PropertySlot&)
    6072{
    61     // ECMA 15.7.3
    62     switch (token) {
    63         case NaNValue:
    64             return jsNaN(exec);
    65         case NegInfinity:
    66             return jsNumberCell(exec, -Inf);
    67         case PosInfinity:
    68             return jsNumberCell(exec, Inf);
    69         case MaxValue:
    70             return jsNumberCell(exec, 1.7976931348623157E+308);
    71         case MinValue:
    72             return jsNumberCell(exec, 5E-324);
    73     }
    74     ASSERT_NOT_REACHED();
    75     return jsNull();
     73    return jsNaN(exec);
     74}
     75
     76JSValue* numberConstructorNegInfinity(ExecState* exec, const Identifier&, const PropertySlot&)
     77{
     78    return jsNumberCell(exec, -Inf);
     79}
     80
     81JSValue* numberConstructorPosInfinity(ExecState* exec, const Identifier&, const PropertySlot&)
     82{
     83    return jsNumberCell(exec, Inf);
     84}
     85
     86JSValue* numberConstructorMaxValue(ExecState* exec, const Identifier&, const PropertySlot&)
     87{
     88    return jsNumberCell(exec, 1.7976931348623157E+308);
     89}
     90
     91JSValue* numberConstructorMinValue(ExecState* exec, const Identifier&, const PropertySlot&)
     92{
     93    return jsNumberCell(exec, 5E-324);
    7694}
    7795
  • trunk/JavaScriptCore/kjs/PropertySlot.h

    r36264 r36977  
    3232    class ExecState;
    3333    class JSObject;
    34     struct HashEntry;
    3534
    3635#define JSC_VALUE_SLOT_MARKER 0
     
    132131        }
    133132
    134         void setStaticEntry(JSValue* slotBase, const HashEntry* staticEntry, GetValueFunc getValue)
    135         {
    136             ASSERT(slotBase);
    137             ASSERT(staticEntry);
    138             ASSERT(getValue);
    139             m_getValue = getValue;
    140             m_slotBase = slotBase;
    141             m_data.staticEntry = staticEntry;
    142         }
    143 
    144133        void setCustom(JSValue* slotBase, GetValueFunc getValue)
    145134        {
     
    199188        }
    200189
    201         const HashEntry* staticEntry() const { return m_data.staticEntry; }
    202190        unsigned index() const { return m_data.index; }
    203191
     
    212200            JSValue** valueSlot;
    213201            Register* registerSlot;
    214             const HashEntry* staticEntry;
    215202            unsigned index;
    216203        } m_data;
  • trunk/JavaScriptCore/kjs/RegExpConstructor.cpp

    r36784 r36977  
    2121#include "config.h"
    2222#include "RegExpConstructor.h"
    23 #include "RegExpConstructor.lut.h"
    2423
    2524#include "ArrayPrototype.h"
     
    3534namespace JSC {
    3635
     36static JSValue* regExpConstructorInput(ExecState*, const Identifier&, const PropertySlot&);
     37static JSValue* regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot&);
     38static JSValue* regExpConstructorLastMatch(ExecState*, const Identifier&, const PropertySlot&);
     39static JSValue* regExpConstructorLastParen(ExecState*, const Identifier&, const PropertySlot&);
     40static JSValue* regExpConstructorLeftContext(ExecState*, const Identifier&, const PropertySlot&);
     41static JSValue* regExpConstructorRightContext(ExecState*, const Identifier&, const PropertySlot&);
     42static JSValue* regExpConstructorDollar1(ExecState*, const Identifier&, const PropertySlot&);
     43static JSValue* regExpConstructorDollar2(ExecState*, const Identifier&, const PropertySlot&);
     44static JSValue* regExpConstructorDollar3(ExecState*, const Identifier&, const PropertySlot&);
     45static JSValue* regExpConstructorDollar4(ExecState*, const Identifier&, const PropertySlot&);
     46static JSValue* regExpConstructorDollar5(ExecState*, const Identifier&, const PropertySlot&);
     47static JSValue* regExpConstructorDollar6(ExecState*, const Identifier&, const PropertySlot&);
     48static JSValue* regExpConstructorDollar7(ExecState*, const Identifier&, const PropertySlot&);
     49static JSValue* regExpConstructorDollar8(ExecState*, const Identifier&, const PropertySlot&);
     50static JSValue* regExpConstructorDollar9(ExecState*, const Identifier&, const PropertySlot&);
     51
     52static void setRegExpConstructorInput(ExecState*, JSObject*, JSValue*);
     53static void setRegExpConstructorMultiline(ExecState*, JSObject*, JSValue*);
     54
     55} // namespace JSC
     56
     57#include "RegExpConstructor.lut.h"
     58
     59namespace JSC {
     60
    3761ASSERT_CLASS_FITS_IN_CELL(RegExpConstructor);
    3862
     
    4165/* Source for RegExpConstructor.lut.h
    4266@begin regExpConstructorTable
    43     input           RegExpConstructor::Input          None
    44     $_              RegExpConstructor::Input          DontEnum
    45     multiline       RegExpConstructor::Multiline      None
    46     $*              RegExpConstructor::Multiline      DontEnum
    47     lastMatch       RegExpConstructor::LastMatch      DontDelete|ReadOnly
    48     $&              RegExpConstructor::LastMatch      DontDelete|ReadOnly|DontEnum
    49     lastParen       RegExpConstructor::LastParen      DontDelete|ReadOnly
    50     $+              RegExpConstructor::LastParen      DontDelete|ReadOnly|DontEnum
    51     leftContext     RegExpConstructor::LeftContext    DontDelete|ReadOnly
    52     $`              RegExpConstructor::LeftContext    DontDelete|ReadOnly|DontEnum
    53     rightContext    RegExpConstructor::RightContext   DontDelete|ReadOnly
    54     $'              RegExpConstructor::RightContext   DontDelete|ReadOnly|DontEnum
    55     $1              RegExpConstructor::Dollar1        DontDelete|ReadOnly
    56     $2              RegExpConstructor::Dollar2        DontDelete|ReadOnly
    57     $3              RegExpConstructor::Dollar3        DontDelete|ReadOnly
    58     $4              RegExpConstructor::Dollar4        DontDelete|ReadOnly
    59     $5              RegExpConstructor::Dollar5        DontDelete|ReadOnly
    60     $6              RegExpConstructor::Dollar6        DontDelete|ReadOnly
    61     $7              RegExpConstructor::Dollar7        DontDelete|ReadOnly
    62     $8              RegExpConstructor::Dollar8        DontDelete|ReadOnly
    63     $9              RegExpConstructor::Dollar9        DontDelete|ReadOnly
     67    input           regExpConstructorInput          None
     68    $_              regExpConstructorInput          DontEnum
     69    multiline       regExpConstructorMultiline      None
     70    $*              regExpConstructorMultiline      DontEnum
     71    lastMatch       regExpConstructorLastMatch      DontDelete|ReadOnly
     72    $&              regExpConstructorLastMatch      DontDelete|ReadOnly|DontEnum
     73    lastParen       regExpConstructorLastParen      DontDelete|ReadOnly
     74    $+              regExpConstructorLastParen      DontDelete|ReadOnly|DontEnum
     75    leftContext     regExpConstructorLeftContext    DontDelete|ReadOnly
     76    $`              regExpConstructorLeftContext    DontDelete|ReadOnly|DontEnum
     77    rightContext    regExpConstructorRightContext   DontDelete|ReadOnly
     78    $'              regExpConstructorRightContext   DontDelete|ReadOnly|DontEnum
     79    $1              regExpConstructorDollar1        DontDelete|ReadOnly
     80    $2              regExpConstructorDollar2        DontDelete|ReadOnly
     81    $3              regExpConstructorDollar3        DontDelete|ReadOnly
     82    $4              regExpConstructorDollar4        DontDelete|ReadOnly
     83    $5              regExpConstructorDollar5        DontDelete|ReadOnly
     84    $6              regExpConstructorDollar6        DontDelete|ReadOnly
     85    $7              regExpConstructorDollar7        DontDelete|ReadOnly
     86    $8              regExpConstructorDollar8        DontDelete|ReadOnly
     87    $9              regExpConstructorDollar9        DontDelete|ReadOnly
    6488@end
    6589*/
     
    203227}
    204228
    205 JSValue* RegExpConstructor::getValueProperty(ExecState* exec, int token) const
    206 {
    207     switch (token) {
    208         case Dollar1:
    209             return getBackref(exec, 1);
    210         case Dollar2:
    211             return getBackref(exec, 2);
    212         case Dollar3:
    213             return getBackref(exec, 3);
    214         case Dollar4:
    215             return getBackref(exec, 4);
    216         case Dollar5:
    217             return getBackref(exec, 5);
    218         case Dollar6:
    219             return getBackref(exec, 6);
    220         case Dollar7:
    221             return getBackref(exec, 7);
    222         case Dollar8:
    223             return getBackref(exec, 8);
    224         case Dollar9:
    225             return getBackref(exec, 9);
    226         case Input:
    227             return jsString(exec, d->input);
    228         case Multiline:
    229             return jsBoolean(d->multiline);
    230         case LastMatch:
    231             return getBackref(exec, 0);
    232         case LastParen:
    233             return getLastParen(exec);
    234         case LeftContext:
    235             return getLeftContext(exec);
    236         case RightContext:
    237             return getRightContext(exec);
    238         default:
    239             ASSERT_NOT_REACHED();
    240     }
    241 
    242     return jsEmptyString(exec);
     229JSValue* regExpConstructorDollar1(ExecState* exec, const Identifier&, const PropertySlot& slot)
     230{
     231    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 1);
     232}
     233
     234JSValue* regExpConstructorDollar2(ExecState* exec, const Identifier&, const PropertySlot& slot)
     235{
     236    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 2);
     237}
     238
     239JSValue* regExpConstructorDollar3(ExecState* exec, const Identifier&, const PropertySlot& slot)
     240{
     241    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 3);
     242}
     243
     244JSValue* regExpConstructorDollar4(ExecState* exec, const Identifier&, const PropertySlot& slot)
     245{
     246    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 4);
     247}
     248
     249JSValue* regExpConstructorDollar5(ExecState* exec, const Identifier&, const PropertySlot& slot)
     250{
     251    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 5);
     252}
     253
     254JSValue* regExpConstructorDollar6(ExecState* exec, const Identifier&, const PropertySlot& slot)
     255{
     256    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 6);
     257}
     258
     259JSValue* regExpConstructorDollar7(ExecState* exec, const Identifier&, const PropertySlot& slot)
     260{
     261    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 7);
     262}
     263
     264JSValue* regExpConstructorDollar8(ExecState* exec, const Identifier&, const PropertySlot& slot)
     265{
     266    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 8);
     267}
     268
     269JSValue* regExpConstructorDollar9(ExecState* exec, const Identifier&, const PropertySlot& slot)
     270{
     271    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 9);
     272}
     273
     274JSValue* regExpConstructorInput(ExecState* exec, const Identifier&, const PropertySlot& slot)
     275{
     276    return jsString(exec, static_cast<RegExpConstructor*>(slot.slotBase())->input());
     277}
     278
     279JSValue* regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot& slot)
     280{
     281    return jsBoolean(static_cast<RegExpConstructor*>(slot.slotBase())->multiline());
     282}
     283
     284JSValue* regExpConstructorLastMatch(ExecState* exec, const Identifier&, const PropertySlot& slot)
     285{
     286    return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 0);
     287}
     288
     289JSValue* regExpConstructorLastParen(ExecState* exec, const Identifier&, const PropertySlot& slot)
     290{
     291    return static_cast<RegExpConstructor*>(slot.slotBase())->getLastParen(exec);
     292}
     293
     294JSValue* regExpConstructorLeftContext(ExecState* exec, const Identifier&, const PropertySlot& slot)
     295{
     296    return static_cast<RegExpConstructor*>(slot.slotBase())->getLeftContext(exec);
     297}
     298
     299JSValue* regExpConstructorRightContext(ExecState* exec, const Identifier&, const PropertySlot& slot)
     300{
     301    return static_cast<RegExpConstructor*>(slot.slotBase())->getRightContext(exec);
    243302}
    244303
     
    248307}
    249308
    250 void RegExpConstructor::putValueProperty(ExecState* exec, int token, JSValue* value)
    251 {
    252     switch (token) {
    253         case Input:
    254             d->input = value->toString(exec);
    255             break;
    256         case Multiline:
    257             d->multiline = value->toBoolean(exec);
    258             break;
    259         default:
    260             ASSERT_NOT_REACHED();
    261     }
     309void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue* value)
     310{
     311    static_cast<RegExpConstructor*>(baseObject)->setInput(value->toString(exec));
     312}
     313
     314void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value)
     315{
     316    static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean(exec));
    262317}
    263318 
     
    306361}
    307362
     363void RegExpConstructor::setInput(const UString& input)
     364{
     365    d->input = input;
     366}
     367
    308368const UString& RegExpConstructor::input() const
    309369{
     
    313373}
    314374
     375void RegExpConstructor::setMultiline(bool multiline)
     376{
     377    d->multiline = multiline;
     378}
     379
     380bool RegExpConstructor::multiline() const
     381{
     382    return d->multiline;
     383}
     384
    315385} // namespace JSC
  • trunk/JavaScriptCore/kjs/RegExpConstructor.h

    r36784 r36977  
    3333    class RegExpConstructor : public InternalFunction {
    3434    public:
    35         enum {
    36             Dollar1,
    37             Dollar2,
    38             Dollar3,
    39             Dollar4,
    40             Dollar5,
    41             Dollar6,
    42             Dollar7,
    43             Dollar8,
    44             Dollar9,
    45             Input,
    46             Multiline,
    47             LastMatch,
    48             LastParen,
    49             LeftContext,
    50             RightContext
    51         };
    52 
    5335        RegExpConstructor(ExecState*, PassRefPtr<StructureID>, RegExpPrototype*);
    5436
    5537        virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
    56         void putValueProperty(ExecState*, int token, JSValue*);
    5738        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    58         JSValue* getValueProperty(ExecState*, int token) const;
    5939
    6040        static const ClassInfo info;
     
    6242        void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0);
    6343        JSObject* arrayOfMatches(ExecState*) const;
     44
     45        void setInput(const UString&);
    6446        const UString& input() const;
     47
     48        void setMultiline(bool);
     49        bool multiline() const;
     50
     51        JSValue* getBackref(ExecState*, unsigned) const;
     52        JSValue* getLastParen(ExecState*) const;
     53        JSValue* getLeftContext(ExecState*) const;
     54        JSValue* getRightContext(ExecState*) const;
    6555
    6656    private:
     
    6959
    7060        virtual const ClassInfo* classInfo() const { return &info; }
    71 
    72         JSValue* getBackref(ExecState*, unsigned) const;
    73         JSValue* getLastParen(ExecState*) const;
    74         JSValue* getLeftContext(ExecState*) const;
    75         JSValue* getRightContext(ExecState*) const;
    7661
    7762        OwnPtr<RegExpConstructorPrivate> d;
  • trunk/JavaScriptCore/kjs/RegExpObject.cpp

    r36726 r36977  
    2121#include "config.h"
    2222#include "RegExpObject.h"
    23 #include "RegExpObject.lut.h"
    2423
    2524#include "JSArray.h"
     
    3130namespace JSC {
    3231
     32static JSValue* regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot&);
     33static JSValue* regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot&);
     34static JSValue* regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot&);
     35static JSValue* regExpObjectSource(ExecState*, const Identifier&, const PropertySlot&);
     36static JSValue* regExpObjectLastIndex(ExecState*, const Identifier&, const PropertySlot&);
     37static void setRegExpObjectLastIndex(ExecState*, JSObject*, JSValue*);
     38
     39} // namespace JSC
     40
     41#include "RegExpObject.lut.h"
     42
     43namespace JSC {
     44
    3345ASSERT_CLASS_FITS_IN_CELL(RegExpObject);
    3446
     
    3749/* Source for RegExpObject.lut.h
    3850@begin regExpTable
    39     global        RegExpObject::Global       DontDelete|ReadOnly|DontEnum
    40     ignoreCase    RegExpObject::IgnoreCase   DontDelete|ReadOnly|DontEnum
    41     multiline     RegExpObject::Multiline    DontDelete|ReadOnly|DontEnum
    42     source        RegExpObject::Source       DontDelete|ReadOnly|DontEnum
    43     lastIndex     RegExpObject::LastIndex    DontDelete|DontEnum
     51    global        regExpObjectGlobal       DontDelete|ReadOnly|DontEnum
     52    ignoreCase    regExpObjectIgnoreCase   DontDelete|ReadOnly|DontEnum
     53    multiline     regExpObjectMultiline    DontDelete|ReadOnly|DontEnum
     54    source        regExpObjectSource       DontDelete|ReadOnly|DontEnum
     55    lastIndex     regExpObjectLastIndex    DontDelete|DontEnum
    4456@end
    4557*/
     
    6072}
    6173
    62 JSValue* RegExpObject::getValueProperty(ExecState* exec, int token) const
     74JSValue* regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot& slot)
    6375{
    64     switch (token) {
    65         case Global:
    66             return jsBoolean(d->regExp->global());
    67         case IgnoreCase:
    68             return jsBoolean(d->regExp->ignoreCase());
    69         case Multiline:
    70             return jsBoolean(d->regExp->multiline());
    71         case Source:
    72             return jsString(exec, d->regExp->pattern());
    73         case LastIndex:
    74             return jsNumber(exec, d->lastIndex);
    75     }
    76    
    77     ASSERT_NOT_REACHED();
    78     return 0;
     76    return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->global());
     77}
     78
     79JSValue* regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot& slot)
     80{
     81    return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->ignoreCase());
     82}
     83 
     84JSValue* regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot& slot)
     85{           
     86    return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->multiline());
     87}
     88
     89JSValue* regExpObjectSource(ExecState* exec, const Identifier&, const PropertySlot& slot)
     90{
     91    return jsString(exec, static_cast<RegExpObject*>(slot.slotBase())->regExp()->pattern());
     92}
     93
     94JSValue* regExpObjectLastIndex(ExecState* exec, const Identifier&, const PropertySlot& slot)
     95{
     96    return jsNumber(exec, static_cast<RegExpObject*>(slot.slotBase())->lastIndex());
    7997}
    8098
     
    84102}
    85103
    86 void RegExpObject::putValueProperty(ExecState* exec, int token, JSValue* value)
     104void setRegExpObjectLastIndex(ExecState* exec, JSObject* baseObject, JSValue* value)
    87105{
    88     UNUSED_PARAM(token);
    89     ASSERT(token == LastIndex);
    90     d->lastIndex = value->toInteger(exec);
     106    static_cast<RegExpObject*>(baseObject)->setLastIndex(value->toInteger(exec));
    91107}
    92108
  • trunk/JavaScriptCore/kjs/RegExpObject.h

    r36726 r36977  
    2929    class RegExpObject : public JSObject {
    3030    public:
    31         enum { Global, IgnoreCase, Multiline, Source, LastIndex };
    32 
    3331        RegExpObject(PassRefPtr<StructureID>, PassRefPtr<RegExp>);
    3432        virtual ~RegExpObject();
     
    3735        RegExp* regExp() const { return d->regExp.get(); }
    3836
     37        void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }
     38        double lastIndex() const { return d->lastIndex; }
     39
    3940        JSValue* test(ExecState*, const ArgList&);
    4041        JSValue* exec(ExecState*, const ArgList&);
    4142
    42         bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    43         JSValue* getValueProperty(ExecState*, int token) const;
    44         void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
    45         void putValueProperty(ExecState*, int token, JSValue*);
     43        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     44        virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
    4645
    4746        virtual const ClassInfo* classInfo() const { return &info; }
    4847        static const ClassInfo info;
    49 
    50         void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }
    5148
    5249    private:
     
    5451
    5552        virtual CallType getCallData(CallData&);
    56        
     53
    5754        struct RegExpObjectData {
    58             RegExpObjectData(PassRefPtr<RegExp> regExp_, double lastIndex_)
    59                 : regExp(regExp_)
    60                 , lastIndex(lastIndex_)
     55            RegExpObjectData(PassRefPtr<RegExp> regExp, double lastIndex)
     56                : regExp(regExp)
     57                , lastIndex(lastIndex)
    6158            {
    6259            }
     
    6562            double lastIndex;
    6663        };
    67        
     64
    6865        OwnPtr<RegExpObjectData> d;
    6966    };
  • trunk/JavaScriptCore/kjs/StructureID.cpp

    r36789 r36977  
    7373        const HashEntry* entry = table->table;
    7474        for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
    75             if (entry->key && !(entry->attributes & DontEnum))
    76                 propertyNames.add(entry->key);
     75            if (entry->key() && !(entry->attributes() & DontEnum))
     76                propertyNames.add(entry->key());
    7777        }
    7878    }
  • trunk/JavaScriptCore/kjs/create_hash_table

    r36263 r36977  
    4141
    4242my @keys = ();
     43my @attrs = ();
    4344my @values = ();
    44 my @attrs = ();
    45 my @params = ();
    4645my @hashes = ();
    4746
     
    5251sub calcSize();
    5352sub output();
     53sub jsc_ucfirst($);
    5454sub hashValue($);
    5555
     
    7070
    7171        @keys = ();
     72        @attrs = ();
    7273        @values = ();
    73         @attrs = ();
    74         @params = ();
    7574        @hashes = ();
    7675
     
    8180        my $att = $3;
    8281        my $param = $4;
     82
    8383        push(@keys, $key);
    84         push(@values, $val);
     84        push(@attrs, length($att) > 0 ? $att : "0");
     85
     86        if ($att =~ m/Function/) {
     87            push(@values, { "type" => "Function", "function" => $val, "params" => (length($param) ? $param : "") });
     88            #printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if (length($param) == 0);
     89        } elsif (length($att)) {
     90            my $get = $val;
     91            my $put = !($att =~ m/ReadOnly/) ? "set" . jsc_ucfirst($val) : "0";
     92            push(@values, { "type" => "Property", "get" => $get, "put" => $put });
     93        } else {
     94            push(@values, { "type" => "Lexer", "value" => $val });       
     95        }
    8596        push(@hashes, hashValue($key));
    86         printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if ($att =~ m/Function/ && length($param) == 0);
    87         push(@attrs, length($att) > 0 ? $att : "0");
    88         push(@params, length($param) > 0 ? $param : "0");
    8997    } elsif ($inside) {
    9098        die "invalid data {" . $_ . "}";
     
    93101
    94102die "missing closing \@end" if ($inside);
     103
     104sub jsc_ucfirst($)
     105{
     106    my ($value) = @_;
     107
     108    if ($value =~ /js/) {
     109        $value =~ s/js/JS/;
     110        return $value;
     111    }
     112
     113    return ucfirst($value);
     114}
     115
    95116
    96117sub ceilingToPowerOf2
     
    189210    print "\n#include \"lookup.h\"\n" if ($includelookup);
    190211    if ($useNameSpace) {
    191         print "\nnamespace ${useNameSpace}\n{\n";
    192         print "\nusing namespace JSC;";
     212        print "\nnamespace ${useNameSpace} {\n";
     213        print "\nusing namespace JSC;\n";
    193214    } else {
    194215        print "\nnamespace JSC {\n";
     
    198219    my $i = 0;
    199220    foreach my $key (@keys) {
    200         print "   { \"$key\", (intptr_t)$values[$i], $attrs[$i], $params[$i] },\n";
     221        my $firstValue = "";
     222        my $secondValue = "";
     223
     224        if ($values[$i]{"type"} eq "Function") {
     225            $firstValue = $values[$i]{"function"};
     226            $secondValue = $values[$i]{"params"};
     227        } elsif ($values[$i]{"type"} eq "Property") {
     228            $firstValue = $values[$i]{"get"};
     229            $secondValue = $values[$i]{"put"};
     230        } elsif ($values[$i]{"type"} eq "Lexer") {
     231            $firstValue = $values[$i]{"value"};
     232            $secondValue = "0";
     233        }
     234        print "   { \"$key\", $attrs[$i], (intptr_t)$firstValue, (intptr_t)$secondValue },\n";
    201235        $i++;
    202236    }
  • trunk/JavaScriptCore/kjs/lexer.cpp

    r36660 r36977  
    560560                break;
    561561            }
    562             token = entry->integerValue;
     562            token = entry->lexerValue();
    563563            // Hack for "f = function somename() { ... }"; too hard to get into the grammar.
    564564            m_eatNextIdentifier = token == FUNCTION && m_lastToken == '=';
  • trunk/JavaScriptCore/kjs/lookup.cpp

    r36877 r36977  
    3030    HashEntry* entries = new HashEntry[hashSizeMask + 1];
    3131    for (int i = 0; i <= hashSizeMask; ++i)
    32         entries[i].key = 0;
     32        entries[i].setKey(0);
    3333    for (int i = 0; values[i].key; ++i) {
    3434        UString::Rep* identifier = Identifier::add(globalData, values[i].key).releaseRef();
    3535        int hashIndex = identifier->computedHash() & hashSizeMask;
    36         ASSERT(!entries[hashIndex].key);
    37         entries[hashIndex].key = identifier;
    38         entries[hashIndex].integerValue = values[i].value;
    39         entries[hashIndex].attributes = values[i].attributes;
    40         entries[hashIndex].length = values[i].length;
     36        ASSERT(!entries[hashIndex].key());
     37        entries[hashIndex].initialize(identifier, values[i].attributes, values[i].value1, values[i].value2);
    4138    }
    4239    table = entries;
     
    4744    if (table) {
    4845        for (int i = 0; i != hashSizeMask + 1; ++i) {
    49             if (UString::Rep* key = table[i].key)
     46            if (UString::Rep* key = table[i].key())
    5047                key->deref();
    5148        }
    52         delete[] table;
     49        delete [] table;
    5350        table = 0;
    5451    }
     
    5754void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
    5855{
    59     ASSERT(entry->attributes & Function);
     56    ASSERT(entry->attributes() & Function);
    6057    JSValue** location = thisObj->getDirectLocation(propertyName);
    61  
     58
    6259    if (!location) {
    63         PrototypeFunction* function = new (exec) PrototypeFunction(exec, entry->length, propertyName, entry->functionValue);
    64         thisObj->putDirect(propertyName, function, entry->attributes);
     60        PrototypeFunction* function = new (exec) PrototypeFunction(exec, entry->functionLength(), propertyName, entry->function());
     61        thisObj->putDirect(propertyName, function, entry->attributes());
    6562        location = thisObj->getDirectLocation(propertyName);
    6663    }
    67    
     64
    6865    slot.setValueSlot(thisObj, location, thisObj->offsetForLocation(location));
    6966}
  • trunk/JavaScriptCore/kjs/lookup.h

    r36877 r36977  
    2626#include "JSGlobalObject.h"
    2727#include "JSObject.h"
     28#include "PropertySlot.h"
    2829#include "identifier.h"
    2930#include <stdio.h>
     
    3334
    3435    // Hash table generated by the create_hash_table script.
    35 
    3636    struct HashTableValue {
    3737        const char* key; // property name
    38         intptr_t value; // integer or function
    3938        unsigned char attributes; // JSObject attributes
    40         unsigned char length; // number of arguments for function
     39        intptr_t value1;
     40        intptr_t value2;
    4141    };
    4242
    43     struct HashEntry {
    44         UString::Rep* key;
     43    // FIXME: There is no reason this get function can't be simpler.
     44    // ie. typedef JSValue* (*GetFunction)(ExecState*, JSObject* baseObject)
     45    typedef PropertySlot::GetValueFunc GetFunction;
     46    typedef void (*PutFunction)(ExecState*, JSObject* baseObject, JSValue* value);
     47
     48    class HashEntry {
     49    public:
     50        void initialize(UString::Rep* key, unsigned char attributes, intptr_t v1, intptr_t v2)
     51        {
     52            m_key = key;
     53            m_attributes = attributes;
     54            m_u.store.value1 = v1;
     55            m_u.store.value2 = v2;
     56        }
     57
     58        void setKey(UString::Rep* key) { m_key = key; }
     59        UString::Rep* key() const { return m_key; }
     60
     61        unsigned char attributes() const { return m_attributes; }
     62
     63        NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; }
     64        unsigned char functionLength() const { ASSERT(m_attributes & Function); return static_cast<unsigned char>(m_u.function.length); }
     65
     66        GetFunction propertyGetter() const { ASSERT(!(m_attributes & Function)); return m_u.property.get; }
     67        PutFunction propertyPutter() const { ASSERT(!(m_attributes & Function)); return m_u.property.put; }
     68
     69        intptr_t lexerValue() const { ASSERT(!m_attributes); return m_u.lexer.value; }
     70
     71    private:
     72        UString::Rep* m_key;
     73        unsigned char m_attributes; // JSObject attributes
     74
    4575        union {
    46             intptr_t integerValue;
    47             NativeFunction functionValue;
    48         };
    49         unsigned char attributes; // JSObject attributes
    50         unsigned char length; // number of arguments for function
     76            struct {
     77                intptr_t value1;
     78                intptr_t value2;
     79            } store;
     80            struct {
     81                NativeFunction functionValue;
     82                intptr_t length; // number of arguments for function
     83            } function;
     84            struct {
     85                GetFunction get;
     86                PutFunction put;
     87            } property;
     88            struct {
     89                intptr_t value;
     90                intptr_t unused;
     91            } lexer;
     92        } m_u;
    5193    };
    5294
     
    88130            ASSERT(table);
    89131            const HashEntry* entry = &table[identifier.ustring().rep()->computedHash() & hashSizeMask];
    90             if (entry->key != identifier.ustring().rep())
     132            if (entry->key() != identifier.ustring().rep())
    91133                return 0;
    92134            return entry;
     
    100142
    101143    /**
    102      * @internal
    103      * Helper for getStaticValueSlot and getStaticPropertySlot
    104      */
    105     template <class ThisImp>
    106     JSValue* staticValueGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    107     {
    108         ThisImp* thisObj = static_cast<ThisImp*>(slot.slotBase());
    109         const HashEntry* entry = slot.staticEntry();
    110         return thisObj->getValueProperty(exec, entry->integerValue);
    111     }
    112 
    113     /**
    114      * Helper method for property lookups
    115      *
    116144     * This method does it all (looking in the hashtable, checking for function
    117145     * overrides, creating the function or retrieving from cache, calling
    118146     * getValueProperty in case of a non-function property, forwarding to parent if
    119147     * unknown property).
    120      *
    121      * Template arguments:
    122      * @param FuncImp the class which implements this object's functions
    123      * @param ThisImp the class of "this". It must implement the getValueProperty(exec,token) method,
    124      * for non-function properties.
    125      * @param ParentImp the class of the parent, to propagate the lookup.
    126      *
    127      * Method arguments:
    128      * @param exec execution state, as usual
    129      * @param propertyName the property we're looking for
    130      * @param table the static hashtable for this class
    131      * @param thisObj "this"
    132148     */
    133149    template <class ThisImp, class ParentImp>
     
    139155            return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot);
    140156
    141         if (entry->attributes & Function)
     157        if (entry->attributes() & Function)
    142158            setUpStaticFunctionSlot(exec, entry, thisObj, propertyName, slot);
    143159        else
    144             slot.setStaticEntry(thisObj, entry, staticValueGetter<ThisImp>);
     160            slot.setCustom(thisObj, entry->propertyGetter());
    145161
    146162        return true;
     
    178194            return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot);
    179195
    180         ASSERT(!(entry->attributes & Function));
    181 
    182         slot.setStaticEntry(thisObj, entry, staticValueGetter<ThisImp>);
     196        ASSERT(!(entry->attributes() & Function));
     197
     198        slot.setCustom(thisObj, entry->propertyGetter());
    183199        return true;
    184200    }
     
    197213            return false;
    198214
    199         if (entry->attributes & Function) // function: put as override property
     215        if (entry->attributes() & Function) // function: put as override property
    200216            thisObj->putDirect(propertyName, value);
    201         else if (!(entry->attributes & ReadOnly))
    202             thisObj->putValueProperty(exec, entry->integerValue, value);
     217        else if (!(entry->attributes() & ReadOnly))
     218            entry->propertyPutter()(exec, thisObj, value);
    203219
    204220        return true;
Note: See TracChangeset for help on using the changeset viewer.