Commit 4aef7247 authored by barraclough@apple.com's avatar barraclough@apple.com

Generalize JSGlobalThis as JSProxy

https://bugs.webkit.org/show_bug.cgi?id=97716

Reviewed by Oliver Hunt.

../JavaScriptCore: 

Generalize JSGlobalThis as JSProxy and move proxying functionality up from the window shell into JSProxy.

* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Target.pri:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::toThisObject):
    - Hoist toThisObject from WebCore.
(JSC):
* runtime/JSGlobalObject.h:
    - removed include.
(JSC::JSGlobalObject::finishCreation):
    - JSGlobalThis -> JSObject
(JSGlobalObject):
    - Hoist toThisObject from WebCore.
* runtime/JSGlobalThis.cpp: Removed.
* runtime/JSGlobalThis.h: Removed.
* runtime/JSObject.cpp:
    - removed include.
* runtime/JSObject.h:
(JSObject):
(JSC::JSObject::isProxy):
    - isGlobalThis -> isProxy
    - GlobalThisType -> ProxyType
* runtime/JSProxy.cpp: Copied from Source/JavaScriptCore/runtime/JSGlobalThis.cpp.
(JSC):
(JSC::JSProxy::visitChildren):
(JSC::JSProxy::setTarget):
(JSC::JSProxy::className):
(JSC::JSProxy::getOwnPropertySlot):
(JSC::JSProxy::getOwnPropertySlotByIndex):
(JSC::JSProxy::getOwnPropertyDescriptor):
(JSC::JSProxy::put):
(JSC::JSProxy::putByIndex):
(JSC::JSProxy::putDirectVirtual):
(JSC::JSProxy::defineOwnProperty):
(JSC::JSProxy::deleteProperty):
(JSC::JSProxy::deletePropertyByIndex):
(JSC::JSProxy::getPropertyNames):
(JSC::JSProxy::getOwnPropertyNames):
    - Class cretaed from JSGlobalThis, JSDOMWindowShell.
* runtime/JSProxy.h: Copied from Source/JavaScriptCore/runtime/JSGlobalThis.h.
(JSC::JSProxy::create):
(JSC::JSProxy::createStructure):
(JSProxy):
(JSC::JSProxy::target):
(JSC::JSProxy::JSProxy):
    - Class cretaed from JSGlobalThis, JSDOMWindowShell.
* runtime/JSType.h:
    - GlobalThisType -> ProxyType

../WebCore: 

This patch moves window shell functionality up to JSC::JSProxy.

* ForwardingHeaders/runtime/JSGlobalThis.h: Removed.
* ForwardingHeaders/runtime/JSProxy.h: Copied from Source/WebCore/ForwardingHeaders/runtime/JSGlobalThis.h.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::finishCreation):
    - JSGlobalThis -> JSObject
* bindings/js/JSDOMGlobalObject.h:
(JSDOMGlobalObject):
    - JSGlobalThis -> JSObject
* bindings/js/JSDOMWindowBase.cpp:
(WebCore):
    - Hoist toThisObject up into JSC.
* bindings/js/JSDOMWindowBase.h:
(JSDOMWindowBase):
    - Hoist toThisObject up into JSC.
* bindings/js/JSDOMWindowShell.cpp:
(WebCore):
    - JSGlobalThis -> JSProxy
    - moved JSObject callbacks to JSProxy
* bindings/js/JSDOMWindowShell.h:
(JSDOMWindowShell):
    - JSGlobalThis -> JSProxy
    - moved JSObject callbacks to JSProxy
(WebCore::JSDOMWindowShell::window):
    - unwrappedObject() -> target()
(WebCore::JSDOMWindowShell::setWindow):
    - setUnwrappedObject() -> setTarget()
