Commit 03752250 authored by ggaren@apple.com's avatar ggaren@apple.com

2011-03-14 Geoffrey Garen <ggaren@apple.com>

        Reviewed by Oliver Hunt.

        Made JSWrapperObject and subclasses moving-GC-safe
        https://bugs.webkit.org/show_bug.cgi?id=56346
        
        SunSpider reports no change.

        * runtime/BooleanObject.cpp:
        (JSC::BooleanObject::BooleanObject):
        * runtime/DateInstance.cpp:
        (JSC::DateInstance::DateInstance): No more need for JSGlobalData, since
        we don't initialize the wrapped value in our constructor.

        * runtime/DateInstance.h: Don't set the OverridesMarkChildren flag because
        we do not in fact override markChildren.

        * runtime/DatePrototype.h: Declare an anonymous slot, since wrapper object
        no longer does so for us. Also added an ASSERT to catch a latent bug,
        where DatePrototype stomped on its base class's anonymous slot. Hard-coded
        anonymous slots are a plague on our code. This doesn't cause any problems
        in our existing code since the base class never reads the anonymous slot
        it declares, but it caused crashes when I tried to start using the slot
        in an initial version of this patch.

        * runtime/JSWrapperObject.h:
        (JSC::JSWrapperObject::JSWrapperObject):
        (JSC::JSWrapperObject::internalValue):
        (JSC::JSWrapperObject::setInternalValue): Resolved a problem where
        our internal value was stored in two places: an anonymous slot, and a
        data member which was not always visited during GC. Now, we only use the
        data member, and we always visit it. (Instead of relying on certain
        subclasses to set the OverridesMarkChildren bit, we set it ourselves.)

        * runtime/NumberObject.cpp:
        (JSC::NumberObject::NumberObject): No more need for JSGlobalData, since
        we don't initialize the wrapped value in our constructor.

        * runtime/NumberObject.h: Removed meaningless declaration.

        * runtime/StringObject.cpp:
        (JSC::StringObject::StringObject): No more need for JSGlobalData, since
        we don't initialize the wrapped value in our constructor.

        * runtime/StringObject.h: Don't set the OverridesMarkChildren flag because
        we do not in fact override markChildren.

        * runtime/StringPrototype.h: Declare an anonymous slot, since wrapper object
        no longer does so for us. Also added an ASSERT to catch a latent bug,
        where DatePrototype stomped on its base class's anonymous slot. Hard-coded
        anonymous slots are a plague on our code.


