Commit ebc08a81 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

De-virtualize isGlobalObject, isVariableObject, isActivationObject, and isErrorInstance in JSObject

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

* API/JSCallbackObject.cpp: Added two specializations for createStructure that use different JSTypes in their
TypeInfo.  Had to also create a specialization for JSNonFinalObject, even JSGlobalObject was the only that 
needed it because Windows wouldn't build without it.
(JSC::::createStructure):
* API/JSCallbackObject.h:
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/ErrorInstance.h: Removed virtual function and changed JSType provided to TypeInfo in createStructure. 
(JSC::ErrorInstance::createStructure):
* runtime/ErrorPrototype.h: Ditto
(JSC::ErrorPrototype::createStructure):
* runtime/JSActivation.h: Ditto
(JSC::JSActivation::createStructure):
* runtime/JSGlobalObject.h: Ditto
(JSC::JSGlobalObject::createStructure):
* runtime/JSObject.h: De-virtualized functions.  They now check the JSType of the object for the corresponding type.
(JSC::JSObject::isGlobalObject):
(JSC::JSObject::isVariableObject):
(JSC::JSObject::isActivationObject):
(JSC::JSObject::isErrorInstance):
* runtime/JSType.h: Added new types for GlobalObject, VariableObject, ActivationObject, and ErrorInstance.
* runtime/JSVariableObject.cpp: Removed virtual function.
* runtime/JSVariableObject.h: Changed JSType provided to TypeInfo in createStructure.
(JSC::JSVariableObject::createStructure):

Source/WebCore: 

No new tests.

