Changeset 59941 in webkit


Ignore:
Timestamp:
May 21, 2010 11:19:42 AM (14 years ago)
Author:
oliver@apple.com
Message:

2010-05-21 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

All callable objects should have a global object reference
https://bugs.webkit.org/show_bug.cgi?id=39495

All objects that may ever return a value other CallTypeNone
or ConstructTypeNone now get a global object in their constructor
and store that in their first anonymous slot. We add a new type
JSObjectWithGlobalObject to allow us to share this logic as much
as possible, however some objects have specific inheritance
requirements so we can't just use it universally.

To enforce this requirement JSValue::getCallData and getConstructData
make use of a new "isValidCallee" function to assert that any object
that returns a value other than CallType/ConstructTypeNone has a
global object in anonymous slot 0.

In order to ensure that static function slots are converted into
function objects with the correct global object, all prototype objects
and other classes with static function slots also gain a global object
reference. Happily this fixes the long standing issue where host
function objects get a prototype from the lexical global object of the
first function that calls them, instead of the global object that they
are defined on.

  • API/JSCallbackConstructor.cpp: (JSC::JSCallbackConstructor::JSCallbackConstructor):
  • API/JSCallbackConstructor.h:
  • API/JSCallbackFunction.cpp: (JSC::JSCallbackFunction::JSCallbackFunction):
  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.cpp: (JSC::):
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h: (JSC::::JSCallbackObject): (JSC::::staticFunctionGetter):
  • API/JSClassRef.cpp: (OpaqueJSClass::prototype):
  • API/JSContextRef.cpp:
  • API/JSObjectRef.cpp: (JSObjectMake): (JSObjectMakeFunctionWithCallback): (JSObjectMakeConstructor): (JSObjectGetPrivate): (JSObjectSetPrivate): (JSObjectGetPrivateProperty): (JSObjectSetPrivateProperty): (JSObjectDeletePrivateProperty):
  • API/JSValueRef.cpp: (JSValueIsObjectOfClass):
  • API/JSWeakObjectMapRefPrivate.cpp:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • JavaScriptCore.exp:
  • JavaScriptCore.gypi:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • jsc.cpp: (GlobalObject::GlobalObject):
  • runtime/ArrayConstructor.cpp: (JSC::ArrayConstructor::ArrayConstructor):
  • runtime/ArrayConstructor.h:
  • runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::ArrayPrototype):
  • runtime/ArrayPrototype.h: (JSC::ArrayPrototype::createStructure):
  • runtime/BooleanConstructor.cpp: (JSC::BooleanConstructor::BooleanConstructor):
  • runtime/BooleanConstructor.h:
  • runtime/BooleanPrototype.cpp: (JSC::BooleanPrototype::BooleanPrototype):
  • runtime/BooleanPrototype.h:
  • runtime/DateConstructor.cpp: (JSC::DateConstructor::DateConstructor):
  • runtime/DateConstructor.h:
  • runtime/DatePrototype.cpp: (JSC::DatePrototype::DatePrototype):
  • runtime/DatePrototype.h:
  • runtime/ErrorConstructor.cpp: (JSC::ErrorConstructor::ErrorConstructor):
  • runtime/ErrorConstructor.h:
  • runtime/ErrorPrototype.cpp: (JSC::ErrorPrototype::ErrorPrototype):
  • runtime/ErrorPrototype.h:
  • runtime/FunctionConstructor.cpp: (JSC::FunctionConstructor::FunctionConstructor):
  • runtime/FunctionConstructor.h:
  • runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::FunctionPrototype): (JSC::FunctionPrototype::addFunctionProperties):
  • runtime/FunctionPrototype.h:
  • runtime/GlobalEvalFunction.cpp: (JSC::GlobalEvalFunction::GlobalEvalFunction):
  • runtime/GlobalEvalFunction.h:
  • runtime/InternalFunction.cpp: (JSC::InternalFunction::InternalFunction):
  • runtime/InternalFunction.h:
  • runtime/JSCell.h: (JSC::JSValue::getCallData): (JSC::JSValue::getConstructData):
  • runtime/JSFunction.cpp: (JSC::JSFunction::JSFunction):
  • runtime/JSFunction.h:
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset):
  • runtime/JSGlobalObject.h: (JSC::JSGlobalObject::JSGlobalObject):
  • runtime/JSONObject.cpp: (JSC::JSONObject::JSONObject):
  • runtime/JSONObject.h:
  • runtime/JSObject.h:
  • runtime/JSObjectWithGlobalObject.cpp: Added. (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
  • runtime/JSObjectWithGlobalObject.h: Added. (JSC::JSObjectWithGlobalObject::createStructure): (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
  • runtime/JSValue.cpp: (JSC::JSValue::isValidCallee):
  • runtime/JSValue.h:
  • runtime/Lookup.cpp: (JSC::setUpStaticFunctionSlot):
  • runtime/MathObject.cpp: (JSC::MathObject::MathObject):
  • runtime/MathObject.h:
  • runtime/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor::NativeErrorConstructor):
  • runtime/NativeErrorConstructor.h:
  • runtime/NativeErrorPrototype.cpp: (JSC::NativeErrorPrototype::NativeErrorPrototype):
  • runtime/NativeErrorPrototype.h:
  • runtime/NumberConstructor.cpp: (JSC::NumberConstructor::NumberConstructor):
  • runtime/NumberConstructor.h:
  • runtime/NumberPrototype.cpp: (JSC::NumberPrototype::NumberPrototype):
  • runtime/NumberPrototype.h:
  • runtime/ObjectConstructor.cpp: (JSC::ObjectConstructor::ObjectConstructor):
  • runtime/ObjectConstructor.h:
  • runtime/ObjectPrototype.cpp: (JSC::ObjectPrototype::ObjectPrototype):
  • runtime/ObjectPrototype.h:
  • runtime/PrototypeFunction.cpp: (JSC::PrototypeFunction::PrototypeFunction):
  • runtime/PrototypeFunction.h:
  • runtime/RegExpConstructor.cpp: (JSC::RegExpConstructor::RegExpConstructor): (JSC::constructRegExp):
  • runtime/RegExpConstructor.h:
  • runtime/RegExpObject.cpp: (JSC::RegExpObject::RegExpObject):
  • runtime/RegExpObject.h:
  • runtime/RegExpPrototype.cpp: (JSC::RegExpPrototype::RegExpPrototype):
  • runtime/RegExpPrototype.h:
  • runtime/StringConstructor.cpp: (JSC::StringConstructor::StringConstructor):
  • runtime/StringConstructor.h:
  • runtime/StringPrototype.cpp: (JSC::StringPrototype::StringPrototype):
  • runtime/StringPrototype.h:

2010-05-21 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

All callable objects should have a global object reference
https://bugs.webkit.org/show_bug.cgi?id=39495

Update expected results as we now give all function objects
get their prototypes from the correct global object.

  • fast/dom/prototype-inheritance-expected.txt:

2010-05-21 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

All callable objects should have a global object reference
https://bugs.webkit.org/show_bug.cgi?id=39495

Update the bindings generator to give prototype objects a
global object. Update all the manually written JSObject
subclasses to pass a global object.

  • ForwardingHeaders/runtime/JSObjectWithGlobalObject.h: Added.
  • WebCore.PluginHostProcess.exp:
  • bindings/js/JSDOMBinding.cpp: (WebCore::objectToStringFunctionGetter):
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::nonCachingStaticFunctionGetter):
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::setWindow):
  • bindings/js/JSHistoryCustom.cpp: (WebCore::nonCachingStaticBackFunctionGetter): (WebCore::nonCachingStaticForwardFunctionGetter): (WebCore::nonCachingStaticGoFunctionGetter):
  • bindings/js/JSLocationCustom.cpp: (WebCore::nonCachingStaticReplaceFunctionGetter): (WebCore::nonCachingStaticReloadFunctionGetter): (WebCore::nonCachingStaticAssignFunctionGetter):
  • bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::initScript):
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/c/CRuntimeObject.cpp: (JSC::Bindings::CRuntimeObject::CRuntimeObject):
  • bridge/c/CRuntimeObject.h:
  • bridge/c/c_instance.cpp: (JSC::Bindings::CInstance::newRuntimeObject): (JSC::Bindings::CRuntimeMethod::CRuntimeMethod): (JSC::Bindings::CInstance::getMethod):
  • bridge/jni/jsc/JavaInstanceJSC.cpp: (JavaInstance::newRuntimeObject): (JavaRuntimeMethod::JavaRuntimeMethod): (JavaInstance::getMethod):
  • bridge/jni/jsc/JavaRuntimeObject.cpp: (JSC::Bindings::JavaRuntimeObject::JavaRuntimeObject):
  • bridge/jni/jsc/JavaRuntimeObject.h:
  • bridge/jsc/BridgeJSC.cpp: (JSC::Bindings::Instance::newRuntimeObject):
  • bridge/objc/ObjCRuntimeObject.h:
  • bridge/objc/ObjCRuntimeObject.mm: (JSC::Bindings::ObjCRuntimeObject::ObjCRuntimeObject):
  • bridge/objc/objc_class.mm: (JSC::Bindings::ObjcClass::fallbackObject):
  • bridge/objc/objc_instance.mm: (ObjcInstance::newRuntimeObject): (ObjCRuntimeMethod::ObjCRuntimeMethod): (ObjcInstance::getMethod):
  • bridge/objc/objc_runtime.h:
  • bridge/objc/objc_runtime.mm: (JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
  • bridge/runtime_method.cpp: (JSC::RuntimeMethod::RuntimeMethod):
  • bridge/runtime_method.h:
  • bridge/runtime_object.cpp: (JSC::Bindings::RuntimeObject::RuntimeObject):
  • bridge/runtime_object.h:

2010-05-21 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

All callable objects should have a global object reference
https://bugs.webkit.org/show_bug.cgi?id=39495

Update the plugin proxy to handle the need for global object.

  • Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::newRuntimeObject): (WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod): (WebKit::ProxyInstance::getMethod):
  • Plugins/Hosted/ProxyRuntimeObject.h:
  • Plugins/Hosted/ProxyRuntimeObject.mm: (WebKit::ProxyRuntimeObject::ProxyRuntimeObject):
Location:
trunk
Files:
3 added
114 edited

