Bug 752092 - Support building SpiderMonkey without JS_HAS_XML_SUPPORT. r=terrence.

This commit is contained in:
Jason Orendorff 2012-05-14 18:53:30 -05:00
parent 474b598d8d
commit c805c1a187
19 changed files with 95 additions and 35 deletions

View File

@ -6032,18 +6032,6 @@ Parser::xmlExpr(JSBool inTag)
return pn;
}
ParseNode *
Parser::atomNode(ParseNodeKind kind, JSOp op)
{
ParseNode *node = NullaryNode::create(kind, this);
if (!node)
return NULL;
node->setOp(op);
const Token &tok = tokenStream.currentToken();
node->pn_atom = tok.atom();
return node;
}
/*
* Parse the productions:
*
@ -6551,6 +6539,18 @@ Parser::starOrAtPropertyIdentifier(TokenKind tt)
}
#endif
ParseNode *
Parser::atomNode(ParseNodeKind kind, JSOp op)
{
ParseNode *node = NullaryNode::create(kind, this);
if (!node)
return NULL;
node->setOp(op);
const Token &tok = tokenStream.currentToken();
node->pn_atom = tok.atom();
return node;
}
ParseNode *
Parser::primaryExpr(TokenKind tt, bool afterDoubleDot)
{

View File

@ -7,6 +7,7 @@
#include "jsprf.h"
#include "jsscope.h"
#include "jsstr.h"
#include "jsxml.h"
#include "gc/Marking.h"
#include "methodjit/MethodJIT.h"
@ -49,8 +50,10 @@
namespace js {
namespace gc {
#if JS_HAS_XML_SUPPORT
static inline void
PushMarkStack(GCMarker *gcmarker, JSXML *thing);
#endif
static inline void
PushMarkStack(GCMarker *gcmarker, JSObject *thing);
@ -451,6 +454,7 @@ MarkValueUnbarriered(JSTracer *trc, Value *v, const char *name)
JS_ASSERT((thing)->compartment()->isCollecting() || \
(thing)->compartment() == (rt)->atomsCompartment);
#if JS_HAS_XML_SUPPORT
static void
PushMarkStack(GCMarker *gcmarker, JSXML *thing)
{
@ -459,6 +463,7 @@ PushMarkStack(GCMarker *gcmarker, JSXML *thing)
if (thing->markIfUnmarked(gcmarker->getMarkColor()))
gcmarker->pushXML(thing);
}
#endif
static void
PushMarkStack(GCMarker *gcmarker, JSObject *thing)
@ -815,7 +820,7 @@ MarkChildren(JSTracer *trc, types::TypeObject *type)
MarkObject(trc, &type->interpretedFunction, "type_function");
}
#ifdef JS_HAS_XML_SUPPORT
#if JS_HAS_XML_SUPPORT
static void
MarkChildren(JSTracer *trc, JSXML *xml)
{
@ -995,10 +1000,13 @@ GCMarker::processMarkStackOther(uintptr_t tag, uintptr_t addr)
pushValueArray(obj, vp, end);
else
pushObject(obj);
} else {
}
#if JS_HAS_XML_SUPPORT
else {
JS_ASSERT(tag == XmlTag);
MarkChildren(this, reinterpret_cast<JSXML *>(addr));
}
#endif
}
inline void

View File

@ -216,11 +216,13 @@ Mark(JSTracer *trc, HeapPtr<JSScript> *o, const char *name)
MarkScript(trc, o, name);
}
#if JS_HAS_XML_SUPPORT
inline void
Mark(JSTracer *trc, HeapPtr<JSXML> *xml, const char *name)
{
MarkXML(trc, xml, name);
}
#endif
inline bool
IsMarked(const Value &v)

View File

@ -1376,7 +1376,7 @@ struct AutoResolving {
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
#ifdef JS_HAS_XML_SUPPORT
#if JS_HAS_XML_SUPPORT
class AutoXMLRooter : private AutoGCRooter {
public:
AutoXMLRooter(JSContext *cx, JSXML *xml

View File

@ -202,6 +202,8 @@ GetGSNCache(JSContext *cx)
return &cx->runtime->gsnCache;
}
#if JS_HAS_XML_SUPPORT
class AutoNamespaceArray : protected AutoGCRooter {
public:
AutoNamespaceArray(JSContext *cx)
@ -223,6 +225,8 @@ class AutoNamespaceArray : protected AutoGCRooter {
JSXMLArray<JSObject> array;
};
#endif /* JS_HAS_XML_SUPPORT */
template <typename T>
class AutoPtr
{

View File

@ -2165,6 +2165,7 @@ AutoGCRooter::trace(JSTracer *trc)
return;
}
#if JS_HAS_XML_SUPPORT
case NAMESPACES: {
JSXMLArray<JSObject> &array = static_cast<AutoNamespaceArray *>(this)->array;
MarkObjectRange(trc, array.length, array.vector, "JSXMLArray.vector");
@ -2175,6 +2176,7 @@ AutoGCRooter::trace(JSTracer *trc)
case XML:
js_TraceXML(trc, static_cast<AutoXMLRooter *>(this)->xml);
return;
#endif
case OBJECT:
if (static_cast<AutoObjectRooter *>(this)->obj)

View File

@ -64,9 +64,6 @@
struct JSCompartment;
extern void
js_TraceXML(JSTracer *trc, JSXML* thing);
#if JS_STACK_GROWTH_DIRECTION > 0
# define JS_CHECK_STACK_SIZE(limit, lval) ((uintptr_t)(lval) < limit)
#else
@ -924,9 +921,11 @@ struct GCMarker : public JSTracer {
pushTaggedPtr(TypeTag, type);
}
#if JS_HAS_XML_SUPPORT
void pushXML(JSXML *xml) {
pushTaggedPtr(XmlTag, xml);
}
#endif
uint32_t getMarkColor() const {
return color;

View File

@ -3635,6 +3635,7 @@ BEGIN_CASE(JSOP_ANYNAME)
PUSH_COPY(IdToValue(id));
}
END_CASE(JSOP_ANYNAME)
#endif
BEGIN_CASE(JSOP_QNAMEPART)
{
@ -3650,6 +3651,7 @@ BEGIN_CASE(JSOP_QNAMEPART)
}
END_CASE(JSOP_QNAMEPART)
#if JS_HAS_XML_SUPPORT
BEGIN_CASE(JSOP_QNAMECONST)
{
JS_ASSERT(!script->strictModeCode);
@ -4116,7 +4118,6 @@ END_CASE(JSOP_ARRAYPUSH)
L_JSOP_TOATTRNAME:
L_JSOP_QNAME:
L_JSOP_QNAMECONST:
L_JSOP_QNAMEPART:
L_JSOP_ANYNAME:
L_JSOP_DEFXMLNS:
# endif

View File

@ -379,8 +379,13 @@ Snapshot(JSContext *cx, JSObject *obj, unsigned flags, AutoIdVector *props)
}
}
if ((flags & JSITER_OWNONLY) || pobj->isXML())
if (flags & JSITER_OWNONLY)
break;
#if JS_HAS_XML_SUPPORT
if (pobj->isXML())
break;
#endif
} while ((pobj = pobj->getProto()) != NULL);
#ifdef JS_MORE_DETERMINISTIC