(WebCore::JSDOMWindowShell::createStructure):
    - GlobalThisType -> ProxyType



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129685 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1e26df03
......@@ -201,7 +201,7 @@ SET(JavaScriptCore_SOURCES
runtime/JSGlobalData.cpp
runtime/JSGlobalObject.cpp
runtime/JSGlobalObjectFunctions.cpp
runtime/JSGlobalThis.cpp
runtime/JSProxy.cpp
runtime/JSLock.cpp
runtime/JSNotAnObject.cpp
runtime/JSObject.cpp
......
2012-09-26 Gavin Barraclough <barraclough@apple.com>
Generalize JSGlobalThis as JSProxy
https://bugs.webkit.org/show_bug.cgi?id=97716
Reviewed by Oliver Hunt.
Generalize JSGlobalThis as JSProxy and move proxying functionality up from the window shell into JSProxy.
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Target.pri:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::toThisObject):
- Hoist toThisObject from WebCore.
(JSC):
* runtime/JSGlobalObject.h:
- removed include.
(JSC::JSGlobalObject::finishCreation):
- JSGlobalThis -> JSObject
(JSGlobalObject):
- Hoist toThisObject from WebCore.
* runtime/JSGlobalThis.cpp: Removed.
* runtime/JSGlobalThis.h: Removed.
* runtime/JSObject.cpp:
- removed include.
* runtime/JSObject.h:
(JSObject):
(JSC::JSObject::isProxy):
- isGlobalThis -> isProxy
- GlobalThisType -> ProxyType
* runtime/JSProxy.cpp: Copied from Source/JavaScriptCore/runtime/JSGlobalThis.cpp.
(JSC):
(JSC::JSProxy::visitChildren):
(JSC::JSProxy::setTarget):
(JSC::JSProxy::className):
(JSC::JSProxy::getOwnPropertySlot):
(JSC::JSProxy::getOwnPropertySlotByIndex):
(JSC::JSProxy::getOwnPropertyDescriptor):
(JSC::JSProxy::put):
(JSC::JSProxy::putByIndex):
(JSC::JSProxy::putDirectVirtual):
(JSC::JSProxy::defineOwnProperty):
(JSC::JSProxy::deleteProperty):
(JSC::JSProxy::deletePropertyByIndex):
(JSC::JSProxy::getPropertyNames):
(JSC::JSProxy::getOwnPropertyNames):
- Class cretaed from JSGlobalThis, JSDOMWindowShell.
* runtime/JSProxy.h: Copied from Source/JavaScriptCore/runtime/JSGlobalThis.h.
(JSC::JSProxy::create):
(JSC::JSProxy::createStructure):
(JSProxy):
(JSC::JSProxy::target):
(JSC::JSProxy::JSProxy):
- Class cretaed from JSGlobalThis, JSDOMWindowShell.
* runtime/JSType.h:
- GlobalThisType -> ProxyType
2012-09-26 Michael Saboff <msaboff@apple.com>
Add ability for JSArray::unshiftCount to unshift in middle of an array
......
......@@ -544,8 +544,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp \
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h \
Source/JavaScriptCore/runtime/JSGlobalObject.h \
Source/JavaScriptCore/runtime/JSGlobalThis.cpp \
Source/JavaScriptCore/runtime/JSGlobalThis.h \
Source/JavaScriptCore/runtime/JSProxy.cpp \
Source/JavaScriptCore/runtime/JSProxy.h \
Source/JavaScriptCore/runtime/JSLock.cpp \
Source/JavaScriptCore/runtime/JSLock.h \
Source/JavaScriptCore/runtime/JSNotAnObject.cpp \
......
......@@ -314,7 +314,7 @@ EXPORTS
?setSetter@PropertyDescriptor@JSC@@QAEXVJSValue@2@@Z
?setToCurrentLocalTime@GregorianDateTime@WTF@@QAEXXZ
?setUndefined@PropertyDescriptor@JSC@@QAEXXZ
?setUnwrappedObject@JSGlobalThis@JSC@@IAEXAAVJSGlobalData@2@PAVJSGlobalObject@2@@Z
?setTarget@JSProxy@JSC@@IAEXAAVJSGlobalData@2@PAVJSGlobalObject@2@@Z
?setUpStaticFunctionSlot@JSC@@YA_NPAVExecState@1@PBVHashEntry@1@PAVJSObject@1@VPropertyName@1@AAVPropertySlot@1@@Z
?setWritable@PropertyDescriptor@JSC@@QAEX_N@Z
?setter@PropertyDescriptor@JSC@@QBE?AVJSValue@2@XZ
......@@ -368,7 +368,7 @@ EXPORTS
?unprotect@Heap@JSC@@QAE_NVJSValue@2@@Z
?validate@SlotVisitor@JSC@@CAXPAVJSCell@2@@Z
?visitChildren@JSGlobalObject@JSC@@SAXPAVJSCell@2@AAVSlotVisitor@2@@Z
?visitChildren@JSGlobalThis@JSC@@KAXPAVJSCell@2@AAVSlotVisitor@2@@Z
?visitChildren@JSProxy@JSC@@KAXPAVJSCell@2@AAVSlotVisitor@2@@Z
?visitChildren@JSObject@JSC@@SAXPAVJSCell@2@AAVSlotVisitor@2@@Z
?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
?waitForThreadCompletion@WTF@@YAHI@Z
......
......@@ -874,11 +874,11 @@
>
</File>
<File
RelativePath="..\..\runtime\JSGlobalThis.cpp"
RelativePath="..\..\runtime\JSProxy.cpp"
>
</File>
<File
RelativePath="..\..\runtime\JSGlobalThis.h"
RelativePath="..\..\runtime\JSProxy.h"
>
</File>
<File
......
......@@ -203,7 +203,7 @@ SOURCES += \
runtime/JSGlobalData.cpp \
runtime/JSGlobalObject.cpp \
runtime/JSGlobalObjectFunctions.cpp \
runtime/JSGlobalThis.cpp \
runtime/JSProxy.cpp \
runtime/JSLock.cpp \
runtime/JSNotAnObject.cpp \
runtime/JSObject.cpp \
......
......@@ -502,6 +502,11 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
visitor.append(&thisObject->m_internalFunctionStructure);
}
JSObject* JSGlobalObject::toThisObject(JSCell* cell, ExecState*)
{
return jsCast<JSGlobalObject*>(cell)->globalThis();
}
ExecState* JSGlobalObject::globalExec()
{
return CallFrame::create(m_globalCallFrame + RegisterFile::CallFrameHeaderSize);
......
......@@ -24,7 +24,6 @@
#include "JSArray.h"
#include "JSGlobalData.h"
#include "JSGlobalThis.h"
#include "JSSegmentedVariableObject.h"
#include "JSWeakObjectMapRefInternal.h"
#include "NumberPrototype.h"
......@@ -192,7 +191,7 @@ namespace JSC {
init(this);
}
void finishCreation(JSGlobalData& globalData, JSGlobalThis* thisValue)
void finishCreation(JSGlobalData& globalData, JSObject* thisValue)
{
Base::finishCreation(globalData);
structure()->setGlobalObject(globalData, this);
......@@ -366,6 +365,8 @@ namespace JSC {
};
JS_EXPORT_PRIVATE void addStaticGlobals(GlobalPropertyInfo*, int count);
JS_EXPORT_PRIVATE static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
private:
friend class LLIntOffsetsExtractor;
......
......@@ -32,7 +32,6 @@
#include "IndexingHeaderInlineMethods.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSGlobalThis.h"
#include "Lookup.h"
#include "NativeErrorConstructor.h"
#include "Nodes.h"
......
......@@ -481,7 +481,7 @@ namespace JSC {
bool isNameScopeObject() const;
bool isActivationObject() const;
bool isErrorInstance() const;
bool isGlobalThis() const;
bool isProxy() const;
void seal(JSGlobalData&);
void freeze(JSGlobalData&);
......@@ -792,9 +792,9 @@ inline bool JSObject::isErrorInstance() const
return structure()->typeInfo().type() == ErrorInstanceType;
}
inline bool JSObject::isGlobalThis() const
inline bool JSObject::isProxy() const
{
return structure()->typeInfo().type() == GlobalThisType;
return structure()->typeInfo().type() == ProxyType;
}
inline void JSObject::setButterfly(JSGlobalData& globalData, Butterfly* butterfly, Structure* structure)
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -24,35 +24,107 @@
*/
#include "config.h"
#include "JSGlobalThis.h"
#include "JSProxy.h"
#include "JSGlobalObject.h"
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(JSGlobalThis);
ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSGlobalThis);
ASSERT_CLASS_FITS_IN_CELL(JSProxy);
ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSProxy);
const ClassInfo JSGlobalThis::s_info = { "JSGlobalThis", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSGlobalThis) };
const ClassInfo JSProxy::s_info = { "JSProxy", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSProxy) };
void JSGlobalThis::visitChildren(JSCell* cell, SlotVisitor& visitor)
void JSProxy::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSGlobalThis* thisObject = jsCast<JSGlobalThis*>(cell);
JSProxy* thisObject = jsCast<JSProxy*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_unwrappedObject);
visitor.append(&thisObject->m_target);
}
void JSGlobalThis::setUnwrappedObject(JSGlobalData& globalData, JSGlobalObject* globalObject)
void JSProxy::setTarget(JSGlobalData& globalData, JSGlobalObject* globalObject)
{
ASSERT_ARG(globalObject, globalObject);
m_unwrappedObject.set(globalData, this, globalObject);
m_target.set(globalData, this, globalObject);
setPrototype(globalData, globalObject->prototype());
resetInheritorID(globalData);
}
String JSProxy::className(const JSObject* object)
{
const JSProxy* thisObject = jsCast<const JSProxy*>(object);
return thisObject->target()->methodTable()->className(thisObject->target());
}
bool JSProxy::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
return thisObject->target()->methodTable()->getOwnPropertySlot(thisObject->target(), exec, propertyName, slot);
}
bool JSProxy::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
return thisObject->target()->methodTable()->getOwnPropertySlotByIndex(thisObject->target(), exec, propertyName, slot);
}
bool JSProxy::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSProxy* thisObject = jsCast<JSProxy*>(object);
return thisObject->target()->methodTable()->getOwnPropertyDescriptor(thisObject->target(), exec, propertyName, descriptor);
}
void JSProxy::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
thisObject->target()->methodTable()->put(thisObject->target(), exec, propertyName, value, slot);
}
void JSProxy::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool shouldThrow)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
thisObject->target()->methodTable()->putByIndex(thisObject->target(), exec, propertyName, value, shouldThrow);
}
void JSProxy::putDirectVirtual(JSObject* object, ExecState* exec, PropertyName propertyName, JSValue value, unsigned attributes)
{
JSProxy* thisObject = jsCast<JSProxy*>(object);
thisObject->target()->putDirectVirtual(thisObject->target(), exec, propertyName, value, attributes);
}
bool JSProxy::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
{
JSProxy* thisObject = jsCast<JSProxy*>(object);
return thisObject->target()->methodTable()->defineOwnProperty(thisObject->target(), exec, propertyName, descriptor, shouldThrow);
}
bool JSProxy::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
return thisObject->target()->methodTable()->deleteProperty(thisObject->target(), exec, propertyName);
}
bool JSProxy::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName)
{
JSProxy* thisObject = jsCast<JSProxy*>(cell);
return thisObject->target()->methodTable()->deletePropertyByIndex(thisObject->target(), exec, propertyName);
}
void JSProxy::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSProxy* thisObject = jsCast<JSProxy*>(object);
thisObject->target()->methodTable()->getPropertyNames(thisObject->target(), exec, propertyNames, mode);
}
void JSProxy::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSProxy* thisObject = jsCast<JSProxy*>(object);
thisObject->target()->methodTable()->getOwnPropertyNames(thisObject->target(), exec, propertyNames, mode);
}
} // namespace JSC
......@@ -23,35 +23,35 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JSGlobalThis_h
#define JSGlobalThis_h
#ifndef JSProxy_h
#define JSProxy_h
#include "JSObject.h"
namespace JSC {
class JSGlobalThis : public JSNonFinalObject {
class JSProxy : public JSNonFinalObject {
public:
typedef JSNonFinalObject Base;
static JSGlobalThis* create(JSGlobalData& globalData, Structure* structure)
static JSProxy* create(JSGlobalData& globalData, Structure* structure)
{
JSGlobalThis* globalThis = new (NotNull, allocateCell<JSGlobalThis>(globalData.heap)) JSGlobalThis(globalData, structure);
globalThis->finishCreation(globalData);
return globalThis;
JSProxy* proxy = new (NotNull, allocateCell<JSProxy>(globalData.heap)) JSProxy(globalData, structure);
proxy->finishCreation(globalData);
return proxy;
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
return Structure::create(globalData, 0, prototype, TypeInfo(GlobalThisType, StructureFlags), &s_info);
return Structure::create(globalData, 0, prototype, TypeInfo(ProxyType, StructureFlags), &s_info);
}
static JS_EXPORTDATA const JSC::ClassInfo s_info;
static JS_EXPORTDATA const ClassInfo s_info;
JSGlobalObject* unwrappedObject() const { return m_unwrappedObject.get(); }
JSGlobalObject* target() const { return m_target.get(); }
protected:
JSGlobalThis(JSGlobalData& globalData, Structure* structure)
JSProxy(JSGlobalData& globalData, Structure* structure)
: JSNonFinalObject(globalData, structure)
{
}
......@@ -61,16 +61,29 @@ protected:
Base::finishCreation(globalData);
}
static const unsigned StructureFlags = OverridesVisitChildren | Base::StructureFlags;
static const unsigned StructureFlags = OverridesVisitChildren | OverridesGetOwnPropertySlot | OverridesGetPropertyNames | Base::StructureFlags;
JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&);
JS_EXPORT_PRIVATE void setUnwrappedObject(JSGlobalData&, JSGlobalObject*);
JS_EXPORT_PRIVATE void setTarget(JSGlobalData&, JSGlobalObject*);
JS_EXPORT_PRIVATE static String className(const JSObject*);
JS_EXPORT_PRIVATE static bool getOwnPropertySlot(JSCell*, ExecState*, PropertyName, PropertySlot&);
JS_EXPORT_PRIVATE static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned, PropertySlot&);
JS_EXPORT_PRIVATE static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&);
JS_EXPORT_PRIVATE static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
JS_EXPORT_PRIVATE static void putByIndex(JSCell*, ExecState*, unsigned, JSValue, bool shouldThrow);
JS_EXPORT_PRIVATE static void putDirectVirtual(JSObject*, ExecState*, PropertyName, JSValue, unsigned attributes);
JS_EXPORT_PRIVATE static bool deleteProperty(JSCell*, ExecState*, PropertyName);
JS_EXPORT_PRIVATE static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned);
JS_EXPORT_PRIVATE static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool shouldThrow);
private:
WriteBarrier<JSGlobalObject> m_unwrappedObject;
WriteBarrier<JSGlobalObject> m_target;
};
} // namespace JSC
#endif // JSGlobalThis_h
#endif // JSProxy_h
......@@ -48,7 +48,7 @@ enum JSType {
NameInstanceType,
NumberObjectType,
ErrorInstanceType,
GlobalThisType,
ProxyType,
WithScopeType,
NameScopeObjectType,
......
2012-09-26 Gavin Barraclough <barraclough@apple.com>
Generalize JSGlobalThis as JSProxy
https://bugs.webkit.org/show_bug.cgi?id=97716
Reviewed by Oliver Hunt.
This patch moves window shell functionality up to JSC::JSProxy.
* ForwardingHeaders/runtime/JSGlobalThis.h: Removed.
* ForwardingHeaders/runtime/JSProxy.h: Copied from Source/WebCore/ForwardingHeaders/runtime/JSGlobalThis.h.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::finishCreation):
- JSGlobalThis -> JSObject
* bindings/js/JSDOMGlobalObject.h:
(JSDOMGlobalObject):
- JSGlobalThis -> JSObject
* bindings/js/JSDOMWindowBase.cpp:
(WebCore):
- Hoist toThisObject up into JSC.
* bindings/js/JSDOMWindowBase.h:
(JSDOMWindowBase):
- Hoist toThisObject up into JSC.
* bindings/js/JSDOMWindowShell.cpp:
(WebCore):
- JSGlobalThis -> JSProxy
- moved JSObject callbacks to JSProxy
* bindings/js/JSDOMWindowShell.h:
(JSDOMWindowShell):
- JSGlobalThis -> JSProxy
- moved JSObject callbacks to JSProxy
(WebCore::JSDOMWindowShell::window):
- unwrappedObject() -> target()
(WebCore::JSDOMWindowShell::setWindow):
- setUnwrappedObject() -> setTarget()
(WebCore::JSDOMWindowShell::createStructure):
- GlobalThisType -> ProxyType
2012-09-26 Andreas Kling <kling@webkit.org>
4.95MB below RenderBlock::insertIntoTrackedRendererMaps() on Membuster3.
#ifndef WebCore_FWD_JSGlobalThis_h
#define WebCore_FWD_JSGlobalThis_h
#include <JavaScriptCore/JSGlobalThis.h>
#endif
#ifndef WebCore_FWD_JSProxy_h
#define WebCore_FWD_JSProxy_h
#include <JavaScriptCore/JSProxy.h>
#endif
......@@ -60,7 +60,7 @@ void JSDOMGlobalObject::finishCreation(JSGlobalData& globalData)
ASSERT(inherits(&s_info));
}
void JSDOMGlobalObject::finishCreation(JSGlobalData& globalData, JSGlobalThis* thisValue)
void JSDOMGlobalObject::finishCreation(JSGlobalData& globalData, JSObject* thisValue)
{
Base::finishCreation(globalData, thisValue);
ASSERT(inherits(&s_info));
......
......@@ -29,7 +29,6 @@
#include "PlatformExportMacros.h"
#include <runtime/JSGlobalObject.h>
#include <runtime/JSGlobalThis.h>
namespace WebCore {
......@@ -52,7 +51,7 @@ namespace WebCore {
JSDOMGlobalObject(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<DOMWrapperWorld>, const JSC::GlobalObjectMethodTable* = 0);
static void destroy(JSC::JSCell*);
void finishCreation(JSC::JSGlobalData&);
void finishCreation(JSC::JSGlobalData&, JSC::JSGlobalThis*);
void finishCreation(JSC::JSGlobalData&, JSC::JSObject*);
public:
JSDOMStructureMap& structures() { return m_structures; }
......
......@@ -169,11 +169,6 @@ void JSDOMWindowBase::willRemoveFromWindowShell()
setCurrentEvent(0);
}
JSObject* JSDOMWindowBase::toThisObject(JSCell* cell, ExecState*)
{
return jsCast<JSDOMWindowBase*>(cell)->shell();
}
JSDOMWindowShell* JSDOMWindowBase::shell() const
{
return m_shell;
......
......@@ -66,7 +66,6 @@ namespace WebCore {
static bool javaScriptExperimentsEnabled(const JSC::JSGlobalObject*);
void printErrorMessage(const String&) const;
static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
JSDOMWindowShell* shell() const;
static JSC::JSGlobalData* commonJSGlobalData();
......
......@@ -81,83 +81,6 @@ void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow)
ASSERT(prototype->globalObject() == jsDOMWindow);
}
// ----
// JSObject methods
// ----
String JSDOMWindowShell::className(const JSObject* object)
{
const JSDOMWindowShell* thisObject = jsCast<const JSDOMWindowShell*>(object);
return thisObject->window()->methodTable()->className(thisObject->window());
}
bool JSDOMWindowShell::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
return thisObject->window()->methodTable()->getOwnPropertySlot(thisObject->window(), exec, propertyName, slot);
}
bool JSDOMWindowShell::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
return thisObject->window()->methodTable()->getOwnPropertySlotByIndex(thisObject->window(), exec, propertyName, slot);
}
bool JSDOMWindowShell::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
return thisObject->window()->methodTable()->getOwnPropertyDescriptor(thisObject->window(), exec, propertyName, descriptor);
}
void JSDOMWindowShell::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
thisObject->window()->methodTable()->put(thisObject->window(), exec, propertyName, value, slot);
}
void JSDOMWindowShell::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value, bool shouldThrow)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
thisObject->window()->methodTable()->putByIndex(thisObject->window(), exec, propertyName, value, shouldThrow);
}
void JSDOMWindowShell::putDirectVirtual(JSObject* object, ExecState* exec, PropertyName propertyName, JSValue value, unsigned attributes)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
thisObject->window()->putDirectVirtual(thisObject->window(), exec, propertyName, value, attributes);
}
bool JSDOMWindowShell::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
return thisObject->window()->methodTable()->defineOwnProperty(thisObject->window(), exec, propertyName, descriptor, shouldThrow);
}
bool JSDOMWindowShell::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
return thisObject->window()->methodTable()->deleteProperty(thisObject->window(), exec, propertyName);
}
bool JSDOMWindowShell::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(cell);
return thisObject->window()->methodTable()->deletePropertyByIndex(thisObject->window(), exec, propertyName);
}
void JSDOMWindowShell::getPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
thisObject->window()->methodTable()->getPropertyNames(thisObject->window(), exec, propertyNames, mode);
}
void JSDOMWindowShell::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
thisObject->window()->methodTable()->getOwnPropertyNames(thisObject->window(), exec, propertyNames, mode);
}
// ----
// JSDOMWindow methods
// ----
......
......@@ -30,24 +30,24 @@
#define JSDOMWindowShell_h
#include "JSDOMWindow.h"
#include <runtime/JSGlobalThis.h>
#include <runtime/JSProxy.h>
namespace WebCore {
class DOMWindow;
class Frame;
class JSDOMWindowShell : public JSC::JSGlobalThis {
typedef JSC::JSGlobalThis Base;
class JSDOMWindowShell : public JSC::JSProxy {
typedef JSC::JSProxy Base;
public:
JSDOMWindowShell(PassRefPtr<DOMWindow>, JSC::Structure*, DOMWrapperWorld*);
static void destroy(JSCell*);
JSDOMWindow* window() const { return JSC::jsCast<JSDOMWindow*>(unwrappedObject()); }
JSDOMWindow* window() const { return JSC::jsCast<JSDOMWindow*>(target()); }
void setWindow(JSC::JSGlobalData& globalData, JSDOMWindow* window)
{
ASSERT_ARG(window, window);
setUnwrappedObject(globalData, window);
setTarget(globalData, window);
structure()->setGlobalObject(*JSDOMWindow::commonJSGlobalData(), window);
}
void setWindow(PassRefPtr<DOMWindow>);
......@@ -66,7 +66,7 @@ namespace WebCore {
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::GlobalThisType, StructureFlags), &s_info);
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::ProxyType, StructureFlags), &s_info);
}
DOMWrapperWorld* world() { return m_world.get(); }
......@@ -75,22 +75,6 @@ namespace WebCore {
JSDOMWindowShell(JSC::Structure*, DOMWrapperWorld*);
void finishCreation(JSC::JSGlobalData&, PassRefPtr<DOMWindow>);
private:
static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | Base::StructureFlags;
static String className(const JSC::JSObject*);
static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC