Fix * and function:: magic object management (299593, r+sr=bz/shaver).
git-svn-id: svn://10.0.0.236/trunk@175675 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
bb4b89c868
commit
8e2a6eb316
@ -230,7 +230,6 @@ struct JSAtomState {
|
||||
JSAtom *TypeErrorAtom;
|
||||
JSAtom *URIErrorAtom;
|
||||
JSAtom *XMLListAtom;
|
||||
JSAtom *anynameAtom;
|
||||
JSAtom *decodeURIAtom;
|
||||
JSAtom *decodeURIComponentAtom;
|
||||
JSAtom *defineGetterAtom;
|
||||
@ -238,7 +237,6 @@ struct JSAtomState {
|
||||
JSAtom *encodeURIAtom;
|
||||
JSAtom *encodeURIComponentAtom;
|
||||
JSAtom *escapeAtom;
|
||||
JSAtom *functionNamespaceAtom;
|
||||
JSAtom *functionNamespaceURIAtom;
|
||||
JSAtom *hasOwnPropertyAtom;
|
||||
JSAtom *isFiniteAtom;
|
||||
|
||||
@ -244,6 +244,10 @@ struct JSRuntime {
|
||||
const char *decimalSeparator;
|
||||
const char *numGrouping;
|
||||
|
||||
/* Weak references to lazily-created, well-known XML singletons. */
|
||||
JSObject *anynameObject;
|
||||
JSObject *functionNamespaceObject;
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Function invocation metering. */
|
||||
jsrefcount inlineCalls;
|
||||
|
||||
@ -178,7 +178,6 @@ namespace_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSXMLNamespace *ns;
|
||||
JSRuntime *rt;
|
||||
JSAtom *fnAtom;
|
||||
|
||||
ns = (JSXMLNamespace *) JS_GetPrivate(cx, obj);
|
||||
if (!ns)
|
||||
@ -188,9 +187,8 @@ namespace_finalize(JSContext *cx, JSObject *obj)
|
||||
UNMETER(xml_stats.livenamespaceobj);
|
||||
|
||||
rt = cx->runtime;
|
||||
fnAtom = rt->atomState.lazy.functionNamespaceAtom;
|
||||
if (fnAtom && ATOM_TO_OBJECT(fnAtom) == obj)
|
||||
rt->atomState.lazy.functionNamespaceAtom = NULL;
|
||||
if (rt->functionNamespaceObject == obj)
|
||||
rt->functionNamespaceObject = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -403,8 +401,8 @@ anyname_finalize(JSContext* cx, JSObject* obj)
|
||||
|
||||
/* Make sure the next call to js_GetAnyName doesn't try to use obj. */
|
||||
rt = cx->runtime;
|
||||
if (obj == ATOM_TO_OBJECT(rt->atomState.lazy.anynameAtom))
|
||||
rt->atomState.lazy.anynameAtom = NULL;
|
||||
if (rt->anynameObject == obj)
|
||||
rt->anynameObject = NULL;
|
||||
|
||||
qname_finalize(cx, obj);
|
||||
}
|
||||
@ -7465,16 +7463,16 @@ JSBool
|
||||
js_GetFunctionNamespace(JSContext *cx, jsval *vp)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
JSObject *obj;
|
||||
JSAtom *atom;
|
||||
JSString *prefix, *uri;
|
||||
JSObject *obj;
|
||||
|
||||
/* An invalid URI, for internal use only, guaranteed not to collide. */
|
||||
static const char anti_uri[] = "@mozilla.org/js/function";
|
||||
|
||||
rt = cx->runtime;
|
||||
atom = rt->atomState.lazy.functionNamespaceAtom;
|
||||
if (!atom) {
|
||||
obj = rt->functionNamespaceObject;
|
||||
if (!obj) {
|
||||
atom = js_Atomize(cx, js_function_str, 8, 0);
|
||||
JS_ASSERT(atom);
|
||||
prefix = ATOM_TO_STRING(atom);
|
||||
@ -7489,12 +7487,9 @@ js_GetFunctionNamespace(JSContext *cx, jsval *vp)
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
|
||||
atom = js_AtomizeObject(cx, obj, 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
rt->atomState.lazy.functionNamespaceAtom = atom;
|
||||
rt->functionNamespaceObject = obj;
|
||||
}
|
||||
*vp = ATOM_KEY(atom);
|
||||
*vp = OBJECT_TO_JSVAL(obj);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -7663,13 +7658,12 @@ JSBool
|
||||
js_GetAnyName(JSContext *cx, jsval *vp)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
JSAtom *atom;
|
||||
JSXMLQName *qn;
|
||||
JSObject *obj;
|
||||
JSXMLQName *qn;
|
||||
|
||||
rt = cx->runtime;
|
||||
atom = rt->atomState.lazy.anynameAtom;
|
||||
if (!atom) {
|
||||
obj = rt->anynameObject;
|
||||
if (!obj) {
|
||||
qn = js_NewXMLQName(cx, rt->emptyString, rt->emptyString,
|
||||
ATOM_TO_STRING(rt->atomState.starAtom));
|
||||
if (!qn)
|
||||
@ -7684,12 +7678,9 @@ js_GetAnyName(JSContext *cx, jsval *vp)
|
||||
METER(xml_stats.qnameobj);
|
||||
METER(xml_stats.liveqnameobj);
|
||||
|
||||
atom = js_AtomizeObject(cx, obj, 0);
|
||||
if (!atom)
|
||||
return JS_FALSE;
|
||||
rt->atomState.lazy.anynameAtom = atom;
|
||||
rt->anynameObject = obj;
|
||||
}
|
||||
*vp = ATOM_KEY(atom);
|
||||
*vp = OBJECT_TO_JSVAL(obj);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user