Changeset 35807 in webkit


Ignore:
Timestamp:
Aug 17, 2008, 1:23:49 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-08-17 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.

Made room for a free word in JSCell.


SunSpider says no change.


I changed JSCallbackObjectData, Arguments, JSArray, and RegExpObject to
store auxiliary data in a secondary structure.

I changed InternalFunction to store the function's name in the property
map.


I changed JSGlobalObjectData to use a virtual destructor, so WebCore's
JSDOMWindowBaseData could inherit from it safely. (It's a strange design
for JSDOMWindowBase to allocate an object that JSGlobalObject deletes,
but that's really our only option, given the size constraint.)


I also added a bunch of compile-time ASSERTs, and removed lots of comments
in JSObject.h because they were often out of date, and they got in the
way of reading what was actually going on.


Also renamed JSArray::getLength to JSArray::length, to match our style
guidelines.

WebCore:

2008-08-17 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.

Made room for a free word in JSCell.


Changed JSDOMWindowBase to store its auxiliary data in a subclass of
JSGlobalData, so the two could share a pointer.


Added a bunch of ASSERTs, to help catch over-sized objects.

WebKit/mac:

2008-08-17 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.

Made room for a free word in JSCell.


(Updated for JavaScriptCore changes.)

Location:
trunk
Files:
85 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r35478 r35807  
    3737namespace KJS {
    3838
     39ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);
     40
    3941const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
    4042
    4143JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
    42     : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
     44    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
    4345    , m_callback(callback)
    4446{
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r32652 r35807  
    3333namespace KJS {
    3434
     35ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>);
     36ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
     37
    3538// Define the two types of JSCallbackObjects we support.
    3639template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
    3740template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
    3841
    39 COMPILE_ASSERT(sizeof(JSCallbackObject<JSGlobalObject>) <= CELL_SIZE, global_callback_object_fits_in_cell);
    40 
    4142} // namespace KJS
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r34754 r35807  
    4747    static const ClassInfo info;
    4848
    49     JSClassRef classRef() const { return m_class; }
     49    JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
    5050    bool inherits(JSClassRef) const;
    5151
     
    8383    static JSValue* staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&);
    8484    static JSValue* callbackGetter(ExecState*, const Identifier&, const PropertySlot&);
     85
     86    struct JSCallbackObjectData {
     87        JSCallbackObjectData(void* privateData_, JSClassRef jsClass_)
     88            : privateData(privateData_)
     89            , jsClass(jsClass_)
     90        {
     91            JSClassRetain(jsClass);
     92        }
     93       
     94        ~JSCallbackObjectData()
     95        {
     96            JSClassRelease(jsClass);
     97        }
     98       
     99        void* privateData;
     100        JSClassRef jsClass;
     101    };
    85102   
    86     void* m_privateData;
    87     JSClassRef m_class;
     103    OwnPtr<JSCallbackObjectData> m_callbackObjectData;
    88104};
    89105
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r35775 r35807  
    4343JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
    4444    : Base(prototype)
    45     , m_privateData(data)
    46     , m_class(JSClassRetain(jsClass))
     45    , m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
    4746{
    4847    init(exec);
     
    5352template <class Base>
    5453JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
    55     : m_privateData(0)
    56     , m_class(JSClassRetain(jsClass))
     54    : m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
    5755{
    5856    ASSERT(Base::isGlobalObject());
     
    6664   
    6765    Vector<JSObjectInitializeCallback, 16> initRoutines;
    68     JSClassRef jsClass = m_class;
     66    JSClassRef jsClass = classRef();
    6967    do {
    7068        if (JSObjectInitializeCallback initialize = jsClass->initialize)
     
    8482    JSObjectRef thisRef = toRef(this);
    8583   
    86     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    87         if (JSObjectFinalizeCallback finalize = jsClass->finalize) {
     84    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
     85        if (JSObjectFinalizeCallback finalize = jsClass->finalize)
    8886            finalize(thisRef);
    89         }
    90            
    91     JSClassRelease(m_class);
    9287}
    9388
     
    9590UString JSCallbackObject<Base>::className() const
    9691{
    97     UString thisClassName = m_class->className();
     92    UString thisClassName = classRef()->className();
    9893    if (!thisClassName.isNull())
    9994        return thisClassName;
     
    109104    RefPtr<OpaqueJSString> propertyNameRef;
    110105   
    111     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     106    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    112107        // optional optimization to bypass getProperty in cases when we only need to know if the property exists
    113108        if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
     
    162157    JSValueRef valueRef = toRef(value);
    163158   
    164     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     159    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    165160        if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
    166161            if (!propertyNameRef)
     
    210205    RefPtr<OpaqueJSString> propertyNameRef;
    211206   
    212     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     207    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    213208        if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
    214209            if (!propertyNameRef)
     
    247242ConstructType JSCallbackObject<Base>::getConstructData(ConstructData& constructData)
    248243{
    249     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     244    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    250245        if (jsClass->callAsConstructor) {
    251246            constructData.native.function = construct;
     
    279274bool JSCallbackObject<Base>::implementsHasInstance() const
    280275{
    281     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
     276    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    282277        if (jsClass->hasInstance)
    283278            return true;
     
    292287    JSObjectRef thisRef = toRef(this);
    293288   
    294     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     289    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    295290        if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance)
    296291            return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
     
    303298CallType JSCallbackObject<Base>::getCallData(CallData& callData)
    304299{
    305     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     300    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    306301        if (jsClass->callAsFunction) {
    307302            callData.native.function = call;
     
    319314    JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec));
    320315   
    321     for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->m_class; jsClass; jsClass = jsClass->parentClass) {
     316    for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) {
    322317        if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
    323318            int argumentCount = static_cast<int>(args.size());
     
    339334    JSObjectRef thisRef = toRef(this);
    340335   
    341     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
     336    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
    342337        if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames)
    343338            getPropertyNames(execRef, thisRef, toRef(&propertyNames));
     
    380375    JSObjectRef thisRef = toRef(this);
    381376   
    382     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
     377    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    383378        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    384379            if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
     
    395390    JSObjectRef thisRef = toRef(this);
    396391   
    397     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
     392    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    398393        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    399394            JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot()));
     
    408403void JSCallbackObject<Base>::setPrivate(void* data)
    409404{
    410     m_privateData = data;
     405    m_callbackObjectData->privateData = data;
    411406}
    412407
     
    414409void* JSCallbackObject<Base>::getPrivate()
    415410{
    416     return m_privateData;
     411    return m_callbackObjectData->privateData;
    417412}
    418413
     
    420415bool JSCallbackObject<Base>::inherits(JSClassRef c) const
    421416{
    422     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
     417    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    423418        if (jsClass == c)
    424419            return true;
     
    444439    RefPtr<OpaqueJSString> propertyNameRef;
    445440   
    446     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
     441    for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
    447442        if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec))
    448443            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
     
    468463        return slot2.getValue(exec, propertyName);
    469464   
    470     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) {
     465    for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
    471466        if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    472467            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
     
    492487    RefPtr<OpaqueJSString> propertyNameRef;
    493488   
    494     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
     489    for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
    495490        if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    496491            if (!propertyNameRef)
  • trunk/JavaScriptCore/ChangeLog

    r35806 r35807  
     12008-08-17  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        Made room for a free word in JSCell.
     6       
     7        SunSpider says no change.
     8       
     9        I changed JSCallbackObjectData, Arguments, JSArray, and RegExpObject to
     10        store auxiliary data in a secondary structure.
     11
     12        I changed InternalFunction to store the function's name in the property
     13        map.
     14       
     15        I changed JSGlobalObjectData to use a virtual destructor, so WebCore's
     16        JSDOMWindowBaseData could inherit from it safely. (It's a strange design
     17        for JSDOMWindowBase to allocate an object that JSGlobalObject deletes,
     18        but that's really our only option, given the size constraint.)
     19       
     20        I also added a bunch of compile-time ASSERTs, and removed lots of comments
     21        in JSObject.h because they were often out of date, and they got in the
     22        way of reading what was actually going on.
     23       
     24        Also renamed JSArray::getLength to JSArray::length, to match our style
     25        guidelines.
     26
    1272008-08-16  Geoffrey Garen  <[email protected]>
    228
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r35806 r35807  
    132132__ZN3KJS14constructArrayEPNS_9ExecStateERKNS_7ArgListE
    133133__ZN3KJS15JSWrapperObject4markEv
    134 __ZN3KJS16InternalFunction14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    135 __ZN3KJS16InternalFunction18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
    136 __ZN3KJS16InternalFunction3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueE
    137134__ZN3KJS16InternalFunction4infoE
    138 __ZN3KJS16InternalFunctionC2EPNS_17FunctionPrototypeERKNS_10IdentifierE
     135__ZN3KJS16InternalFunctionC2EPNS_9ExecStateEPNS_17FunctionPrototypeERKNS_10IdentifierE
    139136__ZN3KJS16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    140137__ZN3KJS16JSVariableObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     
    209206__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
    210207__ZN3KJS8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
    211 __ZN3KJS8JSObject17putDirectFunctionEPNS_16InternalFunctionEj
     208__ZN3KJS8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj
    212209__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEj
    213210__ZN3KJS8JSObject17putWithAttributesEPNS_9ExecStateEjPNS_7JSValueEj
  • trunk/JavaScriptCore/VM/JSPropertyNameIterator.cpp

    r35439 r35807  
    3737namespace KJS {
    3838
    39 COMPILE_ASSERT(sizeof(JSPropertyNameIterator) <= CellSize<sizeof(void*)>::m_value, JSPropertyNameIteratorSizeASSERT);
     39ASSERT_CLASS_FITS_IN_CELL(JSPropertyNameIterator);
    4040
    4141JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue* v)
  • trunk/JavaScriptCore/VM/Machine.cpp

    r35652 r35807  
    646646
    647647    if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
    648         DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
     648        DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
    649649        if (callFrame[RegisterFile::Callee].jsValue(exec))
    650650            debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine());
     
    724724
    725725    if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
    726         DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
     726        DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, exceptionValue);
    727727        debugger->exception(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->lineNumberForVPC(vPC));
    728728    }
     
    956956        return;
    957957
    958     DebuggerCallFrame debuggerCallFrame(exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0);
     958    DebuggerCallFrame debuggerCallFrame(exec, exec->dynamicGlobalObject(), codeBlock, scopeChain, r, 0);
    959959
    960960    switch((DebugHookID)debugHookID) {
  • trunk/JavaScriptCore/kjs/Arguments.cpp

    r35291 r35807  
    3333namespace KJS {
    3434
     35ASSERT_CLASS_FITS_IN_CELL(Arguments);
     36
    3537const ClassInfo Arguments::info = { "Arguments", 0, 0, 0 };
    3638
     
    3840Arguments::Arguments(ExecState* exec, JSFunction* function, const ArgList& args, JSActivation* activation)
    3941    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
    40     , m_activationObject(activation)
    41     , m_indexToNameMap(function, args)
     42    , d(new ArgumentsData(activation, function, args))
    4243{
     44    ASSERT(activation);
     45
    4346    putDirect(exec->propertyNames().callee, function, DontEnum);
    4447    putDirect(exec, exec->propertyNames().length, args.size(), DontEnum);
     
    4851    for (ArgList::const_iterator it = args.begin(); it != end; ++it, ++i) {
    4952        Identifier name = Identifier::from(exec, i);
    50         if (!m_indexToNameMap.isMapped(name))
     53        if (!d->indexToNameMap.isMapped(name))
    5154            putDirect(name, (*it).jsValue(exec), DontEnum);
    5255    }
     
    5659{
    5760    JSObject::mark();
    58     if (m_activationObject && !m_activationObject->marked())
    59         m_activationObject->mark();
     61    if (!d->activation->marked())
     62        d->activation->mark();
    6063}
    6164
     
    6366{
    6467      Arguments* thisObj = static_cast<Arguments*>(slot.slotBase());
    65       return thisObj->m_activationObject->get(exec, thisObj->m_indexToNameMap[propertyName]);
     68      return thisObj->d->activation->get(exec, thisObj->d->indexToNameMap[propertyName]);
    6669}
    6770
    6871bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    6972{
    70     if (m_indexToNameMap.isMapped(propertyName)) {
     73    if (d->indexToNameMap.isMapped(propertyName)) {
    7174        slot.setCustom(this, mappedIndexGetter);
    7275        return true;
     
    7881void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
    7982{
    80     if (m_indexToNameMap.isMapped(propertyName))
    81         m_activationObject->put(exec, m_indexToNameMap[propertyName], value);
     83    if (d->indexToNameMap.isMapped(propertyName))
     84        d->activation->put(exec, d->indexToNameMap[propertyName], value);
    8285    else
    8386        JSObject::put(exec, propertyName, value);
     
    8689bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
    8790{
    88     if (m_indexToNameMap.isMapped(propertyName)) {
    89         m_indexToNameMap.unMap(exec, propertyName);
     91    if (d->indexToNameMap.isMapped(propertyName)) {
     92        d->indexToNameMap.unMap(exec, propertyName);
    9093        return true;
    9194    }
  • trunk/JavaScriptCore/kjs/Arguments.h

    r35022 r35807  
    4848        static JSValue* mappedIndexGetter(ExecState*, const Identifier&, const PropertySlot& slot);
    4949
    50         JSActivation* m_activationObject;
    51         mutable IndexToNameMap m_indexToNameMap;
     50        struct ArgumentsData {
     51            ArgumentsData(JSActivation* activation_, JSFunction* function_, const ArgList& args_)
     52                : activation(activation_)
     53                , indexToNameMap(function_, args_)
     54            {
     55            }
     56
     57            JSActivation* activation;
     58            mutable IndexToNameMap indexToNameMap;
     59        };
     60       
     61        OwnPtr<ArgumentsData> d;
    5262    };
    5363
  • trunk/JavaScriptCore/kjs/ArrayConstructor.cpp

    r35411 r35807  
    3232namespace KJS {
    3333
     34ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
     35
    3436ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ArrayPrototype* arrayPrototype)
    35     : InternalFunction(functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
     37    : InternalFunction(exec, functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
    3638{
    3739    // ECMA 15.4.3.1 Array.prototype
  • trunk/JavaScriptCore/kjs/ArrayPrototype.cpp

    r35291 r35807  
    3434
    3535namespace KJS {
     36
     37ASSERT_CLASS_FITS_IN_CELL(ArrayPrototype);
    3638
    3739static JSValue* arrayProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    263265        if (curArg->isObject(&JSArray::info)) {
    264266            JSArray* curArray = static_cast<JSArray*>(curArg);
    265             unsigned length = curArray->getLength();
     267            unsigned length = curArray->length();
    266268            for (unsigned k = 0; k < length; ++k) {
    267269                if (JSValue* v = getProperty(exec, curArray, k))
  • trunk/JavaScriptCore/kjs/BooleanConstructor.cpp

    r35411 r35807  
    2727namespace KJS {
    2828
     29ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
     30
    2931BooleanConstructor::BooleanConstructor(ExecState* exec, FunctionPrototype* functionPrototype, BooleanPrototype* booleanPrototype)
    30     : InternalFunction(functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
     32    : InternalFunction(exec, functionPrototype, Identifier(exec, booleanPrototype->classInfo()->className))
    3133{
    3234    putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
  • trunk/JavaScriptCore/kjs/BooleanObject.cpp

    r35022 r35807  
    2424namespace KJS {
    2525
     26ASSERT_CLASS_FITS_IN_CELL(BooleanObject);
     27
    2628const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
    2729
  • trunk/JavaScriptCore/kjs/BooleanPrototype.cpp

    r35020 r35807  
    3030namespace KJS {
    3131
     32ASSERT_CLASS_FITS_IN_CELL(BooleanPrototype);
     33
    3234// Functions
    3335static JSValue* booleanProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    4143    setInternalValue(jsBoolean(false));
    4244
    43     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
    44     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
     45    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
     46    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
    4547}
    4648
  • trunk/JavaScriptCore/kjs/DateConstructor.cpp

    r35411 r35807  
    4646// TODO: MakeTime (15.9.11.1) etc. ?
    4747
     48ASSERT_CLASS_FITS_IN_CELL(DateConstructor);
     49
    4850static JSValue* dateParse(ExecState*, JSObject*, JSValue*, const ArgList&);
    4951static JSValue* dateNow(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    5153
    5254DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* functionPrototype, DatePrototype* datePrototype)
    53     : InternalFunction(functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
     55    : InternalFunction(exec, functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
    5456{
    5557      putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
    5658
    57       putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
    58       putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
    59       putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
     59      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
     60      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
     61      putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
    6062
    6163      putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
  • trunk/JavaScriptCore/kjs/DatePrototype.cpp

    r35291 r35807  
    5656
    5757namespace KJS {
     58
     59ASSERT_CLASS_FITS_IN_CELL(DatePrototype);
    5860
    5961static JSValue* dateProtoFuncGetDate(ExecState*, JSObject*, JSValue*, const ArgList&);
  • trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp

    r35291 r35807  
    5050    if (!function)
    5151        return 0;
    52     return &function->functionName().ustring();
     52    return &function->name(m_exec);
    5353}
    5454
  • trunk/JavaScriptCore/kjs/DebuggerCallFrame.h

    r35037 r35807  
    3333   
    3434    class CodeBlock;
     35    class ExecState;
    3536    class JSGlobalObject;
    3637    class JSObject;
     
    4849        };
    4950
    50         DebuggerCallFrame(JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception)
    51             : m_dynamicGlobalObject(dynamicGlobalObject)
     51        DebuggerCallFrame(ExecState* exec, JSGlobalObject* dynamicGlobalObject, const CodeBlock* codeBlock, ScopeChainNode* scopeChain, Register* r, JSValue* exception)
     52            : m_exec(exec)
     53            , m_dynamicGlobalObject(dynamicGlobalObject)
    5254            , m_codeBlock(codeBlock)
    5355            , m_scopeChain(scopeChain)
     
    6870        Register* callFrame() const;
    6971
     72        ExecState* m_exec;
    7073        JSGlobalObject* m_dynamicGlobalObject;
    7174        const CodeBlock* m_codeBlock;
  • trunk/JavaScriptCore/kjs/ErrorConstructor.cpp

    r35411 r35807  
    3030namespace KJS {
    3131
     32ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
     33
    3234ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ErrorPrototype* errorPrototype)
    33     : InternalFunction(functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
     35    : InternalFunction(exec, functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
    3436{
    3537    // ECMA 15.11.3.1 Error.prototype
  • trunk/JavaScriptCore/kjs/ErrorPrototype.cpp

    r35020 r35807  
    3030namespace KJS {
    3131
     32ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
     33
    3234static JSValue* errorProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    3335
     
    4143    putDirect(exec->propertyNames().message, jsString(exec, "Unknown error"), DontEnum);
    4244
    43     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
     45    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
    4446}
    4547
  • trunk/JavaScriptCore/kjs/FunctionConstructor.cpp

    r35411 r35807  
    3333namespace KJS {
    3434
     35ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
     36
    3537FunctionConstructor::FunctionConstructor(ExecState* exec, FunctionPrototype* functionPrototype)
    36     : InternalFunction(functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
     38    : InternalFunction(exec, functionPrototype, Identifier(exec, functionPrototype->classInfo()->className))
    3739{
    3840    putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
  • trunk/JavaScriptCore/kjs/FunctionPrototype.cpp

    r35291 r35807  
    3030namespace KJS {
    3131
     32ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype);
     33
    3234static JSValue* functionProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    3335static JSValue* functionProtoFuncApply(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    3537
    3638FunctionPrototype::FunctionPrototype(ExecState* exec)
     39    : InternalFunction(exec)
    3740{
    3841    putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
    3942
    40     putDirectFunction(new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    41     putDirectFunction(new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
    42     putDirectFunction(new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
     43    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
     44    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 2, exec->propertyNames().apply, functionProtoFuncApply), DontEnum);
     45    putDirectFunction(exec, new (exec) PrototypeFunction(exec, this, 1, exec->propertyNames().call, functionProtoFuncCall), DontEnum);
    4346}
    4447
     
    5962JSValue* functionProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&)
    6063{
    61     if (!thisValue->isObject(&InternalFunction::info))
    62         return throwError(exec, TypeError);
    63 
    64     InternalFunction* function = static_cast<InternalFunction*>(thisValue);
    65 
    66     if (function->inherits(&JSFunction::info)) {
    67         JSFunction* fi = static_cast<JSFunction*>(thisValue);
    68         return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->m_body->paramString() + ") " + fi->m_body->toSourceString());
     64    if (thisValue->isObject(&JSFunction::info)) {
     65        JSFunction* function = static_cast<JSFunction*>(thisValue);
     66        return jsString(exec, "function " + function->name(exec) + "(" + function->m_body->paramString() + ") " + function->m_body->toSourceString());
    6967    }
    7068
    71     return jsString(exec, "function " + function->functionName().ustring() + "() {\n    [native code]\n}");
     69    if (thisValue->isObject(&InternalFunction::info)) {
     70        InternalFunction* function = static_cast<InternalFunction*>(thisValue);
     71        return jsString(exec, "function " + function->name(exec) + "() {\n    [native code]\n}");
     72    }
     73
     74    return throwError(exec, TypeError);
    7275}
    7376
  • trunk/JavaScriptCore/kjs/GlobalEvalFunction.cpp

    r35016 r35807  
    3232namespace KJS {
    3333
     34ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction);
     35
    3436GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, FunctionPrototype* functionPrototype, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
    3537    : PrototypeFunction(exec, functionPrototype, len, name, function)
  • trunk/JavaScriptCore/kjs/InternalFunction.cpp

    r35229 r35807  
    2929namespace KJS {
    3030
     31ASSERT_CLASS_FITS_IN_CELL(InternalFunction);
     32
    3133const ClassInfo InternalFunction::info = { "Function", 0, 0, 0 };
    3234
    33 InternalFunction::InternalFunction()
     35InternalFunction::InternalFunction(ExecState* exec)
    3436{
     37    putDirect(exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);
    3538}
    3639
    37 InternalFunction::InternalFunction(FunctionPrototype* prototype, const Identifier& name)
     40InternalFunction::InternalFunction(ExecState* exec, FunctionPrototype* prototype, const Identifier& name)
    3841    : JSObject(prototype)
    39     , m_name(name)
    4042{
     43    putDirect(exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum);
     44}
     45
     46const UString& InternalFunction::name(ExecState* exec)
     47{
     48    JSValue* v = getDirect(exec->propertyNames().name);
     49    ASSERT(v->isString());
     50    return static_cast<JSString*>(v)->value();
    4151}
    4252
     
    4656}
    4757
    48 bool InternalFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    49 {
    50     if (propertyName == exec->propertyNames().name) {
    51         slot.setCustom(this, nameGetter);
    52         return true;
    53     }
    54 
    55     return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    56 }
    57 
    58 void InternalFunction::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
    59 {
    60     if (propertyName == exec->propertyNames().name)
    61         return;
    62     JSObject::put(exec, propertyName, value);
    63 }
    64 
    65 bool InternalFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
    66 {
    67     if (propertyName == exec->propertyNames().name)
    68         return false;
    69     return JSObject::deleteProperty(exec, propertyName);
    70 }
    71 
    72 JSValue* InternalFunction::nameGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
    73 {
    74     InternalFunction* thisObj = static_cast<InternalFunction*>(slot.slotBase());
    75     return jsString(exec, thisObj->functionName().ustring());
    76 }
    77 
    7858} // namespace KJS
  • trunk/JavaScriptCore/kjs/InternalFunction.h

    r35228 r35807  
    3636        virtual const ClassInfo* classInfo() const { return &info; }
    3737        static const ClassInfo info;
    38 
    39         virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    40         virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    41         virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    42 
    43         const Identifier& functionName() const { return m_name; }
     38       
     39        const UString& name(ExecState*);
    4440
    4541    protected:
    46         InternalFunction();
    47         InternalFunction(FunctionPrototype*, const Identifier&);
     42        InternalFunction(ExecState*);
     43        InternalFunction(ExecState*, FunctionPrototype*, const Identifier&);
    4844
    4945    private:
    50         static JSValue* nameGetter(ExecState*, const Identifier&, const PropertySlot&);
    5146        virtual CallType getCallData(CallData&) = 0;
    5247        virtual bool implementsHasInstance() const;
    53 
    54         Identifier m_name;
    5548    };
    5649
  • trunk/JavaScriptCore/kjs/JSActivation.cpp

    r35657 r35807  
    3737
    3838namespace KJS {
     39
     40ASSERT_CLASS_FITS_IN_CELL(JSActivation);
    3941
    4042const ClassInfo JSActivation::info = { "JSActivation", 0, 0, 0 };
  • trunk/JavaScriptCore/kjs/JSArray.cpp

    r35806 r35807  
    3535
    3636namespace KJS {
     37
     38ASSERT_CLASS_FITS_IN_CELL(JSArray);
    3739
    3840// Overview of JSArray
     
    129131    unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX);
    130132
    131     m_length = initialLength;
     133    m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
    132134    m_fastAccessCutoff = 0;
    133     m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
    134135    m_storage->m_vectorLength = initialCapacity;
     136    m_storage->m_length = initialLength;
    135137
    136138    Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue*));
     
    144146    unsigned length = list.size();
    145147
    146     m_length = length;
    147148    m_fastAccessCutoff = length;
    148149
     
    152153    storage->m_numValuesInVector = length;
    153154    storage->m_sparseValueMap = 0;
     155    storage->m_length = length;
    154156
    155157    size_t i = 0;
     
    178180    ArrayStorage* storage = m_storage;
    179181
    180     if (i >= m_length) {
     182    if (i >= storage->m_length) {
    181183        if (i > MAX_ARRAY_INDEX)
    182184            return getOwnPropertySlot(exec, Identifier::from(exec, i), slot);
     
    206208{
    207209    if (propertyName == exec->propertyNames().length) {
    208         slot.setValue(jsNumber(exec, getLength()));
     210        slot.setValue(jsNumber(exec, length()));
    209211        return true;
    210212    }
     
    245247    checkConsistency();
    246248
    247     unsigned length = m_length;
     249    unsigned length = m_storage->m_length;
    248250    if (i >= length && i <= MAX_ARRAY_INDEX) {
    249251        length = i + 1;
    250         m_length = length;
     252        m_storage->m_length = length;
    251253    }
    252254
     
    259261        }
    260262        valueSlot = value;
    261         if (++m_storage->m_numValuesInVector == m_length)
    262             m_fastAccessCutoff = m_length;
     263        if (++m_storage->m_numValuesInVector == m_storage->m_length)
     264            m_fastAccessCutoff = m_storage->m_length;
    263265        checkConsistency();
    264266        return;
     
    414416    ArrayStorage* storage = m_storage;
    415417
    416     unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
     418    unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength);
    417419    for (unsigned i = 0; i < usedVectorLength; ++i) {
    418420        if (storage->m_vector[i])
     
    460462    ArrayStorage* storage = m_storage;
    461463
    462     unsigned length = m_length;
     464    unsigned length = m_storage->m_length;
    463465
    464466    if (newLength < length) {
     
    488490    }
    489491
    490     m_length = newLength;
     492    m_storage->m_length = newLength;
    491493
    492494    checkConsistency();
     
    499501    ArrayStorage* storage = m_storage;
    500502
    501     unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
     503    unsigned usedVectorLength = min(storage->m_length, storage->m_vectorLength);
    502504    for (unsigned i = 0; i < usedVectorLength; ++i) {
    503505        JSValue* value = storage->m_vector[i];
     
    662664    // The maximum tree depth is compiled in - but the caller is clearly up to no good
    663665    // if a larger array is passed.
    664     ASSERT(m_length <= static_cast<unsigned>(std::numeric_limits<int>::max()));
    665     if (m_length > static_cast<unsigned>(std::numeric_limits<int>::max()))
    666         return;
    667 
    668     if (!m_length)
    669         return;
    670 
    671     unsigned usedVectorLength = min(m_length, m_storage->m_vectorLength);
     666    ASSERT(m_storage->m_length <= static_cast<unsigned>(std::numeric_limits<int>::max()));
     667    if (m_storage->m_length > static_cast<unsigned>(std::numeric_limits<int>::max()))
     668        return;
     669
     670    if (!m_storage->m_length)
     671        return;
     672
     673    unsigned usedVectorLength = min(m_storage->m_length, m_storage->m_vectorLength);
    672674
    673675    AVLTree<AVLTreeAbstractorForArrayCompare, 44> tree; // Depth 44 is enough for 2^31 items
     
    766768    ArrayStorage* storage = m_storage;
    767769
    768     unsigned usedVectorLength = min(m_length, storage->m_vectorLength);
     770    unsigned usedVectorLength = min(m_storage->m_length, storage->m_vectorLength);
    769771
    770772    unsigned numDefined = 0;
     
    836838        ASSERT(!m_storage->m_sparseValueMap);
    837839
    838     ASSERT(m_fastAccessCutoff <= m_length);
     840    ASSERT(m_fastAccessCutoff <= m_storage->m_length);
    839841    ASSERT(m_fastAccessCutoff <= m_storage->m_numValuesInVector);
    840842
     
    842844    for (unsigned i = 0; i < m_storage->m_vectorLength; ++i) {
    843845        if (JSValue* value = m_storage->m_vector[i]) {
    844             ASSERT(i < m_length);
     846            ASSERT(i < m_storage->m_length);
    845847            if (type != DestructorConsistencyCheck)
    846848                value->type(); // Likely to crash if the object was deallocated.
     
    858860        for (SparseArrayValueMap::iterator it = m_storage->m_sparseValueMap->begin(); it != end; ++it) {
    859861            unsigned index = it->first;
    860             ASSERT(index < m_length);
     862            ASSERT(index < m_storage->m_length);
    861863            ASSERT(index >= m_storage->m_vectorLength);
    862864            ASSERT(index <= MAX_ARRAY_INDEX);
  • trunk/JavaScriptCore/kjs/JSArray.h

    r35806 r35807  
    3030
    3131    struct ArrayStorage {
     32        unsigned m_length;
    3233        unsigned m_vectorLength;
    3334        unsigned m_numValuesInVector;
     
    4950        static const ClassInfo info;
    5051
    51         unsigned getLength() const { return m_length; }
     52        unsigned length() const { return m_storage->m_length; }
    5253        void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
    5354
     
    9293        void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
    9394
    94         unsigned m_length;
    9595        unsigned m_fastAccessCutoff;
    9696        ArrayStorage* m_storage;
  • trunk/JavaScriptCore/kjs/JSCell.h

    r35022 r35807  
    9797        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    9898        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     99       
     100        intptr_t reserved; // Reserved for work in progress.
    99101    };
    100102
  • trunk/JavaScriptCore/kjs/JSFunction.cpp

    r35022 r35807  
    2626#include "JSFunction.h"
    2727
     28#include "CommonIdentifiers.h"
    2829#include "ExecState.h"
    2930#include "FunctionPrototype.h"
     
    4041namespace KJS {
    4142
    42 const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
     43ASSERT_CLASS_FITS_IN_CELL(JSFunction);
     44
     45const ClassInfo JSFunction::info = { "Function", 0, 0, 0 };
    4346
    4447JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
    45     : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
     48    : Base(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
    4649    , m_body(body)
    4750    , m_scopeChain(scopeChainNode)
     
    5154void JSFunction::mark()
    5255{
    53     InternalFunction::mark();
     56    Base::mark();
    5457    m_body->mark();
    5558    m_scopeChain.mark();
     
    103106    }
    104107
    105     return InternalFunction::getOwnPropertySlot(exec, propertyName, slot);
     108    return Base::getOwnPropertySlot(exec, propertyName, slot);
    106109}
    107110
     
    110113    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    111114        return;
    112     InternalFunction::put(exec, propertyName, value);
     115    Base::put(exec, propertyName, value);
    113116}
    114117
     
    117120    if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
    118121        return false;
    119     return InternalFunction::deleteProperty(exec, propertyName);
     122    return Base::deleteProperty(exec, propertyName);
    120123}
    121124
  • trunk/JavaScriptCore/kjs/JSFunction.h

    r35022 r35807  
    3939
    4040    class JSFunction : public InternalFunction {
     41        typedef InternalFunction Base;
    4142    public:
    4243        JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
  • trunk/JavaScriptCore/kjs/JSGlobalObject.cpp

    r35657 r35807  
    6363namespace KJS {
    6464
     65ASSERT_CLASS_FITS_IN_CELL(JSGlobalObject);
     66
    6567// Default number of ticks before a timeout check should be done.
    6668static const int initialTickCountThreshold = 255;
     
    312314
    313315    d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
    314     putDirectFunction(d()->evalFunction, DontEnum);
    315     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
    316     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
    317     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
    318     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
    319     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
    320     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
    321     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
    322     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
    323     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
    324     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
     316    putDirectFunction(exec, d()->evalFunction, DontEnum);
     317    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
     318    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
     319    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
     320    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
     321    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
     322    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
     323    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
     324    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
     325    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
     326    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
    325327#ifndef NDEBUG
    326     putDirectFunction(new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
     328    putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
    327329#endif
    328330
  • trunk/JavaScriptCore/kjs/JSGlobalObject.h

    r35203 r35807  
    7878            {
    7979            }
     80           
     81            virtual ~JSGlobalObjectData()
     82            {
     83            }
    8084
    8185            JSGlobalObject* next;
     
    134138
    135139    protected:
    136         JSGlobalObject(JSValue* prototype, JSObject* globalThisValue)
    137             : JSVariableObject(prototype, new JSGlobalObjectData(this, globalThisValue))
     140        JSGlobalObject(JSValue* prototype, JSGlobalObjectData* d, JSObject* globalThisValue)
     141            : JSVariableObject(prototype, d)
    138142        {
    139143            init(globalThisValue);
  • trunk/JavaScriptCore/kjs/JSNotAnObject.cpp

    r34754 r35807  
    3434
    3535namespace KJS {
     36
     37ASSERT_CLASS_FITS_IN_CELL(JSNotAnObject);
    3638
    3739// JSValue methods
  • trunk/JavaScriptCore/kjs/JSObject.cpp

    r35750 r35807  
    4343namespace KJS {
    4444
     45ASSERT_CLASS_FITS_IN_CELL(JSObject);
     46
    4547void JSObject::mark()
    4648{
     
    461463}
    462464
    463 void JSObject::putDirectFunction(InternalFunction* function, unsigned attr)
    464 {
    465     putDirect(function->functionName(), function, attr);
     465void JSObject::putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr)
     466{
     467    putDirect(Identifier(exec, function->name(exec)), function, attr);
    466468}
    467469
  • trunk/JavaScriptCore/kjs/JSObject.h

    r35657 r35807  
    7070        virtual JSType type() const;
    7171
    72         /**
    73          * A pointer to a ClassInfo struct for this class. This provides a basic
    74          * facility for run-time type information, and can be used to check an
    75          * object's class an inheritance (see inherits()). This should
    76          * always return a statically declared pointer, or 0 to indicate that
    77          * there is no class information.
    78          *
    79          * This is primarily useful if you have application-defined classes that you
    80          * wish to check against for casting purposes.
    81          *
    82          * For example, to specify the class info for classes FooImp and BarImp,
    83          * where FooImp inherits from BarImp, you would add the following in your
    84          * class declarations:
    85          *
    86          * \code
    87          *   class BarImp : public JSObject {
    88          *     virtual const ClassInfo *classInfo() const { return &info; }
    89          *     static const ClassInfo info;
    90          *     // ...
    91          *   };
    92          *
    93          *   class FooImp : public JSObject {
    94          *     virtual const ClassInfo *classInfo() const { return &info; }
    95          *     static const ClassInfo info;
    96          *     // ...
    97          *   };
    98          * \endcode
    99          *
    100          * And in your source file:
    101          *
    102          * \code
    103          *   const ClassInfo BarImp::info = { "Bar", 0, 0, 0 }; // no parent class
    104          *   const ClassInfo FooImp::info = { "Foo", &BarImp::info, 0, 0 };
    105          * \endcode
    106          *
    107          * @see inherits()
    108          */
    109 
    110         /**
    111          * Checks whether this object inherits from the class with the specified
    112          * classInfo() pointer. This requires that both this class and the other
    113          * class return a non-NULL pointer for their classInfo() methods (otherwise
    114          * it will return false).
    115          *
    116          * For example, for two JSObject pointers obj1 and obj2, you can check
    117          * if obj1's class inherits from obj2's class using the following:
    118          *
    119          *   if (obj1->inherits(obj2->classInfo())) {
    120          *     // ...
    121          *   }
    122          *
    123          * If you have a handle to a statically declared ClassInfo, such as in the
    124          * classInfo() example, you can check for inheritance without needing
    125          * an instance of the other class:
    126          *
    127          *   if (obj1->inherits(FooImp::info)) {
    128          *     // ...
    129          *   }
    130          *
    131          * @param cinfo The ClassInfo pointer for the class you want to check
    132          * inheritance against.
    133          * @return true if this object's class inherits from class with the
    134          * ClassInfo pointer specified in cinfo
    135          */
    13672        bool inherits(const ClassInfo* classInfo) const { return isObject(classInfo); } // FIXME: Merge with isObject.
    13773
    138         // internal properties (ECMA 262-3 8.6.2)
    139 
    140         /**
    141          * Returns the prototype of this object. Note that this is not the same as
    142          * the "prototype" property.
    143          *
    144          * See ECMA 8.6.2
    145          *
    146          * @return The object's prototype
    147          */
    14874        JSValue* prototype() const;
    14975        void setPrototype(JSValue* prototype);
    15076
    151         /**
    152          * Returns the class name of the object
    153          *
    154          * See ECMA 8.6.2
    155          *
    156          * @return The object's class name
    157          */
    158         /**
    159          * Implementation of the [[Class]] internal property (implemented by all
    160          * Objects)
    161          *
    162          * The default implementation uses classInfo().
    163          * You should either implement classInfo(), or
    164          * if you simply need a classname, you can reimplement className()
    165          * instead.
    166          */
    16777        virtual UString className() const;
    16878
    169         /**
    170          * Retrieves the specified property from the object. If neither the object
    171          * or any other object in its prototype chain have the property, this
    172          * function will return Undefined.
    173          *
    174          * See ECMA 8.6.2.1
    175          *
    176          * @param exec The current execution state
    177          * @param propertyName The name of the property to retrieve
    178          *
    179          * @return The specified property, or Undefined
    180          */
    18179        JSValue* get(ExecState*, const Identifier& propertyName) const;
    18280        JSValue* get(ExecState*, unsigned propertyName) const;
     
    18886        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    18987
    190         /**
    191          * Sets the specified property.
    192          *
    193          * See ECMA 8.6.2.2
    194          *
    195          * @param exec The current execution state
    196          * @param propertyName The name of the property to set
    197          * @param propertyValue The value to set
    198          */
    19988        virtual void put(ExecState*, const Identifier& propertyName, JSValue* value);
    20089        virtual void put(ExecState*, unsigned propertyName, JSValue* value);
     
    20392        virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue* value, unsigned attributes);
    20493
    205         /**
    206          * Checks if a property is enumerable, that is if it doesn't have the DontEnum
    207          * flag set
    208          *
    209          * See ECMA 15.2.4
    210          * @param exec The current execution state
    211          * @param propertyName The name of the property
    212          * @return true if the property is enumerable, otherwise false
    213          */
    21494        bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const;
    21595
    216         /**
    217          * Checks to see whether the object (or any object in its prototype chain)
    218          * has a property with the specified name.
    219          *
    220          * See ECMA 8.6.2.4
    221          *
    222          * @param exec The current execution state
    223          * @param propertyName The name of the property to check for
    224          * @return true if the object has the property, otherwise false
    225          */
    22696        bool hasProperty(ExecState*, const Identifier& propertyName) const;
    22797        bool hasProperty(ExecState*, unsigned propertyName) const;
    22898        bool hasOwnProperty(ExecState*, const Identifier& propertyName) const;
    22999
    230         /**
    231          * Removes the specified property from the object.
    232          *
    233          * See ECMA 8.6.2.5
    234          *
    235          * @param exec The current execution state
    236          * @param propertyName The name of the property to delete
    237          * @return true if the property was successfully deleted or did not
    238          * exist on the object. false if deleting the specified property is not
    239          * allowed.
    240          */
    241100        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    242101        virtual bool deleteProperty(ExecState*, unsigned propertyName);
    243102
    244         /**
    245          * Converts the object into a primitive value. The value return may differ
    246          * depending on the supplied hint
    247          *
    248          * See ECMA 8.6.2.6
    249          *
    250          * @param exec The current execution state
    251          * @param hint The desired primitive type to convert to
    252          * @return A primitive value converted from the objetc. Note that the
    253          * type of primitive value returned may not be the same as the requested
    254          * hint.
    255          */
    256         /**
    257          * Implementation of the [[DefaultValue]] internal property (implemented by
    258          * all Objects)
    259          */
    260103        virtual JSValue* defaultValue(ExecState*, JSType hint) const;
    261104
    262         /**
    263          * Whether or not the object implements the hasInstance() method. If this
    264          * returns false you should not call the hasInstance() method on this
    265          * object (typically, an assertion will fail to indicate this).
    266          *
    267          * @return true if this object implements the hasInstance() method,
    268          * otherwise false
    269          */
    270105        virtual bool implementsHasInstance() const;
    271 
    272         /**
    273          * Checks whether value delegates behavior to this object. Used by the
    274          * instanceof operator.
    275          *
    276          * @param exec The current execution state
    277          * @param value The value to check
    278          * @return true if value delegates behavior to this object, otherwise
    279          * false
    280          */
    281106        virtual bool hasInstance(ExecState*, JSValue*);
    282107
     
    299124
    300125        // This get function only looks at the property map.
    301         // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
    302         // to look up in the prototype, it might already exist there)
    303126        JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); }
    304127        JSValue** getDirectLocation(const Identifier& propertyName) { return m_propertyMap.getLocation(propertyName); }
     
    310133
    311134        // convenience to add a function property under the function's own built-in name
    312         void putDirectFunction(InternalFunction*, unsigned attr = 0);
     135        void putDirectFunction(ExecState*, InternalFunction*, unsigned attr = 0);
    313136
    314137        void fillGetterPropertySlot(PropertySlot&, JSValue** location);
  • trunk/JavaScriptCore/kjs/JSStaticScopeObject.cpp

    r35533 r35807  
    2929
    3030namespace KJS {
     31
     32ASSERT_CLASS_FITS_IN_CELL(JSStaticScopeObject);
    3133
    3234JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const
  • trunk/JavaScriptCore/kjs/JSWrapperObject.cpp

    r31124 r35807  
    2626namespace KJS {
    2727
     28ASSERT_CLASS_FITS_IN_CELL(JSWrapperObject);
     29
    2830void JSWrapperObject::mark()
    2931{
  • trunk/JavaScriptCore/kjs/MathObject.cpp

    r35476 r35807  
    2929
    3030namespace KJS {
     31
     32ASSERT_CLASS_FITS_IN_CELL(MathObject);
    3133
    3234static JSValue* mathProtoFuncAbs(ExecState*, JSObject*, JSValue*, const ArgList&);
  • trunk/JavaScriptCore/kjs/NativeErrorConstructor.cpp

    r35411 r35807  
    2929namespace KJS {
    3030
     31ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
     32
    3133const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 };
    3234
    3335NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NativeErrorPrototype* nativeErrorPrototype)
    34     : InternalFunction(functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
     36    : InternalFunction(exec, functionPrototype, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
    3537    , m_proto(nativeErrorPrototype)
    3638{
  • trunk/JavaScriptCore/kjs/NativeErrorPrototype.cpp

    r35027 r35807  
    2828namespace KJS {
    2929
     30ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
     31
    3032NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, ErrorPrototype* errorPrototype, const UString& name, const UString& message)
    3133    : JSObject(errorPrototype)
  • trunk/JavaScriptCore/kjs/NumberConstructor.cpp

    r35411 r35807  
    2929namespace KJS {
    3030
     31ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
     32
    3133const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable };
    3234
     
    4143*/
    4244NumberConstructor::NumberConstructor(ExecState* exec, FunctionPrototype* functionPrototype, NumberPrototype* numberPrototype)
    43     : InternalFunction(functionPrototype, Identifier(exec, numberPrototype->info.className))
     45    : InternalFunction(exec, functionPrototype, Identifier(exec, numberPrototype->info.className))
    4446{
    4547    // Number.Prototype
  • trunk/JavaScriptCore/kjs/NumberObject.cpp

    r35027 r35807  
    2828namespace KJS {
    2929
     30ASSERT_CLASS_FITS_IN_CELL(NumberObject);
     31
    3032const ClassInfo NumberObject::info = { "Number", 0, 0, 0 };
    3133
  • trunk/JavaScriptCore/kjs/NumberPrototype.cpp

    r35291 r35807  
    3636namespace KJS {
    3737
     38ASSERT_CLASS_FITS_IN_CELL(NumberPrototype);
     39
    3840static JSValue* numberProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
    3941static JSValue* numberProtoFuncToLocaleString(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    5254    // The constructor will be added later, after NumberConstructor has been constructed
    5355
    54     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
    55     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
    56     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
    57     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
    58     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
    59     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
     56    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
     57    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
     58    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
     59    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
     60    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
     61    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
    6062}
    6163
  • trunk/JavaScriptCore/kjs/ObjectConstructor.cpp

    r35411 r35807  
    2828namespace KJS {
    2929
     30ASSERT_CLASS_FITS_IN_CELL(ObjectConstructor);
     31
    3032ObjectConstructor::ObjectConstructor(ExecState* exec, ObjectPrototype* objectPrototype, FunctionPrototype* functionPrototype)
    31     : InternalFunction(functionPrototype, Identifier(exec, "Object"))
     33    : InternalFunction(exec, functionPrototype, Identifier(exec, "Object"))
    3234{
    3335    // ECMA 15.2.3.1
  • trunk/JavaScriptCore/kjs/ObjectPrototype.cpp

    r35291 r35807  
    2929namespace KJS {
    3030
     31ASSERT_CLASS_FITS_IN_CELL(ObjectPrototype);
     32
    3133static JSValue* objectProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);
    3234static JSValue* objectProtoFuncHasOwnProperty(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    4244    : JSObject() // [[Prototype]] is null
    4345{
    44     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
    45     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    46     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    47     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
    48     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
    49     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
     46    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
     47    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
     48    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
     49    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     50    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     51    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    5052
    5153    // Mozilla extensions
    52     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
    53     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
    54     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
    55     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
     54    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     55    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     56    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     57    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    5658}
    5759
  • trunk/JavaScriptCore/kjs/PrototypeFunction.cpp

    r35242 r35807  
    3232namespace KJS {
    3333
     34ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction);
     35
    3436PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
    35     : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
     37    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), name)
    3638    , m_function(function)
    3739{
     
    4143
    4244PrototypeFunction::PrototypeFunction(ExecState* exec, FunctionPrototype* functionPrototype, int length, const Identifier& name, NativeFunction function)
    43     : InternalFunction(functionPrototype, name)
     45    : InternalFunction(exec, functionPrototype, name)
    4446    , m_function(function)
    4547{
  • trunk/JavaScriptCore/kjs/RegExpConstructor.cpp

    r35411 r35807  
    3333
    3434namespace KJS {
     35
     36ASSERT_CLASS_FITS_IN_CELL(RegExpConstructor);
    3537
    3638const ClassInfo RegExpConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::regExpConstructorTable };
     
    7779
    7880RegExpConstructor::RegExpConstructor(ExecState* exec, FunctionPrototype* functionPrototype, RegExpPrototype* regExpPrototype)
    79     : InternalFunction(functionPrototype, Identifier(exec, "RegExp"))
     81    : InternalFunction(exec, functionPrototype, Identifier(exec, "RegExp"))
    8082    , d(new RegExpConstructorPrivate)
    8183{
  • trunk/JavaScriptCore/kjs/RegExpObject.cpp

    r35291 r35807  
    3131namespace KJS {
    3232
     33ASSERT_CLASS_FITS_IN_CELL(RegExpObject);
     34
    3335const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable };
    3436
     
    4547RegExpObject::RegExpObject(RegExpPrototype* regExpPrototype, PassRefPtr<RegExp> regExp)
    4648    : JSObject(regExpPrototype)
    47     , m_regExp(regExp)
    48     , m_lastIndex(0)
     49    , d(new RegExpObjectData(regExp, 0))
    4950{
    5051}
     
    6364    switch (token) {
    6465        case Global:
    65             return jsBoolean(m_regExp->global());
     66            return jsBoolean(d->regExp->global());
    6667        case IgnoreCase:
    67             return jsBoolean(m_regExp->ignoreCase());
     68            return jsBoolean(d->regExp->ignoreCase());
    6869        case Multiline:
    69             return jsBoolean(m_regExp->multiline());
     70            return jsBoolean(d->regExp->multiline());
    7071        case Source:
    71             return jsString(exec, m_regExp->pattern());
     72            return jsString(exec, d->regExp->pattern());
    7273        case LastIndex:
    73             return jsNumber(exec, m_lastIndex);
     74            return jsNumber(exec, d->lastIndex);
    7475    }
    7576   
     
    8788    UNUSED_PARAM(token);
    8889    ASSERT(token == LastIndex);
    89     m_lastIndex = value->toInteger(exec);
     90    d->lastIndex = value->toInteger(exec);
    9091}
    9192
     
    108109    int lastIndex = 0;
    109110    if (global) {
    110         if (m_lastIndex < 0 || m_lastIndex > input.size()) {
    111             m_lastIndex = 0;
     111        if (d->lastIndex < 0 || d->lastIndex > input.size()) {
     112            d->lastIndex = 0;
    112113            return false;
    113114        }
    114         lastIndex = static_cast<int>(m_lastIndex);
     115        lastIndex = static_cast<int>(d->lastIndex);
    115116    }
    116117
    117118    int foundIndex;
    118119    int foundLength;
    119     regExpObj->performMatch(m_regExp.get(), input, lastIndex, foundIndex, foundLength);
     120    regExpObj->performMatch(d->regExp.get(), input, lastIndex, foundIndex, foundLength);
    120121
    121122    if (global) {
    122123        lastIndex = foundIndex < 0 ? 0 : foundIndex + foundLength;
    123         m_lastIndex = lastIndex;
     124        d->lastIndex = lastIndex;
    124125    }
    125126
  • trunk/JavaScriptCore/kjs/RegExpObject.h

    r35027 r35807  
    3636        virtual ~RegExpObject();
    3737
    38         void setRegExp(PassRefPtr<RegExp> r) { m_regExp = r; }
    39         RegExp* regExp() const { return m_regExp.get(); }
     38        void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; }
     39        RegExp* regExp() const { return d->regExp.get(); }
    4040
    4141        JSValue* test(ExecState*, const ArgList&);
     
    5050        static const ClassInfo info;
    5151
    52         void setLastIndex(double lastIndex) { m_lastIndex = lastIndex; }
     52        void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }
    5353
    5454    private:
     
    5656
    5757        virtual CallType getCallData(CallData&);
     58       
     59        struct RegExpObjectData {
     60            RegExpObjectData(PassRefPtr<RegExp> regExp_, double lastIndex_)
     61                : regExp(regExp_)
     62                , lastIndex(lastIndex_)
     63            {
     64            }
    5865
    59         RefPtr<RegExp> m_regExp;
    60         double m_lastIndex;
     66            RefPtr<RegExp> regExp;
     67            double lastIndex;
     68        };
     69       
     70        OwnPtr<RegExpObjectData> d;
    6171    };
    6272
  • trunk/JavaScriptCore/kjs/RegExpPrototype.cpp

    r35291 r35807  
    3535namespace KJS {
    3636
     37ASSERT_CLASS_FITS_IN_CELL(RegExpPrototype);
     38
    3739static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&);
    3840static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&);
     
    4749    : JSObject(objectPrototype)
    4850{
    49     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
    50     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
    51     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
    52     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
     51    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
     52    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
     53    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
     54    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
    5355}
    5456
  • trunk/JavaScriptCore/kjs/Shell.cpp

    r35478 r35807  
    166166};
    167167COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false);
     168ASSERT_CLASS_FITS_IN_CELL(GlobalObject);
    168169
    169170GlobalObject::GlobalObject(Vector<UString>& arguments)
    170171{
    171     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));
    172     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));
    173     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));
    174     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));
    175     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));
    176     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));
    177     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
    178     putDirectFunction(new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
     172    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "debug"), functionDebug));
     173    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "print"), functionPrint));
     174    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "quit"), functionQuit));
     175    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "gc"), functionGC));
     176    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "version"), functionVersion));
     177    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "run"), functionRun));
     178    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 1, Identifier(globalExec(), "load"), functionLoad));
     179    putDirectFunction(globalExec(), new (globalExec()) PrototypeFunction(globalExec(), functionPrototype(), 0, Identifier(globalExec(), "readline"), functionReadline));
    179180
    180181    JSObject* array = constructEmptyArray(globalExec());
  • trunk/JavaScriptCore/kjs/StringConstructor.cpp

    r35411 r35807  
    4545}
    4646
     47ASSERT_CLASS_FITS_IN_CELL(StringConstructor);
     48
    4749StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* functionPrototype, StringPrototype* stringPrototype)
    48     : InternalFunction(functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))
     50    : InternalFunction(exec, functionPrototype, Identifier(exec, stringPrototype->classInfo()->className))
    4951{
    5052    // ECMA 15.5.3.1 String.prototype
     
    5254
    5355    // ECMA 15.5.3.2 fromCharCode()
    54     putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
     56    putDirectFunction(exec, new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
    5557
    5658    // no. of arguments for constructor
  • trunk/JavaScriptCore/kjs/StringObject.cpp

    r35806 r35807  
    2525
    2626namespace KJS {
     27
     28ASSERT_CLASS_FITS_IN_CELL(StringObject);
    2729
    2830const ClassInfo StringObject::info = { "String", 0, 0, 0 };
  • trunk/JavaScriptCore/kjs/StringPrototype.cpp

    r35291 r35807  
    3434
    3535namespace KJS {
     36
     37ASSERT_CLASS_FITS_IN_CELL(StringPrototype);
    3638
    3739static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&);
  • trunk/JavaScriptCore/kjs/collector.h

    r35639 r35807  
    3434#include <pthread.h>
    3535#endif
     36
     37#define ASSERT_CLASS_FITS_IN_CELL(class) COMPILE_ASSERT(sizeof(class) <= CELL_SIZE, class_fits_in_cell)
    3638
    3739namespace KJS {
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r35756 r35807  
    3030#include "Profiler.h"
    3131
     32#include "CommonIdentifiers.h"
    3233#include "ExecState.h"
    3334#include "JSFunction.h"
     
    4445static unsigned ProfilesUID = 0;
    4546
    46 static CallIdentifier createCallIdentifier(JSObject*);
    47 static CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber);
    48 static CallIdentifier createCallIdentifierFromFunctionImp(JSFunction*);
     47static CallIdentifier createCallIdentifier(ExecState*, JSObject*);
     48static CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber);
     49static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSFunction*);
    4950
    5051Profiler* Profiler::s_sharedProfiler = 0;
     
    116117    ASSERT(!m_currentProfiles.isEmpty());
    117118
    118     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->profileGroup());
     119    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
    119120}
    120121
     
    123124    ASSERT(!m_currentProfiles.isEmpty());
    124125
    125     CallIdentifier callIdentifier = createCallIdentifier(sourceURL, startingLineNumber);
     126    CallIdentifier callIdentifier = createCallIdentifier(exec, sourceURL, startingLineNumber);
    126127
    127128    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->profileGroup());
     
    132133    ASSERT(!m_currentProfiles.isEmpty());
    133134
    134     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->profileGroup());
     135    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, calledFunction), exec->lexicalGlobalObject()->profileGroup());
    135136}
    136137
     
    139140    ASSERT(!m_currentProfiles.isEmpty());
    140141
    141     dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
     142    dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
    142143}
    143144
    144 CallIdentifier createCallIdentifier(JSObject* calledFunction)
     145CallIdentifier createCallIdentifier(ExecState* exec, JSObject* calledFunction)
    145146{
    146147    if (calledFunction->inherits(&JSFunction::info))
    147         return createCallIdentifierFromFunctionImp(static_cast<JSFunction*>(calledFunction));
     148        return createCallIdentifierFromFunctionImp(exec, static_cast<JSFunction*>(calledFunction));
    148149    if (calledFunction->inherits(&InternalFunction::info))
    149         return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->functionName().ustring(), "", 0);
     150        return CallIdentifier(static_cast<InternalFunction*>(calledFunction)->name(exec), "", 0);
    150151
    151152    UString name = "(" + calledFunction->className() + " object)";
     
    153154}
    154155
    155 CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber)
     156CallIdentifier createCallIdentifier(ExecState*, const UString& sourceURL, int startingLineNumber)
    156157{
    157158    return CallIdentifier(GlobalCodeExecution, sourceURL, startingLineNumber);
    158159}
    159160
    160 CallIdentifier createCallIdentifierFromFunctionImp(JSFunction* functionImp)
     161CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function)
    161162{
    162     UString name = functionImp->functionName().ustring();
    163     if (name.isEmpty())
    164         name = AnonymousFunction;
    165 
    166     return CallIdentifier(name, functionImp->m_body->sourceURL(), functionImp->m_body->lineNo());
     163    const UString& name = function->name(exec);
     164    return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->m_body->sourceURL(), function->m_body->lineNo());
    167165}
    168166
  • trunk/WebCore/ChangeLog

    r35804 r35807  
     12008-08-17  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        Made room for a free word in JSCell.
     6       
     7        Changed JSDOMWindowBase to store its auxiliary data in a subclass of
     8        JSGlobalData, so the two could share a pointer.
     9       
     10        Added a bunch of ASSERTs, to help catch over-sized objects.
     11
    1122008-08-15  Mark Rowe  <[email protected]>
    213
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r35804 r35807  
    1545715457                        projectDirPath = "";
    1545815458                        projectRoot = "";
    15459                         projectRoots = (
    15460                                 "",
    15461                         );
    1546215459                        targets = (
    1546315460                                93F198A508245E59001E9ABC /* WebCore */,
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r35666 r35807  
    193193*/
    194194
     195JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_)
     196    : JSGlobalObjectData(jsWindow_, shell_)
     197    , impl(window_)
     198    , evt(0)
     199    , returnValueSlot(0)
     200    , shell(shell_)
     201{
     202}
     203
    195204JSDOMWindowBase::JSDOMWindowBase(JSObject* prototype, DOMWindow* window, JSDOMWindowShell* shell)
    196     : JSGlobalObject(prototype, shell)
    197     , m_impl(window)
    198     , d(new JSDOMWindowBasePrivate(shell))
     205    : JSGlobalObject(prototype, new JSDOMWindowBaseData(window, this, shell), shell)
    199206{
    200207    // Time in milliseconds before the script timeout handler kicks in.
     
    203210    GlobalPropertyInfo staticGlobals[] = {
    204211        GlobalPropertyInfo(Identifier(globalExec(), "document"), jsNull(), DontDelete | ReadOnly),
    205         GlobalPropertyInfo(Identifier(globalExec(), "window"), d->m_shell, DontDelete | ReadOnly)
     212        GlobalPropertyInfo(Identifier(globalExec(), "window"), d()->shell, DontDelete | ReadOnly)
    206213    };
    207214   
     
    211218void JSDOMWindowBase::updateDocument()
    212219{
    213     ASSERT(m_impl->document());
     220    ASSERT(d()->impl->document());
    214221    ExecState* exec = globalExec();
    215     symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, m_impl->document()), DontDelete | ReadOnly);
     222    symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, d()->impl->document()), DontDelete | ReadOnly);
    216223}
    217224
    218225JSDOMWindowBase::~JSDOMWindowBase()
    219226{
    220     if (m_impl->frame())
    221         m_impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this));
     227    if (d()->impl->frame())
     228        d()->impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this));
    222229
    223230    clearAllTimeouts();
     
    225232    // Clear any backpointers to the window
    226233
    227     ListenersMap::iterator i2 = d->jsEventListeners.begin();
    228     ListenersMap::iterator e2 = d->jsEventListeners.end();
     234    ListenersMap::iterator i2 = d()->jsEventListeners.begin();
     235    ListenersMap::iterator e2 = d()->jsEventListeners.end();
    229236    for (; i2 != e2; ++i2)
    230237        i2->second->clearWindow();
    231     i2 = d->jsHTMLEventListeners.begin();
    232     e2 = d->jsHTMLEventListeners.end();
     238    i2 = d()->jsHTMLEventListeners.begin();
     239    e2 = d()->jsHTMLEventListeners.end();
    233240    for (; i2 != e2; ++i2)
    234241        i2->second->clearWindow();
    235242
    236     UnprotectedListenersMap::iterator i1 = d->jsUnprotectedEventListeners.begin();
    237     UnprotectedListenersMap::iterator e1 = d->jsUnprotectedEventListeners.end();
     243    UnprotectedListenersMap::iterator i1 = d()->jsUnprotectedEventListeners.begin();
     244    UnprotectedListenersMap::iterator e1 = d()->jsUnprotectedEventListeners.end();
    238245    for (; i1 != e1; ++i1)
    239246        i1->second->clearWindow();
    240     i1 = d->jsUnprotectedHTMLEventListeners.begin();
    241     e1 = d->jsUnprotectedHTMLEventListeners.end();
     247    i1 = d()->jsUnprotectedHTMLEventListeners.begin();
     248    e1 = d()->jsUnprotectedHTMLEventListeners.end();
    242249    for (; i1 != e1; ++i1)
    243250        i1->second->clearWindow();
     
    432439      if (!allowsAccessFrom(exec))
    433440        return jsUndefined();
    434       if (!d->m_evt)
    435         return jsUndefined();
    436       return toJS(exec, d->m_evt);
     441      if (!d()->evt)
     442        return jsUndefined();
     443      return toJS(exec, d()->evt);
    437444    case Image:
    438445      if (!allowsAccessFrom(exec))
     
    835842        return 0;
    836843    JSObject* object = static_cast<JSObject*>(val);
    837     ListenersMap& listeners = html ? d->jsHTMLEventListeners : d->jsEventListeners;
     844    ListenersMap& listeners = html ? d()->jsHTMLEventListeners : d()->jsEventListeners;
    838845    return listeners.get(object);
    839846}
     
    858865        return 0;
    859866    JSObject* object = static_cast<JSObject*>(val);
    860     UnprotectedListenersMap& listeners = html ? d->jsUnprotectedHTMLEventListeners : d->jsUnprotectedEventListeners;
     867    UnprotectedListenersMap& listeners = html ? d()->jsUnprotectedHTMLEventListeners : d()->jsUnprotectedEventListeners;
    861868    return listeners.get(object);
    862869}
     
    877884void JSDOMWindowBase::clearHelperObjectProperties()
    878885{
    879     d->m_evt = 0;
     886    d()->evt = 0;
    880887}
    881888
    882889void JSDOMWindowBase::clear()
    883890{
    884     if (d->m_returnValueSlot && !*d->m_returnValueSlot)
    885         *d->m_returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));
     891    if (d()->returnValueSlot && !*d()->returnValueSlot)
     892        *d()->returnValueSlot = getDirect(Identifier(globalExec(), "returnValue"));
    886893
    887894    clearAllTimeouts();
     
    891898void JSDOMWindowBase::setCurrentEvent(Event* evt)
    892899{
    893     d->m_evt = evt;
     900    d()->evt = evt;
    894901}
    895902
    896903Event* JSDOMWindowBase::currentEvent()
    897904{
    898     return d->m_evt;
     905    return d()->evt;
    899906}
    900907
     
    906913JSDOMWindowShell* JSDOMWindowBase::shell() const
    907914{
    908     return d->m_shell;
     915    return d()->shell;
    909916}
    910917
     
    11541161void JSDOMWindowBase::setReturnValueSlot(JSValue** slot)
    11551162{
    1156     d->m_returnValueSlot = slot;
     1163    d()->returnValueSlot = slot;
    11571164}
    11581165
     
    11611168void JSDOMWindowBase::clearAllTimeouts()
    11621169{
    1163     deleteAllValues(d->m_timeouts);
    1164     d->m_timeouts.clear();
     1170    deleteAllValues(d()->timeouts);
     1171    d()->timeouts.clear();
    11651172}
    11661173
     
    11751182    int nestLevel = timerNestingLevel + 1;
    11761183    DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, nestLevel, this, a);
    1177     ASSERT(!d->m_timeouts.get(timeoutId));
    1178     d->m_timeouts.set(timeoutId, timer);
     1184    ASSERT(!d()->timeouts.get(timeoutId));
     1185    d()->timeouts.set(timeoutId, timer);
    11791186    // Use a minimum interval of 10 ms to match other browsers, but only once we've
    11801187    // nested enough to notice that we're repeating.
     
    12021209PausedTimeouts* JSDOMWindowBase::pauseTimeouts()
    12031210{
    1204     size_t count = d->m_timeouts.size();
     1211    size_t count = d()->timeouts.size();
    12051212    if (count == 0)
    12061213        return 0;
     
    12091216    PausedTimeouts* result = new PausedTimeouts(t, count);
    12101217
    1211     JSDOMWindowBasePrivate::TimeoutsMap::iterator it = d->m_timeouts.begin();
     1218    JSDOMWindowBaseData::TimeoutsMap::iterator it = d()->timeouts.begin();
    12121219    for (size_t i = 0; i != count; ++i, ++it) {
    12131220        int timeoutId = it->first;
     
    12191226        t[i].action = timer->takeAction();
    12201227    }
    1221     ASSERT(it == d->m_timeouts.end());
    1222 
    1223     deleteAllValues(d->m_timeouts);
    1224     d->m_timeouts.clear();
     1228    ASSERT(it == d()->timeouts.end());
     1229
     1230    deleteAllValues(d()->timeouts);
     1231    d()->timeouts.clear();
    12251232
    12261233    return result;
     
    12361243        int timeoutId = array[i].timeoutId;
    12371244        DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, array[i].nestingLevel, this, array[i].action);
    1238         d->m_timeouts.set(timeoutId, timer);
     1245        d()->timeouts.set(timeoutId, timer);
    12391246        timer->start(array[i].nextFireInterval, array[i].repeatInterval);
    12401247    }
     
    12501257        return;
    12511258
    1252     delete d->m_timeouts.take(timeoutId);
     1259    delete d()->timeouts.take(timeoutId);
    12531260}
    12541261
     
    12621269        // The DOMWindowTimer object may have been deleted or replaced during execution,
    12631270        // so we re-fetch it.
    1264         timer = d->m_timeouts.get(timeoutId);
     1271        timer = d()->timeouts.get(timeoutId);
    12651272        if (!timer)
    12661273            return;
     
    12761283    // Delete timer before executing the action for one-shot timers.
    12771284    ScheduledAction* action = timer->takeAction();
    1278     d->m_timeouts.remove(timer->timeoutId());
     1285    d()->timeouts.remove(timer->timeoutId());
    12791286    delete timer;
    12801287    action->execute(shell());
     
    12901297JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsEventListeners()
    12911298{
    1292     return d->jsEventListeners;
     1299    return d()->jsEventListeners;
    12931300}
    12941301
    12951302JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsHTMLEventListeners()
    12961303{
    1297     return d->jsHTMLEventListeners;
     1304    return d()->jsHTMLEventListeners;
    12981305}
    12991306
    13001307JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventListeners()
    13011308{
    1302     return d->jsUnprotectedEventListeners;
     1309    return d()->jsUnprotectedEventListeners;
    13031310}
    13041311
    13051312JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedHTMLEventListeners()
    13061313{
    1307     return d->jsUnprotectedHTMLEventListeners;
     1314    return d()->jsUnprotectedHTMLEventListeners;
    13081315}
    13091316
  • trunk/WebCore/bindings/js/JSDOMWindowBase.h

    r35666 r35807  
    6161        void updateDocument();
    6262
    63         DOMWindow* impl() const { return m_impl.get(); }
     63        DOMWindow* impl() const { return d()->impl.get(); }
    6464
    6565        void disconnectFrame();
     
    147147
    148148    private:
     149        struct JSDOMWindowBaseData : public JSGlobalObjectData {
     150            JSDOMWindowBaseData(PassRefPtr<DOMWindow> window_, JSDOMWindowBase* jsWindow_, JSDOMWindowShell* shell_);
     151
     152            RefPtr<DOMWindow> impl;
     153
     154            JSDOMWindowBase::ListenersMap jsEventListeners;
     155            JSDOMWindowBase::ListenersMap jsHTMLEventListeners;
     156            JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;
     157            JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
     158            Event* evt;
     159            KJS::JSValue** returnValueSlot;
     160            JSDOMWindowShell* shell;
     161
     162            typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;
     163            TimeoutsMap timeouts;
     164        };
     165       
    149166        KJS::JSValue* getListener(KJS::ExecState*, const AtomicString& eventType) const;
    150167        void setListener(KJS::ExecState*, const AtomicString& eventType, KJS::JSValue* function);
     
    160177        bool allowsAccessFromPrivate(const KJS::JSGlobalObject*) const;
    161178        String crossDomainAccessErrorMessage(const KJS::JSGlobalObject*) const;
    162 
    163         RefPtr<DOMWindow> m_impl;
    164         OwnPtr<JSDOMWindowBasePrivate> d;
     179       
     180        JSDOMWindowBaseData* d() const { return static_cast<JSDOMWindowBaseData*>(KJS::JSVariableObject::d); }
    165181    };
    166182
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.h

    r34607 r35807  
    2525
    2626namespace WebCore {
    27 
    28 struct JSDOMWindowBasePrivate {
    29     JSDOMWindowBasePrivate(JSDOMWindowShell* shell)
    30         : m_evt(0)
    31         , m_returnValueSlot(0)
    32         , m_shell(shell)
    33     {
    34     }
    35 
    36     JSDOMWindowBase::ListenersMap jsEventListeners;
    37     JSDOMWindowBase::ListenersMap jsHTMLEventListeners;
    38     JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;
    39     JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
    40     Event* m_evt;
    41     KJS::JSValue** m_returnValueSlot;
    42     JSDOMWindowShell* m_shell;
    43 
    44     typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;
    45     TimeoutsMap m_timeouts;
    46 };
    4727
    4828inline JSDOMWindow* asJSDOMWindow(KJS::JSGlobalObject* globalObject)
     
    181161{
    182162    const JSDOMWindow* originWindow = asJSDOMWindow(other);
    183     const JSDOMWindow* targetWindow = d->m_shell->window();
     163    const JSDOMWindow* targetWindow = d()->shell->window();
    184164
    185165    if (originWindow == targetWindow)
  • trunk/WebCore/bindings/js/JSDOMWindowShell.cpp

    r35159 r35807  
    3939
    4040namespace WebCore {
     41
     42ASSERT_CLASS_FITS_IN_CELL(JSDOMWindowShell)
    4143
    4244const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", 0, 0, 0 };
  • trunk/WebCore/bindings/js/JSEventListener.cpp

    r35783 r35807  
    4242using namespace EventNames;
    4343
     44ASSERT_CLASS_FITS_IN_CELL(JSAbstractEventListener)
     45
    4446void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
    4547{
  • trunk/WebCore/bindings/js/JSEventTargetNode.cpp

    r34659 r35807  
    3535using namespace KJS;
    3636
     37ASSERT_CLASS_FITS_IN_CELL(JSEventTargetNode)
     38
    3739JSEventTargetNode::JSEventTargetNode(JSObject* prototype, Node* node)
    3840    : JSNode(prototype, node)
  • trunk/WebCore/bindings/js/JSHTMLInputElementBase.cpp

    r35291 r35807  
    2626
    2727namespace WebCore {
     28
     29ASSERT_CLASS_FITS_IN_CELL(JSHTMLInputElementBase)
    2830
    2931static JSValue* jsHTMLInputElementBaseFunctionSetSelectionRange(ExecState*, JSObject*, JSValue*, const ArgList&);
  • trunk/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp

    r35411 r35807  
    2929
    3030namespace WebCore {
     31
     32ASSERT_CLASS_FITS_IN_CELL(JSHTMLOptionElementConstructor)
    3133
    3234const ClassInfo JSHTMLOptionElementConstructor::s_info = { "OptionConstructor", 0, 0, 0 };
  • trunk/WebCore/bindings/js/JSImageConstructor.cpp

    r35411 r35807  
    2828
    2929namespace WebCore {
     30
     31ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor)
    3032
    3133const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 };
  • trunk/WebCore/bindings/js/JSInspectedObjectWrapper.cpp

    r34659 r35807  
    3232
    3333namespace WebCore {
     34
     35ASSERT_CLASS_FITS_IN_CELL(JSInspectedObjectWrapper)
    3436
    3537typedef HashMap<JSObject*, JSInspectedObjectWrapper*> WrapperMap;
  • trunk/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp

    r34754 r35807  
    3232
    3333namespace WebCore {
     34
     35ASSERT_CLASS_FITS_IN_CELL(JSInspectorCallbackWrapper)
    3436
    3537typedef HashMap<JSObject*, JSInspectorCallbackWrapper*> WrapperMap;
  • trunk/WebCore/bindings/js/JSNSResolver.cpp

    r35478 r35807  
    3535
    3636namespace WebCore {
     37
     38ASSERT_CLASS_FITS_IN_CELL(JSNSResolver)
    3739
    3840JSNSResolver::JSNSResolver(JSValue* resolver)
  • trunk/WebCore/bindings/js/JSNamedNodesCollection.cpp

    r34659 r35807  
    3636using namespace KJS;
    3737
     38ASSERT_CLASS_FITS_IN_CELL(JSNamedNodesCollection)
     39
    3840const ClassInfo JSNamedNodesCollection::s_info = { "Collection", 0, 0, 0 };
    3941
     
    4345JSNamedNodesCollection::JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >& nodes)
    4446    : DOMObject(prototype)
    45     , m_nodes(nodes)
     47    , m_nodes(new Vector<RefPtr<Node> >(nodes))
    4648{
    4749}
     
    5052{
    5153    JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
    52     return jsNumber(exec, thisObj->m_nodes.size());
     54    return jsNumber(exec, thisObj->m_nodes->size());
    5355}
    5456
     
    5658{
    5759    JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(slot.slotBase());
    58     return toJS(exec, thisObj->m_nodes[slot.index()].get());
     60    return toJS(exec, (*thisObj->m_nodes)[slot.index()].get());
    5961}
    6062
     
    6870    bool ok;
    6971    unsigned index = propertyName.toUInt32(&ok);
    70     if (ok && index < m_nodes.size()) {
     72    if (ok && index < m_nodes->size()) {
    7173        slot.setCustomIndex(this, index, indexGetter);
    7274        return true;
     
    7779
    7880    AtomicString atomicPropertyName = propertyName;
    79     for (unsigned i = 0; i < m_nodes.size(); i++) {
    80         Node* node = m_nodes[i].get();
     81    for (unsigned i = 0; i < m_nodes->size(); i++) {
     82        Node* node = (*m_nodes)[i].get();
    8183        if (node->hasAttributes() && node->attributes()->id() == atomicPropertyName) {
    8284            slot.setCustomIndex(this, i, indexGetter);
  • trunk/WebCore/bindings/js/JSNamedNodesCollection.h

    r34561 r35807  
    4949        static KJS::JSValue* indexGetter(KJS::ExecState*, const KJS::Identifier&, const KJS::PropertySlot&);
    5050
    51         Vector<RefPtr<Node> > m_nodes;
     51        OwnPtr<Vector<RefPtr<Node> > > m_nodes;
    5252    };
    5353
  • trunk/WebCore/bindings/js/JSNodeFilterCondition.cpp

    r35478 r35807  
    2828
    2929using namespace KJS;
     30
     31ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition)
    3032
    3133JSNodeFilterCondition::JSNodeFilterCondition(JSValue* filter)
  • trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp

    r35411 r35807  
    3333namespace WebCore {
    3434
     35ASSERT_CLASS_FITS_IN_CELL(JSQuarantinedObjectWrapper)
     36
    3537const ClassInfo JSQuarantinedObjectWrapper::s_info = { "JSQuarantinedObjectWrapper", 0, 0, 0 };
    3638
  • trunk/WebCore/bindings/js/JSRGBColor.cpp

    r34754 r35807  
    3232
    3333namespace WebCore {
     34
     35ASSERT_CLASS_FITS_IN_CELL(JSRGBColor)
    3436
    3537const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 };
  • trunk/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp

    r35411 r35807  
    2929namespace WebCore {
    3030
     31ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor)
     32
    3133const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 };
    3234
  • trunk/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp

    r35411 r35807  
    3838namespace WebCore {
    3939
     40ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor)
     41
    4042const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 };
    4143
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r35674 r35807  
    727727    push(@implContent, "\nusing namespace KJS;\n\n");
    728728    push(@implContent, "namespace WebCore {\n\n");
     729
     730    push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className)\n\n");
    729731
    730732    # - Add all attributes in a hashtable definition
  • trunk/WebCore/bridge/jni/jni_utility.cpp

    r35478 r35807  
    355355    // other than a string.
    356356    JSArray *jsArray = static_cast<JSArray *>(value);
    357     unsigned length = jsArray->getLength();
     357    unsigned length = jsArray->length();
    358358    jobjectArray jarray = 0;
    359359   
  • trunk/WebCore/bridge/runtime_method.cpp

    r35242 r35807  
    3535using namespace Bindings;
    3636
     37ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod);
     38
    3739RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m)
    38     : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), ident)
     40    : InternalFunction(exec, exec->lexicalGlobalObject()->functionPrototype(), ident)
    3941    , _methodList(new MethodList(m))
    4042{
  • trunk/WebKit/mac/ChangeLog

    r35802 r35807  
     12008-08-17  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        Made room for a free word in JSCell.
     6       
     7        (Updated for JavaScriptCore changes.)
     8
    192008-08-15  Mark Rowe  <[email protected]>
    210
  • trunk/WebKit/mac/WebView/WebScriptDebugger.mm

    r35590 r35807  
    8181{
    8282    attach(globalObject);
    83     DebuggerCallFrame globalCallFrame(globalObject, 0, globalObject->globalScopeChain().node(), 0, 0);
     83    DebuggerCallFrame globalCallFrame(0, globalObject, 0, globalObject->globalScopeChain().node(), 0, 0);
    8484    callEvent(globalCallFrame, 0, -1);
    8585}
  • trunk/WebKit/mac/WebView/WebView.mm

    r35767 r35807  
    32513251                    JSArray* array = static_cast<JSArray*>(object);
    32523252                    aeDesc = [NSAppleEventDescriptor listDescriptor];
    3253                     unsigned numItems = array->getLength();
     3253                    unsigned numItems = array->length();
    32543254                    for (unsigned i = 0; i < numItems; ++i)
    32553255                        [aeDesc insertDescriptor:aeDescFromJSValue(exec, array->get(exec, i)) atIndex:0];
Note: See TracChangeset for help on using the changeset viewer.