Commit 737a158c authored by barraclough@apple.com's avatar barraclough@apple.com
Browse files

Bug 54894 - Make inheritance structure described by ClassInfo match C++ class hierarchy.

Reviewed by Sam Weinig.

The ClassInfo objects describe an inheritance hierarchy, with each ClassInfo instance
containing a pointer to its parent class. These links should reflect the inheritance
hierarchy of C++ classes below JSObject. For the large part it does, but in some cases
entries in the C++ hierarchy are skipped over. This presently likely doesn't matter,
since intervening C++ classes may not have ClassInfo - but would be a potential bug
were ClassInfo were to be added.

Source/JavaScriptCore: 

* API/JSCallbackConstructor.cpp:
* API/JSCallbackFunction.cpp:
* API/JSCallbackObjectFunctions.h:
* runtime/Arguments.h:
* runtime/ArrayPrototype.cpp:
* runtime/BooleanObject.cpp:
* runtime/DateInstance.cpp:
* runtime/DatePrototype.cpp:
* runtime/ErrorInstance.cpp:
* runtime/InternalFunction.cpp:
* runtime/JSActivation.cpp:
* runtime/JSArray.cpp:
* runtime/JSFunction.cpp:
* runtime/JSONObject.cpp:
* runtime/JSObject.h:
* runtime/JSZombie.h:
* runtime/MathObject.cpp:
* runtime/NativeErrorConstructor.cpp:
* runtime/NumberConstructor.cpp:
* runtime/NumberObject.cpp:
* runtime/RegExpConstructor.cpp:
* runtime/RegExpObject.cpp:
* runtime/StringObject.cpp:
* runtime/StringPrototype.cpp:

Source/WebCore: 

* bindings/js/JSAudioConstructor.cpp:
* bindings/js/JSDOMGlobalObject.cpp:
* bindings/js/JSImageConstructor.cpp:
* bindings/js/JSOptionConstructor.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/objc/objc_runtime.mm:
* bridge/runtime_object.cpp:

Source/WebKit2: 