View File

@ -2401,10 +2401,12 @@ obj_create(JSContext *cx, unsigned argc, Value *vp)
}
JSObject *proto = v.toObjectOrNull();
#if JS_HAS_XML_SUPPORT
if (proto && proto->isXML()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN);
return false;
}
#endif
/*
* Use the callee's global as the parent of the new object to avoid dynamic
@ -4131,10 +4133,12 @@ SetProto(JSContext *cx, HandleObject obj, HandleObject proto, bool checkForCycle
JS_ASSERT_IF(!checkForCycles, obj != proto);
JS_ASSERT(obj->isExtensible());
#if JS_HAS_XML_SUPPORT
if (proto && proto->isXML()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_XML_PROTO_FORBIDDEN);
return false;
}
#endif
/*
* Regenerate shapes for all of the scopes along the old prototype chain,
@ -5602,7 +5606,9 @@ JSBool
DefaultValue(JSContext *cx, HandleObject obj, JSType hint, Value *vp)
{
JS_ASSERT(hint == JSTYPE_NUMBER || hint == JSTYPE_STRING || hint == JSTYPE_VOID);
#if JS_HAS_XML_SUPPORT
JS_ASSERT(!obj->isXML());
#endif
Class *clasp = obj->getClass();
if (hint == JSTYPE_STRING) {

View File

@ -925,9 +925,7 @@ struct JSObject : public js::ObjectImpl
inline bool isGenerator() const;
inline bool isGlobal() const;
inline bool isIterator() const;
inline bool isNamespace() const;
inline bool isObject() const;
inline bool isQName() const;
inline bool isPrimitive() const;
inline bool isProxy() const;
inline bool isRegExp() const;
@ -937,8 +935,12 @@ struct JSObject : public js::ObjectImpl
inline bool isStopIteration() const;
inline bool isTypedArray() const;
inline bool isWeakMap() const;
#if JS_HAS_XML_SUPPORT
inline bool isNamespace() const;
inline bool isQName() const;
inline bool isXML() const;
inline bool isXMLId() const;
#endif
/* Subtypes of ScopeObject. */
inline bool isBlock() const;

