2010-05-21 Oliver Hunt <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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):