* bindings/js/JSDOMGlobalObject.h: Changed JSType provided to TypeInfo in createStructure since this 
class inherits from JSGlobalObject. 
(WebCore::JSDOMGlobalObject::createStructure):
* bindings/js/JSDOMWindowBase.h: Ditto
(WebCore::JSDOMWindowBase::createStructure):
* bindings/js/JSWorkerContextBase.h: Ditto
(WebCore::JSWorkerContextBase::createStructure):
* bindings/scripts/CodeGeneratorJS.pm: Added extra check to make sure subclasses of JSGlobalObject,
namely JSDOMWindow and JSWorkerContext, get their special JSType in their createStructure function.
(GenerateHeader):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@98747 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c57529ee
......@@ -39,6 +39,18 @@ ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
template <> const ClassInfo JSCallbackObject<JSNonFinalObject>::s_info = { "CallbackObject", &JSNonFinalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSCallbackObject) };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::s_info = { "CallbackGlobalObject", &JSGlobalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSCallbackObject) };
template <>
Structure* JSCallbackObject<JSNonFinalObject>::createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
{
return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info);
}
template <>
Structure* JSCallbackObject<JSGlobalObject>::createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
{
return Structure::create(globalData, globalObject, proto, TypeInfo(GlobalObjectType, StructureFlags), &s_info);
}
void JSCallbackObjectData::finalize(Handle<Unknown> handle, void* context)
{
JSClassRef jsClass = static_cast<JSClassRef>(context);
......
......@@ -152,10 +152,7 @@ public:
JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
{
return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info);
}
static Structure* createStructure(JSGlobalData&, JSGlobalObject*, JSValue);
JSValue getPrivateProperty(const Identifier& propertyName) const
{
......
2011-10-28 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize isGlobalObject, isVariableObject, isActivationObject, and isErrorInstance in JSObject
https://bugs.webkit.org/show_bug.cgi?id=70968
Reviewed by Geoffrey Garen.
* API/JSCallbackObject.cpp: Added two specializations for createStructure that use different JSTypes in their
TypeInfo. Had to also create a specialization for JSNonFinalObject, even JSGlobalObject was the only that
needed it because Windows wouldn't build without it.
(JSC::::createStructure):
* API/JSCallbackObject.h:
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/ErrorInstance.h: Removed virtual function and changed JSType provided to TypeInfo in createStructure.
(JSC::ErrorInstance::createStructure):
* runtime/ErrorPrototype.h: Ditto
(JSC::ErrorPrototype::createStructure):
* runtime/JSActivation.h: Ditto
(JSC::JSActivation::createStructure):
* runtime/JSGlobalObject.h: Ditto
(JSC::JSGlobalObject::createStructure):
* runtime/JSObject.h: De-virtualized functions. They now check the JSType of the object for the corresponding type.
(JSC::JSObject::isGlobalObject):
(JSC::JSObject::isVariableObject):
(JSC::JSObject::isActivationObject):
(JSC::JSObject::isErrorInstance):
* runtime/JSType.h: Added new types for GlobalObject, VariableObject, ActivationObject, and ErrorInstance.
* runtime/JSVariableObject.cpp: Removed virtual function.
* runtime/JSVariableObject.h: Changed JSType provided to TypeInfo in createStructure.
(JSC::JSVariableObject::createStructure):
2011-10-28 Pavel Feldman <pfeldman@google.com>
Reset line numbers for scripts generated with document.write.
......@@ -533,7 +533,6 @@ __ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_10JSFunctionE
__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
__ZNK3JSC12PropertySlot14functionGetterEPNS_9ExecStateE
__ZNK3JSC14JSGlobalObject14isDynamicScopeERb
__ZNK3JSC16JSVariableObject16isVariableObjectEv
__ZNK3JSC17DebuggerCallFrame10thisObjectEv
__ZNK3JSC17DebuggerCallFrame12functionNameEv
__ZNK3JSC17DebuggerCallFrame22calculatedFunctionNameEv
......
......@@ -233,7 +233,6 @@ EXPORTS
?isTerminatedExecutionException@JSC@@YA_NVJSValue@1@@Z
?isValidAllocation@Heap@JSC@@AAE_NI@Z
?isValidCallee@JSValue@JSC@@QAE_NXZ
?isVariableObject@JSVariableObject@JSC@@UBE_NXZ
?jsOwnedString@JSC@@YAPAVJSString@1@PAVJSGlobalData@1@ABVUString@1@@Z
?jsString@JSC@@YAPAVJSString@1@PAVJSGlobalData@1@ABVUString@1@@Z
?length@CString@WTF@@QBEIXZ
......
......@@ -33,7 +33,7 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info);
}
static ErrorInstance* create(JSGlobalData& globalData, Structure* structure, const UString& message)
......@@ -56,8 +56,6 @@ namespace JSC {
void setAppendSourceToMessage() { m_appendSourceToMessage = true; }
void clearAppendSourceToMessage() { m_appendSourceToMessage = false; }
virtual bool isErrorInstance() const { return true; }
protected:
explicit ErrorInstance(JSGlobalData&, Structure*);
......
......@@ -42,7 +42,7 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, globalObject, prototype, TypeInfo(ErrorInstanceType, StructureFlags), &s_info);
}
protected:
......
......@@ -59,8 +59,6 @@ namespace JSC {
virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
virtual bool isActivationObject() const { return true; }
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode);
......@@ -75,7 +73,7 @@ namespace JSC {
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info); }
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(ActivationObjectType, StructureFlags), &s_info); }
protected:
void finishCreation(CallFrame*);
......
......@@ -267,8 +267,6 @@ namespace JSC {
ScopeChainNode* globalScopeChain() { return m_globalScopeChain.get(); }
virtual bool isGlobalObject() const { return true; }
ExecState* globalExec();
virtual bool shouldInterruptScript() const { return true; }
......@@ -288,7 +286,7 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
return Structure::create(globalData, 0, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, 0, prototype, TypeInfo(GlobalObjectType, StructureFlags), &s_info);
}
void registerWeakMap(OpaqueJSWeakObjectMap* map)
......
......@@ -191,10 +191,10 @@ namespace JSC {
virtual JSValue lookupSetter(ExecState*, const Identifier& propertyName);
virtual bool defineOwnProperty(ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
virtual bool isGlobalObject() const { return false; }
virtual bool isVariableObject() const { return false; }
virtual bool isActivationObject() const { return false; }
virtual bool isErrorInstance() const { return false; }
bool isGlobalObject() const;
bool isVariableObject() const;
bool isActivationObject() const;
bool isErrorInstance() const;
void seal(JSGlobalData&);
void freeze(JSGlobalData&);
......@@ -404,6 +404,26 @@ inline size_t JSObject::offsetOfInheritorID()
return OBJECT_OFFSETOF(JSObject, m_inheritorID);
}
inline bool JSObject::isGlobalObject() const
{
return structure()->typeInfo().type() == GlobalObjectType;
}
inline bool JSObject::isVariableObject() const
{
return structure()->typeInfo().type() >= VariableObjectType;
}
inline bool JSObject::isActivationObject() const
{
return structure()->typeInfo().type() == ActivationObjectType;
}
inline bool JSObject::isErrorInstance() const
{
return structure()->typeInfo().type() == ErrorInstanceType;
}
inline JSObject* constructEmptyObject(ExecState* exec, Structure* structure)
{
return JSFinalObject::create(exec, structure);
......
......@@ -42,6 +42,12 @@ enum JSType {
FinalObjectType = 11,
JSFunctionType = 12,
NumberObjectType = 13,
ErrorInstanceType = 14,
// VariableObjectType must be less than all of the types of its subclasses and only its subclasses.
VariableObjectType = 15,
GlobalObjectType = 16,
ActivationObjectType = 17,
};
} // namespace JSC
......
......@@ -54,11 +54,6 @@ void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& p
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
}
bool JSVariableObject::isVariableObject() const
{
return true;
}
bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertyDescriptor& descriptor)
{
SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
......
......@@ -53,7 +53,6 @@ namespace JSC {
static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
virtual bool isVariableObject() const;
virtual bool isDynamicScope(bool& requiresDynamicChecks) const = 0;
WriteBarrier<Unknown>& registerAt(int index) const { return m_registers[index]; }
......@@ -63,7 +62,7 @@ namespace JSC {
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
return Structure::create(globalData, globalObject, prototype, TypeInfo(VariableObjectType, StructureFlags), &s_info);
}
protected:
......
2011-10-28 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize isGlobalObject, isVariableObject, isActivationObject, and isErrorInstance in JSObject
https://bugs.webkit.org/show_bug.cgi?id=70968
Reviewed by Geoffrey Garen.
No new tests.
* bindings/js/JSDOMGlobalObject.h: Changed JSType provided to TypeInfo in createStructure since this
class inherits from JSGlobalObject.
(WebCore::JSDOMGlobalObject::createStructure):
* bindings/js/JSDOMWindowBase.h: Ditto
(WebCore::JSDOMWindowBase::createStructure):
* bindings/js/JSWorkerContextBase.h: Ditto
(WebCore::JSWorkerContextBase::createStructure):
* bindings/scripts/CodeGeneratorJS.pm: Added extra check to make sure subclasses of JSGlobalObject,
namely JSDOMWindow and JSWorkerContext, get their special JSType in their createStructure function.
(GenerateHeader):
2011-10-28 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r98736.
......
......@@ -75,7 +75,7 @@ namespace WebCore {
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);
}
protected:
......
......@@ -53,7 +53,7 @@ namespace WebCore {
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
{
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);
}
virtual bool supportsProfiling() const;
......
......@@ -50,7 +50,7 @@ namespace WebCore {
static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);
}
protected:
......
......@@ -808,11 +808,14 @@ sub GenerateHeader
if ($interfaceName eq "DOMWindow") {
$structureFlags{"JSC::ImplementsHasInstance"} = 1;
}
push(@headerContent,
" static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n" .
" {\n" .
" return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n" .
" }\n\n");
push(@headerContent, " static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)\n");
push(@headerContent, " {\n");
if ($interfaceName eq "DOMWindow" || $dataNode->extendedAttributes->{"IsWorkerContext"}) {
push(@headerContent, " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), &s_info);\n");
} else {
push(@headerContent, " return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);\n");
}
push(@headerContent, " }\n\n");
# Custom pushEventHandlerScope function
push(@headerContent, " virtual JSC::ScopeChainNode* pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChainNode*) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment