Changeset 27022 in webkit


Ignore:
Timestamp:
Oct 24, 2007 11:38:35 PM (16 years ago)
Author:
eseidel
Message:

2007-10-24 Eric Seidel <eric@webkit.org>

Reviewed by Maciej.


Add a JSGlobalObject class and remove the InterpreterMap
http://bugs.webkit.org/show_bug.cgi?id=15681


This required making JSCallbackObject a template class to allow for
JSGlobalObjects with JSCallbackObject functionality.


SunSpider claims this was a 0.5% speedup.

  • API/JSCallbackObject.cpp: (KJS::):
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: Copied from API/JSCallbackObject.cpp. (KJS::::JSCallbackObject): (KJS::::init): (KJS::::~JSCallbackObject): (KJS::::initializeIfNeeded): (KJS::::className): (KJS::::getOwnPropertySlot): (KJS::::put): (KJS::::deleteProperty): (KJS::::implementsConstruct): (KJS::::construct): (KJS::::implementsHasInstance): (KJS::::hasInstance): (KJS::::implementsCall): (KJS::::callAsFunction): (KJS::::getPropertyNames): (KJS::::toNumber): (KJS::::toString): (KJS::::setPrivate): (KJS::::getPrivate): (KJS::::inherits): (KJS::::cachedValueGetter): (KJS::::staticValueGetter): (KJS::::staticFunctionGetter): (KJS::::callbackGetter):
  • API/JSClassRef.cpp: (OpaqueJSClass::prototype):
  • API/JSContextRef.cpp: (JSGlobalContextCreate):
  • API/JSObjectRef.cpp: (JSObjectMake): (JSObjectGetPrivate): (JSObjectSetPrivate):
  • API/JSValueRef.cpp: (JSValueIsObjectOfClass):
  • JavaScriptCore.exp:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/c/c_utility.cpp: (KJS::Bindings::convertValueToNPVariant):
  • bindings/jni/jni_jsobject.cpp:
  • bindings/objc/objc_utility.mm: (KJS::Bindings::convertValueToObjcValue):
  • kjs/Context.cpp: (KJS::Context::Context):
  • kjs/ExecState.cpp: (KJS::ExecState::lexicalInterpreter):
  • kjs/JSGlobalObject.h: Added. (KJS::JSGlobalObject::JSGlobalObject): (KJS::JSGlobalObject::isGlobalObject): (KJS::JSGlobalObject::interpreter): (KJS::JSGlobalObject::setInterpreter):
  • kjs/array_instance.cpp:
  • kjs/context.h:
  • kjs/function.cpp: (KJS::FunctionImp::callAsFunction): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/interpreter.cpp: (KJS::Interpreter::Interpreter): (KJS::Interpreter::init): (KJS::Interpreter::~Interpreter): (KJS::Interpreter::globalObject): (KJS::Interpreter::initGlobalObject): (KJS::Interpreter::evaluate):
  • kjs/interpreter.h:
  • kjs/lookup.h: (KJS::cacheGlobalObject):
  • kjs/object.h: (KJS::JSObject::isGlobalObject):
  • kjs/testkjs.cpp:
Location:
trunk
Files:
1 added
31 edited
1 copied