git-svn-id: svn://svn.chromium.org/blink/trunk@81086 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9aa7a0d0
2011-03-14 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
Made JSWrapperObject and subclasses moving-GC-safe
https://bugs.webkit.org/show_bug.cgi?id=56346
SunSpider reports no change.
* runtime/BooleanObject.cpp:
(JSC::BooleanObject::BooleanObject):
* runtime/DateInstance.cpp:
(JSC::DateInstance::DateInstance): No more need for JSGlobalData, since
we don't initialize the wrapped value in our constructor.
* runtime/DateInstance.h: Don't set the OverridesMarkChildren flag because
we do not in fact override markChildren.
* runtime/DatePrototype.h: Declare an anonymous slot, since wrapper object
no longer does so for us. Also added an ASSERT to catch a latent bug,
where DatePrototype stomped on its base class's anonymous slot. Hard-coded
anonymous slots are a plague on our code. This doesn't cause any problems
in our existing code since the base class never reads the anonymous slot
it declares, but it caused crashes when I tried to start using the slot
in an initial version of this patch.
* runtime/JSWrapperObject.h:
(JSC::JSWrapperObject::JSWrapperObject):
(JSC::JSWrapperObject::internalValue):
(JSC::JSWrapperObject::setInternalValue): Resolved a problem where
our internal value was stored in two places: an anonymous slot, and a
data member which was not always visited during GC. Now, we only use the
data member, and we always visit it. (Instead of relying on certain
subclasses to set the OverridesMarkChildren bit, we set it ourselves.)
* runtime/NumberObject.cpp:
(JSC::NumberObject::NumberObject): No more need for JSGlobalData, since
we don't initialize the wrapped value in our constructor.
* runtime/NumberObject.h: Removed meaningless declaration.
* runtime/StringObject.cpp:
(JSC::StringObject::StringObject): No more need for JSGlobalData, since
we don't initialize the wrapped value in our constructor.
* runtime/StringObject.h: Don't set the OverridesMarkChildren flag because
we do not in fact override markChildren.
* runtime/StringPrototype.h: Declare an anonymous slot, since wrapper object
no longer does so for us. Also added an ASSERT to catch a latent bug,
where DatePrototype stomped on its base class's anonymous slot. Hard-coded
anonymous slots are a plague on our code.
2011-03-14 Michael Saboff <msaboff@apple.com> 2011-03-14 Michael Saboff <msaboff@apple.com>
Reviewed by Gavin Barraclough. Reviewed by Gavin Barraclough.
......
...@@ -27,8 +27,8 @@ ASSERT_CLASS_FITS_IN_CELL(BooleanObject); ...@@ -27,8 +27,8 @@ ASSERT_CLASS_FITS_IN_CELL(BooleanObject);
const ClassInfo BooleanObject::s_info = { "Boolean", &JSWrapperObject::s_info, 0, 0 }; const ClassInfo BooleanObject::s_info = { "Boolean", &JSWrapperObject::s_info, 0, 0 };
BooleanObject::BooleanObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure) BooleanObject::BooleanObject(JSGlobalData&, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(globalData, structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
} }
......
...@@ -35,21 +35,21 @@ namespace JSC { ...@@ -35,21 +35,21 @@ namespace JSC {
const ClassInfo DateInstance::s_info = {"Date", &JSWrapperObject::s_info, 0, 0}; const ClassInfo DateInstance::s_info = {"Date", &JSWrapperObject::s_info, 0, 0};
DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure) DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(exec->globalData(), structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNaN()); setInternalValue(exec->globalData(), jsNaN());
} }
DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure, double time) DateInstance::DateInstance(ExecState* exec, NonNullPassRefPtr<Structure> structure, double time)
: JSWrapperObject(exec->globalData(), structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNumber(timeClip(time))); setInternalValue(exec->globalData(), jsNumber(timeClip(time)));
} }
DateInstance::DateInstance(ExecState* exec, double time) DateInstance::DateInstance(ExecState* exec, double time)
: JSWrapperObject(exec->globalData(), exec->lexicalGlobalObject()->dateStructure()) : JSWrapperObject(exec->lexicalGlobalObject()->dateStructure())
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsNumber(timeClip(time))); setInternalValue(exec->globalData(), jsNumber(timeClip(time)));
......
...@@ -58,9 +58,6 @@ namespace JSC { ...@@ -58,9 +58,6 @@ namespace JSC {
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
} }
protected:
static const unsigned StructureFlags = OverridesMarkChildren | JSWrapperObject::StructureFlags;
private: private:
const GregorianDateTime* calculateGregorianDateTime(ExecState*) const; const GregorianDateTime* calculateGregorianDateTime(ExecState*) const;
const GregorianDateTime* calculateGregorianDateTimeUTC(ExecState*) const; const GregorianDateTime* calculateGregorianDateTimeUTC(ExecState*) const;
......
...@@ -44,6 +44,8 @@ namespace JSC { ...@@ -44,6 +44,8 @@ namespace JSC {
protected: protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | DateInstance::StructureFlags; static const unsigned StructureFlags = OverridesGetOwnPropertySlot | DateInstance::StructureFlags;
COMPILE_ASSERT(!DateInstance::AnonymousSlotCount, DatePrototype_stomps_on_your_anonymous_slot);
static const unsigned AnonymousSlotCount = 1;
}; };
} // namespace JSC } // namespace JSC
......
...@@ -30,10 +30,10 @@ namespace JSC { ...@@ -30,10 +30,10 @@ namespace JSC {
// Number, Boolean and Date which are wrappers for primitive types. // Number, Boolean and Date which are wrappers for primitive types.
class JSWrapperObject : public JSNonFinalObject { class JSWrapperObject : public JSNonFinalObject {
protected: protected:
explicit JSWrapperObject(JSGlobalData&, NonNullPassRefPtr<Structure>); explicit JSWrapperObject(NonNullPassRefPtr<Structure>);
public: public:
JSValue internalValue() const { return m_internalValue.get(); } JSValue internalValue() const;
void setInternalValue(JSGlobalData&, JSValue); void setInternalValue(JSGlobalData&, JSValue);
static PassRefPtr<Structure> createStructure(JSValue prototype) static PassRefPtr<Structure> createStructure(JSValue prototype)
...@@ -42,7 +42,7 @@ namespace JSC { ...@@ -42,7 +42,7 @@ namespace JSC {
} }
protected: protected:
static const unsigned AnonymousSlotCount = 1 + JSObject::AnonymousSlotCount; static const unsigned StructureFlags = OverridesMarkChildren | JSNonFinalObject::StructureFlags;
private: private:
virtual void markChildren(MarkStack&); virtual void markChildren(MarkStack&);
...@@ -50,10 +50,14 @@ namespace JSC { ...@@ -50,10 +50,14 @@ namespace JSC {
WriteBarrier<Unknown> m_internalValue; WriteBarrier<Unknown> m_internalValue;
}; };
inline JSWrapperObject::JSWrapperObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure) inline JSWrapperObject::JSWrapperObject(NonNullPassRefPtr<Structure> structure)
: JSNonFinalObject(structure) : JSNonFinalObject(structure)
{ {
putAnonymousValue(globalData, 0, jsNull()); }
inline JSValue JSWrapperObject::internalValue() const
{
return m_internalValue.get();
} }
inline void JSWrapperObject::setInternalValue(JSGlobalData& globalData, JSValue value) inline void JSWrapperObject::setInternalValue(JSGlobalData& globalData, JSValue value)
...@@ -61,7 +65,6 @@ namespace JSC { ...@@ -61,7 +65,6 @@ namespace JSC {
ASSERT(value); ASSERT(value);
ASSERT(!value.isObject()); ASSERT(!value.isObject());
m_internalValue.set(globalData, this, value); m_internalValue.set(globalData, this, value);
putAnonymousValue(globalData, 0, value);
} }
} // namespace JSC } // namespace JSC
......
...@@ -31,8 +31,8 @@ ASSERT_CLASS_FITS_IN_CELL(NumberObject); ...@@ -31,8 +31,8 @@ ASSERT_CLASS_FITS_IN_CELL(NumberObject);
const ClassInfo NumberObject::s_info = { "Number", &JSWrapperObject::s_info, 0, 0 }; const ClassInfo NumberObject::s_info = { "Number", &JSWrapperObject::s_info, 0, 0 };
NumberObject::NumberObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure) NumberObject::NumberObject(JSGlobalData&, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(globalData, structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
} }
......
...@@ -36,9 +36,6 @@ namespace JSC { ...@@ -36,9 +36,6 @@ namespace JSC {
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
} }
protected:
static const unsigned StructureFlags = JSWrapperObject::StructureFlags;
private: private:
virtual JSValue getJSNumber(); virtual JSValue getJSNumber();
}; };
......
...@@ -30,21 +30,21 @@ ASSERT_CLASS_FITS_IN_CELL(StringObject); ...@@ -30,21 +30,21 @@ ASSERT_CLASS_FITS_IN_CELL(StringObject);
const ClassInfo StringObject::s_info = { "String", &JSWrapperObject::s_info, 0, 0 }; const ClassInfo StringObject::s_info = { "String", &JSWrapperObject::s_info, 0, 0 };
StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure) StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure)
: JSWrapperObject(exec->globalData(), structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsEmptyString(exec)); setInternalValue(exec->globalData(), jsEmptyString(exec));
} }
StringObject::StringObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure, JSString* string) StringObject::StringObject(JSGlobalData& globalData, NonNullPassRefPtr<Structure> structure, JSString* string)
: JSWrapperObject(globalData, structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(globalData, string); setInternalValue(globalData, string);
} }
StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, const UString& string) StringObject::StringObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, const UString& string)
: JSWrapperObject(exec->globalData(), structure) : JSWrapperObject(structure)
{ {
ASSERT(inherits(&s_info)); ASSERT(inherits(&s_info));
setInternalValue(exec->globalData(), jsString(exec, string)); setInternalValue(exec->globalData(), jsString(exec, string));
......
...@@ -51,9 +51,9 @@ namespace JSC { ...@@ -51,9 +51,9 @@ namespace JSC {
} }
protected: protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames | JSWrapperObject::StructureFlags; static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSWrapperObject::StructureFlags;
StringObject(JSGlobalData&, NonNullPassRefPtr<Structure>, JSString*); StringObject(JSGlobalData&, NonNullPassRefPtr<Structure>, JSString*);
}; };
StringObject* asStringObject(JSValue); StringObject* asStringObject(JSValue);
......
...@@ -40,6 +40,12 @@ namespace JSC { ...@@ -40,6 +40,12 @@ namespace JSC {
} }
static const ClassInfo s_info; static const ClassInfo s_info;
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | StringObject::StructureFlags;
COMPILE_ASSERT(!StringObject::AnonymousSlotCount, StringPrototype_stomps_on_your_anonymous_slot);
static const unsigned AnonymousSlotCount = 1;
}; };
} // namespace JSC } // namespace JSC
......
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