* WebProcess/Plugins/Netscape/JSNPObject.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a3f96aa8
......@@ -43,6 +43,7 @@ JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNu
, m_class(jsClass)
, m_callback(callback)
{
ASSERT(inherits(&s_info));
if (m_class)
JSClassRetain(jsClass);
}
......
......@@ -46,6 +46,7 @@ JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalOb
: InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
, m_callback(callback)
{
ASSERT(inherits(&s_info));
}
EncodedJSValue JSCallbackFunction::call(ExecState* exec)
......
......@@ -54,6 +54,7 @@ JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* global
: Base(globalObject, structure)
, m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass)))
{
ASSERT(Base::inherits(&s_info));
init(exec);
}
......@@ -64,6 +65,7 @@ JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, NonNullPassRefPtr<S
: Base(structure)
, m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass)))
{
ASSERT(Base::inherits(&s_info));
ASSERT(Base::isGlobalObject());
init(static_cast<JSGlobalObject*>(this)->globalExec());
}
......
2011-02-21 Gavin Barraclough <barraclough@apple.com>
Reviewed by Sam Weinig.
Bug 54894 - Make inheritance structure described by ClassInfo match C++ class hierarchy.
The ClassInfo objects describe an inheritance hierarchy, with each ClassInfo instance
containing a pointer to its parent class. These links should reflect the inheritance
hierarchy of C++ classes below JSObject. For the large part it does, but in some cases
entries in the C++ hierarchy are skipped over. This presently likely doesn't matter,
since intervening C++ classes may not have ClassInfo - but would be a potential bug
were ClassInfo were to be added.
* API/JSCallbackConstructor.cpp:
* API/JSCallbackFunction.cpp:
* API/JSCallbackObjectFunctions.h:
* runtime/Arguments.h:
* runtime/ArrayPrototype.cpp:
* runtime/BooleanObject.cpp:
* runtime/DateInstance.cpp:
* runtime/DatePrototype.cpp:
* runtime/ErrorInstance.cpp:
* runtime/InternalFunction.cpp:
* runtime/JSActivation.cpp:
* runtime/JSArray.cpp:
* runtime/JSFunction.cpp:
* runtime/JSONObject.cpp:
* runtime/JSObject.h:
* runtime/JSZombie.h:
* runtime/MathObject.cpp:
* runtime/NativeErrorConstructor.cpp:
* runtime/NumberConstructor.cpp:
* runtime/NumberObject.cpp:
* runtime/RegExpConstructor.cpp:
* runtime/RegExpObject.cpp:
* runtime/StringObject.cpp:
* runtime/StringPrototype.cpp:
2011-02-21 Adam Roben <aroben@apple.com>
Export JSObject::s_info from JavaScriptCore.dll
......
......@@ -145,6 +145,8 @@ namespace JSC {
: JSNonFinalObject(callFrame->lexicalGlobalObject()->argumentsStructure())
, d(adoptPtr(new ArgumentsData))
{
ASSERT(inherits(&s_info));
JSFunction* callee;
ptrdiff_t firstParameterIndex;
Register* argv;
......@@ -185,6 +187,7 @@ namespace JSC {
: JSNonFinalObject(callFrame->lexicalGlobalObject()->argumentsStructure())
, d(adoptPtr(new ArgumentsData))
{
ASSERT(inherits(&s_info));
ASSERT(!asFunction(callFrame->callee())->jsExecutable()->parameterCount());
unsigned numArguments = callFrame->argumentCount();
......
......@@ -117,6 +117,7 @@ const ClassInfo ArrayPrototype::s_info = {"Array", &JSArray::s_info, 0, ExecStat
ArrayPrototype::ArrayPrototype(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: JSArray(structure)
{
ASSERT(inherits(&s_info));
putAnonymousValue(globalObject->globalData(), 0, globalObject);
}
......
......@@ -30,6 +30,7 @@ const ClassInfo BooleanObject::s_info = { "Boolean", &JSWrapperObject::s_info, 0
BooleanObject::BooleanObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(globalData, structure)
{
ASSERT(inherits(&s_info));
}
} // namespace JSC
......@@ -37,18 +37,21 @@ const ClassInfo DateInstance::s_info = {"Date", &JSWrapperObject::s_info, 0, 0};
DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(exec->globalData(), structure)
{
ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNaN());
}
DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure, double time)
: JSWrapperObject(exec->globalData(), structure)
{
ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNumber(timeClip(time)));
}
DateInstance::DateInstance(ExecState* exec, double time)
: JSWrapperObject(exec->globalData(), exec->lexicalGlobalObject()->dateStructure())
{
ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNumber(timeClip(time)));
}
......
......@@ -432,6 +432,8 @@ const ClassInfo DatePrototype::s_info = {"Date", &DateInstance::s_info, 0, ExecS
DatePrototype::DatePrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: DateInstance(exec, structure)
{
ASSERT(inherits(&s_info));
// The constructor will be added later, after DateConstructor has been built.
putAnonymousValue(exec->globalData(), 0, globalObject);
}
......
......@@ -29,6 +29,7 @@ ErrorInstance::ErrorInstance(JSGlobalData* globalData, NonNullPassRefPtr<Structu
: JSNonFinalObject(structure)
, m_appendSourceToMessage(false)
{
ASSERT(inherits(&s_info));
putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, ""));
}
......@@ -36,6 +37,7 @@ ErrorInstance::ErrorInstance(JSGlobalData* globalData, NonNullPassRefPtr<Structu
: JSNonFinalObject(structure)
, m_appendSourceToMessage(false)
{
ASSERT(inherits(&s_info));
putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, message));
}
......
......@@ -39,11 +39,13 @@ const ClassInfo InternalFunction::s_info = { "Function", &JSObjectWithGlobalObje
InternalFunction::InternalFunction(NonNullPassRefPtr<Structure> structure)
: JSObjectWithGlobalObject(structure)
{
ASSERT(inherits(&s_info));
}
InternalFunction::InternalFunction(JSGlobalData* globalData, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const Identifier& name)
: JSObjectWithGlobalObject(globalObject, structure)
{
ASSERT(inherits(&s_info));
putDirect(*globalData, globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
......
......@@ -42,6 +42,7 @@ const ClassInfo JSActivation::s_info = { "JSActivation", &Base::s_info, 0, 0 };
JSActivation::JSActivation(CallFrame* callFrame, NonNullPassRefPtr<FunctionExecutable> functionExecutable)
: Base(callFrame->globalData().activationStructure, new JSActivationData(functionExecutable, callFrame->registers()))
{
ASSERT(inherits(&s_info));
}
JSActivation::~JSActivation()
......
......@@ -129,6 +129,8 @@ inline void JSArray::checkConsistency(ConsistencyCheckType)
JSArray::JSArray(VPtrStealingHackType)
: JSNonFinalObject(createStructure(jsNull()))
{
ASSERT(inherits(&s_info));
unsigned initialCapacity = 0;
m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
......@@ -146,6 +148,8 @@ JSArray::JSArray(VPtrStealingHackType)
JSArray::JSArray(NonNullPassRefPtr<Structure> structure)
: JSNonFinalObject(structure)
{
ASSERT(inherits(&s_info));
unsigned initialCapacity = 0;
m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity)));
......@@ -161,6 +165,8 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure)
JSArray::JSArray(NonNullPassRefPtr<Structure> structure, unsigned initialLength, ArrayCreationMode creationMode)
: JSNonFinalObject(structure)
{
ASSERT(inherits(&s_info));
unsigned initialCapacity;
if (creationMode == CreateCompact)
initialCapacity = initialLength;
......@@ -201,6 +207,8 @@ JSArray::JSArray(NonNullPassRefPtr<Structure> structure, unsigned initialLength,
JSArray::JSArray(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure, const ArgList& list)
: JSNonFinalObject(structure)
{
ASSERT(inherits(&s_info));
unsigned initialCapacity = list.size();
unsigned initialStorage;
......
......@@ -61,6 +61,7 @@ JSFunction::JSFunction(NonNullPassRefPtr<Structure> structure)
, m_executable(adoptRef(new VPtrHackExecutable()))
, m_scopeChain(NoScopeChain())
{
ASSERT(inherits(&s_info));
}
JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk)
......@@ -68,6 +69,7 @@ JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPas
, m_executable(thunk)
, m_scopeChain(globalObject->globalScopeChain())
{
ASSERT(inherits(&s_info));
putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum);
}
......@@ -77,6 +79,7 @@ JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPas
, m_executable(exec->globalData().getHostFunction(func))
, m_scopeChain(globalObject->globalScopeChain())
{
ASSERT(inherits(&s_info));
putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum);
}
......@@ -86,6 +89,7 @@ JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<FunctionExecutable> ex
, m_executable(executable)
, m_scopeChain(scopeChainNode)
{
ASSERT(inherits(&s_info));
const Identifier& name = static_cast<FunctionExecutable*>(m_executable.get())->name();
putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
......
......@@ -54,6 +54,7 @@ namespace JSC {
JSONObject::JSONObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: JSObjectWithGlobalObject(globalObject, structure)
{
ASSERT(inherits(&s_info));
}
// PropertyNameForFunctionCall objects must be on the stack, since the JSValue that they create is not marked.
......
......@@ -388,6 +388,7 @@ inline JSObject::JSObject(NonNullPassRefPtr<Structure> structure, PropertyStorag
: JSCell(structure.releaseRef()) // ~JSObject balances this ref()
, m_propertyStorage(inlineStorage)
{
ASSERT(inherits(&s_info));
ASSERT(m_structure->propertyStorageCapacity() < baseExternalStorageCapacity);
ASSERT(m_structure->isEmpty());
ASSERT(prototype().isNull() || Heap::heap(this) == Heap::heap(prototype()));
......
......@@ -37,7 +37,9 @@ public:
: JSCell(structure)
, m_oldInfo(oldInfo)
{
ASSERT(inherits(&s_info));
}
virtual bool isZombie() const { return true; }
static Structure* leakedZombieStructure();
......
......@@ -89,6 +89,8 @@ const ClassInfo MathObject::s_info = { "Math", &JSObjectWithGlobalObject::s_info
MathObject::MathObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: JSObjectWithGlobalObject(globalObject, structure)
{
ASSERT(inherits(&s_info));
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "E"), jsNumber(exp(1.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "LN2"), jsNumber(log(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->globalData(), Identifier(exec, "LN10"), jsNumber(log(10.0)), DontDelete | DontEnum | ReadOnly);
......
......@@ -35,6 +35,8 @@ const ClassInfo NativeErrorConstructor::s_info = { "Function", &InternalFunction
NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<Structure> prototypeStructure, const UString& nameAndMessage)
: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, nameAndMessage))
{
ASSERT(inherits(&s_info));
NativeErrorPrototype* prototype = new (exec) NativeErrorPrototype(exec, globalObject, prototypeStructure, nameAndMessage, this);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
......
......@@ -57,6 +57,8 @@ const ClassInfo NumberConstructor::s_info = { "Function", &InternalFunction::s_i
NumberConstructor::NumberConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NumberPrototype* numberPrototype)
: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, numberPrototype->s_info.className))
{
ASSERT(inherits(&s_info));
// Number.Prototype
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
......
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