View File

@ -580,6 +580,8 @@ JSObject::setNativeIterator(js::NativeIterator *ni)
setPrivate(ni);
}
#if JS_HAS_XML_SUPPORT
inline JSLinearString *
JSObject::getNamePrefix() const
{
@ -667,6 +669,8 @@ JSObject::setQNameLocalName(JSAtom *name)
setSlot(JSSLOT_QNAME_LOCAL_NAME, name ? js::StringValue(name) : js::UndefinedValue());
}
#endif
inline bool
JSObject::setSingletonType(JSContext *cx)
{
@ -799,7 +803,6 @@ inline bool JSObject::isFunction() const { return hasClass(&js::FunctionClass);
inline bool JSObject::isFunctionProxy() const { return hasClass(&js::FunctionProxyClass); }
inline bool JSObject::isGenerator() const { return hasClass(&js::GeneratorClass); }
inline bool JSObject::isIterator() const { return hasClass(&js::IteratorClass); }
inline bool JSObject::isNamespace() const { return hasClass(&js::NamespaceClass); }
inline bool JSObject::isNestedScope() const { return isBlock() || isWith(); }
inline bool JSObject::isNormalArguments() const { return hasClass(&js::NormalArgumentsObjectClass); }
inline bool JSObject::isNumber() const { return hasClass(&js::NumberClass); }
@ -815,6 +818,9 @@ inline bool JSObject::isString() const { return hasClass(&js::StringClass); }
inline bool JSObject::isTypedArray() const { return IsTypedArrayClass(getClass()); }
inline bool JSObject::isWeakMap() const { return hasClass(&js::WeakMapClass); }
inline bool JSObject::isWith() const { return hasClass(&js::WithClass); }
#if JS_HAS_XML_SUPPORT
inline bool JSObject::isNamespace() const { return hasClass(&js::NamespaceClass); }
inline bool JSObject::isXML() const { return hasClass(&js::XMLClass); }
inline bool
@ -832,6 +838,7 @@ JSObject::isQName() const
|| hasClass(&js::AttributeNameClass)
|| hasClass(&js::AnyNameClass);
}
#endif /* JS_HAS_XML_SUPPORT */
/* static */ inline JSObject *
JSObject::create(JSContext *cx, js::gc::AllocKind kind,
@ -1224,11 +1231,12 @@ OBJ_TO_OUTER_OBJECT(JSContext *cx, JSObject *&obj)
obj = op(cx, obj);
}
#if JS_HAS_XML_SUPPORT
/*
* Methods to test whether an object or a value is of type "xml" (per typeof).
*/
#define VALUE_IS_XML(v) (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isXML())
#define VALUE_IS_XML(v) ((v).isObject() && (v).toObject().isXML())
static inline bool
IsXML(const js::Value &v)
@ -1236,6 +1244,12 @@ IsXML(const js::Value &v)
return v.isObject() && v.toObject().isXML();
}
#else
#define VALUE_IS_XML(v) false
#endif /* JS_HAS_XML_SUPPORT */
static inline bool
IsStopIteration(const js::Value &v)
{
@ -1595,10 +1609,10 @@ IsObjectWithClass(const Value &v, ESClassValue classValue, JSContext *cx)
static JS_ALWAYS_INLINE bool
ValueIsSpecial(JSObject *obj, Value *propval, SpecialId *sidp, JSContext *cx)
{
#if JS_HAS_XML_SUPPORT
if (!propval->isObject())
return false;
#if JS_HAS_XML_SUPPORT
if (obj->isXML()) {
*sidp = SpecialId(propval->toObject());
return true;

View File

@ -391,7 +391,7 @@ PreprocessValue(JSContext *cx, JSObject *holder, KeyType key, Value *vp, Stringi
static inline bool
IsFilteredValue(const Value &v)
{
return v.isUndefined() || js_IsCallable(v) || (v.isObject() && v.toObject().isXML());
return v.isUndefined() || js_IsCallable(v) || VALUE_IS_XML(v);
}
/* ES5 15.12.3 JO. */

View File

@ -2575,8 +2575,9 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
JSFunction *fun = NULL; /* init to shut GCC up */
JSString *str;
JSBool ok;
JSBool foreach;
#if JS_HAS_XML_SUPPORT
JSBool foreach, inXML, quoteAttr;
JSBool inXML, quoteAttr;
#else
#define inXML JS_FALSE
#endif
@ -2682,8 +2683,9 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
sn = NULL;
rval = NULL;
bool forOf = false;
foreach = false;
#if JS_HAS_XML_SUPPORT
foreach = inXML = quoteAttr = JS_FALSE;
inXML = quoteAttr = false;
#endif
while (nb < 0 || pc < endpc) {
@ -5202,17 +5204,21 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
todo = ss->sprinter.put("*", 1);
}
break;
#endif
case JSOP_QNAMEPART:
LOAD_ATOM(0);
#if JS_HAS_XML_SUPPORT
if (pc[JSOP_QNAMEPART_LENGTH] == JSOP_TOATTRNAME) {
saveop = JSOP_TOATTRNAME;
len += JSOP_TOATTRNAME_LENGTH;
lval = "@";
goto do_qname;
}
#endif
goto do_name;
#if JS_HAS_XML_SUPPORT
case JSOP_QNAMECONST:
LOAD_ATOM(0);
rval = QuoteString(&ss->sprinter, atom, 0);

View File

@ -95,7 +95,10 @@ typedef struct JSPrinter JSPrinter;
typedef struct JSStackHeader JSStackHeader;
typedef struct JSSubString JSSubString;
typedef struct JSSpecializedNative JSSpecializedNative;
#if JS_HAS_XML_SUPPORT
typedef struct JSXML JSXML;
#endif
/*
* Template declarations.

View File

@ -2496,7 +2496,7 @@ ASTSerializer::expression(ParseNode *pn, Value *dst)
case PNK_NEW:
case PNK_LP:
{
#ifdef JS_HAS_GENERATOR_EXPRS
#if JS_HAS_GENERATOR_EXPRS
if (pn->isGeneratorExpr())
return generatorExpression(pn->generatorExpr(), dst);
#endif
@ -2611,7 +2611,7 @@ ASTSerializer::expression(ParseNode *pn, Value *dst)
case PNK_LET:
return let(pn, true, dst);
#ifdef JS_HAS_XML_SUPPORT
#if JS_HAS_XML_SUPPORT
case PNK_XMLUNARY:
JS_ASSERT(pn->isOp(JSOP_XMLNAME) ||
pn->isOp(JSOP_SETXMLNAME) ||
@ -2685,7 +2685,7 @@ ASTSerializer::xml(ParseNode *pn, Value *dst)
{
JS_CHECK_RECURSION(cx, return false);
switch (pn->getKind()) {
#ifdef JS_HAS_XML_SUPPORT
#if JS_HAS_XML_SUPPORT
case PNK_XMLCURLYEXPR:
{
Value expr;
@ -2949,14 +2949,14 @@ ASTSerializer::function(ParseNode *pn, ASTType type, Value *dst)
JSFunction *func = (JSFunction *)pn->pn_funbox->object;
bool isGenerator =
#ifdef JS_HAS_GENERATORS
#if JS_HAS_GENERATORS
pn->pn_funbox->tcflags & TCF_FUN_IS_GENERATOR;
#else
false;
#endif
bool isExpression =
#ifdef JS_HAS_EXPR_CLOSURES
#if JS_HAS_EXPR_CLOSURES
func->flags & JSFUN_EXPR_CLOSURE;
#else
false;

View File

@ -413,10 +413,13 @@ JSObject *
Wrapper::New(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent, Wrapper *handler)
{
JS_ASSERT(parent);
#if JS_HAS_XML_SUPPORT
if (obj->isXML()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_WRAP_XML_OBJECT);
return NULL;
}
#endif
return NewProxyObject(cx, handler, ObjectValue(*obj), proto, parent,
obj->isCallable() ? obj : NULL, NULL);
}

View File

@ -37,8 +37,11 @@
*
* ***** END LICENSE BLOCK ***** */
#include <stddef.h>
#include "jsversion.h"
size_t sE4XObjectsCreated = 0;
#if JS_HAS_XML_SUPPORT
#include <math.h>
@ -174,8 +177,6 @@ xml_isXMLName(JSContext *cx, unsigned argc, jsval *vp)
return JS_TRUE;
}
size_t sE4XObjectsCreated = 0;
/*
* This wrapper is needed because NewBuiltinClassInstance doesn't
* call the constructor, and we need a place to set the

View File

@ -45,6 +45,8 @@
#include "gc/Barrier.h"
#include "gc/Heap.h"
#if JS_HAS_XML_SUPPORT
extern const char js_AnyName_str[];
extern const char js_AttributeName_str[];
extern const char js_isXMLName_str[];
@ -332,4 +334,6 @@ GetLocalNameFromFunctionQName(JSObject *qn, JSAtom **namep, JSContext *cx);
} /* namespace js */
#endif /* JS_HAS_XML_SUPPORT */
#endif /* jsxml_h___ */