<rdar://problem/
4058167> Unit Converter and Weather widgets crashed in KJS::Collector::markCurrentThreadConservatively
Avoid possibly allocating new prototype objects as parameters to
superclass constructors - there may be an allocated but
uninitilized object so this is a bad time to allocate. Instead,
set the prototype in the constructor body, since the object is
happily allocated by then.
* khtml/ecma/kjs_binding.h:
* khtml/ecma/kjs_css.cpp:
(DOMCSSStyleDeclaration::DOMCSSStyleDeclaration):
(DOMMediaList::DOMMediaList):
(DOMCSSStyleSheet::DOMCSSStyleSheet):
(DOMCSSPrimitiveValue::DOMCSSPrimitiveValue):
(DOMCSSValueList::DOMCSSValueList):
* khtml/ecma/kjs_css.h:
(KJS::DOMStyleSheet::DOMStyleSheet):
(KJS::DOMCSSValue::DOMCSSValue):
* khtml/ecma/kjs_dom.cpp:
(DOMNode::DOMNode):
(DOMDocument::DOMDocument):
(DOMElement::DOMElement):
(DOMDOMImplementation::DOMDOMImplementation):
(DOMNamedNodeMap::DOMNamedNodeMap):
(DOMNamedNodesCollection::DOMNamedNodesCollection):
(DOMCharacterData::DOMCharacterData):
(DOMText::DOMText):
* khtml/ecma/kjs_dom.h:
(KJS::NodeConstructor::NodeConstructor):
(KJS::DOMExceptionConstructor::DOMExceptionConstructor):
* khtml/ecma/kjs_events.cpp:
(DOMEvent::DOMEvent):
(Clipboard::Clipboard):
* khtml/ecma/kjs_html.cpp:
(HTMLCollection::HTMLCollection):
* khtml/ecma/kjs_range.cpp:
(DOMRange::DOMRange):
* khtml/ecma/kjs_traversal.cpp:
(DOMNodeIterator::DOMNodeIterator):
(DOMNodeFilter::DOMNodeFilter):
(DOMTreeWalker::DOMTreeWalker):
* khtml/ecma/xmlhttprequest.cpp:
(KJS::XMLHttpRequest::XMLHttpRequest):
* khtml/ecma/xmlserializer.cpp:
(KJS::XMLSerializer::XMLSerializer):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9129
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-05-05 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/4058167> Unit Converter and Weather widgets crashed in KJS::Collector::markCurrentThreadConservatively
+
+ Avoid possibly allocating new prototype objects as parameters to
+ superclass constructors - there may be an allocated but
+ uninitilized object so this is a bad time to allocate. Instead,
+ set the prototype in the constructor body, since the object is
+ happily allocated by then.
+
+ * khtml/ecma/kjs_binding.h:
+ * khtml/ecma/kjs_css.cpp:
+ (DOMCSSStyleDeclaration::DOMCSSStyleDeclaration):
+ (DOMMediaList::DOMMediaList):
+ (DOMCSSStyleSheet::DOMCSSStyleSheet):
+ (DOMCSSPrimitiveValue::DOMCSSPrimitiveValue):
+ (DOMCSSValueList::DOMCSSValueList):
+ * khtml/ecma/kjs_css.h:
+ (KJS::DOMStyleSheet::DOMStyleSheet):
+ (KJS::DOMCSSValue::DOMCSSValue):
+ * khtml/ecma/kjs_dom.cpp:
+ (DOMNode::DOMNode):
+ (DOMDocument::DOMDocument):
+ (DOMElement::DOMElement):
+ (DOMDOMImplementation::DOMDOMImplementation):
+ (DOMNamedNodeMap::DOMNamedNodeMap):
+ (DOMNamedNodesCollection::DOMNamedNodesCollection):
+ (DOMCharacterData::DOMCharacterData):
+ (DOMText::DOMText):
+ * khtml/ecma/kjs_dom.h:
+ (KJS::NodeConstructor::NodeConstructor):
+ (KJS::DOMExceptionConstructor::DOMExceptionConstructor):
+ * khtml/ecma/kjs_events.cpp:
+ (DOMEvent::DOMEvent):
+ (Clipboard::Clipboard):
+ * khtml/ecma/kjs_html.cpp:
+ (HTMLCollection::HTMLCollection):
+ * khtml/ecma/kjs_range.cpp:
+ (DOMRange::DOMRange):
+ * khtml/ecma/kjs_traversal.cpp:
+ (DOMNodeIterator::DOMNodeIterator):
+ (DOMNodeFilter::DOMNodeFilter):
+ (DOMTreeWalker::DOMTreeWalker):
+ * khtml/ecma/xmlhttprequest.cpp:
+ (KJS::XMLHttpRequest::XMLHttpRequest):
+ * khtml/ecma/xmlserializer.cpp:
+ (KJS::XMLSerializer::XMLSerializer):
+
2005-05-06 Darin Adler <darin@apple.com>
Reviewed by Maciej.
* khtml/editing/htmlediting.cpp:
(khtml::EditCommandPtr::setEndingSelection):
+>>>>>>> 1.4172
2005-05-02 Maciej Stachowiak <mjs@apple.com>
Reviewed by Vicki.
*/
class DOMObject : public ObjectImp {
public:
- DOMObject(const Object &proto) : ObjectImp(proto) {}
DOMObject() : ObjectImp() {}
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const
const ClassInfo DOMCSSStyleDeclaration::info = { "CSSStyleDeclaration", 0, &DOMCSSStyleDeclarationTable, 0 };
DOMCSSStyleDeclaration::DOMCSSStyleDeclaration(ExecState *exec, DOM::CSSStyleDeclaration s)
- : DOMObject(DOMCSSStyleDeclarationProto::self(exec)), styleDecl(s)
-{ }
+ : styleDecl(s)
+{
+ setPrototype(DOMCSSStyleDeclarationProto::self(exec));
+}
DOMCSSStyleDeclaration::~DOMCSSStyleDeclaration()
{
IMPLEMENT_PROTOTYPE(DOMMediaListProto, DOMMediaListProtoFunc)
DOMMediaList::DOMMediaList(ExecState *exec, DOM::MediaList ml)
- : DOMObject(DOMMediaListProto::self(exec)), mediaList(ml) { }
+ : mediaList(ml)
+{
+ setPrototype(DOMMediaListProto::self(exec));
+}
DOMMediaList::~DOMMediaList()
{
IMPLEMENT_PROTOTYPE(DOMCSSStyleSheetProto,DOMCSSStyleSheetProtoFunc) // warning, use _WITH_PARENT if DOMStyleSheet gets a proto
DOMCSSStyleSheet::DOMCSSStyleSheet(ExecState *exec, DOM::CSSStyleSheet ss)
- : DOMStyleSheet(DOMCSSStyleSheetProto::self(exec),ss) { }
+ : DOMStyleSheet(ss)
+{
+ setPrototype(DOMCSSStyleSheetProto::self(exec));
+}
DOMCSSStyleSheet::~DOMCSSStyleSheet()
{
IMPLEMENT_PROTOTYPE(DOMCSSPrimitiveValueProto,DOMCSSPrimitiveValueProtoFunc)
DOMCSSPrimitiveValue::DOMCSSPrimitiveValue(ExecState *exec, DOM::CSSPrimitiveValue v)
- : DOMCSSValue(DOMCSSPrimitiveValueProto::self(exec), v) { }
+ : DOMCSSValue(v)
+{
+ setPrototype(DOMCSSPrimitiveValueProto::self(exec));
+}
Value DOMCSSPrimitiveValue::tryGet(ExecState *exec, const Identifier &p) const
{
IMPLEMENT_PROTOFUNC(DOMCSSValueListFunc) // not really a proto, but doesn't matter
DOMCSSValueList::DOMCSSValueList(ExecState *exec, DOM::CSSValueList v)
- : DOMCSSValue(exec, v) { }
+ : DOMCSSValue(exec, v)
+{
+}
Value DOMCSSValueList::tryGet(ExecState *exec, const Identifier &p) const
{
// Build a DOMStyleSheet
DOMStyleSheet(ExecState *, DOM::StyleSheet ss) : styleSheet(ss) { }
// Constructor for inherited classes
- DOMStyleSheet(Object proto, DOM::StyleSheet ss) : DOMObject(proto), styleSheet(ss) { }
+ DOMStyleSheet(DOM::StyleSheet ss) : styleSheet(ss) { }
virtual ~DOMStyleSheet();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
class DOMCSSValue : public DOMObject {
public:
DOMCSSValue(ExecState *, DOM::CSSValue v) : cssValue(v) { }
- DOMCSSValue(Object proto, DOM::CSSValue v) : DOMObject(proto), cssValue(v) { }
+ DOMCSSValue(DOM::CSSValue v) : cssValue(v) { }
virtual ~DOMCSSValue();
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
const ClassInfo DOMNode::info = { "Node", 0, &DOMNodeTable, 0 };
DOMNode::DOMNode(ExecState *exec, const DOM::Node &n)
- : DOMObject(DOMNodeProto::self(exec)), node(n)
+ : node(n)
{
+ setPrototype(DOMNodeProto::self(exec));
}
-DOMNode::DOMNode(const Object &proto, const DOM::Node &n)
- : DOMObject(proto), node(n)
+DOMNode::DOMNode(const DOM::Node &n)
+ : node(n)
{
}
*/
DOMDocument::DOMDocument(ExecState *exec, const DOM::Document &d)
- : DOMNode(DOMDocumentProto::self(exec), d) { }
+ : DOMNode(d)
+{
+ setPrototype(DOMDocumentProto::self(exec));
+}
-DOMDocument::DOMDocument(const Object &proto, const DOM::Document &d)
- : DOMNode(proto, d) { }
+DOMDocument::DOMDocument(const DOM::Document &d)
+ : DOMNode(d)
+{
+}
DOMDocument::~DOMDocument()
{
@end
*/
DOMElement::DOMElement(ExecState *exec, const DOM::Element &e)
- : DOMNode(DOMElementProto::self(exec), e) { }
+ : DOMNode(e)
+{
+ setPrototype(DOMElementProto::self(exec));
+}
-DOMElement::DOMElement(const Object &proto, const DOM::Element &e)
- : DOMNode(proto, e) { }
+DOMElement::DOMElement(const DOM::Element &e)
+ : DOMNode(e)
+{
+}
Value DOMElement::tryGet(ExecState *exec, const Identifier &propertyName) const
{
const ClassInfo DOMDOMImplementation::info = { "DOMImplementation", 0, 0, 0 };
DOMDOMImplementation::DOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation &i)
- : DOMObject(DOMDOMImplementationProto::self(exec)), implementation(i) { }
+ : implementation(i)
+{
+ setPrototype(DOMDOMImplementationProto::self(exec));
+}
DOMDOMImplementation::~DOMDOMImplementation()
{
const ClassInfo DOMNamedNodeMap::info = { "NamedNodeMap", 0, 0, 0 };
DOMNamedNodeMap::DOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m)
- : DOMObject(DOMNamedNodeMapProto::self(exec)), map(m) { }
+ : map(m)
+{
+ setPrototype(DOMNamedNodeMapProto::self(exec));
+}
DOMNamedNodeMap::~DOMNamedNodeMap()
{
// for constructs like document.forms.<name>[1],
// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState *, const QValueList<DOM::Node>& nodes )
- : DOMObject(), m_nodes(nodes)
+ : m_nodes(nodes)
{
// Maybe we should ref (and deref in the dtor) the nodes, though ?
}
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMCharacterDataProto,DOMCharacterDataProtoFunc, DOMNodeProto)
DOMCharacterData::DOMCharacterData(ExecState *exec, const DOM::CharacterData &d)
- : DOMNode(DOMCharacterDataProto::self(exec), d) {}
+ : DOMNode(d)
+{
+ setPrototype(DOMCharacterDataProto::self(exec));
+}
-DOMCharacterData::DOMCharacterData(const Object &proto, const DOM::CharacterData &d)
- : DOMNode(proto, d) {}
+DOMCharacterData::DOMCharacterData(const DOM::CharacterData &d)
+ : DOMNode(d)
+{
+}
Value DOMCharacterData::tryGet(ExecState *exec, const Identifier &p) const
{
IMPLEMENT_PROTOTYPE_WITH_PARENT(DOMTextProto,DOMTextProtoFunc,DOMCharacterDataProto)
DOMText::DOMText(ExecState *exec, const DOM::Text &t)
- : DOMCharacterData(DOMTextProto::self(exec), t) { }
+ : DOMCharacterData(t)
+{
+ setPrototype(DOMTextProto::self(exec));
+}
Value DOMText::tryGet(ExecState *exec, const Identifier &p) const
{
// Build a DOMNode
DOMNode(ExecState *exec, const DOM::Node &n);
// Constructor for inherited classes
- DOMNode(const Object &proto, const DOM::Node &n);
+ DOMNode(const DOM::Node &n);
virtual bool toBoolean(ExecState *) const;
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// Build a DOMDocument
DOMDocument(ExecState *exec, const DOM::Document &d);
// Constructor for inherited classes
- DOMDocument(const Object &proto, const DOM::Document &d);
+ DOMDocument(const DOM::Document &d);
~DOMDocument();
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// Build a DOMElement
DOMElement(ExecState *exec, const DOM::Element &e);
// Constructor for inherited classes
- DOMElement(const Object &proto, const DOM::Element &e);
+ DOMElement(const DOM::Element &e);
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
// no put - all read-only
virtual const ClassInfo* classInfo() const { return &info; }
// Constructor for Node - constructor stuff not implemented yet
class NodeConstructor : public DOMObject {
public:
- NodeConstructor(ExecState *) : DOMObject() { }
+ NodeConstructor(ExecState *) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
// Constructor for DOMException - constructor stuff not implemented yet
class DOMExceptionConstructor : public DOMObject {
public:
- DOMExceptionConstructor(ExecState *) : DOMObject() { }
+ DOMExceptionConstructor(ExecState *) { }
virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
Value getValueProperty(ExecState *exec, int token) const;
// no put - all read-only
// Build a DOMCharacterData
DOMCharacterData(ExecState *exec, const DOM::CharacterData &d);
// Constructor for inherited classes
- DOMCharacterData(const Object &proto, const DOM::CharacterData &d);
+ DOMCharacterData(const DOM::CharacterData &d);
virtual Value tryGet(ExecState *exec,const Identifier &propertyName) const;
Value getValueProperty(ExecState *, int token) const;
virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
IMPLEMENT_PROTOTYPE(DOMEventProto, DOMEventProtoFunc)
DOMEvent::DOMEvent(ExecState *exec, DOM::Event e)
- : DOMObject(DOMEventProto::self(exec)), event(e), clipboard(0) { }
+ : event(e), clipboard(0)
+{
+ setPrototype(DOMEventProto::self(exec));
+}
DOMEvent::~DOMEvent()
{
IMPLEMENT_PROTOTYPE(ClipboardProto, ClipboardProtoFunc)
Clipboard::Clipboard(ExecState *exec, DOM::ClipboardImpl *cb)
-: DOMObject(ClipboardProto::self(exec)), clipboard(cb)
+ : clipboard(cb)
{
+ setPrototype(ClipboardProto::self(exec));
+
if (clipboard)
clipboard->ref();
}
const ClassInfo HTMLCollection::info = { "HTMLCollection", 0, 0, 0 };
HTMLCollection::HTMLCollection(ExecState *exec, const DOM::HTMLCollection &c)
- : DOMObject(HTMLCollectionProto::self(exec)), collection(c) {}
+ : collection(c)
+{
+ setPrototype(HTMLCollectionProto::self(exec));
+}
HTMLCollection::~HTMLCollection()
{
IMPLEMENT_PROTOTYPE(DOMRangeProto,DOMRangeProtoFunc)
DOMRange::DOMRange(ExecState *exec, DOM::Range r)
- : DOMObject(DOMRangeProto::self(exec)), range(r) {}
+ : range(r)
+{
+ setPrototype(DOMRangeProto::self(exec));
+}
DOMRange::~DOMRange()
{
IMPLEMENT_PROTOTYPE(DOMNodeIteratorProto,DOMNodeIteratorProtoFunc)
DOMNodeIterator::DOMNodeIterator(ExecState *exec, DOM::NodeIterator ni)
- : DOMObject(DOMNodeIteratorProto::self(exec)), nodeIterator(ni) {}
+ : nodeIterator(ni)
+{
+ setPrototype(DOMNodeIteratorProto::self(exec));
+}
DOMNodeIterator::~DOMNodeIterator()
{
IMPLEMENT_PROTOTYPE(DOMNodeFilterProto,DOMNodeFilterProtoFunc)
DOMNodeFilter::DOMNodeFilter(ExecState *exec, DOM::NodeFilter nf)
- : DOMObject(DOMNodeFilterProto::self(exec)), nodeFilter(nf) {}
+ : nodeFilter(nf)
+{
+ setPrototype(DOMNodeFilterProto::self(exec));
+}
DOMNodeFilter::~DOMNodeFilter()
{
IMPLEMENT_PROTOTYPE(DOMTreeWalkerProto,DOMTreeWalkerProtoFunc)
DOMTreeWalker::DOMTreeWalker(ExecState *exec, DOM::TreeWalker tw)
- : DOMObject(DOMTreeWalkerProto::self(exec)), treeWalker(tw) {}
+ : treeWalker(tw)
+{
+ setPrototype(DOMTreeWalkerProto::self(exec));
+}
DOMTreeWalker::~DOMTreeWalker()
{
XMLHttpRequest::XMLHttpRequest(ExecState *exec, const DOM::Document &d)
- : DOMObject(XMLHttpRequestProto::self(exec)),
- qObject(new XMLHttpRequestQObject(this)),
+ : qObject(new XMLHttpRequestQObject(this)),
doc(static_cast<DOM::DocumentImpl*>(d.handle())),
async(true),
job(0),
createdDocument(false),
aborted(false)
{
+ setPrototype(XMLHttpRequestProto::self(exec));
}
XMLHttpRequest::~XMLHttpRequest()
*/
XMLSerializer::XMLSerializer(ExecState *exec)
- : DOMObject(XMLSerializerProto::self(exec))
{
+ setPrototype(XMLSerializerProto::self(exec));
}
Value XMLSerializerProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)