From 671daec412a21572b7759fb3d3339ec1334fbd80 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Wed, 16 Nov 2011 10:48:51 -0800 Subject: [PATCH] Back out 2f276de2e526 (burning) --- js/src/jsgc.cpp | 2 +- js/src/jsgcmark.h | 6 ------ js/src/jsxml.cpp | 31 ++++++++++++++++++++++--------- js/src/jsxml.h | 6 ++---- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 723a78a127d..a63af23d3c8 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1947,7 +1947,7 @@ AutoGCRooter::trace(JSTracer *trc) case NAMESPACES: { JSXMLArray &array = static_cast(this)->array; MarkObjectRange(trc, array.length, array.vector, "JSXMLArray.vector"); - js_XMLArrayCursorTrace(trc, array.cursors); + array.cursors->trace(trc); return; } diff --git a/js/src/jsgcmark.h b/js/src/jsgcmark.h index ef8cd5a2724..b9205416dae 100644 --- a/js/src/jsgcmark.h +++ b/js/src/jsgcmark.h @@ -210,12 +210,6 @@ Mark(JSTracer *trc, const MarkablePtr &o, const char *name) MarkObject(trc, o, name); } -inline void -Mark(JSTracer *trc, const MarkablePtr &xml, const char *name) -{ - MarkXML(trc, xml, name); -} - inline bool IsMarked(JSContext *cx, const js::Value &v) { diff --git a/js/src/jsxml.cpp b/js/src/jsxml.cpp index e19894e5691..8075d73cf86 100644 --- a/js/src/jsxml.cpp +++ b/js/src/jsxml.cpp @@ -874,14 +874,27 @@ attr_identity(const JSXML *xmla, const JSXML *xmlb) return qname_identity(xmla->name, xmlb->name); } -template +template<> void -js_XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor) +JSXMLArrayCursor::trace(JSTracer *trc) { - for (; cursor; cursor = cursor->next) { - if (cursor->root) - Mark(trc, (const MarkablePtr &)cursor->root, "cursor_root"); - } + for (JSXMLArrayCursor *cursor = this; cursor; cursor = cursor->next) + MarkXML(trc, cursor->root, "cursor_root"); +} + +template<> +void +JSXMLArrayCursor::trace(JSTracer *trc) +{ + for (JSXMLArrayCursor *cursor = this; cursor; cursor = cursor->next) + MarkObject(trc, cursor->root, "cursor_root"); +} + +template +static void +XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor) +{ + cursor->trace(trc); } template @@ -7347,7 +7360,7 @@ js_TraceXML(JSTracer *trc, JSXML *xml) } MarkXMLRange(trc, xml->xml_kids.length, xml->xml_kids.vector, "xml_kids"); - js_XMLArrayCursorTrace(trc, xml->xml_kids.cursors); + XMLArrayCursorTrace(trc, xml->xml_kids.cursors); if (xml->xml_class == JSXML_CLASS_LIST) { if (xml->xml_target) @@ -7358,10 +7371,10 @@ js_TraceXML(JSTracer *trc, JSXML *xml) MarkObjectRange(trc, xml->xml_namespaces.length, xml->xml_namespaces.vector, "xml_namespaces"); - js_XMLArrayCursorTrace(trc, xml->xml_namespaces.cursors); + XMLArrayCursorTrace(trc, xml->xml_namespaces.cursors); MarkXMLRange(trc, xml->xml_attrs.length, xml->xml_attrs.vector, "xml_attrs"); - js_XMLArrayCursorTrace(trc, xml->xml_attrs.cursors); + XMLArrayCursorTrace(trc, xml->xml_attrs.cursors); } } diff --git a/js/src/jsxml.h b/js/src/jsxml.h index 4a82e1fd7e4..888c9d6bb00 100644 --- a/js/src/jsxml.h +++ b/js/src/jsxml.h @@ -121,11 +121,9 @@ struct JSXMLArrayCursor return NULL; return root = array->vector[index]; } -}; -template -void -js_XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor); + void trace(JSTracer *trc); +}; #define JSXML_PRESET_CAPACITY JS_BIT(31) #define JSXML_CAPACITY_MASK JS_BITMASK(31)