Legend:

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

    r25258 r27022  
    22/*
    33 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    2526 */
    2627
    27 #include <wtf/Platform.h>
    2828#include "JSCallbackObject.h"
    29 
    30 #include "APICast.h"
    31 #include "JSCallbackFunction.h"
    32 #include "JSClassRef.h"
    33 #include "JSObjectRef.h"
    34 #include "JSStringRef.h"
    35 #include "PropertyNameArray.h"
    36 #include "internal.h"
    37 #include <wtf/Vector.h>
    3829
    3930namespace KJS {
    4031
    41 const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 };
    42 
    43 JSCallbackObject::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
    44     : JSObject(prototype)
    45     , m_class(0)
    46     , m_isInitialized(false)
    47 {
    48     init(exec, jsClass, data);
    49 }
    50 
    51 void JSCallbackObject::init(ExecState* exec, JSClassRef jsClass, void* data)
    52 {
    53     m_privateData = data;
    54     JSClassRef oldClass = m_class;
    55     m_class = JSClassRetain(jsClass);
    56     if (oldClass)
    57         JSClassRelease(oldClass);
    58 
    59     if (!exec)
    60         return;
    61 
    62     Vector<JSObjectInitializeCallback, 16> initRoutines;
    63     do {
    64         if (JSObjectInitializeCallback initialize = jsClass->initialize)
    65             initRoutines.append(initialize);
    66     } while ((jsClass = jsClass->parentClass));
    67    
    68     // initialize from base to derived
    69     for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) {
    70         JSLock::DropAllLocks dropAllLocks;
    71         JSObjectInitializeCallback initialize = initRoutines[i];
    72         initialize(toRef(exec), toRef(this));
    73     }
    74     m_isInitialized = true;
    75 }
    76 
    77 JSCallbackObject::~JSCallbackObject()
    78 {
    79     JSObjectRef thisRef = toRef(this);
    80    
    81     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    82         if (JSObjectFinalizeCallback finalize = jsClass->finalize) {
    83             finalize(thisRef);
    84         }
    85    
    86     JSClassRelease(m_class);
    87 }
    88 
    89 void JSCallbackObject::initializeIfNeeded(ExecState* exec)
    90 {
    91     if (m_isInitialized)
    92         return;
    93     init(exec, m_class, m_privateData);
    94 }
    95 
    96 UString JSCallbackObject::className() const
    97 {
    98     if (!m_class->className.isNull())
    99         return m_class->className;
    100    
    101     return JSObject::className();
    102 }
    103 
    104 bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    105 {
    106     JSContextRef ctx = toRef(exec);
    107     JSObjectRef thisRef = toRef(this);
    108     JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    109 
    110     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    111         // optional optimization to bypass getProperty in cases when we only need to know if the property exists
    112         if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
    113             JSLock::DropAllLocks dropAllLocks;
    114             if (hasProperty(ctx, thisRef, propertyNameRef)) {
    115                 slot.setCustom(this, callbackGetter);
    116                 return true;
    117             }
    118         } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    119             JSLock::DropAllLocks dropAllLocks;
    120             if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {
    121                 // cache the value so we don't have to compute it again
    122                 // FIXME: This violates the PropertySlot design a little bit.
    123                 // We should either use this optimization everywhere, or nowhere.
    124                 slot.setCustom(reinterpret_cast<JSObject*>(toJS(value)), cachedValueGetter);
    125                 return true;
    126             }
    127         }
    128 
    129         if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    130             if (staticValues->contains(propertyName.ustring().rep())) {
    131                 slot.setCustom(this, staticValueGetter);
    132                 return true;
    133             }
    134         }
    135        
    136         if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    137             if (staticFunctions->contains(propertyName.ustring().rep())) {
    138                 slot.setCustom(this, staticFunctionGetter);
    139                 return true;
    140             }
    141         }
    142     }
    143 
    144     return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    145 }
    146 
    147 bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    148 {
    149     return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);
    150 }
    151 
    152 void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
    153 {
    154     JSContextRef ctx = toRef(exec);
    155     JSObjectRef thisRef = toRef(this);
    156     JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    157     JSValueRef valueRef = toRef(value);
    158 
    159     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    160         if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
    161             JSLock::DropAllLocks dropAllLocks;
    162             if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
    163                 return;
    164         }
    165    
    166         if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    167             if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
    168                 if (entry->attributes & kJSPropertyAttributeReadOnly)
    169                     return;
    170                 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
    171                     JSLock::DropAllLocks dropAllLocks;
    172                     if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
    173                         return;
    174                 } else
    175                     throwError(exec, ReferenceError, "Attempt to set a property that is not settable.");
    176             }
    177         }
    178        
    179         if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    180             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    181                 if (entry->attributes & kJSPropertyAttributeReadOnly)
    182                     return;
    183                 putDirect(propertyName, value, attr); // put as override property
    184                 return;
    185             }
    186         }
    187     }
    188 
    189     return JSObject::put(exec, propertyName, value, attr);
    190 }
    191 
    192 void JSCallbackObject::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)
    193 {
    194     return put(exec, Identifier::from(propertyName), value, attr);
    195 }
    196 
    197 bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
    198 {
    199     JSContextRef ctx = toRef(exec);
    200     JSObjectRef thisRef = toRef(this);
    201     JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    202    
    203     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    204         if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
    205             JSLock::DropAllLocks dropAllLocks;
    206             if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    207                 return true;
    208         }
    209 
    210         if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    211             if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
    212                 if (entry->attributes & kJSPropertyAttributeDontDelete)
    213                     return false;
    214                 return true;
    215             }
    216         }
    217        
    218         if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    219             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    220                 if (entry->attributes & kJSPropertyAttributeDontDelete)
    221                     return false;
    222                 return true;
    223             }
    224         }
    225     }
    226 
    227     return JSObject::deleteProperty(exec, propertyName);
    228 }
    229 
    230 bool JSCallbackObject::deleteProperty(ExecState* exec, unsigned propertyName)
    231 {
    232     return deleteProperty(exec, Identifier::from(propertyName));
    233 }
    234 
    235 bool JSCallbackObject::implementsConstruct() const
    236 {
    237     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    238         if (jsClass->callAsConstructor)
    239             return true;
    240 
    241     return false;
    242 }
    243 
    244 JSObject* JSCallbackObject::construct(ExecState* exec, const List& args)
    245 {
    246     JSContextRef execRef = toRef(exec);
    247     JSObjectRef thisRef = toRef(this);
    248    
    249     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    250         if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) {
    251             int argumentCount = static_cast<int>(args.size());
    252             Vector<JSValueRef, 16> arguments(argumentCount);
    253             for (int i = 0; i < argumentCount; i++)
    254                 arguments[i] = toRef(args[i]);
    255             JSLock::DropAllLocks dropAllLocks;
    256             return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    257         }
    258     }
    259    
    260     ASSERT(0); // implementsConstruct should prevent us from reaching here
    261     return 0;
    262 }
    263 
    264 bool JSCallbackObject::implementsHasInstance() const
    265 {
    266     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    267         if (jsClass->hasInstance)
    268             return true;
    269 
    270     return false;
    271 }
    272 
    273 bool JSCallbackObject::hasInstance(ExecState *exec, JSValue *value)
    274 {
    275     JSContextRef execRef = toRef(exec);
    276     JSObjectRef thisRef = toRef(this);
    277 
    278     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    279         if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
    280             JSLock::DropAllLocks dropAllLocks;
    281             return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
    282         }
    283 
    284     ASSERT(0); // implementsHasInstance should prevent us from reaching here
    285     return 0;
    286 }
    287 
    288 
    289 bool JSCallbackObject::implementsCall() const
    290 {
    291     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    292         if (jsClass->callAsFunction)
    293             return true;
    294    
    295     return false;
    296 }
    297 
    298 JSValue* JSCallbackObject::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
    299 {
    300     JSContextRef execRef = toRef(exec);
    301     JSObjectRef thisRef = toRef(this);
    302     JSObjectRef thisObjRef = toRef(thisObj);
    303 
    304     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    305         if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
    306             int argumentCount = static_cast<int>(args.size());
    307             Vector<JSValueRef, 16> arguments(argumentCount);
    308             for (int i = 0; i < argumentCount; i++)
    309                 arguments[i] = toRef(args[i]);
    310             JSLock::DropAllLocks dropAllLocks;
    311             return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot())));
    312         }
    313     }
    314 
    315     ASSERT(0); // implementsCall should prevent us from reaching here
    316     return 0;
    317 }
    318 
    319 void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    320 {
    321     JSContextRef execRef = toRef(exec);
    322     JSObjectRef thisRef = toRef(this);
    323 
    324     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    325         if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
    326             JSLock::DropAllLocks dropAllLocks;
    327             getPropertyNames(execRef, thisRef, toRef(&propertyNames));
    328         }
    329 
    330         if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    331             typedef OpaqueJSClass::StaticValuesTable::const_iterator iterator;
    332             iterator end = staticValues->end();
    333             for (iterator it = staticValues->begin(); it != end; ++it) {
    334                 UString::Rep* name = it->first.get();
    335                 StaticValueEntry* entry = it->second;
    336                 if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum))
    337                     propertyNames.add(Identifier(name));
    338             }
    339         }
    340 
    341         if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    342             typedef OpaqueJSClass::StaticFunctionsTable::const_iterator iterator;
    343             iterator end = staticFunctions->end();
    344             for (iterator it = staticFunctions->begin(); it != end; ++it) {
    345                 UString::Rep* name = it->first.get();
    346                 StaticFunctionEntry* entry = it->second;
    347                 if (!(entry->attributes & kJSPropertyAttributeDontEnum))
    348                     propertyNames.add(Identifier(name));
    349             }
    350         }
    351     }
    352 
    353     JSObject::getPropertyNames(exec, propertyNames);
    354 }
    355 
    356 double JSCallbackObject::toNumber(ExecState* exec) const
    357 {
    358     JSContextRef ctx = toRef(exec);
    359     JSObjectRef thisRef = toRef(this);
    360 
    361     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    362         if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    363             JSLock::DropAllLocks dropAllLocks;
    364             if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
    365                 return toJS(value)->getNumber();
    366         }
    367 
    368     return JSObject::toNumber(exec);
    369 }
    370 
    371 UString JSCallbackObject::toString(ExecState* exec) const
    372 {
    373     JSContextRef ctx = toRef(exec);
    374     JSObjectRef thisRef = toRef(this);
    375 
    376     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    377         if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
    378             JSLock::DropAllLocks dropAllLocks;
    379             if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())))
    380                 return toJS(value)->getString();
    381         }
    382 
    383     return JSObject::toString(exec);
    384 }
    385 
    386 void JSCallbackObject::setPrivate(void* data)
    387 {
    388     m_privateData = data;
    389 }
    390 
    391 void* JSCallbackObject::getPrivate()
    392 {
    393     return m_privateData;
    394 }
    395 
    396 bool JSCallbackObject::inherits(JSClassRef c) const
    397 {
    398     for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    399         if (jsClass == c)
    400             return true;
    401 
    402     return false;
    403 }
    404 
    405 JSValue* JSCallbackObject::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
    406 {
    407     JSValue* v = slot.slotBase();
    408     ASSERT(v);
    409     return v;
    410 }
    411 
    412 JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    413 {
    414     ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    415     JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    416 
    417     JSObjectRef thisRef = toRef(thisObj);
    418     JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    419 
    420     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    421         if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues)
    422             if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
    423                 if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
    424                     JSLock::DropAllLocks dropAllLocks;
    425                     if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    426                         return toJS(value);
    427                 }
    428 
    429     return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback.");
    430 }
    431 
    432 JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    433 {
    434     ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    435     JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    436 
    437     if (JSValue* cachedOrOverrideValue = thisObj->getDirect(propertyName))
    438         return cachedOrOverrideValue;
    439 
    440     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) {
    441         if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    442             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    443                 if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
    444                     JSObject* o = new JSCallbackFunction(exec, callAsFunction, propertyName);
    445                     thisObj->putDirect(propertyName, o, entry->attributes);
    446                     return o;
    447                 }
    448             }
    449         }
    450     }
    451 
    452     return throwError(exec, ReferenceError, "Static function property defined with NULL callAsFunction callback.");
    453 }
    454 
    455 JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    456 {
    457     ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    458     JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    459 
    460     JSObjectRef thisRef = toRef(thisObj);
    461     JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    462 
    463     for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    464         if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    465             JSLock::DropAllLocks dropAllLocks;
    466             if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    467                 return toJS(value);
    468         }
    469 
    470     return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist.");
    471 }
     32// Define the two types of JSCallbackObjects we support.
     33template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
     34template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
    47235
    47336} // namespace KJS
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r25257 r27022  
    22/*
    33 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    3435namespace KJS {
    3536
    36 class JSCallbackObject : public JSObject
     37template <class Base>
     38class JSCallbackObject : public Base
    3739{
    3840public:
     
    9395} // namespace KJS
    9496
     97// include the actual template class implementation
     98#include "JSCallbackObjectFunctions.h"
     99
    95100#endif // JSCallbackObject_h
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r27021 r27022  
    22/*
    33 * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    2627
    2728#include <wtf/Platform.h>
    28 #include "JSCallbackObject.h"
    29 
    3029#include "APICast.h"
    3130#include "JSCallbackFunction.h"
    3231#include "JSClassRef.h"
    3332#include "JSObjectRef.h"
     33#include "JSGlobalObject.h"
    3434#include "JSStringRef.h"
    3535#include "PropertyNameArray.h"
     
    3939namespace KJS {
    4040
    41 const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 };
    42 
    43 JSCallbackObject::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
    44     : JSObject(prototype)
     41template <class Base>
     42JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JSValue* prototype, void* data)
     43    : Base(prototype)
    4544    , m_class(0)
    4645    , m_isInitialized(false)
     
    4948}
    5049
    51 void JSCallbackObject::init(ExecState* exec, JSClassRef jsClass, void* data)
     50template <class Base>
     51void JSCallbackObject<Base>::init(ExecState* exec, JSClassRef jsClass, void* data)
    5252{
    5353    m_privateData = data;
     
    5656    if (oldClass)
    5757        JSClassRelease(oldClass);
    58 
     58   
    5959    if (!exec)
    6060        return;
    61 
     61   
    6262    Vector<JSObjectInitializeCallback, 16> initRoutines;
    6363    do {
     
    7575}
    7676
    77 JSCallbackObject::~JSCallbackObject()
     77template <class Base>
     78JSCallbackObject<Base>::~JSCallbackObject()
    7879{
    7980    JSObjectRef thisRef = toRef(this);
     
    8384            finalize(thisRef);
    8485        }
    85    
     86           
    8687    JSClassRelease(m_class);
    8788}
    8889
    89 void JSCallbackObject::initializeIfNeeded(ExecState* exec)
     90template <class Base>
     91void JSCallbackObject<Base>::initializeIfNeeded(ExecState* exec)
    9092{
    9193    if (m_isInitialized)
     
    9496}
    9597
    96 UString JSCallbackObject::className() const
     98template <class Base>
     99UString JSCallbackObject<Base>::className() const
    97100{
    98101    if (!m_class->className.isNull())
     
    102105}
    103106
    104 bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
     107template <class Base>
     108bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    105109{
    106110    JSContextRef ctx = toRef(exec);
    107111    JSObjectRef thisRef = toRef(this);
    108112    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    109 
     113   
    110114    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    111115        // optional optimization to bypass getProperty in cases when we only need to know if the property exists
     
    126130            }
    127131        }
    128 
     132       
    129133        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    130134            if (staticValues->contains(propertyName.ustring().rep())) {
     
    141145        }
    142146    }
    143 
     147   
    144148    return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    145149}
    146150
    147 bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
     151template <class Base>
     152bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    148153{
    149154    return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);
    150155}
    151156
    152 void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
     157template <class Base>
     158void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
    153159{
    154160    JSContextRef ctx = toRef(exec);
     
    156162    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    157163    JSValueRef valueRef = toRef(value);
    158 
     164   
    159165    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    160166        if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
     
    163169                return;
    164170        }
    165    
     171       
    166172        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    167173            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
     
    181187                if (entry->attributes & kJSPropertyAttributeReadOnly)
    182188                    return;
    183                 putDirect(propertyName, value, attr); // put as override property
     189                JSCallbackObject<Base>::putDirect(propertyName, value, attr); // put as override property
    184190                return;
    185191            }
    186192        }
    187193    }
    188 
     194   
    189195    return JSObject::put(exec, propertyName, value, attr);
    190196}
    191197
    192 void JSCallbackObject::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)
     198template <class Base>
     199void JSCallbackObject<Base>::put(ExecState* exec, unsigned propertyName, JSValue* value, int attr)
    193200{
    194201    return put(exec, Identifier::from(propertyName), value, attr);
    195202}
    196203
    197 bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
     204template <class Base>
     205bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, const Identifier& propertyName)
    198206{
    199207    JSContextRef ctx = toRef(exec);
     
    207215                return true;
    208216        }
    209 
     217       
    210218        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    211219            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
     
    224232        }
    225233    }
    226 
     234   
    227235    return JSObject::deleteProperty(exec, propertyName);
    228236}
    229237
    230 bool JSCallbackObject::deleteProperty(ExecState* exec, unsigned propertyName)
     238template <class Base>
     239bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, unsigned propertyName)
    231240{
    232241    return deleteProperty(exec, Identifier::from(propertyName));
    233242}
    234243
    235 bool JSCallbackObject::implementsConstruct() const
     244template <class Base>
     245bool JSCallbackObject<Base>::implementsConstruct() const
    236246{
    237247    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    238248        if (jsClass->callAsConstructor)
    239249            return true;
    240 
     250   
    241251    return false;
    242252}
    243253
    244 JSObject* JSCallbackObject::construct(ExecState* exec, const List& args)
     254template <class Base>
     255JSObject* JSCallbackObject<Base>::construct(ExecState* exec, const List& args)
    245256{
    246257    JSContextRef execRef = toRef(exec);
     
    262273}
    263274
    264 bool JSCallbackObject::implementsHasInstance() const
     275template <class Base>
     276bool JSCallbackObject<Base>::implementsHasInstance() const
    265277{
    266278    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    267279        if (jsClass->hasInstance)
    268280            return true;
    269 
     281   
    270282    return false;
    271283}
    272284
    273 bool JSCallbackObject::hasInstance(ExecState *exec, JSValue *value)
     285template <class Base>
     286bool JSCallbackObject<Base>::hasInstance(ExecState *exec, JSValue *value)
    274287{
    275288    JSContextRef execRef = toRef(exec);
    276289    JSObjectRef thisRef = toRef(this);
    277 
     290   
    278291    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    279292        if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
     
    281294            return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
    282295        }
    283 
    284     ASSERT(0); // implementsHasInstance should prevent us from reaching here
     296           
     297    ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here
    285298    return 0;
    286299}
    287300
    288301
    289 bool JSCallbackObject::implementsCall() const
     302template <class Base>
     303bool JSCallbackObject<Base>::implementsCall() const
    290304{
    291305    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
     
    296310}
    297311
    298 JSValue* JSCallbackObject::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
     312template <class Base>
     313JSValue* JSCallbackObject<Base>::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
    299314{
    300315    JSContextRef execRef = toRef(exec);
    301316    JSObjectRef thisRef = toRef(this);
    302317    JSObjectRef thisObjRef = toRef(thisObj);
    303 
     318   
    304319    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    305320        if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
     
    312327        }
    313328    }
    314 
    315     ASSERT(0); // implementsCall should prevent us from reaching here
     329   
     330    ASSERT_NOT_REACHED(); // implementsCall should prevent us from reaching here
    316331    return 0;
    317332}
    318333
    319 void JSCallbackObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
     334template <class Base>
     335void JSCallbackObject<Base>::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
    320336{
    321337    JSContextRef execRef = toRef(exec);
    322338    JSObjectRef thisRef = toRef(this);
    323 
     339   
    324340    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    325341        if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
     
    327343            getPropertyNames(execRef, thisRef, toRef(&propertyNames));
    328344        }
    329 
     345       
    330346        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
    331347            typedef OpaqueJSClass::StaticValuesTable::const_iterator iterator;
     
    338354            }
    339355        }
    340 
     356       
    341357        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
    342358            typedef OpaqueJSClass::StaticFunctionsTable::const_iterator iterator;
     
    350366        }
    351367    }
    352 
     368   
    353369    JSObject::getPropertyNames(exec, propertyNames);
    354370}
    355371
    356 double JSCallbackObject::toNumber(ExecState* exec) const
     372template <class Base>
     373double JSCallbackObject<Base>::toNumber(ExecState* exec) const
    357374{
    358375    JSContextRef ctx = toRef(exec);
    359376    JSObjectRef thisRef = toRef(this);
    360 
     377   
    361378    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    362379        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
     
    365382                return toJS(value)->getNumber();
    366383        }
    367 
     384           
    368385    return JSObject::toNumber(exec);
    369386}
    370387
    371 UString JSCallbackObject::toString(ExecState* exec) const
     388template <class Base>
     389UString JSCallbackObject<Base>::toString(ExecState* exec) const
    372390{
    373391    JSContextRef ctx = toRef(exec);
    374392    JSObjectRef thisRef = toRef(this);
    375 
     393   
    376394    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    377395        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
     
    380398                return toJS(value)->getString();
    381399        }
    382 
     400           
    383401    return JSObject::toString(exec);
    384402}
    385403
    386 void JSCallbackObject::setPrivate(void* data)
     404template <class Base>
     405void JSCallbackObject<Base>::setPrivate(void* data)
    387406{
    388407    m_privateData = data;
    389408}
    390409
    391 void* JSCallbackObject::getPrivate()
     410template <class Base>
     411void* JSCallbackObject<Base>::getPrivate()
    392412{
    393413    return m_privateData;
    394414}
    395415
    396 bool JSCallbackObject::inherits(JSClassRef c) const
     416template <class Base>
     417bool JSCallbackObject<Base>::inherits(JSClassRef c) const
    397418{
    398419    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    399420        if (jsClass == c)
    400421            return true;
    401 
     422   
    402423    return false;
    403424}
    404425
    405 JSValue* JSCallbackObject::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
     426template <class Base>
     427JSValue* JSCallbackObject<Base>::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
    406428{
    407429    JSValue* v = slot.slotBase();
     
    410432}
    411433
    412 JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     434template <class Base>
     435JSValue* JSCallbackObject<Base>::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    413436{
    414437    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    415438    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    416 
     439   
    417440    JSObjectRef thisRef = toRef(thisObj);
    418441    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    419 
     442   
    420443    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    421444        if (OpaqueJSClass::StaticValuesTable* staticValues = jsClass->staticValues)
     
    426449                        return toJS(value);
    427450                }
    428 
     451                   
    429452    return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback.");
    430453}
    431454
    432 JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     455template <class Base>
     456JSValue* JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    433457{
    434458    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    435459    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    436 
     460   
    437461    if (JSValue* cachedOrOverrideValue = thisObj->getDirect(propertyName))
    438462        return cachedOrOverrideValue;
    439 
     463   
    440464    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass) {
    441465        if (OpaqueJSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     
    449473        }
    450474    }
    451 
     475   
    452476    return throwError(exec, ReferenceError, "Static function property defined with NULL callAsFunction callback.");
    453477}
    454478
    455 JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     479template <class Base>
     480JSValue* JSCallbackObject<Base>::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
    456481{
    457482    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
    458483    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
    459 
     484   
    460485    JSObjectRef thisRef = toRef(thisObj);
    461486    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
    462 
     487   
    463488    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parentClass)
    464489        if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
     
    467492                return toJS(value);
    468493        }
    469 
     494           
    470495    return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist.");
    471496}
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r24809 r27022  
    157157        if (!parentPrototype)
    158158            parentPrototype = exec->dynamicInterpreter()->builtinObjectPrototype();
    159         cachedPrototype = new JSCallbackObject(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
     159        cachedPrototype = new JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
    160160    }
    161161    return cachedPrototype;
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r25257 r27022  
    3030
    3131#include "JSCallbackObject.h"
     32#include "JSGlobalObject.h"
    3233#include "completion.h"
    3334#include "interpreter.h"
     
    4041    JSLock lock;
    4142
    42     JSObject* globalObject;
     43    JSGlobalObject* globalObject;
    4344    if (globalObjectClass)
    4445        // Specify jsNull() as the prototype.  Interpreter will fix it up to point at builtinObjectPrototype() in its constructor
    45         globalObject = new JSCallbackObject(0, globalObjectClass, jsNull(), 0);
     46        globalObject = new JSCallbackObject<JSGlobalObject>(0, globalObjectClass, jsNull(), 0);
    4647    else
    47         globalObject = new JSObject();
     48        globalObject = new JSGlobalObject();
    4849
    4950    Interpreter* interpreter = new Interpreter(globalObject); // adds the built-in object prototype to the global object
    5051    if (globalObjectClass)
    51         static_cast<JSCallbackObject*>(globalObject)->initializeIfNeeded(interpreter->globalExec());
     52        static_cast<JSCallbackObject<JSGlobalObject>*>(globalObject)->initializeIfNeeded(interpreter->globalExec());
    5253    JSGlobalContextRef ctx = reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec());
    5354    return JSGlobalContextRetain(ctx);
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r26625 r27022  
    3333#include "JSCallbackObject.h"
    3434#include "JSClassRef.h"
     35#include "JSGlobalObject.h"
    3536
    3637#include "identifier.h"
     
    7879        jsPrototype = exec->lexicalInterpreter()->builtinObjectPrototype();
    7980
    80     return toRef(new JSCallbackObject(exec, jsClass, jsPrototype, data));
     81    return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
    8182}
    8283
     
    236237    JSObject* jsObject = toJS(object);
    237238   
    238     if (jsObject->inherits(&JSCallbackObject::info))
    239         return static_cast<JSCallbackObject*>(jsObject)->getPrivate();
     239    if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
     240        return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
     241    else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
     242        return static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivate();
    240243   
    241244    return 0;
     
    246249    JSObject* jsObject = toJS(object);
    247250   
    248     if (jsObject->inherits(&JSCallbackObject::info)) {
    249         static_cast<JSCallbackObject*>(jsObject)->setPrivate(data);
     251    if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
     252        static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
     253        return true;
     254    } else if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
     255        static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivate(data);
    250256        return true;
    251257    }
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r19193 r27022  
    3131
    3232#include <kjs/JSType.h>
     33#include <kjs/JSGlobalObject.h>
    3334#include <kjs/internal.h>
    3435#include <kjs/operations.h>
     
    105106    JSValue* jsValue = toJS(value);
    106107   
    107     if (JSObject* o = jsValue->getObject())
    108         if (o->inherits(&JSCallbackObject::info))
    109             return static_cast<JSCallbackObject*>(o)->inherits(jsClass);
     108    if (JSObject* o = jsValue->getObject()) {
     109        if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
     110            return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
     111        else if (o->inherits(&JSCallbackObject<JSObject>::info))
     112            return static_cast<JSCallbackObject<JSObject>*>(o)->inherits(jsClass);
     113    }
    110114    return false;
    111115}
  • trunk/JavaScriptCore/ChangeLog

    r27002 r27022  
     12007-10-24  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Maciej.
     4       
     5        Add a JSGlobalObject class and remove the InterpreterMap
     6        http://bugs.webkit.org/show_bug.cgi?id=15681
     7       
     8        This required making JSCallbackObject a template class to allow for
     9        JSGlobalObjects with JSCallbackObject functionality.
     10       
     11        SunSpider claims this was a 0.5% speedup.
     12
     13        * API/JSCallbackObject.cpp:
     14        (KJS::):
     15        * API/JSCallbackObject.h:
     16        * API/JSCallbackObjectFunctions.h: Copied from API/JSCallbackObject.cpp.
     17        (KJS::::JSCallbackObject):
     18        (KJS::::init):
     19        (KJS::::~JSCallbackObject):
     20        (KJS::::initializeIfNeeded):
     21        (KJS::::className):
     22        (KJS::::getOwnPropertySlot):
     23        (KJS::::put):
     24        (KJS::::deleteProperty):
     25        (KJS::::implementsConstruct):
     26        (KJS::::construct):
     27        (KJS::::implementsHasInstance):
     28        (KJS::::hasInstance):
     29        (KJS::::implementsCall):
     30        (KJS::::callAsFunction):
     31        (KJS::::getPropertyNames):
     32        (KJS::::toNumber):
     33        (KJS::::toString):
     34        (KJS::::setPrivate):
     35        (KJS::::getPrivate):
     36        (KJS::::inherits):
     37        (KJS::::cachedValueGetter):
     38        (KJS::::staticValueGetter):
     39        (KJS::::staticFunctionGetter):
     40        (KJS::::callbackGetter):
     41        * API/JSClassRef.cpp:
     42        (OpaqueJSClass::prototype):
     43        * API/JSContextRef.cpp:
     44        (JSGlobalContextCreate):
     45        * API/JSObjectRef.cpp:
     46        (JSObjectMake):
     47        (JSObjectGetPrivate):
     48        (JSObjectSetPrivate):
     49        * API/JSValueRef.cpp:
     50        (JSValueIsObjectOfClass):
     51        * JavaScriptCore.exp:
     52        * JavaScriptCore.xcodeproj/project.pbxproj:
     53        * bindings/c/c_utility.cpp:
     54        (KJS::Bindings::convertValueToNPVariant):
     55        * bindings/jni/jni_jsobject.cpp:
     56        * bindings/objc/objc_utility.mm:
     57        (KJS::Bindings::convertValueToObjcValue):
     58        * kjs/Context.cpp:
     59        (KJS::Context::Context):
     60        * kjs/ExecState.cpp:
     61        (KJS::ExecState::lexicalInterpreter):
     62        * kjs/JSGlobalObject.h: Added.
     63        (KJS::JSGlobalObject::JSGlobalObject):
     64        (KJS::JSGlobalObject::isGlobalObject):
     65        (KJS::JSGlobalObject::interpreter):
     66        (KJS::JSGlobalObject::setInterpreter):
     67        * kjs/array_instance.cpp:
     68        * kjs/context.h:
     69        * kjs/function.cpp:
     70        (KJS::FunctionImp::callAsFunction):
     71        (KJS::GlobalFuncImp::callAsFunction):
     72        * kjs/interpreter.cpp:
     73        (KJS::Interpreter::Interpreter):
     74        (KJS::Interpreter::init):
     75        (KJS::Interpreter::~Interpreter):
     76        (KJS::Interpreter::globalObject):
     77        (KJS::Interpreter::initGlobalObject):
     78        (KJS::Interpreter::evaluate):
     79        * kjs/interpreter.h:
     80        * kjs/lookup.h:
     81        (KJS::cacheGlobalObject):
     82        * kjs/object.h:
     83        (KJS::JSObject::isGlobalObject):
     84        * kjs/testkjs.cpp:
     85
    1862007-10-24  Eric Seidel  <eric@webkit.org>
    287
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r26994 r27022  
    123123__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
    124124__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
    125 __ZN3KJS11InterpreterC1EPNS_8JSObjectE
     125__ZN3KJS11InterpreterC1EPNS_14JSGlobalObjectE
     126__ZN3KJS11InterpreterC2EPNS_14JSGlobalObjectE
    126127__ZN3KJS11InterpreterC1Ev
    127 __ZN3KJS11InterpreterC2EPNS_8JSObjectE
    128128__ZN3KJS11InterpreterD1Ev
    129129__ZN3KJS11InterpreterD2Ev
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r26995 r27022  
    232232                93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F0B3AA09BB4DC00068FCE3 /* Parser.h */; };
    233233                95C18D490C90E82600E72F73 /* JSRetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 95C18D3E0C90E7EF00E72F73 /* JSRetainPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
     234                A8E894320CD0602400367179 /* JSCallbackObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */; };
     235                A8E894340CD0603F00367179 /* JSGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8E894330CD0603F00367179 /* JSGlobalObject.h */; };
    234236                BCF655590A2049710038A194 /* MathExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF6553B0A2048DE0038A194 /* MathExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
    235237                D212022B0AD4310D00ED79B6 /* DateMath.h in Headers */ = {isa = PBXBuildFile; fileRef = D21202290AD4310C00ED79B6 /* DateMath.h */; };
     
    587589                93F1981A08245AAE001E9ABC /* keywords.table */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = text; path = keywords.table; sourceTree = "<group>"; tabWidth = 8; };
    588590                95C18D3E0C90E7EF00E72F73 /* JSRetainPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRetainPtr.h; sourceTree = "<group>"; };
     591                A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
     592                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
    589593                BCF6553B0A2048DE0038A194 /* MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MathExtras.h; sourceTree = "<group>"; };
    590594                D21202280AD4310C00ED79B6 /* DateMath.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DateMath.cpp; sourceTree = "<group>"; };
     
    771775                                14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */,
    772776                                14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */,
     777                                A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */,
    773778                                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */,
    774779                                1440FCE10A51E46B0005F061 /* JSClassRef.h */,
     
    780785                                1482B74C0A43032800517CFC /* JSStringRef.cpp */,
    781786                                1482B74B0A43032800517CFC /* JSStringRef.h */,
     787                                146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */,
    782788                                146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */,
    783                                 146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */,
    784789                                14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */,
    785790                                1482B6EA0A4300B300517CFC /* JSValueRef.h */,
     
    946951                        isa = PBXGroup;
    947952                        children = (
    948                                 65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
    949                                 65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */,
    950                                 65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */,
    951                                 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
    952                                 65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
    953                                 65400C100A69BAF200509887 /* PropertyNameArray.h */,
     953                                659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
     954                                93ADFCE60CCBD7AC00D30B08 /* array_instance.cpp */,
    954955                                938772E5038BFE19008635CE /* array_instance.h */,
    955                                 93ADFCE60CCBD7AC00D30B08 /* array_instance.cpp */,
    956                                 659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
    957956                                F692A84D0255597D01FF60F7 /* array_object.cpp */,
    958957                                F692A84E0255597D01FF60F7 /* array_object.h */,
     
    961960                                F692A8520255597D01FF60F7 /* collector.cpp */,
    962961                                F692A8530255597D01FF60F7 /* collector.h */,
     962                                5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */,
    963963                                5DBD18AA0C54018700C15EAE /* CollectorHeapIntrospector.h */,
    964                                 5DBD18A90C54018700C15EAE /* CollectorHeapIntrospector.cpp */,
     964                                65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */,
     965                                65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */,
    965966                                F5BB2BC5030F772101FCFE1D /* completion.h */,
    966967                                F68EBB8C0255D4C601FF60F7 /* config.h */,
     
    978979                                F692A85A0255597D01FF60F7 /* error_object.cpp */,
    979980                                F692A85B0255597D01FF60F7 /* error_object.h */,
     981                                14BD53F40A3E12D800BAF59C /* ExecState.cpp */,
     982                                14BD53F30A3E12D800BAF59C /* ExecState.h */,
    980983                                9364B273045B7D6C00A9CAC1 /* fpconst.cpp */,
    981984                                F692A85E0255597D01FF60F7 /* function.cpp */,
     
    991994                                F692A8640255597D01FF60F7 /* interpreter.h */,
    992995                                F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */,
     996                                A8E894330CD0603F00367179 /* JSGlobalObject.h */,
    993997                                14760863099C633800437128 /* JSImmediate.cpp */,
    994998                                1483B589099BC1950016E4F0 /* JSImmediate.h */,
     
    9961000                                65EA4C9A092AF9E20093D800 /* JSLock.h */,
    9971001                                14ABB454099C2A0F00E2A24F /* JSType.h */,
     1002                                65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
     1003                                65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
    9981004                                93F1981A08245AAE001E9ABC /* keywords.table */,
    9991005                                F692A8650255597D01FF60F7 /* lexer.cpp */,
     
    10221028                                65621E6B089E859700760F35 /* property_slot.cpp */,
    10231029                                65621E6C089E859700760F35 /* property_slot.h */,
     1030                                65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
     1031                                65400C100A69BAF200509887 /* PropertyNameArray.h */,
    10241032                                65C02FBB0637462A003E7EE6 /* protect.h */,
    10251033                                F692A87D0255597D01FF60F7 /* regexp.cpp */,
     
    10271035                                F692A87B0255597D01FF60F7 /* regexp_object.cpp */,
    10281036                                F692A87C0255597D01FF60F7 /* regexp_object.h */,
     1037                                14BD534A0A3E0AEA00BAF59C /* SavedBuiltins.h */,
    10291038                                9374D3A8038D9D74008635CE /* scope_chain.cpp */,
    10301039                                9374D3A7038D9D74008635CE /* scope_chain.h */,
     
    10361045                                F692A8870255597D01FF60F7 /* value.cpp */,
    10371046                                14ABB36E099C076400E2A24F /* value.h */,
    1038                                 14BD534A0A3E0AEA00BAF59C /* SavedBuiltins.h */,
    1039                                 14BD53F30A3E12D800BAF59C /* ExecState.h */,
    1040                                 14BD53F40A3E12D800BAF59C /* ExecState.cpp */,
    10411047                        );
    10421048                        path = kjs;
     
    12571263                                938C4F6C0CA06BCE00D9310A /* DisallowCType.h in Headers */,
    12581264                                5186111E0CC824900081412B /* Deque.h in Headers */,
     1265                                A8E894320CD0602400367179 /* JSCallbackObjectFunctions.h in Headers */,
     1266                                A8E894340CD0603F00367179 /* JSGlobalObject.h in Headers */,
    12591267                        );
    12601268                        runOnlyForDeploymentPostprocessing = 0;
     
    13721380                        isa = PBXProject;
    13731381                        buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
    1374                         compatibilityVersion = "Xcode 2.4";
    13751382                        hasScannedForEncodings = 1;
    13761383                        mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
  • trunk/JavaScriptCore/bindings/c/c_utility.cpp

    r26688 r27022  
    3232
    3333#include "NP_jsobject.h"
    34 #include "c_instance.h"
     34#include "c_instance.h"
     35#include "JSGlobalObject.h"
    3536#include "npruntime_impl.h"
    3637#include "npruntime_priv.h"
     
    131132
    132133            Interpreter* interpreter = 0;
    133             if (originInterpreter->isGlobalObject(value)) {
    134                 interpreter = originInterpreter->interpreterForGlobalObject(value);
    135             }
     134            if (object->isGlobalObject())
     135                interpreter = static_cast<JSGlobalObject*>(object)->interpreter();
    136136
    137137            if (!interpreter)
  • trunk/JavaScriptCore/bindings/jni/jni_jsobject.cpp

    r26688 r27022  
    3131#include "jni_runtime.h"
    3232#include "jni_utility.h"
     33#include "JSGlobalObject.h"
    3334#include "list.h"
    3435#include "runtime_object.h"
  • trunk/JavaScriptCore/bindings/objc/objc_utility.mm

    r26688 r27022  
    2828
    2929#include "objc_instance.h"
     30#include "JSGlobalObject.h"
    3031#include "runtime_array.h"
    3132#include "runtime_object.h"
     
    141142
    142143            Interpreter *interpreter = 0;
    143             if (originInterpreter->isGlobalObject(value))
    144                 interpreter = originInterpreter->interpreterForGlobalObject(value);
     144            if (value->isObject() && static_cast<JSObject*>(value)->isGlobalObject())
     145                interpreter = static_cast<JSGlobalObject*>(value)->interpreter();
    145146
    146147            if (!interpreter)
  • trunk/JavaScriptCore/kjs/Context.cpp

    r26620 r27022  
    2828
    2929// ECMA 10.2
    30 Context::Context(JSObject* glob, Interpreter* interpreter, JSObject* thisV,
     30Context::Context(JSGlobalObject* glob, Interpreter* interpreter, JSObject* thisV,
    3131                 FunctionBodyNode* currentBody, CodeType type, Context* callingCon,
    3232                 FunctionImp* func, const List* args)
  • trunk/JavaScriptCore/kjs/ExecState.cpp

    r15118 r27022  
    3131Interpreter* ExecState::lexicalInterpreter() const
    3232{
    33   if (!m_context)
     33    if (!m_context)
     34        return dynamicInterpreter();
     35   
     36    JSObject* object = m_context->scopeChain().bottom();
     37    if (object && object->isGlobalObject())
     38        return static_cast<JSGlobalObject*>(object)->interpreter();
     39
    3440    return dynamicInterpreter();
    35 
    36   Interpreter* result = Interpreter::interpreterWithGlobalObject(m_context->scopeChain().bottom());
    37 
    38   if (!result)
    39     return dynamicInterpreter();
    40 
    41   return result;
    4241}
    4342
  • trunk/JavaScriptCore/kjs/array_instance.cpp

    r26897 r27022  
    492492    JSObject *compareFunction;
    493493    List arguments;
    494     JSObject *globalObject;
     494    JSGlobalObject* globalObject;
    495495};
    496496
  • trunk/JavaScriptCore/kjs/context.h

    r25534 r27022  
    5151  class Context {
    5252  public:
    53     Context(JSObject* global, Interpreter*, JSObject* thisV,
     53    Context(JSGlobalObject*, Interpreter*, JSObject* thisV,
    5454            FunctionBodyNode* currentBody, CodeType type = GlobalCode,
    5555            Context* callingContext = 0, FunctionImp* function = 0, const List* args = 0);
  • trunk/JavaScriptCore/kjs/function.cpp

    r26808 r27022  
    3131#include "function_object.h"
    3232#include "internal.h"
     33#include "JSGlobalObject.h"
    3334#include "lexer.h"
    3435#include "nodes.h"
     
    6667JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
    6768{
    68   JSObject* globalObj = exec->dynamicInterpreter()->globalObject();
     69  JSGlobalObject* globalObj = exec->dynamicInterpreter()->globalObject();
    6970
    7071  // enter a new execution context
     
    755756          return throwError(exec, SyntaxError, errMsg, errLine, sid, NULL);
    756757
    757         bool switchGlobal = thisObj && exec->dynamicInterpreter()->isGlobalObject(thisObj) && thisObj != exec->dynamicInterpreter()->globalObject();
     758        bool switchGlobal = thisObj && thisObj != exec->dynamicInterpreter()->globalObject();
    758759         
    759760        // enter a new execution context
    760         Interpreter* interpreter = switchGlobal ? exec->dynamicInterpreter()->interpreterForGlobalObject(thisObj) : exec->dynamicInterpreter();
     761        Interpreter* interpreter = switchGlobal ? static_cast<JSGlobalObject*>(thisObj)->interpreter() : exec->dynamicInterpreter();
    761762        JSObject* thisVal = static_cast<JSObject*>(exec->context()->thisValue());
    762763        Context ctx(interpreter->globalObject(),
  • trunk/JavaScriptCore/kjs/interpreter.cpp

    r26808 r27022  
    8080    return* map;
    8181}
    82    
    83 Interpreter::Interpreter(JSObject* globalObject)
     82
     83Interpreter::Interpreter(JSGlobalObject* globalObject)
    8484    : m_globalExec(this, 0)
    8585    , m_globalObject(globalObject)
     
    9090Interpreter::Interpreter()
    9191    : m_globalExec(this, 0)
    92     , m_globalObject(new JSObject())
     92    , m_globalObject(new JSGlobalObject())
    9393{
    9494    init();
     
    119119        s_hook = next = prev = this;
    120120    }
    121     interpreterMap().set(m_globalObject, this);
    122121
    123122    initGlobalObject();
     
    138137        s_hook = 0;
    139138    }
    140     interpreterMap().remove(m_globalObject);
    141 }
    142 
    143 JSObject* Interpreter::globalObject() const
    144 {
    145   return m_globalObject;
     139}
     140
     141JSGlobalObject* Interpreter::globalObject() const
     142{
     143    return m_globalObject;
    146144}
    147145
    148146void Interpreter::initGlobalObject()
    149147{
     148    m_globalObject->setInterpreter(this);
     149
    150150    // Clear before inititalizing, to avoid marking uninitialized (dangerous) or
    151151    // stale (wasteful) pointers during initialization.
    152 
     152   
    153153    // Prototypes
    154154    m_FunctionPrototype = 0;
     
    348348    m_recursion++;
    349349   
    350     JSObject* globalObj = m_globalObject;
     350    JSGlobalObject* globalObj = m_globalObject;
    351351    JSObject* thisObj = globalObj;
    352352   
     
    611611}
    612612
    613 Interpreter* Interpreter::interpreterWithGlobalObject(JSObject* globalObject)
    614 {
    615     return interpreterMap().get(globalObject);
    616 }
    617 
    618613#ifdef KJS_DEBUG_MEM
    619614#include "lexer.h"
  • trunk/JavaScriptCore/kjs/interpreter.h

    r20310 r27022  
    4646  class FunctionObjectImp;
    4747  class FunctionPrototype;
     48  class JSGlobalObject;
    4849  class NativeErrorImp;
    4950  class NativeErrorPrototype;
     
    9596     * @param global The object to use as the global object for this interpreter
    9697     */
    97     Interpreter(JSObject* globalObject);
     98    Interpreter(JSGlobalObject*);
    9899    /**
    99100     * Creates a new interpreter. A global object will be created and
     
    112113     * execution performed by this interpreter
    113114     */
    114     JSObject* globalObject() const;
     115    JSGlobalObject* globalObject() const;
    115116
    116117    /**
     
    301302    void saveBuiltins (SavedBuiltins&) const;
    302303    void restoreBuiltins (const SavedBuiltins&);
    303 
    304     /**
    305      * Determine if the value is a global object (for any interpreter).  This may
    306      * be difficult to determine for multiple uses of JSC in a process that are
    307      * logically independent of each other.  In the case of WebCore, this method
    308      * is used to determine if an object is the Window object so we can perform
    309      * security checks.
    310      */
    311     virtual bool isGlobalObject(JSValue*) { return false; }
    312    
    313     /**
    314      * Find the interpreter for a particular global object.  This should really
    315      * be a static method, but we can't do that is C++.  Again, as with isGlobalObject()
    316      * implementation really need to know about all instances of Interpreter
    317      * created in an application to correctly implement this method.  The only
    318      * override of this method is currently in WebCore.
    319      */
    320     virtual Interpreter* interpreterForGlobalObject(const JSValue*) { return 0; }
    321304   
    322305    /**
     
    338321    void setContext(Context* c) { m_context = c; }
    339322    Context* context() const { return m_context; }
    340    
    341     static Interpreter* interpreterWithGlobalObject(JSObject*);
    342    
     323       
    343324    void setTimeoutTime(unsigned timeoutTime) { m_timeoutTime = timeoutTime; }
    344325
     
    389370    unsigned m_ticksUntilNextTimeoutCheck;
    390371
    391     JSObject* m_globalObject;
     372    JSGlobalObject* m_globalObject;
    392373
    393374    ObjectObjectImp* m_Object;
  • trunk/JavaScriptCore/kjs/lookup.h

    r26956 r27022  
    2020 */
    2121
    22 #ifndef _KJSLOOKUP_H_
    23 #define _KJSLOOKUP_H_
     22#ifndef KJS_lookup_h
     23#define KJS_lookup_h
    2424
    2525#include "context.h"
    2626#include "identifier.h"
    2727#include "interpreter.h"
     28#include "JSGlobalObject.h"
    2829#include "object.h"
    2930#include <stdio.h>
     
    270271  inline JSObject* cacheGlobalObject(ExecState* exec, const Identifier& propertyName)
    271272  {
    272     JSObject* globalObject = static_cast<JSObject*>(exec->lexicalInterpreter()->globalObject());
     273    JSGlobalObject* globalObject = exec->lexicalInterpreter()->globalObject();
    273274    JSValue* obj = globalObject->getDirect(propertyName);
    274275    if (obj) {
     
    352353  };
    353354
    354 #endif
     355#endif // KJS_lookup_h
  • trunk/JavaScriptCore/kjs/object.h

    r26688 r27022  
    458458
    459459    virtual bool isActivation() { return false; }
     460    virtual bool isGlobalObject() const { return false; }
    460461  protected:
    461462    PropertyMap _prop;
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r26783 r27022  
    2727#include "Parser.h"
    2828#include "collector.h"
     29#include "JSGlobalObject.h"
    2930#include "object.h"
    3031#include "protect.h"
     
    111112}
    112113
    113 class GlobalImp : public JSObject {
     114class GlobalImp : public JSGlobalObject {
    114115public:
    115116  virtual UString className() const { return "global"; }
  • trunk/WebCore/ChangeLog

    r27020 r27022  
     12007-10-24  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Maciej.
     4       
     5        Make Window subclass from JSGlobalObject (for a .5% win in Sunspider)
     6        http://bugs.webkit.org/show_bug.cgi?id=15681
     7
     8        No test cases necessary, no functional changes.
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11        * bindings/js/kjs_binding.cpp:
     12        (KJS::ScriptInterpreter::ScriptInterpreter):
     13        * bindings/js/kjs_binding.h:
     14        * bindings/js/kjs_proxy.cpp:
     15        (WebCore::KJSProxy::initScriptIfNeeded):
     16        * bindings/js/kjs_window.cpp:
     17        (KJS::Window::Window):
     18        * bindings/js/kjs_window.h:
     19        * bindings/objc/WebScriptObject.mm:
     20        (_didExecute):
     21        * bridge/mac/WebCoreScriptDebugger.mm:
     22
    1232007-10-24  Adam Roben  <aroben@apple.com>
    224
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r26933 r27022  
    1361413614                        isa = PBXProject;
    1361513615                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
    13616                         compatibilityVersion = "Xcode 2.4";
    1361713616                        hasScannedForEncodings = 1;
    1361813617                        knownRegions = (
  • trunk/WebCore/bindings/js/kjs_binding.cpp

    r26992 r27022  
    131131}
    132132
    133 ScriptInterpreter::ScriptInterpreter(JSObject* global, Frame* frame)
     133ScriptInterpreter::ScriptInterpreter(JSGlobalObject* global, Frame* frame)
    134134    : Interpreter(global)
    135135    , m_frame(frame)
  • trunk/WebCore/bindings/js/kjs_binding.h

    r26421 r27022  
    5151
    5252    /**
    53      * Base class for all objects in this binding.
     53     * Base class for all objects in this binding EXCEPT Window
    5454     */
    5555    class DOMObject : public JSObject {
     
    7373    class ScriptInterpreter : public Interpreter {
    7474    public:
    75         ScriptInterpreter(JSObject* global, WebCore::Frame*);
     75        ScriptInterpreter(JSGlobalObject*, WebCore::Frame*);
    7676
    7777        static DOMObject* getDOMObject(void* objectHandle);
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r26816 r27022  
    152152  // Build the global object - which is a Window instance
    153153  JSLock lock;
    154   JSObject* globalObject = new JSDOMWindow(m_frame->domWindow());
     154  JSDOMWindow* globalObject = new JSDOMWindow(m_frame->domWindow());
    155155
    156156  // Create a KJS interpreter for this frame
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r27011 r27022  
    216216  , d(new WindowPrivate)
    217217{
     218    // Window destruction is not thread-safe because of
     219    // the non-thread-safe WebCore structures it references.
     220    Collector::collectOnMainThreadOnly(this);
    218221}
    219222
  • trunk/WebCore/bindings/js/kjs_window.h

    r26584 r27022  
    6666  class WindowPrivate;
    6767
    68   class Window : public DOMObject {
     68  // This is the only WebCore JS binding which does not inherit from DOMNode
     69  class Window : public JSGlobalObject {
    6970    friend class Location;
    7071    friend class WindowFunc;
  • trunk/WebCore/bindings/objc/WebScriptObject.mm

    r25697 r27022  
    3636#import <JavaScriptCore/runtime_object.h>
    3737#import <JavaScriptCore/APICast.h>
     38#import <JavaScriptCore/JSGlobalObject.h>
    3839
    3940using namespace KJS;
     
    116117    KJSDidExecuteFunctionPtr func = Instance::didExecuteFunction();
    117118    if (func)
    118         func(exec, static_cast<JSObject*>(root->interpreter()->globalObject()));
     119        func(exec, root->interpreter()->globalObject());
    119120}
    120121
  • trunk/WebCore/bridge/mac/WebCoreScriptDebugger.mm

    r20004 r27022  
    3737#import <JavaScriptCore/context.h>
    3838#import <JavaScriptCore/debugger.h>
     39#import <JavaScriptCore/JSGlobalObject.h>
    3940
    4041using namespace KJS;
Note: See TracChangeset for help on using the changeset viewer.