Legend:

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

    r52751 r59941  
    3838const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
    3939
    40 JSCallbackConstructor::JSCallbackConstructor(NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
    41     : JSObject(structure)
     40JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
     41    : JSObjectWithGlobalObject(globalObject, structure)
    4242    , m_class(jsClass)
    4343    , m_callback(callback)
  • trunk/JavaScriptCore/API/JSCallbackConstructor.h

    r54022 r59941  
    2828
    2929#include "JSObjectRef.h"
    30 #include <runtime/JSObject.h>
     30#include <runtime/JSObjectWithGlobalObject.h>
    3131
    3232namespace JSC {
    3333
    34 class JSCallbackConstructor : public JSObject {
     34class JSCallbackConstructor : public JSObjectWithGlobalObject {
    3535public:
    36     JSCallbackConstructor(NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
     36    JSCallbackConstructor(JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
    3737    virtual ~JSCallbackConstructor();
    3838    JSClassRef classRef() const { return m_class; }
  • trunk/JavaScriptCore/API/JSCallbackFunction.cpp

    r55633 r59941  
    4242const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
    4343
    44 JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
    45     : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name)
     44JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
     45    : InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
    4646    , m_callback(callback)
    4747{
  • trunk/JavaScriptCore/API/JSCallbackFunction.h

    r54022 r59941  
    3434class JSCallbackFunction : public InternalFunction {
    3535public:
    36     JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name);
     36    JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);
    3737
    3838    static const ClassInfo info;
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r58115 r59941  
    3333namespace JSC {
    3434
    35 ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>);
     35ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObjectWithGlobalObject>);
    3636ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
    3737
    3838// Define the two types of JSCallbackObjects we support.
    39 template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
     39template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::info = { "CallbackObject", 0, 0, 0 };
    4040template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
    4141
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r56314 r59941  
    115115class JSCallbackObject : public Base {
    116116public:
    117     JSCallbackObject(ExecState*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
    118     JSCallbackObject(JSClassRef);
     117    JSCallbackObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
     118    JSCallbackObject(JSClassRef, NonNullPassRefPtr<Structure>);
    119119    virtual ~JSCallbackObject();
    120120
  • trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r55401 r59941  
    4949
    5050template <class Base>
    51 JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
    52     : Base(structure)
     51JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
     52    : Base(globalObject, structure)
    5353    , m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
    5454{
     
    5959// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
    6060template <class Base>
    61 JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
    62     : Base()
     61JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, NonNullPassRefPtr<Structure> structure)
     62    : Base(structure)
    6363    , m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
    6464{
     
    561561            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
    562562                if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
    563                     JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
     563                   
     564                    JSObject* o = new (exec) JSCallbackFunction(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
    564565                    thisObj->putDirect(propertyName, o, entry->attributes);
    565566                    return o;
  • trunk/JavaScriptCore/API/JSClassRef.cpp

    r58001 r59941  
    257257    if (!jsClassData.cachedPrototype) {
    258258        // Recursive, but should be good enough for our purposes
    259         jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
     259        jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
    260260        if (parentClass) {
    261261            if (JSObject* prototype = parentClass->prototype(exec))
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r58133 r59941  
    9898    }
    9999
    100     JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
     100    JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(jsNull()));
    101101    ExecState* exec = globalObject->globalExec();
    102102    JSValue prototype = globalObjectClass->prototype(exec);
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r56314 r59941  
    8282        return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
    8383
    84     JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
     84    JSCallbackObject<JSObjectWithGlobalObject>* object = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
    8585    if (JSObject* prototype = jsClass->prototype(exec))
    8686        object->setPrototype(prototype);
     
    9696    Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
    9797   
    98     return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
     98    return toRef(new (exec) JSCallbackFunction(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
    9999}
    100100
     
    108108        jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
    109109
    110     JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
     110    JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
    111111    constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
    112112    return toRef(constructor);
     
    344344    if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
    345345        return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
    346     else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
    347         return static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivate();
     346    else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
     347        return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivate();
    348348   
    349349    return 0;
     
    357357        static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
    358358        return true;
    359     } else if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
    360         static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivate(data);
     359    } else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
     360        static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivate(data);
    361361        return true;
    362362    }
     
    374374    if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
    375375        result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
    376     else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
    377         result = static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivateProperty(name);
     376    else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
     377        result = static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivateProperty(name);
    378378    return toRef(exec, result);
    379379}
     
    390390        return true;
    391391    }
    392     if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
    393         static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivateProperty(name, jsValue);
     392    if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
     393        static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
    394394        return true;
    395395    }
     
    407407        return true;
    408408    }
    409     if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
    410         static_cast<JSCallbackObject<JSObject>*>(jsObject)->deletePrivateProperty(name);
     409    if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
     410        static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->deletePrivateProperty(name);
    411411        return true;
    412412    }
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r58003 r59941  
    132132        if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
    133133            return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
    134         else if (o->inherits(&JSCallbackObject<JSObject>::info))
    135             return static_cast<JSCallbackObject<JSObject>*>(o)->inherits(jsClass);
     134        else if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
     135            return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(o)->inherits(jsClass);
    136136    }
    137137    return false;
  • trunk/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp

    r58116 r59941  
    5959    if (!obj)
    6060        return;
    61     ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObject>::info));
     61    ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
    6262    map->map().set(key, obj);
    6363}
  • trunk/JavaScriptCore/CMakeLists.txt

    r59537 r59941  
    123123    runtime/JSNumberCell.cpp
    124124    runtime/JSObject.cpp
     125    runtime/JSObjectWithGlobalObject.cpp
    125126    runtime/JSONObject.cpp
    126127    runtime/JSPropertyNameIterator.cpp
  • trunk/JavaScriptCore/ChangeLog

    r59939 r59941  
     12010-05-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        All callable objects should have a global object reference
     6        https://bugs.webkit.org/show_bug.cgi?id=39495
     7
     8        All objects that may ever return a value other CallTypeNone
     9        or ConstructTypeNone now get a global object in their constructor
     10        and store that in their first anonymous slot.  We add a new type
     11        JSObjectWithGlobalObject to allow us to share this logic as much
     12        as possible, however some objects have specific inheritance
     13        requirements so we can't just use it universally.
     14
     15        To enforce this requirement JSValue::getCallData and getConstructData
     16        make use of a new "isValidCallee" function to assert that any object
     17        that returns a value other than CallType/ConstructTypeNone has a
     18        global object in anonymous slot 0.
     19
     20        In order to ensure that static function slots are converted into
     21        function objects with the correct global object, all prototype objects
     22        and other classes with static function slots also gain a global object
     23        reference.  Happily this fixes the long standing issue where host
     24        function objects get a prototype from the lexical global object of the
     25        first function that calls them, instead of the global object that they
     26        are defined on.
     27
     28        * API/JSCallbackConstructor.cpp:
     29        (JSC::JSCallbackConstructor::JSCallbackConstructor):
     30        * API/JSCallbackConstructor.h:
     31        * API/JSCallbackFunction.cpp:
     32        (JSC::JSCallbackFunction::JSCallbackFunction):
     33        * API/JSCallbackFunction.h:
     34        * API/JSCallbackObject.cpp:
     35        (JSC::):
     36        * API/JSCallbackObject.h:
     37        * API/JSCallbackObjectFunctions.h:
     38        (JSC::::JSCallbackObject):
     39        (JSC::::staticFunctionGetter):
     40        * API/JSClassRef.cpp:
     41        (OpaqueJSClass::prototype):
     42        * API/JSContextRef.cpp:
     43        * API/JSObjectRef.cpp:
     44        (JSObjectMake):
     45        (JSObjectMakeFunctionWithCallback):
     46        (JSObjectMakeConstructor):
     47        (JSObjectGetPrivate):
     48        (JSObjectSetPrivate):
     49        (JSObjectGetPrivateProperty):
     50        (JSObjectSetPrivateProperty):
     51        (JSObjectDeletePrivateProperty):
     52        * API/JSValueRef.cpp:
     53        (JSValueIsObjectOfClass):
     54        * API/JSWeakObjectMapRefPrivate.cpp:
     55        * CMakeLists.txt:
     56        * GNUmakefile.am:
     57        * JavaScriptCore.exp:
     58        * JavaScriptCore.gypi:
     59        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     60        * JavaScriptCore.xcodeproj/project.pbxproj:
     61        * interpreter/Interpreter.cpp:
     62        (JSC::Interpreter::privateExecute):
     63        * jit/JITStubs.cpp:
     64        (JSC::DEFINE_STUB_FUNCTION):
     65        * jsc.cpp:
     66        (GlobalObject::GlobalObject):
     67        * runtime/ArrayConstructor.cpp:
     68        (JSC::ArrayConstructor::ArrayConstructor):
     69        * runtime/ArrayConstructor.h:
     70        * runtime/ArrayPrototype.cpp:
     71        (JSC::ArrayPrototype::ArrayPrototype):
     72        * runtime/ArrayPrototype.h:
     73        (JSC::ArrayPrototype::createStructure):
     74        * runtime/BooleanConstructor.cpp:
     75        (JSC::BooleanConstructor::BooleanConstructor):
     76        * runtime/BooleanConstructor.h:
     77        * runtime/BooleanPrototype.cpp:
     78        (JSC::BooleanPrototype::BooleanPrototype):
     79        * runtime/BooleanPrototype.h:
     80        * runtime/DateConstructor.cpp:
     81        (JSC::DateConstructor::DateConstructor):
     82        * runtime/DateConstructor.h:
     83        * runtime/DatePrototype.cpp:
     84        (JSC::DatePrototype::DatePrototype):
     85        * runtime/DatePrototype.h:
     86        * runtime/ErrorConstructor.cpp:
     87        (JSC::ErrorConstructor::ErrorConstructor):
     88        * runtime/ErrorConstructor.h:
     89        * runtime/ErrorPrototype.cpp:
     90        (JSC::ErrorPrototype::ErrorPrototype):
     91        * runtime/ErrorPrototype.h:
     92        * runtime/FunctionConstructor.cpp:
     93        (JSC::FunctionConstructor::FunctionConstructor):
     94        * runtime/FunctionConstructor.h:
     95        * runtime/FunctionPrototype.cpp:
     96        (JSC::FunctionPrototype::FunctionPrototype):
     97        (JSC::FunctionPrototype::addFunctionProperties):
     98        * runtime/FunctionPrototype.h:
     99        * runtime/GlobalEvalFunction.cpp:
     100        (JSC::GlobalEvalFunction::GlobalEvalFunction):
     101        * runtime/GlobalEvalFunction.h:
     102        * runtime/InternalFunction.cpp:
     103        (JSC::InternalFunction::InternalFunction):
     104        * runtime/InternalFunction.h:
     105        * runtime/JSCell.h:
     106        (JSC::JSValue::getCallData):
     107        (JSC::JSValue::getConstructData):
     108        * runtime/JSFunction.cpp:
     109        (JSC::JSFunction::JSFunction):
     110        * runtime/JSFunction.h:
     111        * runtime/JSGlobalObject.cpp:
     112        (JSC::JSGlobalObject::reset):
     113        * runtime/JSGlobalObject.h:
     114        (JSC::JSGlobalObject::JSGlobalObject):
     115        * runtime/JSONObject.cpp:
     116        (JSC::JSONObject::JSONObject):
     117        * runtime/JSONObject.h:
     118        * runtime/JSObject.h:
     119        * runtime/JSObjectWithGlobalObject.cpp: Added.
     120        (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
     121        * runtime/JSObjectWithGlobalObject.h: Added.
     122        (JSC::JSObjectWithGlobalObject::createStructure):
     123        (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
     124        * runtime/JSValue.cpp:
     125        (JSC::JSValue::isValidCallee):
     126        * runtime/JSValue.h:
     127        * runtime/Lookup.cpp:
     128        (JSC::setUpStaticFunctionSlot):
     129        * runtime/MathObject.cpp:
     130        (JSC::MathObject::MathObject):
     131        * runtime/MathObject.h:
     132        * runtime/NativeErrorConstructor.cpp:
     133        (JSC::NativeErrorConstructor::NativeErrorConstructor):
     134        * runtime/NativeErrorConstructor.h:
     135        * runtime/NativeErrorPrototype.cpp:
     136        (JSC::NativeErrorPrototype::NativeErrorPrototype):
     137        * runtime/NativeErrorPrototype.h:
     138        * runtime/NumberConstructor.cpp:
     139        (JSC::NumberConstructor::NumberConstructor):
     140        * runtime/NumberConstructor.h:
     141        * runtime/NumberPrototype.cpp:
     142        (JSC::NumberPrototype::NumberPrototype):
     143        * runtime/NumberPrototype.h:
     144        * runtime/ObjectConstructor.cpp:
     145        (JSC::ObjectConstructor::ObjectConstructor):
     146        * runtime/ObjectConstructor.h:
     147        * runtime/ObjectPrototype.cpp:
     148        (JSC::ObjectPrototype::ObjectPrototype):
     149        * runtime/ObjectPrototype.h:
     150        * runtime/PrototypeFunction.cpp:
     151        (JSC::PrototypeFunction::PrototypeFunction):
     152        * runtime/PrototypeFunction.h:
     153        * runtime/RegExpConstructor.cpp:
     154        (JSC::RegExpConstructor::RegExpConstructor):
     155        (JSC::constructRegExp):
     156        * runtime/RegExpConstructor.h:
     157        * runtime/RegExpObject.cpp:
     158        (JSC::RegExpObject::RegExpObject):
     159        * runtime/RegExpObject.h:
     160        * runtime/RegExpPrototype.cpp:
     161        (JSC::RegExpPrototype::RegExpPrototype):
     162        * runtime/RegExpPrototype.h:
     163        * runtime/StringConstructor.cpp:
     164        (JSC::StringConstructor::StringConstructor):
     165        * runtime/StringConstructor.h:
     166        * runtime/StringPrototype.cpp:
     167        (JSC::StringPrototype::StringPrototype):
     168        * runtime/StringPrototype.h:
     169
    11702010-05-21  Geoffrey Garen  <ggaren@apple.com>
    2171
  • trunk/JavaScriptCore/GNUmakefile.am

    r59187 r59941  
    464464        JavaScriptCore/runtime/JSNumberCell.h \
    465465        JavaScriptCore/runtime/JSObject.cpp \
     466        JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp \
    466467        JavaScriptCore/runtime/JSObject.h \
    467468        JavaScriptCore/runtime/JSStaticScopeObject.cpp \
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r59811 r59941  
    102102__Z15jsRegExpExecutePK8JSRegExpPKtiiPii
    103103__ZN14OpaqueJSString6createERKN3JSC7UStringE
     104__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
    104105__ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPN7WebCore10StringImplE
    105106__ZN3JSC10Identifier11addSlowCaseEPNS_9ExecStateEPN7WebCore10StringImplE
     
    112113__ZN3JSC10JSFunction4infoE
    113114__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
    114 __ZN3JSC10JSFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
    115115__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
    116116__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
     
    170170__ZN3JSC16InternalFunction4infoE
    171171__ZN3JSC16InternalFunction4nameEPNS_9ExecStateE
    172 __ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
     172__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
    173173__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    174174__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
     
    177177__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb
    178178__ZN3JSC17PropertyNameArray3addEPN7WebCore10StringImplE
    179 __ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
    180 __ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectES6_RKNS_7ArgListEE
     179__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
    181180__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
    182181__ZN3JSC18DebuggerActivationC1EPNS_8JSObjectE
     
    196195__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
    197196__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
     197__ZN3JSC24JSObjectWithGlobalObjectC2EPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEE
    198198__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
    199199__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
     
    241241__ZN3JSC7JSArrayC2EN3WTF17NonNullPassRefPtrINS_9StructureEEE
    242242__ZN3JSC7JSArrayD2Ev
     243__ZN3JSC7JSValue13isValidCalleeEv
    243244__ZN3JSC7Profile10restoreAllEv
    244245__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
  • trunk/JavaScriptCore/JavaScriptCore.gypi

    r59187 r59941  
    248248            'runtime/JSObject.cpp',
    249249            'runtime/JSObject.h',
     250            'runtime/JSObjectWithGlobalObject.cpp',
     251            'runtime/JSObjectWithGlobalObject.h',
    250252            'runtime/JSONObject.cpp',
    251253            'runtime/JSONObject.h',
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r59187 r59941  
    851851                        <File
    852852                                RelativePath="..\..\runtime\JSObject.h"
     853                                >
     854                        </File>
     855                        <File
     856                                RelativePath="..\..\runtime\JSObjectWithGlobalObject.cpp"
     857                                >
     858                        </File>
     859                        <File
     860                                RelativePath="..\..\runtime\JSObjectWithGlobalObject.h"
    853861                                >
    854862                        </File>
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r59637 r59941  
    310310                A7795590101A74D500114E55 /* MarkStack.h in Headers */ = {isa = PBXBuildFile; fileRef = A779558F101A74D500114E55 /* MarkStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
    311311                A782F1A50EEC9FA20036273F /* ExecutableAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */; };
     312                A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
     313                A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */; };
    312314                A791EF280F11E07900AE1F68 /* JSByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A791EF260F11E07900AE1F68 /* JSByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
    313315                A791EF290F11E07900AE1F68 /* JSByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A791EF270F11E07900AE1F68 /* JSByteArray.cpp */; };
     
    899901                A779558F101A74D500114E55 /* MarkStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStack.h; sourceTree = "<group>"; };
    900902                A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorPosix.cpp; sourceTree = "<group>"; };
     903                A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectWithGlobalObject.h; sourceTree = "<group>"; };
     904                A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectWithGlobalObject.cpp; sourceTree = "<group>"; };
    901905                A791EF260F11E07900AE1F68 /* JSByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSByteArray.h; sourceTree = "<group>"; };
    902906                A791EF270F11E07900AE1F68 /* JSByteArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSByteArray.cpp; sourceTree = "<group>"; };
     
    17111715                                14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */,
    17121716                                1420BE7A10AA6DDB00F455D2 /* WeakRandom.h */,
     1717                                A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */,
     1718                                A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */,
    17131719                        );
    17141720                        path = runtime;
     
    21482154                                86C568E111A213EE0007F7F0 /* MacroAssemblerMIPS.h in Headers */,
    21492155                                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
     2156                                A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */,
    21502157                        );
    21512158                        runOnlyForDeploymentPostprocessing = 0;
     
    26012608                                A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */,
    26022609                                86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
     2610                                A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */,
    26032611                        );
    26042612                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r59777 r59941  
    29602960    STUB_INIT_STACK_FRAME(stackFrame);
    29612961
    2962     return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
     2962    return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
    29632963}
    29642964
  • trunk/JavaScriptCore/jsc.cpp

    r58012 r59941  
    151151    : JSGlobalObject()
    152152{
    153     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
    154     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
    155     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
    156     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
    157     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
    158     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
    159     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
    160     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
    161     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
     153    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
     154    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
     155    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
     156    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
     157    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
     158    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
     159    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
     160    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
     161    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
    162162
    163163#if ENABLE(SAMPLING_FLAGS)
    164     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
    165     putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
     164    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
     165    putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
    166166#endif
    167167
  • trunk/JavaScriptCore/runtime/ArrayConstructor.cpp

    r49365 r59941  
    3838static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList&);
    3939
    40 ArrayConstructor::ArrayConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
    41     : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className))
     40ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
     41    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, arrayPrototype->classInfo()->className))
    4242{
    4343    // ECMA 15.4.3.1 Array.prototype
     
    4848
    4949    // ES5
    50     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
     50    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
    5151}
    5252
  • trunk/JavaScriptCore/runtime/ArrayConstructor.h

    r48836 r59941  
    3030    class ArrayConstructor : public InternalFunction {
    3131    public:
    32         ArrayConstructor(ExecState*, NonNullPassRefPtr<Structure>, ArrayPrototype*, Structure*);
     32        ArrayConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ArrayPrototype*, Structure*);
    3333
    3434        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/runtime/ArrayPrototype.cpp

    r59355 r59941  
    117117
    118118// ECMA 15.4.4
    119 ArrayPrototype::ArrayPrototype(NonNullPassRefPtr<Structure> structure)
     119ArrayPrototype::ArrayPrototype(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
    120120    : JSArray(structure)
    121121{
     122    putAnonymousValue(0, globalObject);
    122123}
    123124
  • trunk/JavaScriptCore/runtime/ArrayPrototype.h

    r48836 r59941  
    2929    class ArrayPrototype : public JSArray {
    3030    public:
    31         explicit ArrayPrototype(NonNullPassRefPtr<Structure>);
     31        explicit ArrayPrototype(JSGlobalObject*, NonNullPassRefPtr<Structure>);
    3232
    3333        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     
    3636        virtual const ClassInfo* classInfo() const { return &info; }
    3737        static const ClassInfo info;
     38
     39        static PassRefPtr<Structure> createStructure(JSValue prototype)
     40        {
     41            return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
     42        }
     43
     44    protected:
     45        static const unsigned AnonymousSlotCount = JSArray::AnonymousSlotCount + 1;
    3846    };
    3947
  • trunk/JavaScriptCore/runtime/BooleanConstructor.cpp

    r48836 r59941  
    2929ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
    3030
    31 BooleanConstructor::BooleanConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, BooleanPrototype* booleanPrototype)
    32     : InternalFunction(&exec->globalData(), structure, Identifier(exec, booleanPrototype->classInfo()->className))
     31BooleanConstructor::BooleanConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, BooleanPrototype* booleanPrototype)
     32    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, booleanPrototype->classInfo()->className))
    3333{
    3434    putDirectWithoutTransition(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
  • trunk/JavaScriptCore/runtime/BooleanConstructor.h

    r48836 r59941  
    3030    class BooleanConstructor : public InternalFunction {
    3131    public:
    32         BooleanConstructor(ExecState*, NonNullPassRefPtr<Structure>, BooleanPrototype*);
     32        BooleanConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, BooleanPrototype*);
    3333
    3434    private:
  • trunk/JavaScriptCore/runtime/BooleanPrototype.cpp

    r48836 r59941  
    3838// ECMA 15.6.4
    3939
    40 BooleanPrototype::BooleanPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
     40BooleanPrototype::BooleanPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
    4141    : BooleanObject(structure)
    4242{
    4343    setInternalValue(jsBoolean(false));
    4444
    45     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
    46     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
     45    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
     46    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
    4747}
    4848
  • trunk/JavaScriptCore/runtime/BooleanPrototype.h

    r48836 r59941  
    2828    class BooleanPrototype : public BooleanObject {
    2929    public:
    30         BooleanPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
     30        BooleanPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3131    };
    3232
  • trunk/JavaScriptCore/runtime/DateConstructor.cpp

    r54394 r59941  
    5959static JSValue JSC_HOST_CALL dateUTC(ExecState*, JSObject*, JSValue, const ArgList&);
    6060
    61 DateConstructor::DateConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
    62     : InternalFunction(&exec->globalData(), structure, Identifier(exec, datePrototype->classInfo()->className))
     61DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
     62    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, datePrototype->classInfo()->className))
    6363{
    6464      putDirectWithoutTransition(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
    6565
    66       putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
    67       putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
    68       putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
     66      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
     67      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
     68      putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
    6969
    7070      putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 7), ReadOnly | DontEnum | DontDelete);
  • trunk/JavaScriptCore/runtime/DateConstructor.h

    r48836 r59941  
    3030    class DateConstructor : public InternalFunction {
    3131    public:
    32         DateConstructor(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, DatePrototype*);
     32        DateConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, DatePrototype*);
    3333
    3434    private:
  • trunk/JavaScriptCore/runtime/DatePrototype.cpp

    r59545 r59941  
    419419// ECMA 15.9.4
    420420
    421 DatePrototype::DatePrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
     421DatePrototype::DatePrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
    422422    : DateInstance(exec, structure)
    423423{
    424424    // The constructor will be added later, after DateConstructor has been built.
     425    putAnonymousValue(0, globalObject);
    425426}
    426427
  • trunk/JavaScriptCore/runtime/DatePrototype.h

    r54022 r59941  
    3030    class DatePrototype : public DateInstance {
    3131    public:
    32         DatePrototype(ExecState*, NonNullPassRefPtr<Structure>);
     32        DatePrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
    3333
    3434        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
  • trunk/JavaScriptCore/runtime/ErrorConstructor.cpp

    r48836 r59941  
    3030ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
    3131
    32 ErrorConstructor::ErrorConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ErrorPrototype* errorPrototype)
    33     : InternalFunction(&exec->globalData(), structure, Identifier(exec, errorPrototype->classInfo()->className))
     32ErrorConstructor::ErrorConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ErrorPrototype* errorPrototype)
     33    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, errorPrototype->classInfo()->className))
    3434{
    3535    // ECMA 15.11.3.1 Error.prototype
  • trunk/JavaScriptCore/runtime/ErrorConstructor.h

    r48836 r59941  
    3131    class ErrorConstructor : public InternalFunction {
    3232    public:
    33         ErrorConstructor(ExecState*, NonNullPassRefPtr<Structure>, ErrorPrototype*);
     33        ErrorConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ErrorPrototype*);
    3434
    3535    private:
  • trunk/JavaScriptCore/runtime/ErrorPrototype.cpp

    r54394 r59941  
    3636
    3737// ECMA 15.9.4
    38 ErrorPrototype::ErrorPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
     38ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
    3939    : ErrorInstance(structure)
    4040{
     
    4444    putDirectWithoutTransition(exec->propertyNames().message, jsNontrivialString(exec, "Unknown error"), DontEnum);
    4545
    46     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
     46    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
    4747}
    4848
  • trunk/JavaScriptCore/runtime/ErrorPrototype.h

    r48836 r59941  
    3030    class ErrorPrototype : public ErrorInstance {
    3131    public:
    32         ErrorPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
     32        ErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3333    };
    3434
  • trunk/JavaScriptCore/runtime/FunctionConstructor.cpp

    r54571 r59941  
    3636ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
    3737
    38 FunctionConstructor::FunctionConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, FunctionPrototype* functionPrototype)
    39     : InternalFunction(&exec->globalData(), structure, Identifier(exec, functionPrototype->classInfo()->className))
     38FunctionConstructor::FunctionConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, FunctionPrototype* functionPrototype)
     39    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, functionPrototype->classInfo()->className))
    4040{
    4141    putDirectWithoutTransition(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
  • trunk/JavaScriptCore/runtime/FunctionConstructor.h

    r48836 r59941  
    3030    class FunctionConstructor : public InternalFunction {
    3131    public:
    32         FunctionConstructor(ExecState*, NonNullPassRefPtr<Structure>, FunctionPrototype*);
     32        FunctionConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, FunctionPrototype*);
    3333
    3434    private:
  • trunk/JavaScriptCore/runtime/FunctionPrototype.cpp

    r59811 r59941  
    3939static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*, JSObject*, JSValue, const ArgList&);
    4040
    41 FunctionPrototype::FunctionPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
    42     : InternalFunction(&exec->globalData(), structure, exec->propertyNames().nullIdentifier)
     41FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
     42    : InternalFunction(&exec->globalData(), globalObject, structure, exec->propertyNames().nullIdentifier)
    4343{
    4444    putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
    4545}
    4646
    47 void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
     47void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
    4848{
    49     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
    50     *applyFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
     49    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
     50    *applyFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
    5151    putDirectFunctionWithoutTransition(exec, *applyFunction, DontEnum);
    52     *callFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
     52    *callFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
    5353    putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
    5454}
  • trunk/JavaScriptCore/runtime/FunctionPrototype.h

    r54022 r59941  
    3030    class FunctionPrototype : public InternalFunction {
    3131    public:
    32         FunctionPrototype(ExecState*, NonNullPassRefPtr<Structure>);
    33         void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
     32        FunctionPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
     33        void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
    3434
    3535        static PassRefPtr<Structure> createStructure(JSValue proto)
  • trunk/JavaScriptCore/runtime/GlobalEvalFunction.cpp

    r48836 r59941  
    3333ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction);
    3434
    35 GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
    36     : PrototypeFunction(exec, structure, len, name, function)
     35GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
     36    : PrototypeFunction(exec, globalObject, structure, len, name, function)
    3737    , m_cachedGlobalObject(cachedGlobalObject)
    3838{
  • trunk/JavaScriptCore/runtime/GlobalEvalFunction.h

    r54022 r59941  
    3333    class GlobalEvalFunction : public PrototypeFunction {
    3434    public:
    35         GlobalEvalFunction(ExecState*, NonNullPassRefPtr<Structure>, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
     35        GlobalEvalFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
    3636        JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
    3737
  • trunk/JavaScriptCore/runtime/InternalFunction.cpp

    r57055 r59941  
    2525
    2626#include "FunctionPrototype.h"
     27#include "JSGlobalObject.h"
    2728#include "JSString.h"
    2829
     
    3839}
    3940
    40 InternalFunction::InternalFunction(JSGlobalData* globalData, NonNullPassRefPtr<Structure> structure, const Identifier& name)
    41     : JSObject(structure)
     41InternalFunction::InternalFunction(NonNullPassRefPtr<Structure> structure)
     42    : JSObjectWithGlobalObject(structure)
     43{
     44}
     45
     46InternalFunction::InternalFunction(JSGlobalData* globalData, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const Identifier& name)
     47    : JSObjectWithGlobalObject(globalObject, structure)
    4248{
    4349    putDirect(globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
  • trunk/JavaScriptCore/runtime/InternalFunction.h

    r54022 r59941  
    2525#define InternalFunction_h
    2626
    27 #include "JSObject.h"
     27#include "JSObjectWithGlobalObject.h"
    2828#include "Identifier.h"
    2929
     
    3232    class FunctionPrototype;
    3333
    34     class InternalFunction : public JSObject {
     34    class InternalFunction : public JSObjectWithGlobalObject {
    3535    public:
    3636        virtual const ClassInfo* classInfo() const;
     
    4949        static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags;
    5050
    51         InternalFunction(NonNullPassRefPtr<Structure> structure) : JSObject(structure) { }
    52         InternalFunction(JSGlobalData*, NonNullPassRefPtr<Structure>, const Identifier&);
     51        // Only used to allow us to determine the JSFunction vptr
     52        InternalFunction(NonNullPassRefPtr<Structure> structure);
     53
     54        InternalFunction(JSGlobalData*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const Identifier&);
    5355
    5456    private:
  • trunk/JavaScriptCore/runtime/JSCell.h

    r59055 r59941  
    208208    inline CallType JSValue::getCallData(CallData& callData)
    209209    {
    210         return isCell() ? asCell()->getCallData(callData) : CallTypeNone;
     210        CallType result = isCell() ? asCell()->getCallData(callData) : CallTypeNone;
     211        ASSERT(result == CallTypeNone || isValidCallee());
     212        return result;
    211213    }
    212214
    213215    inline ConstructType JSValue::getConstructData(ConstructData& constructData)
    214216    {
    215         return isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;
     217        ConstructType result = isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;
     218        ASSERT(result == ConstructTypeNone || isValidCallee());
     219        return result;
    216220    }
    217221
  • trunk/JavaScriptCore/runtime/JSFunction.cpp

    r59811 r59941  
    5858}
    5959
    60 JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk)
    61     : Base(structure)
     60JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk)
     61    : Base(globalObject, structure)
    6262#if ENABLE(JIT)
    6363    , m_executable(thunk)
    6464#endif
    65     , m_scopeChain(NoScopeChain())
     65    , m_scopeChain(globalObject->globalScopeChain())
    6666{
    6767    putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
     
    7575}
    7676
    77 JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
    78     : Base(structure)
     77JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
     78    : Base(globalObject, structure)
    7979#if ENABLE(JIT)
    8080    , m_executable(exec->globalData().getHostFunction(func))
    8181#endif
    82     , m_scopeChain(NoScopeChain())
     82    , m_scopeChain(globalObject->globalScopeChain())
    8383{
    8484    putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
     
    9393
    9494JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode)
    95     : Base(exec->lexicalGlobalObject()->functionStructure())
     95    : Base(scopeChainNode->globalObject, scopeChainNode->globalObject->functionStructure())
    9696    , m_executable(executable)
    9797    , m_scopeChain(scopeChainNode)
  • trunk/JavaScriptCore/runtime/JSFunction.h

    r59811 r59941  
    2525#define JSFunction_h
    2626
    27 #include "JSObject.h"
     27#include "JSObjectWithGlobalObject.h"
    2828
    2929namespace JSC {
     
    3636    class NativeExecutable;
    3737
    38     class JSFunction : public JSObject {
     38    class JSFunction : public JSObjectWithGlobalObject {
    3939        friend class JIT;
    4040        friend class JSGlobalData;
    4141
    42         typedef JSObject Base;
     42        typedef JSObjectWithGlobalObject Base;
    4343
    4444    public:
    45         JSFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
    46         JSFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, PassRefPtr<NativeExecutable>);
     45        JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
     46        JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, PassRefPtr<NativeExecutable>);
    4747        JSFunction(ExecState*, NonNullPassRefPtr<FunctionExecutable>, ScopeChainNode*);
    4848        virtual ~JSFunction();
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r58986 r59941  
    204204    // Prototypes
    205205
    206     d()->functionPrototype = new (exec) FunctionPrototype(exec, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created.
     206    d()->functionPrototype = new (exec) FunctionPrototype(exec, this, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created.
    207207    d()->prototypeFunctionStructure = PrototypeFunction::createStructure(d()->functionPrototype);
    208208    NativeFunctionWrapper* callFunction = 0;
    209209    NativeFunctionWrapper* applyFunction = 0;
    210     d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
     210    d()->functionPrototype->addFunctionProperties(exec, this, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
    211211    d()->callFunction = callFunction;
    212212    d()->applyFunction = applyFunction;
    213     d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
     213    d()->objectPrototype = new (exec) ObjectPrototype(exec, this, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
    214214    d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype);
    215215
     
    220220    d()->argumentsStructure = Arguments::createStructure(d()->objectPrototype);
    221221    d()->callbackConstructorStructure = JSCallbackConstructor::createStructure(d()->objectPrototype);
    222     d()->callbackObjectStructure = JSCallbackObject<JSObject>::createStructure(d()->objectPrototype);
    223 
    224     d()->arrayPrototype = new (exec) ArrayPrototype(ArrayPrototype::createStructure(d()->objectPrototype));
     222    d()->callbackObjectStructure = JSCallbackObject<JSObjectWithGlobalObject>::createStructure(d()->objectPrototype);
     223
     224    d()->arrayPrototype = new (exec) ArrayPrototype(this, ArrayPrototype::createStructure(d()->objectPrototype));
    225225    d()->arrayStructure = JSArray::createStructure(d()->arrayPrototype);
    226226    d()->regExpMatchesArrayStructure = RegExpMatchesArray::createStructure(d()->arrayPrototype);
    227227
    228     d()->stringPrototype = new (exec) StringPrototype(exec, StringPrototype::createStructure(d()->objectPrototype));
     228    d()->stringPrototype = new (exec) StringPrototype(exec, this, StringPrototype::createStructure(d()->objectPrototype));
    229229    d()->stringObjectStructure = StringObject::createStructure(d()->stringPrototype);
    230230
    231     d()->booleanPrototype = new (exec) BooleanPrototype(exec, BooleanPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
     231    d()->booleanPrototype = new (exec) BooleanPrototype(exec, this, BooleanPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
    232232    d()->booleanObjectStructure = BooleanObject::createStructure(d()->booleanPrototype);
    233233
    234     d()->numberPrototype = new (exec) NumberPrototype(exec, NumberPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
     234    d()->numberPrototype = new (exec) NumberPrototype(exec, this, NumberPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
    235235    d()->numberObjectStructure = NumberObject::createStructure(d()->numberPrototype);
    236236
    237     d()->datePrototype = new (exec) DatePrototype(exec, DatePrototype::createStructure(d()->objectPrototype));
     237    d()->datePrototype = new (exec) DatePrototype(exec, this, DatePrototype::createStructure(d()->objectPrototype));
    238238    d()->dateStructure = DateInstance::createStructure(d()->datePrototype);
    239239
    240     d()->regExpPrototype = new (exec) RegExpPrototype(exec, RegExpPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
     240    d()->regExpPrototype = new (exec) RegExpPrototype(exec, this, RegExpPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
    241241    d()->regExpStructure = RegExpObject::createStructure(d()->regExpPrototype);
    242242
    243243    d()->methodCallDummy = constructEmptyObject(exec);
    244244
    245     ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, ErrorPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
     245    ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, this, ErrorPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
    246246    d()->errorStructure = ErrorInstance::createStructure(errorPrototype);
    247247
    248248    RefPtr<Structure> nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(errorPrototype);
    249249
    250     NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "EvalError", "EvalError");
    251     NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "RangeError", "RangeError");
    252     NativeErrorPrototype* referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "ReferenceError", "ReferenceError");
    253     NativeErrorPrototype* syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "SyntaxError", "SyntaxError");
    254     NativeErrorPrototype* typeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "TypeError", "TypeError");
    255     NativeErrorPrototype* URIErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "URIError", "URIError");
     250    NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "EvalError", "EvalError");
     251    NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "RangeError", "RangeError");
     252    NativeErrorPrototype* referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "ReferenceError", "ReferenceError");
     253    NativeErrorPrototype* syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "SyntaxError", "SyntaxError");
     254    NativeErrorPrototype* typeErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "TypeError", "TypeError");
     255    NativeErrorPrototype* URIErrorPrototype = new (exec) NativeErrorPrototype(exec, this, nativeErrorPrototypeStructure, "URIError", "URIError");
    256256
    257257    // Constructors
    258258
    259     JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
    260     JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
    261     JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
    262     JSCell* stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
    263     JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype);
    264     JSCell* numberConstructor = new (exec) NumberConstructor(exec, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype);
    265     JSCell* dateConstructor = new (exec) DateConstructor(exec, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
    266 
    267     d()->regExpConstructor = new (exec) RegExpConstructor(exec, RegExpConstructor::createStructure(d()->functionPrototype), d()->regExpPrototype);
    268 
    269     d()->errorConstructor = new (exec) ErrorConstructor(exec, ErrorConstructor::createStructure(d()->functionPrototype), errorPrototype);
     259    JSCell* objectConstructor = new (exec) ObjectConstructor(exec, this, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
     260    JSCell* functionConstructor = new (exec) FunctionConstructor(exec, this, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
     261    JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, this, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
     262    JSCell* stringConstructor = new (exec) StringConstructor(exec, this, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
     263    JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, this, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype);
     264    JSCell* numberConstructor = new (exec) NumberConstructor(exec, this, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype);
     265    JSCell* dateConstructor = new (exec) DateConstructor(exec, this, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
     266
     267    d()->regExpConstructor = new (exec) RegExpConstructor(exec, this, RegExpConstructor::createStructure(d()->functionPrototype), d()->regExpPrototype);
     268
     269    d()->errorConstructor = new (exec) ErrorConstructor(exec, this, ErrorConstructor::createStructure(d()->functionPrototype), errorPrototype);
    270270
    271271    RefPtr<Structure> nativeErrorStructure = NativeErrorConstructor::createStructure(d()->functionPrototype);
    272272
    273     d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype);
    274     d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype);
    275     d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, referenceErrorPrototype);
    276     d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, syntaxErrorPrototype);
    277     d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype);
    278     d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype);
     273    d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, evalErrorPrototype);
     274    d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, rangeErrorPrototype);
     275    d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, referenceErrorPrototype);
     276    d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, syntaxErrorPrototype);
     277    d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, typeErrorPrototype);
     278    d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, URIErrorPrototype);
    279279
    280280    d()->objectPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum);
     
    317317    // Set global values.
    318318    GlobalPropertyInfo staticGlobals[] = {
    319         GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, MathObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete),
     319        GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, this, MathObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete),
    320320        GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete | ReadOnly),
    321321        GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete | ReadOnly),
    322322        GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete | ReadOnly),
    323         GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(JSONObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete)
     323        GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(this, JSONObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete)
    324324    };
    325325
     
    328328    // Set global functions.
    329329
    330     d()->evalFunction = new (exec) GlobalEvalFunction(exec, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
     330    d()->evalFunction = new (exec) GlobalEvalFunction(exec, this, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
    331331    putDirectFunctionWithoutTransition(exec, d()->evalFunction, DontEnum);
    332     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
    333     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
    334     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
    335     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
    336     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
    337     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
    338     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
    339     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
    340     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
    341     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
     332    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
     333    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
     334    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
     335    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
     336    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
     337    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
     338    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
     339    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
     340    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
     341    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
    342342#ifndef NDEBUG
    343     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
     343    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
    344344#endif
    345345
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r58986 r59941  
    161161    public:
    162162        void* operator new(size_t, JSGlobalData*);
    163 
     163       
    164164        explicit JSGlobalObject()
    165165            : JSVariableObject(JSGlobalObject::createStructure(jsNull()), new JSGlobalObjectData(destroyJSGlobalObjectData))
    166166        {
     167            COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
     168            putAnonymousValue(0, this);
     169            init(this);
     170        }
     171       
     172        explicit JSGlobalObject(NonNullPassRefPtr<Structure> structure)
     173            : JSVariableObject(structure, new JSGlobalObjectData(destroyJSGlobalObjectData))
     174        {
     175            COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
     176            putAnonymousValue(0, this);
    167177            init(this);
    168178        }
     
    172182            : JSVariableObject(structure, data)
    173183        {
     184            COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
     185            putAnonymousValue(0, this);
    174186            init(thisValue);
    175187        }
     
    286298    protected:
    287299
     300        static const unsigned AnonymousSlotCount = JSVariableObject::AnonymousSlotCount + 1;
    288301        static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
    289302
  • trunk/JavaScriptCore/runtime/JSONObject.cpp

    r57978 r59941  
    3131#include "ExceptionHelpers.h"
    3232#include "JSArray.h"
     33#include "JSGlobalObject.h"
    3334#include "LiteralParser.h"
    3435#include "Lookup.h"
     
    4950
    5051namespace JSC {
     52
     53JSONObject::JSONObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
     54    : JSObjectWithGlobalObject(globalObject, structure)
     55{
     56}
    5157
    5258// PropertyNameForFunctionCall objects must be on the stack, since the JSValue that they create is not marked.
  • trunk/JavaScriptCore/runtime/JSONObject.h

    r56189 r59941  
    2727#define JSONObject_h
    2828
    29 #include "JSObject.h"
     29#include "JSObjectWithGlobalObject.h"
    3030
    3131namespace JSC {
     
    3333    class Stringifier;
    3434
    35     class JSONObject : public JSObject {
     35    class JSONObject : public JSObjectWithGlobalObject {
    3636    public:
    37         JSONObject(NonNullPassRefPtr<Structure> structure)
    38             : JSObject(structure)
    39         {
    40         }
     37        JSONObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure);
    4138
    4239        static PassRefPtr<Structure> createStructure(JSValue prototype)
  • trunk/JavaScriptCore/runtime/JSObject.h

    r59811 r59941  
    7575        friend class JIT;
    7676        friend class JSCell;
     77        friend void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot);
    7778
    7879    public:
     
    220221        }
    221222
     223        void putAnonymousValue(unsigned index, JSValue value)
     224        {
     225            ASSERT(index < m_structure->anonymousSlotCount());
     226            *locationForOffset(index) = value;
     227        }
     228        JSValue getAnonymousValue(unsigned index) const
     229        {
     230            ASSERT(index < m_structure->anonymousSlotCount());
     231            return *locationForOffset(index);
     232        }
     233       
    222234    protected:
    223235        static const unsigned StructureFlags = 0;
    224 
    225         void putAnonymousValue(unsigned index, JSValue value)
    226         {
    227             ASSERT(index < m_structure->anonymousSlotCount());
    228             *locationForOffset(index) = value;
    229         }
    230         JSValue getAnonymousValue(unsigned index) const
    231         {
    232             ASSERT(index < m_structure->anonymousSlotCount());
    233             return *locationForOffset(index);
    234         }
    235 
     236       
    236237    private:
    237238        // Nobody should ever ask any of these questions on something already known to be a JSObject.
  • trunk/JavaScriptCore/runtime/JSValue.cpp

    r54539 r59941  
    182182}
    183183
     184bool JSValue::isValidCallee()
     185{
     186    return asObject(asObject(asCell())->getAnonymousValue(0))->isGlobalObject();
     187}
     188
    184189} // namespace JSC
  • trunk/JavaScriptCore/runtime/JSValue.h

    r58286 r59941  
    204204        bool isCell() const;
    205205        JSCell* asCell() const;
     206        bool isValidCallee();
    206207
    207208#ifndef NDEBUG
  • trunk/JavaScriptCore/runtime/Lookup.cpp

    r59811 r59941  
    7272void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
    7373{
     74    ASSERT(thisObj->structure()->anonymousSlotCount() > 0);
     75    ASSERT(thisObj->getAnonymousValue(0).isCell() && asObject(thisObj->getAnonymousValue(0).asCell())->isGlobalObject());
    7476    ASSERT(entry->attributes() & Function);
    7577    JSValue* location = thisObj->getDirectLocation(propertyName);
     
    7779    if (!location) {
    7880        NativeFunctionWrapper* function;
     81        JSGlobalObject* globalObject = asGlobalObject(thisObj->getAnonymousValue(0).asCell());
    7982#if ENABLE(JIT)
    8083        if (entry->generator())
    81             function = new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
     84            function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
    8285        else
    8386#endif
    84             function = new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
     87            function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
    8588
    8689        thisObj->putDirectFunction(propertyName, function, entry->attributes());
  • trunk/JavaScriptCore/runtime/MathObject.cpp

    r58935 r59941  
    8787*/
    8888
    89 MathObject::MathObject(ExecState* exec, NonNullPassRefPtr<Structure> structure)
    90     : JSObject(structure)
     89MathObject::MathObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
     90    : JSObjectWithGlobalObject(globalObject, structure)
    9191{
    9292    putDirectWithoutTransition(Identifier(exec, "E"), jsNumber(exec, exp(1.0)), DontDelete | DontEnum | ReadOnly);
  • trunk/JavaScriptCore/runtime/MathObject.h

    r54022 r59941  
    2222#define MathObject_h
    2323
    24 #include "JSObject.h"
     24#include "JSObjectWithGlobalObject.h"
    2525
    2626namespace JSC {
    2727
    28     class MathObject : public JSObject {
     28    class MathObject : public JSObjectWithGlobalObject {
    2929    public:
    30         MathObject(ExecState*, NonNullPassRefPtr<Structure>);
     30        MathObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
    3131
    3232        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
  • trunk/JavaScriptCore/runtime/NativeErrorConstructor.cpp

    r51801 r59941  
    3333const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 };
    3434
    35 NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, NativeErrorPrototype* nativeErrorPrototype)
    36     : InternalFunction(&exec->globalData(), structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name).getString(exec)))
     35NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NativeErrorPrototype* nativeErrorPrototype)
     36    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name).getString(exec)))
    3737    , m_errorStructure(ErrorInstance::createStructure(nativeErrorPrototype))
    3838{
  • trunk/JavaScriptCore/runtime/NativeErrorConstructor.h

    r48836 r59941  
    3232    class NativeErrorConstructor : public InternalFunction {
    3333    public:
    34         NativeErrorConstructor(ExecState*, NonNullPassRefPtr<Structure>, NativeErrorPrototype*);
     34        NativeErrorConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, NativeErrorPrototype*);
    3535
    3636        static const ClassInfo info;
  • trunk/JavaScriptCore/runtime/NativeErrorPrototype.cpp

    r48836 r59941  
    2323
    2424#include "ErrorPrototype.h"
     25#include "JSGlobalObject.h"
    2526#include "JSString.h"
    2627#include "UString.h"
     
    3031ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
    3132
    32 NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, const UString& name, const UString& message)
    33     : JSObject(structure)
     33NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const UString& name, const UString& message)
     34    : JSObjectWithGlobalObject(globalObject, structure)
    3435{
    3536    putDirect(exec->propertyNames().name, jsString(exec, name), 0);
  • trunk/JavaScriptCore/runtime/NativeErrorPrototype.h

    r48836 r59941  
    2222#define NativeErrorPrototype_h
    2323
    24 #include "JSObject.h"
     24#include "JSObjectWithGlobalObject.h"
    2525
    2626namespace JSC {
    2727
    28     class NativeErrorPrototype : public JSObject {
     28    class NativeErrorPrototype : public JSObjectWithGlobalObject {
    2929    public:
    30         NativeErrorPrototype(ExecState*, NonNullPassRefPtr<Structure>, const UString& name, const UString& message);
     30        NativeErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const UString& name, const UString& message);
    3131    };
    3232
  • trunk/JavaScriptCore/runtime/NumberConstructor.cpp

    r57978 r59941  
    5555*/
    5656
    57 NumberConstructor::NumberConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, NumberPrototype* numberPrototype)
    58     : InternalFunction(&exec->globalData(), structure, Identifier(exec, numberPrototype->info.className))
     57NumberConstructor::NumberConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NumberPrototype* numberPrototype)
     58    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, numberPrototype->info.className))
    5959{
    6060    // Number.Prototype
  • trunk/JavaScriptCore/runtime/NumberConstructor.h

    r54022 r59941  
    3030    class NumberConstructor : public InternalFunction {
    3131    public:
    32         NumberConstructor(ExecState*, NonNullPassRefPtr<Structure>, NumberPrototype*);
     32        NumberConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, NumberPrototype*);
    3333
    3434        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
  • trunk/JavaScriptCore/runtime/NumberPrototype.cpp

    r58974 r59941  
    4848// ECMA 15.7.4
    4949
    50 NumberPrototype::NumberPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
     50NumberPrototype::NumberPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
    5151    : NumberObject(structure)
    5252{
     
    5555    // The constructor will be added later, after NumberConstructor has been constructed
    5656
    57     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
    58     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
    59     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
    60     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
    61     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
    62     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
     57    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
     58    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
     59    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
     60    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
     61    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
     62    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
    6363}
    6464
  • trunk/JavaScriptCore/runtime/NumberPrototype.h

    r48836 r59941  
    2828    class NumberPrototype : public NumberObject {
    2929    public:
    30         NumberPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
     30        NumberPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3131    };
    3232
  • trunk/JavaScriptCore/runtime/ObjectConstructor.cpp

    r53170 r59941  
    4343static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*, JSObject*, JSValue, const ArgList&);
    4444
    45 ObjectConstructor::ObjectConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure)
    46 : InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object"))
     45ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure)
     46: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, "Object"))
    4747{
    4848    // ECMA 15.2.3.1
     
    5252    putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
    5353   
    54     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum);
    55     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum);
    56     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getOwnPropertyNames, objectConstructorGetOwnPropertyNames), DontEnum);
    57     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum);
    58     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum);
    59     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum);
    60     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().create, objectConstructorCreate), DontEnum);
     54    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum);
     55    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().getOwnPropertyNames, objectConstructorGetOwnPropertyNames), DontEnum);
     57    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum);
     58    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum);
     59    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum);
     60    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().create, objectConstructorCreate), DontEnum);
    6161}
    6262
  • trunk/JavaScriptCore/runtime/ObjectConstructor.h

    r48836 r59941  
    3030    class ObjectConstructor : public InternalFunction {
    3131    public:
    32         ObjectConstructor(ExecState*, NonNullPassRefPtr<Structure>, ObjectPrototype*, Structure* prototypeFunctionStructure);
     32        ObjectConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ObjectPrototype*, Structure* prototypeFunctionStructure);
    3333
    3434    private:
  • trunk/JavaScriptCore/runtime/ObjectPrototype.cpp

    r54394 r59941  
    4242static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&);
    4343
    44 ObjectPrototype::ObjectPrototype(ExecState* exec, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
     44ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
    4545    : JSObject(stucture)
    4646    , m_hasNoPropertiesWithUInt32Names(true)
    4747{
    48     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
    49     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
    50     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
    51     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
    52     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
    53     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
     48    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
     49    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
     50    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
     51    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
     52    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
     53    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
    5454
    5555    // Mozilla extensions
    56     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
    57     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
    58     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
    59     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
     57    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
     58    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
     59    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
    6060}
    6161
  • trunk/JavaScriptCore/runtime/ObjectPrototype.h

    r48836 r59941  
    2828    class ObjectPrototype : public JSObject {
    2929    public:
    30         ObjectPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
     30        ObjectPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3131
    3232    private:
  • trunk/JavaScriptCore/runtime/PrototypeFunction.cpp

    r48836 r59941  
    3333ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction);
    3434
    35 PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
    36     : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
     35PrototypeFunction::PrototypeFunction(ExecState* exec, JSGlobalObject* globalObject, int length, const Identifier& name, NativeFunction function)
     36    : InternalFunction(&exec->globalData(), globalObject, exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
    3737    , m_function(function)
    3838{
     
    4141}
    4242
    43 PrototypeFunction::PrototypeFunction(ExecState* exec, NonNullPassRefPtr<Structure> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
    44     : InternalFunction(&exec->globalData(), prototypeFunctionStructure, name)
     43PrototypeFunction::PrototypeFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
     44    : InternalFunction(&exec->globalData(), globalObject, prototypeFunctionStructure, name)
    4545    , m_function(function)
    4646{
  • trunk/JavaScriptCore/runtime/PrototypeFunction.h

    r48836 r59941  
    3232    class PrototypeFunction : public InternalFunction {
    3333    public:
    34         PrototypeFunction(ExecState*, int length, const Identifier&, NativeFunction);
    35         PrototypeFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
     34        PrototypeFunction(ExecState*, JSGlobalObject*, int length, const Identifier&, NativeFunction);
     35        PrototypeFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
    3636
    3737    private:
  • trunk/JavaScriptCore/runtime/RegExpConstructor.cpp

    r57978 r59941  
    9292*/
    9393
    94 RegExpConstructor::RegExpConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, RegExpPrototype* regExpPrototype)
    95     : InternalFunction(&exec->globalData(), structure, Identifier(exec, "RegExp"))
     94RegExpConstructor::RegExpConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, RegExpPrototype* regExpPrototype)
     95    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, "RegExp"))
    9696    , d(new RegExpConstructorPrivate)
    9797{
     
    305305    if (!regExp->isValid())
    306306        return throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage()));
    307     return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
     307    return new (exec) RegExpObject(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
    308308}
    309309
  • trunk/JavaScriptCore/runtime/RegExpConstructor.h

    r59355 r59941  
    5656    class RegExpConstructor : public InternalFunction {
    5757    public:
    58         RegExpConstructor(ExecState*, NonNullPassRefPtr<Structure>, RegExpPrototype*);
     58        RegExpConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, RegExpPrototype*);
    5959
    6060        static PassRefPtr<Structure> createStructure(JSValue prototype)
  • trunk/JavaScriptCore/runtime/RegExpObject.cpp

    r57978 r59941  
    5959*/
    6060
    61 RegExpObject::RegExpObject(NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp)
    62     : JSObject(structure)
     61RegExpObject::RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp)
     62    : JSObjectWithGlobalObject(globalObject, structure)
    6363    , d(new RegExpObjectData(regExp, 0))
    6464{
  • trunk/JavaScriptCore/runtime/RegExpObject.h

    r54022 r59941  
    2222#define RegExpObject_h
    2323
    24 #include "JSObject.h"
     24#include "JSObjectWithGlobalObject.h"
    2525#include "RegExp.h"
    2626
    2727namespace JSC {
    2828
    29     class RegExpObject : public JSObject {
     29    class RegExpObject : public JSObjectWithGlobalObject {
    3030    public:
    31         RegExpObject(NonNullPassRefPtr<Structure>, NonNullPassRefPtr<RegExp>);
     31        RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure>, NonNullPassRefPtr<RegExp>);
    3232        virtual ~RegExpObject();
    3333
     
    5454
    5555    protected:
    56         static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
    57 
     56        static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObjectWithGlobalObject::StructureFlags;
     57       
    5858    private:
    5959        bool match(ExecState*, const ArgList&);
  • trunk/JavaScriptCore/runtime/RegExpPrototype.cpp

    r54394 r59941  
    4848const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0, 0 };
    4949
    50 RegExpPrototype::RegExpPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
     50RegExpPrototype::RegExpPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
    5151    : JSObject(structure)
    5252{
    53     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
    54     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
    55     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
    56     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
     53    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
     54    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
     55    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
     56    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
    5757}
    5858
  • trunk/JavaScriptCore/runtime/RegExpPrototype.h

    r48836 r59941  
    2828    class RegExpPrototype : public JSObject {
    2929    public:
    30         RegExpPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
     30        RegExpPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
    3131
    3232        virtual const ClassInfo* classInfo() const { return &info; }
  • trunk/JavaScriptCore/runtime/StringConstructor.cpp

    r59746 r59941  
    5050ASSERT_CLASS_FITS_IN_CELL(StringConstructor);
    5151
    52 StringConstructor::StringConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, StringPrototype* stringPrototype)
    53     : InternalFunction(&exec->globalData(), structure, Identifier(exec, stringPrototype->classInfo()->className))
     52StringConstructor::StringConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, StringPrototype* stringPrototype)
     53    : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, stringPrototype->classInfo()->className))
    5454{
    5555    // ECMA 15.5.3.1 String.prototype
     
    5858    // ECMA 15.5.3.2 fromCharCode()
    5959#if ENABLE(JIT)
    60     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getHostFunction(stringFromCharCode, fromCharCodeThunkGenerator)), DontEnum);
     60    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getHostFunction(stringFromCharCode, fromCharCodeThunkGenerator)), DontEnum);
    6161#else
    62     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
     62    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
    6363#endif
    6464    // no. of arguments for constructor
  • trunk/JavaScriptCore/runtime/StringConstructor.h

    r48836 r59941  
    3030    class StringConstructor : public InternalFunction {
    3131    public:
    32         StringConstructor(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, StringPrototype*);
     32        StringConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, StringPrototype*);
    3333
    3434        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/runtime/StringPrototype.cpp

    r59355 r59941  
    133133
    134134// ECMA 15.5.4
    135 StringPrototype::StringPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
     135StringPrototype::StringPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
    136136    : StringObject(exec, structure)
    137137{
     138    putAnonymousValue(0, globalObject);
    138139    // The constructor will be added later, after StringConstructor has been built
    139140    putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
  • trunk/JavaScriptCore/runtime/StringPrototype.h

    r48836 r59941  
    3030    class StringPrototype : public StringObject {
    3131    public:
    32         StringPrototype(ExecState*, NonNullPassRefPtr<Structure>);
     32        StringPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
    3333
    3434        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
  • trunk/LayoutTests/ChangeLog

    r59940 r59941  
     12010-05-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        All callable objects should have a global object reference
     6        https://bugs.webkit.org/show_bug.cgi?id=39495
     7
     8        Update expected results as we now give all function objects
     9        get their prototypes from the correct global object.
     10
     11        * fast/dom/prototype-inheritance-expected.txt:
     12
    1132010-05-21  Victor Wang  <victorw@chromium.org>
    214
  • trunk/LayoutTests/fast/dom/prototype-inheritance-expected.txt

    r59010 r59941  
    606606PASS inner.XSLTProcessor.isInner is true
    607607PASS inner.XSLTProcessor.constructor.isInner is true
    608 FAIL inner.addEventListener.isInner should be true. Was false.
    609 FAIL inner.addEventListener.constructor.isInner should be true. Was false.
    610 FAIL inner.alert.isInner should be true. Was false.
    611 FAIL inner.alert.constructor.isInner should be true. Was false.
     608PASS inner.addEventListener.isInner is true
     609PASS inner.addEventListener.constructor.isInner is true
     610PASS inner.alert.isInner is true
     611PASS inner.alert.constructor.isInner is true
    612612PASS inner.applicationCache.isInner is true
    613613PASS inner.applicationCache.constructor.isInner is true
    614 FAIL inner.atob.isInner should be true. Was false.
    615 FAIL inner.atob.constructor.isInner should be true. Was false.
    616 FAIL inner.blur.isInner should be true. Was false.
    617 FAIL inner.blur.constructor.isInner should be true. Was false.
    618 FAIL inner.btoa.isInner should be true. Was false.
    619 FAIL inner.btoa.constructor.isInner should be true. Was false.
    620 FAIL inner.captureEvents.isInner should be true. Was false.
    621 FAIL inner.captureEvents.constructor.isInner should be true. Was false.
    622 FAIL inner.clearInterval.isInner should be true. Was false.
    623 FAIL inner.clearInterval.constructor.isInner should be true. Was false.
    624 FAIL inner.clearTimeout.isInner should be true. Was false.
    625 FAIL inner.clearTimeout.constructor.isInner should be true. Was false.
     614PASS inner.atob.isInner is true
     615PASS inner.atob.constructor.isInner is true
     616PASS inner.blur.isInner is true
     617PASS inner.blur.constructor.isInner is true
     618PASS inner.btoa.isInner is true
     619PASS inner.btoa.constructor.isInner is true
     620PASS inner.captureEvents.isInner is true
     621PASS inner.captureEvents.constructor.isInner is true
     622PASS inner.clearInterval.isInner is true
     623PASS inner.clearInterval.constructor.isInner is true
     624PASS inner.clearTimeout.isInner is true
     625PASS inner.clearTimeout.constructor.isInner is true
    626626PASS inner.clientInformation.isInner is true
    627627PASS inner.clientInformation.constructor.isInner is true
    628 FAIL inner.close.isInner should be true. Was false.
    629 FAIL inner.close.constructor.isInner should be true. Was false.
     628PASS inner.close.isInner is true
     629PASS inner.close.constructor.isInner is true
    630630FAIL inner.closed.isInner should be true. Was false.
    631631FAIL inner.closed.constructor.isInner should be true. Was false.
    632 FAIL inner.confirm.isInner should be true. Was false.
    633 FAIL inner.confirm.constructor.isInner should be true. Was false.
     632PASS inner.confirm.isInner is true
     633PASS inner.confirm.constructor.isInner is true
    634634PASS inner.console.isInner is true
    635635PASS inner.console.constructor.isInner is true
     
    640640FAIL inner.devicePixelRatio.isInner should be true. Was false.
    641641FAIL inner.devicePixelRatio.constructor.isInner should be true. Was false.
    642 FAIL inner.dispatchEvent.isInner should be true. Was false.
    643 FAIL inner.dispatchEvent.constructor.isInner should be true. Was false.
     642PASS inner.dispatchEvent.isInner is true
     643PASS inner.dispatchEvent.constructor.isInner is true
    644644PASS inner.document.isInner is true
    645645PASS inner.document.constructor.isInner is true
    646 FAIL inner.find.isInner should be true. Was false.
    647 FAIL inner.find.constructor.isInner should be true. Was false.
    648 FAIL inner.focus.isInner should be true. Was false.
    649 FAIL inner.focus.constructor.isInner should be true. Was false.
     646PASS inner.find.isInner is true
     647PASS inner.find.constructor.isInner is true
     648PASS inner.focus.isInner is true
     649PASS inner.focus.constructor.isInner is true
    650650FAIL inner.frameElement.isInner should be true. Was false.
    651651FAIL inner.frameElement.constructor.isInner should be true. Was false.
    652652PASS inner.frames.isInner is true
    653653PASS inner.frames.constructor.isInner is true
    654 FAIL inner.getComputedStyle.isInner should be true. Was false.
    655 FAIL inner.getComputedStyle.constructor.isInner should be true. Was false.
    656 FAIL inner.getMatchedCSSRules.isInner should be true. Was false.
    657 FAIL inner.getMatchedCSSRules.constructor.isInner should be true. Was false.
    658 FAIL inner.getSelection.isInner should be true. Was false.
    659 FAIL inner.getSelection.constructor.isInner should be true. Was false.
     654PASS inner.getComputedStyle.isInner is true
     655PASS inner.getComputedStyle.constructor.isInner is true
     656PASS inner.getMatchedCSSRules.isInner is true
     657PASS inner.getMatchedCSSRules.constructor.isInner is true
     658PASS inner.getSelection.isInner is true
     659PASS inner.getSelection.constructor.isInner is true
    660660PASS inner.history.isInner is true
    661661PASS inner.history.constructor.isInner is true
     
    676676PASS inner.menubar.isInner is true
    677677PASS inner.menubar.constructor.isInner is true
    678 FAIL inner.moveBy.isInner should be true. Was false.
    679 FAIL inner.moveBy.constructor.isInner should be true. Was false.
    680 FAIL inner.moveTo.isInner should be true. Was false.
    681 FAIL inner.moveTo.constructor.isInner should be true. Was false.
     678PASS inner.moveBy.isInner is true
     679PASS inner.moveBy.constructor.isInner is true
     680PASS inner.moveTo.isInner is true
     681PASS inner.moveTo.constructor.isInner is true
    682682FAIL inner.name.isInner should be true. Was false.
    683683FAIL inner.name.constructor.isInner should be true. Was false.
     
    686686FAIL inner.offscreenBuffering.isInner should be true. Was false.
    687687FAIL inner.offscreenBuffering.constructor.isInner should be true. Was false.
    688 FAIL inner.open.isInner should be true. Was false.
    689 FAIL inner.open.constructor.isInner should be true. Was false.
    690 FAIL inner.openDatabase.isInner should be true. Was false.
    691 FAIL inner.openDatabase.constructor.isInner should be true. Was false.
     688PASS inner.open.isInner is true
     689PASS inner.open.constructor.isInner is true
     690PASS inner.openDatabase.isInner is true
     691PASS inner.openDatabase.constructor.isInner is true
    692692FAIL inner.outerHeight.isInner should be true. Was false.
    693693FAIL inner.outerHeight.constructor.isInner should be true. Was false.
     
    700700PASS inner.personalbar.isInner is true
    701701PASS inner.personalbar.constructor.isInner is true
    702 FAIL inner.postMessage.isInner should be true. Was false.
    703 FAIL inner.postMessage.constructor.isInner should be true. Was false.
    704 FAIL inner.print.isInner should be true. Was false.
    705 FAIL inner.print.constructor.isInner should be true. Was false.
    706 FAIL inner.prompt.isInner should be true. Was false.
    707 FAIL inner.prompt.constructor.isInner should be true. Was false.
    708 FAIL inner.releaseEvents.isInner should be true. Was false.
    709 FAIL inner.releaseEvents.constructor.isInner should be true. Was false.
    710 FAIL inner.removeEventListener.isInner should be true. Was false.
    711 FAIL inner.removeEventListener.constructor.isInner should be true. Was false.
    712 FAIL inner.resizeBy.isInner should be true. Was false.
    713 FAIL inner.resizeBy.constructor.isInner should be true. Was false.
    714 FAIL inner.resizeTo.isInner should be true. Was false.
    715 FAIL inner.resizeTo.constructor.isInner should be true. Was false.
     702PASS inner.postMessage.isInner is true
     703PASS inner.postMessage.constructor.isInner is true
     704PASS inner.print.isInner is true
     705PASS inner.print.constructor.isInner is true
     706PASS inner.prompt.isInner is true
     707PASS inner.prompt.constructor.isInner is true
     708PASS inner.releaseEvents.isInner is true
     709PASS inner.releaseEvents.constructor.isInner is true
     710PASS inner.removeEventListener.isInner is true
     711PASS inner.removeEventListener.constructor.isInner is true
     712PASS inner.resizeBy.isInner is true
     713PASS inner.resizeBy.constructor.isInner is true
     714PASS inner.resizeTo.isInner is true
     715PASS inner.resizeTo.constructor.isInner is true
    716716PASS inner.screen.isInner is true
    717717PASS inner.screen.constructor.isInner is true
     
    724724FAIL inner.screenY.isInner should be true. Was false.
    725725FAIL inner.screenY.constructor.isInner should be true. Was false.
    726 FAIL inner.scroll.isInner should be true. Was false.
    727 FAIL inner.scroll.constructor.isInner should be true. Was false.
    728 FAIL inner.scrollBy.isInner should be true. Was false.
    729 FAIL inner.scrollBy.constructor.isInner should be true. Was false.
    730 FAIL inner.scrollTo.isInner should be true. Was false.
    731 FAIL inner.scrollTo.constructor.isInner should be true. Was false.
     726PASS inner.scroll.isInner is true
     727PASS inner.scroll.constructor.isInner is true
     728PASS inner.scrollBy.isInner is true
     729PASS inner.scrollBy.constructor.isInner is true
     730PASS inner.scrollTo.isInner is true
     731PASS inner.scrollTo.constructor.isInner is true
    732732FAIL inner.scrollX.isInner should be true. Was false.
    733733FAIL inner.scrollX.constructor.isInner should be true. Was false.
     
    740740PASS inner.sessionStorage.isInner is true
    741741PASS inner.sessionStorage.constructor.isInner is true
    742 FAIL inner.setInterval.isInner should be true. Was false.
    743 FAIL inner.setInterval.constructor.isInner should be true. Was false.
    744 FAIL inner.setTimeout.isInner should be true. Was false.
    745 FAIL inner.setTimeout.constructor.isInner should be true. Was false.
     742PASS inner.setInterval.isInner is true
     743PASS inner.setInterval.constructor.isInner is true
     744PASS inner.setTimeout.isInner is true
     745PASS inner.setTimeout.constructor.isInner is true
    746746FAIL inner.status.isInner should be true. Was false.
    747747FAIL inner.status.constructor.isInner should be true. Was false.
    748748PASS inner.statusbar.isInner is true
    749749PASS inner.statusbar.constructor.isInner is true
    750 FAIL inner.stop.isInner should be true. Was false.
    751 FAIL inner.stop.constructor.isInner should be true. Was false.
     750PASS inner.stop.isInner is true
     751PASS inner.stop.constructor.isInner is true
    752752PASS inner.styleMedia.isInner is true
    753753PASS inner.styleMedia.constructor.isInner is true
    754754PASS inner.toolbar.isInner is true
    755755PASS inner.toolbar.constructor.isInner is true
    756 FAIL inner.webkitConvertPointFromNodeToPage.isInner should be true. Was false.
    757 FAIL inner.webkitConvertPointFromNodeToPage.constructor.isInner should be true. Was false.
    758 FAIL inner.webkitConvertPointFromPageToNode.isInner should be true. Was false.
    759 FAIL inner.webkitConvertPointFromPageToNode.constructor.isInner should be true. Was false.
     756PASS inner.webkitConvertPointFromNodeToPage.isInner is true
     757PASS inner.webkitConvertPointFromNodeToPage.constructor.isInner is true
     758PASS inner.webkitConvertPointFromPageToNode.isInner is true
     759PASS inner.webkitConvertPointFromPageToNode.constructor.isInner is true
    760760PASS inner.window.isInner is true
    761761PASS inner.window.constructor.isInner is true
  • trunk/WebCore/ChangeLog

    r59935 r59941  
     12010-05-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        All callable objects should have a global object reference
     6        https://bugs.webkit.org/show_bug.cgi?id=39495
     7
     8        Update the bindings generator to give prototype objects a
     9        global object.  Update all the manually written JSObject
     10        subclasses to pass a global object.
     11
     12        * ForwardingHeaders/runtime/JSObjectWithGlobalObject.h: Added.
     13        * WebCore.PluginHostProcess.exp:
     14        * bindings/js/JSDOMBinding.cpp:
     15        (WebCore::objectToStringFunctionGetter):
     16        * bindings/js/JSDOMWindowCustom.cpp:
     17        (WebCore::nonCachingStaticFunctionGetter):
     18        * bindings/js/JSDOMWindowShell.cpp:
     19        (WebCore::JSDOMWindowShell::setWindow):
     20        * bindings/js/JSHistoryCustom.cpp:
     21        (WebCore::nonCachingStaticBackFunctionGetter):
     22        (WebCore::nonCachingStaticForwardFunctionGetter):
     23        (WebCore::nonCachingStaticGoFunctionGetter):
     24        * bindings/js/JSLocationCustom.cpp:
     25        (WebCore::nonCachingStaticReplaceFunctionGetter):
     26        (WebCore::nonCachingStaticReloadFunctionGetter):
     27        (WebCore::nonCachingStaticAssignFunctionGetter):
     28        * bindings/js/WorkerScriptController.cpp:
     29        (WebCore::WorkerScriptController::initScript):
     30        * bindings/scripts/CodeGeneratorJS.pm:
     31        * bridge/c/CRuntimeObject.cpp:
     32        (JSC::Bindings::CRuntimeObject::CRuntimeObject):
     33        * bridge/c/CRuntimeObject.h:
     34        * bridge/c/c_instance.cpp:
     35        (JSC::Bindings::CInstance::newRuntimeObject):
     36        (JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
     37        (JSC::Bindings::CInstance::getMethod):
     38        * bridge/jni/jsc/JavaInstanceJSC.cpp:
     39        (JavaInstance::newRuntimeObject):
     40        (JavaRuntimeMethod::JavaRuntimeMethod):
     41        (JavaInstance::getMethod):
     42        * bridge/jni/jsc/JavaRuntimeObject.cpp:
     43        (JSC::Bindings::JavaRuntimeObject::JavaRuntimeObject):
     44        * bridge/jni/jsc/JavaRuntimeObject.h:
     45        * bridge/jsc/BridgeJSC.cpp:
     46        (JSC::Bindings::Instance::newRuntimeObject):
     47        * bridge/objc/ObjCRuntimeObject.h:
     48        * bridge/objc/ObjCRuntimeObject.mm:
     49        (JSC::Bindings::ObjCRuntimeObject::ObjCRuntimeObject):
     50        * bridge/objc/objc_class.mm:
     51        (JSC::Bindings::ObjcClass::fallbackObject):
     52        * bridge/objc/objc_instance.mm:
     53        (ObjcInstance::newRuntimeObject):
     54        (ObjCRuntimeMethod::ObjCRuntimeMethod):
     55        (ObjcInstance::getMethod):
     56        * bridge/objc/objc_runtime.h:
     57        * bridge/objc/objc_runtime.mm:
     58        (JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
     59        * bridge/runtime_method.cpp:
     60        (JSC::RuntimeMethod::RuntimeMethod):
     61        * bridge/runtime_method.h:
     62        * bridge/runtime_object.cpp:
     63        (JSC::Bindings::RuntimeObject::RuntimeObject):
     64        * bridge/runtime_object.h:
     65
    1662010-05-21  Steve Block  <steveblock@google.com>
    267
  • trunk/WebCore/WebCore.PluginHostProcess.exp

    r57911 r59941  
    55__ZN3JSC13RuntimeMethod24getOwnPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
    66__ZN3JSC13RuntimeMethod6s_infoE
    7 __ZN3JSC13RuntimeMethodC1EPNS_9ExecStateERKNS_10IdentifierERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
    8 __ZN3JSC13RuntimeMethodC2EPNS_9ExecStateERKNS_10IdentifierERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
     7__ZN3JSC13RuntimeMethodC2EPNS_9ExecStateEPNS_14JSGlobalObjectERKNS_10IdentifierERN3WTF6VectorIPNS_8Bindings6MethodELm0EEE
    98__ZN3JSC8Bindings10RootObjectD1Ev
    109__ZN3JSC8Bindings13RuntimeObject11getCallDataERNS_8CallDataE
     
    1615__ZN3JSC8Bindings13RuntimeObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
    1716__ZN3JSC8Bindings13RuntimeObject6s_infoE
    18 __ZN3JSC8Bindings13RuntimeObjectC2EPNS_9ExecStateEN3WTF10PassRefPtrINS0_8InstanceEEE
     17__ZN3JSC8Bindings13RuntimeObjectC2EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF10PassRefPtrINS0_8InstanceEEE
    1918__ZN3JSC8Bindings13RuntimeObjectD2Ev
    2019__ZN3JSC8Bindings8Instance19createRuntimeObjectEPNS_9ExecStateE
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r58027 r59941  
    687687JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    688688{
    689     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, objectProtoFuncToString);
     689    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, objectProtoFuncToString);
    690690}
    691691
  • trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r59499 r59941  
    131131JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    132132{
    133     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), length, propertyName, nativeFunction);
     133    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), length, propertyName, nativeFunction);
    134134}
    135135
  • trunk/WebCore/bindings/js/JSDOMWindowShell.cpp

    r53170 r59941  
    6262    // constructed, it can mark its own prototype.)
    6363    RefPtr<Structure> prototypeStructure = JSDOMWindowPrototype::createStructure(jsNull());
    64     ProtectedPtr<JSDOMWindowPrototype> prototype = new JSDOMWindowPrototype(prototypeStructure.release());
     64    ProtectedPtr<JSDOMWindowPrototype> prototype = new JSDOMWindowPrototype(0, prototypeStructure.release());
    6565
    6666    RefPtr<Structure> structure = JSDOMWindow::createStructure(prototype);
    6767    JSDOMWindow* jsDOMWindow = new (JSDOMWindow::commonJSGlobalData()) JSDOMWindow(structure.release(), domWindow, this);
     68    prototype->putAnonymousValue(0, jsDOMWindow);
    6869    setWindow(jsDOMWindow);
    6970}
  • trunk/WebCore/bindings/js/JSHistoryCustom.cpp

    r55401 r59941  
    4141static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    4242{
    43     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack);
     43    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack);
    4444}
    4545
    4646static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    4747{
    48     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward);
     48    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward);
    4949}
    5050
    5151static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    5252{
    53     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo);
     53    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo);
    5454}
    5555
  • trunk/WebCore/bindings/js/JSLocationCustom.cpp

    r57738 r59941  
    4242static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    4343{
    44     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
     44    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
    4545}
    4646
    4747static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    4848{
    49     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
     49    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
    5050}
    5151
    5252static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
    5353{
    54     return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
     54    return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
    5555}
    5656
  • trunk/WebCore/bindings/js/WorkerScriptController.cpp

    r58012 r59941  
    7272    // constructed, it can mark its own prototype.)
    7373    RefPtr<Structure> workerContextPrototypeStructure = JSWorkerContextPrototype::createStructure(jsNull());
    74     ProtectedPtr<JSWorkerContextPrototype> workerContextPrototype = new (m_globalData.get()) JSWorkerContextPrototype(workerContextPrototypeStructure.release());
     74    ProtectedPtr<JSWorkerContextPrototype> workerContextPrototype = new (m_globalData.get()) JSWorkerContextPrototype(0, workerContextPrototypeStructure.release());
    7575
    7676    if (m_workerContext->isDedicatedWorkerContext()) {
    7777        RefPtr<Structure> dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(workerContextPrototype);
    78         ProtectedPtr<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype = new (m_globalData.get()) JSDedicatedWorkerContextPrototype(dedicatedContextPrototypeStructure.release());
     78        ProtectedPtr<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype = new (m_globalData.get()) JSDedicatedWorkerContextPrototype(0, dedicatedContextPrototypeStructure.release());
    7979        RefPtr<Structure> structure = JSDedicatedWorkerContext::createStructure(dedicatedContextPrototype);
    8080
    8181        m_workerContextWrapper = new (m_globalData.get()) JSDedicatedWorkerContext(structure.release(), m_workerContext->toDedicatedWorkerContext());
     82        workerContextPrototype->putAnonymousValue(0, m_workerContextWrapper);
     83        dedicatedContextPrototype->putAnonymousValue(0, m_workerContextWrapper);
    8284#if ENABLE(SHARED_WORKERS)
    8385    } else {
    8486        ASSERT(m_workerContext->isSharedWorkerContext());
    8587        RefPtr<Structure> sharedContextPrototypeStructure = JSSharedWorkerContextPrototype::createStructure(workerContextPrototype);
    86         ProtectedPtr<JSSharedWorkerContextPrototype> sharedContextPrototype = new (m_globalData.get()) JSSharedWorkerContextPrototype(sharedContextPrototypeStructure.release());
     88        ProtectedPtr<JSSharedWorkerContextPrototype> sharedContextPrototype = new (m_globalData.get()) JSSharedWorkerContextPrototype(0, sharedContextPrototypeStructure.release());
    8789        RefPtr<Structure> structure = JSSharedWorkerContext::createStructure(sharedContextPrototype);
    8890
    8991        m_workerContextWrapper = new (m_globalData.get()) JSSharedWorkerContext(structure.release(), m_workerContext->toSharedWorkerContext());
     92        workerContextPrototype->putAnonymousValue(0, m_workerContextWrapper);
     93        sharedContextPrototype->putAnonymousValue(0, m_workerContextWrapper);
    9094#endif
    9195    }
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r59794 r59941  
    644644        $headerIncludes{"$implClassName.h"} = 1;
    645645    }
     646   
     647    $headerIncludes{"<runtime/JSObjectWithGlobalObject.h>"} = 1;
    646648
    647649    $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/;
     
    936938    # Add prototype declaration.
    937939    %structureFlags = ();
    938     push(@headerContent, "class ${className}Prototype : public JSC::JSObject {\n");
    939     push(@headerContent, "    typedef JSC::JSObject Base;\n");
     940    push(@headerContent, "class ${className}Prototype : public JSC::JSObjectWithGlobalObject {\n");
     941    push(@headerContent, "    typedef JSC::JSObjectWithGlobalObject Base;\n");
    940942    push(@headerContent, "public:\n");
    941943    if ($interfaceName eq "DOMWindow") {
     
    971973    push(@headerContent, "    virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomPrototypeDefineGetter"};
    972974
    973     push(@headerContent, "    ${className}Prototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { }\n");
     975    push(@headerContent, "    ${className}Prototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { }\n");
    974976
    975977    # structure flags
     
    14411443        push(@implContent, "{\n");
    14421444        if ($hasParent && $parentClassName ne "JSC::DOMNodeFilter") {
    1443             push(@implContent, "    return new (exec) ${className}Prototype(${className}Prototype::createStructure(${parentClassName}Prototype::self(exec, globalObject)));\n");
     1445            push(@implContent, "    return new (exec) ${className}Prototype(globalObject, ${className}Prototype::createStructure(${parentClassName}Prototype::self(exec, globalObject)));\n");
    14441446        } else {
    1445             push(@implContent, "    return new (exec) ${className}Prototype(${className}Prototype::createStructure(globalObject->objectPrototype()));\n");
     1447            push(@implContent, "    return new (exec) ${className}Prototype(globalObject, ${className}Prototype::createStructure(globalObject->objectPrototype()));\n");
    14461448        }
    14471449        push(@implContent, "}\n\n");
  • trunk/WebCore/bridge/c/CRuntimeObject.cpp

    r55250 r59941  
    3636const ClassInfo CRuntimeObject::s_info = { "CRuntimeObject", &RuntimeObject::s_info, 0, 0 };
    3737
    38 CRuntimeObject::CRuntimeObject(ExecState* exec, PassRefPtr<CInstance> instance)
    39     : RuntimeObject(exec, instance)
     38CRuntimeObject::CRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
     39    : RuntimeObject(exec, globalObject, instance)
    4040{
    4141}
  • trunk/WebCore/bridge/c/CRuntimeObject.h

    r55250 r59941  
    3838class CRuntimeObject : public RuntimeObject {
    3939public:
    40     CRuntimeObject(ExecState*, PassRefPtr<CInstance>);
     40    CRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<CInstance>);
    4141    virtual ~CRuntimeObject();
    4242
  • trunk/WebCore/bridge/c/c_instance.cpp

    r57227 r59941  
    9494RuntimeObject* CInstance::newRuntimeObject(ExecState* exec)
    9595{
    96     return new (exec) CRuntimeObject(exec, this);
     96    return new (exec) CRuntimeObject(exec, exec->lexicalGlobalObject(), this);
    9797}
    9898
     
    111111class CRuntimeMethod : public RuntimeMethod {
    112112public:
    113     CRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list)
    114         : RuntimeMethod(exec, name, list)
     113    CRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
     114        : RuntimeMethod(exec, globalObject, name, list)
    115115    {
    116116    }
     
    126126{
    127127    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    128     return new (exec) CRuntimeMethod(exec, propertyName, methodList);
     128    return new (exec) CRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
    129129}
    130130
  • trunk/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp

    r59918 r59941  
    6161RuntimeObject* JavaInstance::newRuntimeObject(ExecState* exec)
    6262{
    63     return new (exec) JavaRuntimeObject(exec, this);
     63    return new (exec) JavaRuntimeObject(exec, exec->lexicalGlobalObject(), this);
    6464}
    6565
     
    114114class JavaRuntimeMethod : public RuntimeMethod {
    115115public:
    116     JavaRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list)
    117         : RuntimeMethod(exec, name, list)
     116    JavaRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
     117        : RuntimeMethod(exec, globalObject, name, list)
    118118    {
    119119    }
     
    129129{
    130130    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    131     return new (exec) JavaRuntimeMethod(exec, propertyName, methodList);
     131    return new (exec) JavaRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
    132132}
    133133
  • trunk/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp

    r55250 r59941  
    3434const ClassInfo JavaRuntimeObject::s_info = { "JavaRuntimeObject", &RuntimeObject::s_info, 0, 0 };
    3535
    36 JavaRuntimeObject::JavaRuntimeObject(ExecState* exec, PassRefPtr<JavaInstance> instance)
    37     : RuntimeObject(exec, instance)
     36JavaRuntimeObject::JavaRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<JavaInstance> instance)
     37    : RuntimeObject(exec, globalObject, instance)
    3838{
    3939}
  • trunk/WebCore/bridge/jni/jsc/JavaRuntimeObject.h

    r55250 r59941  
    3636class JavaRuntimeObject : public RuntimeObject {
    3737public:
    38     JavaRuntimeObject(ExecState*, PassRefPtr<JavaInstance>);
     38    JavaRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<JavaInstance>);
    3939    virtual ~JavaRuntimeObject();
    4040
  • trunk/WebCore/bridge/jsc/BridgeJSC.cpp

    r55109 r59941  
    9999{
    100100    JSLock lock(SilenceAssertionsOnly);
    101     return new (exec)RuntimeObject(exec, this);
     101    return new (exec)RuntimeObject(exec, exec->lexicalGlobalObject(), this);
    102102}
    103103
  • trunk/WebCore/bridge/objc/ObjCRuntimeObject.h

    r55250 r59941  
    3636class ObjCRuntimeObject : public RuntimeObject {
    3737public:
    38     ObjCRuntimeObject(ExecState*, PassRefPtr<ObjcInstance>);
     38    ObjCRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<ObjcInstance>);
    3939    virtual ~ObjCRuntimeObject();
    4040
  • trunk/WebCore/bridge/objc/ObjCRuntimeObject.mm

    r55250 r59941  
    3434const ClassInfo ObjCRuntimeObject::s_info = { "ObjCRuntimeObject", &RuntimeObject::s_info, 0, 0 };
    3535
    36 ObjCRuntimeObject::ObjCRuntimeObject(ExecState* exec, PassRefPtr<ObjcInstance> instance)
    37     : RuntimeObject(exec, instance)
     36ObjCRuntimeObject::ObjCRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<ObjcInstance> instance)
     37    : RuntimeObject(exec, globalObject, instance)
    3838{
    3939}
  • trunk/WebCore/bridge/objc/objc_class.mm

    r43122 r59941  
    247247    if (![targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
    248248        return jsUndefined();
    249     return new (exec) ObjcFallbackObjectImp(exec, objcInstance, propertyName);
    250 }
    251 
    252 }
    253 }
     249    return new (exec) ObjcFallbackObjectImp(exec, exec->lexicalGlobalObject(), objcInstance, propertyName);
     250}
     251
     252}
     253}
  • trunk/WebCore/bridge/objc/objc_instance.mm

    r55760 r59941  
    6666RuntimeObject* ObjcInstance::newRuntimeObject(ExecState* exec)
    6767{
    68     return new (exec) ObjCRuntimeObject(exec, this);
     68    return new (exec) ObjCRuntimeObject(exec, exec->lexicalGlobalObject(), this);
    6969}
    7070
     
    177177class ObjCRuntimeMethod : public RuntimeMethod {
    178178public:
    179     ObjCRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list)
    180         : RuntimeMethod(exec, name, list)
     179    ObjCRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
     180        : RuntimeMethod(exec, globalObject, name, list)
    181181    {
    182182    }
     
    192192{
    193193    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    194     return new (exec) ObjCRuntimeMethod(exec, propertyName, methodList);
     194    return new (exec) ObjCRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
    195195}
    196196
  • trunk/WebCore/bridge/objc/objc_runtime.h

    r54022 r59941  
    3030#include "objc_header.h"
    3131#include <runtime/JSGlobalObject.h>
     32#include <runtime/JSObjectWithGlobalObject.h>
    3233#include <wtf/RetainPtr.h>
    3334
     
    9091};
    9192
    92 class ObjcFallbackObjectImp : public JSObject {
     93class ObjcFallbackObjectImp : public JSObjectWithGlobalObject {
    9394public:
    94     ObjcFallbackObjectImp(ExecState*, ObjcInstance*, const Identifier& propertyName);
     95    ObjcFallbackObjectImp(ExecState*, JSGlobalObject*, ObjcInstance*, const Identifier& propertyName);
    9596
    9697    static const ClassInfo s_info;
  • trunk/WebCore/bridge/objc/objc_runtime.mm

    r55312 r59941  
    190190const ClassInfo ObjcFallbackObjectImp::s_info = { "ObjcFallbackObject", 0, 0, 0 };
    191191
    192 ObjcFallbackObjectImp::ObjcFallbackObjectImp(ExecState* exec, ObjcInstance* i, const Identifier& propertyName)
     192ObjcFallbackObjectImp::ObjcFallbackObjectImp(ExecState* exec, JSGlobalObject* globalObject, ObjcInstance* i, const Identifier& propertyName)
    193193    // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
    194     : JSObject(deprecatedGetDOMStructure<ObjcFallbackObjectImp>(exec))
     194    : JSObjectWithGlobalObject(globalObject, deprecatedGetDOMStructure<ObjcFallbackObjectImp>(exec))
    195195    , _instance(i)
    196196    , _item(propertyName)
  • trunk/WebCore/bridge/runtime_method.cpp

    r55564 r59941  
    4444const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::info, 0, 0 };
    4545
    46 RuntimeMethod::RuntimeMethod(ExecState* exec, const Identifier& ident, Bindings::MethodList& m)
     46RuntimeMethod::RuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& ident, Bindings::MethodList& m)
    4747    // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
    4848    // exec-globalData() is also likely wrong.
    4949    // Callers will need to pass in the right global object corresponding to this native object "m".
    50     : InternalFunction(&exec->globalData(), deprecatedGetDOMStructure<RuntimeMethod>(exec), ident)
     50    : InternalFunction(&exec->globalData(), globalObject, deprecatedGetDOMStructure<RuntimeMethod>(exec), ident)
    5151    , _methodList(new MethodList(m))
    5252{
  • trunk/WebCore/bridge/runtime_method.h

    r55401 r59941  
    3636class RuntimeMethod : public InternalFunction {
    3737public:
    38     RuntimeMethod(ExecState*, const Identifier& name, Bindings::MethodList&);
     38    RuntimeMethod(ExecState*, JSGlobalObject*, const Identifier& name, Bindings::MethodList&);
    3939    Bindings::MethodList* methods() const { return _methodList.get(); }
    4040
  • trunk/WebCore/bridge/runtime_object.cpp

    r55401 r59941  
    3939const ClassInfo RuntimeObject::s_info = { "RuntimeObject", 0, 0, 0 };
    4040
    41 RuntimeObject::RuntimeObject(ExecState* exec, PassRefPtr<Instance> instance)
     41RuntimeObject::RuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
    4242    // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
    4343    // We need to pass in the right global object for "i".
    44     : JSObject(deprecatedGetDOMStructure<RuntimeObject>(exec))
     44    : JSObjectWithGlobalObject(globalObject, deprecatedGetDOMStructure<RuntimeObject>(exec))
    4545    , m_instance(instance)
    4646{
    4747}
    4848
    49 RuntimeObject::RuntimeObject(ExecState*, NonNullPassRefPtr<Structure> structure, PassRefPtr<Instance> instance)
    50     : JSObject(structure)
     49RuntimeObject::RuntimeObject(ExecState*, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, PassRefPtr<Instance> instance)
     50    : JSObjectWithGlobalObject(globalObject, structure)
    5151    , m_instance(instance)
    5252{
  • trunk/WebCore/bridge/runtime_object.h

    r55401 r59941  
    2929#include "Bridge.h"
    3030#include <runtime/JSGlobalObject.h>
     31#include <runtime/JSObjectWithGlobalObject.h>
    3132
    3233namespace JSC {
    3334namespace Bindings {
    3435
    35 class RuntimeObject : public JSObject {
     36class RuntimeObject : public JSObjectWithGlobalObject {
    3637public:
    37     RuntimeObject(ExecState*, PassRefPtr<Instance>);
     38    RuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
    3839    virtual ~RuntimeObject();
    3940
     
    6869protected:
    6970    static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
    70     RuntimeObject(ExecState*, NonNullPassRefPtr<Structure>, PassRefPtr<Instance>);
     71    RuntimeObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, PassRefPtr<Instance>);
    7172
    7273private:
  • trunk/WebKit/mac/ChangeLog

    r59935 r59941  
     12010-05-21  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        All callable objects should have a global object reference
     6        https://bugs.webkit.org/show_bug.cgi?id=39495
     7
     8        Update the plugin proxy to handle the need for global object.
     9
     10        * Plugins/Hosted/ProxyInstance.mm:
     11        (WebKit::ProxyInstance::newRuntimeObject):
     12        (WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
     13        (WebKit::ProxyInstance::getMethod):
     14        * Plugins/Hosted/ProxyRuntimeObject.h:
     15        * Plugins/Hosted/ProxyRuntimeObject.mm:
     16        (WebKit::ProxyRuntimeObject::ProxyRuntimeObject):
     17
    1182010-05-21  Steve Block  <steveblock@google.com>
    219
  • trunk/WebKit/mac/Plugins/Hosted/ProxyInstance.mm

    r57738 r59941  
    134134RuntimeObject* ProxyInstance::newRuntimeObject(ExecState* exec)
    135135{
    136     return new (exec) ProxyRuntimeObject(exec, this);
     136    return new (exec) ProxyRuntimeObject(exec, exec->lexicalGlobalObject(), this);
    137137}
    138138
     
    179179class ProxyRuntimeMethod : public RuntimeMethod {
    180180public:
    181     ProxyRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list)
    182         : RuntimeMethod(exec, name, list)
     181    ProxyRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
     182        : RuntimeMethod(exec, globalObject, name, list)
    183183    {
    184184    }
     
    194194{
    195195    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    196     return new (exec) ProxyRuntimeMethod(exec, propertyName, methodList);
     196    return new (exec) ProxyRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
    197197}
    198198
  • trunk/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.h

    r55250 r59941  
    3737class ProxyRuntimeObject : public JSC::Bindings::RuntimeObject {
    3838public:
    39     ProxyRuntimeObject(JSC::ExecState*, PassRefPtr<ProxyInstance>);
     39    ProxyRuntimeObject(JSC::ExecState*, JSC::JSGlobalObject*, PassRefPtr<ProxyInstance>);
    4040    virtual ~ProxyRuntimeObject();
    4141
  • trunk/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.mm

    r55250 r59941  
    3636const ClassInfo ProxyRuntimeObject::s_info = { "ProxyRuntimeObject", &RuntimeObject::s_info, 0, 0 };
    3737
    38 ProxyRuntimeObject::ProxyRuntimeObject(ExecState* exec, PassRefPtr<ProxyInstance> instance)
    39     : RuntimeObject(exec, instance)
     38ProxyRuntimeObject::ProxyRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<ProxyInstance> instance)
     39    : RuntimeObject(exec, globalObject, instance)
    4040{
    4141}
Note: See TracChangeset for help on using the changeset viewer.