mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 537204 - No more BOGUS_CX bogosities (r=jwalden).
This commit is contained in:
parent
4629cf448e
commit
398f5f3b9b
@ -1206,7 +1206,7 @@ array_trace(JSTracer *trc, JSObject *obj)
|
||||
size_t i;
|
||||
jsval v;
|
||||
|
||||
JS_ASSERT(js_IsDenseArray(obj));
|
||||
JS_ASSERT(obj->isDenseArray());
|
||||
obj->traceProtoAndParent(trc);
|
||||
|
||||
capacity = js_DenseArrayCapacity(obj);
|
||||
@ -3541,7 +3541,7 @@ js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count,
|
||||
{
|
||||
uint32 length;
|
||||
|
||||
if (!obj || !js_IsDenseArray(obj))
|
||||
if (!obj || !obj->isDenseArray())
|
||||
return JS_FALSE;
|
||||
|
||||
length = obj->fslots[JSSLOT_ARRAY_LENGTH];
|
||||
|
@ -55,16 +55,20 @@ js_IdIsIndex(jsval id, jsuint *indexp);
|
||||
|
||||
extern JSClass js_ArrayClass, js_SlowArrayClass;
|
||||
|
||||
static JS_INLINE JSBool
|
||||
js_IsDenseArray(JSObject *obj)
|
||||
inline bool
|
||||
JSObject::isDenseArray() const
|
||||
{
|
||||
return STOBJ_GET_CLASS(obj) == &js_ArrayClass;
|
||||
return getClass() == &js_ArrayClass;
|
||||
}
|
||||
|
||||
#define OBJ_IS_DENSE_ARRAY(cx, obj) js_IsDenseArray(obj)
|
||||
inline bool
|
||||
JSObject::isArray() const
|
||||
{
|
||||
return isDenseArray() || getClass() == &js_SlowArrayClass;
|
||||
}
|
||||
|
||||
#define OBJ_IS_ARRAY(cx,obj) (OBJ_IS_DENSE_ARRAY(cx, obj) || \
|
||||
OBJ_GET_CLASS(cx, obj) == &js_SlowArrayClass)
|
||||
#define OBJ_IS_DENSE_ARRAY(cx,obj) (obj)->isDenseArray()
|
||||
#define OBJ_IS_ARRAY(cx,obj) (obj)->isArray()
|
||||
|
||||
/*
|
||||
* Dense arrays are not native (OBJ_IS_NATIVE(cx, aobj) for a dense array aobj
|
||||
@ -122,14 +126,14 @@ js_MakeArraySlow(JSContext *cx, JSObject *obj);
|
||||
static JS_INLINE uint32
|
||||
js_DenseArrayCapacity(JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(js_IsDenseArray(obj));
|
||||
JS_ASSERT(obj->isDenseArray());
|
||||
return obj->dslots ? (uint32) obj->dslots[-1] : 0;
|
||||
}
|
||||
|
||||
static JS_INLINE void
|
||||
js_SetDenseArrayCapacity(JSObject *obj, uint32 capacity)
|
||||
{
|
||||
JS_ASSERT(js_IsDenseArray(obj));
|
||||
JS_ASSERT(obj->isDenseArray());
|
||||
JS_ASSERT(obj->dslots);
|
||||
obj->dslots[-1] = (jsval) capacity;
|
||||
}
|
||||
|
@ -212,7 +212,13 @@ extern const uint32 CALL_CLASS_FIXED_RESERVED_SLOTS;
|
||||
/* JS_FRIEND_DATA so that VALUE_IS_FUNCTION is callable from the shell. */
|
||||
extern JS_FRIEND_DATA(JSClass) js_FunctionClass;
|
||||
|
||||
#define HAS_FUNCTION_CLASS(obj) (STOBJ_GET_CLASS(obj) == &js_FunctionClass)
|
||||
inline bool
|
||||
JSObject::isFunction() const
|
||||
{
|
||||
return getClass() == &js_FunctionClass;
|
||||
}
|
||||
|
||||
#define HAS_FUNCTION_CLASS(obj) (obj)->isFunction()
|
||||
|
||||
/*
|
||||
* NB: jsapi.h and jsobj.h must be included before any call to this macro.
|
||||
|
@ -2278,7 +2278,7 @@ class AutoDescriptorArray : private JSTempValueRooter
|
||||
|
||||
public:
|
||||
AutoDescriptorArray(JSContext *cx)
|
||||
: cx(cx), descriptors(cx)
|
||||
: cx(cx), descriptors(cx)
|
||||
{
|
||||
JS_PUSH_TEMP_ROOT_TRACE(cx, trace, this);
|
||||
}
|
||||
@ -6907,8 +6907,7 @@ js_DumpObject(JSObject *obj)
|
||||
clasp = STOBJ_GET_CLASS(obj);
|
||||
fprintf(stderr, "class %p %s\n", (void *)clasp, clasp->name);
|
||||
|
||||
/* OBJ_IS_DENSE_ARRAY ignores the cx argument. */
|
||||
if (OBJ_IS_DENSE_ARRAY(BOGUS_CX, obj)) {
|
||||
if (obj->isDenseArray()) {
|
||||
slots = JS_MIN((jsuint) obj->fslots[JSSLOT_ARRAY_LENGTH],
|
||||
js_DenseArrayCapacity(obj));
|
||||
fprintf(stderr, "elements\n");
|
||||
|
@ -391,6 +391,12 @@ struct JSObject {
|
||||
if (map->ops->dropProperty)
|
||||
map->ops->dropProperty(cx, this, prop);
|
||||
}
|
||||
|
||||
inline bool isArray() const;
|
||||
inline bool isDenseArray() const;
|
||||
inline bool isFunction() const;
|
||||
inline bool isRegExp() const;
|
||||
inline bool isXML() const;
|
||||
};
|
||||
|
||||
/* Compatibility macros. */
|
||||
|
@ -149,11 +149,16 @@ extern void
|
||||
js_FreeRegExpStatics(JSContext *cx);
|
||||
|
||||
#define VALUE_IS_REGEXP(cx, v) \
|
||||
(JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) && \
|
||||
OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_RegExpClass)
|
||||
(!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isRegExp())
|
||||
|
||||
extern JSClass js_RegExpClass;
|
||||
|
||||
inline bool
|
||||
JSObject::isRegExp() const
|
||||
{
|
||||
return getClass() == &js_RegExpClass;
|
||||
}
|
||||
|
||||
enum regexp_tinyid {
|
||||
REGEXP_SOURCE = -1,
|
||||
REGEXP_GLOBAL = -2,
|
||||
|
@ -554,7 +554,7 @@ struct JSScopeProperty {
|
||||
jsval getterValue() const {
|
||||
JS_ASSERT(attrs & JSPROP_GETTER);
|
||||
jsval getterVal = getter ? js_CastAsObjectJSVal(getter) : JSVAL_VOID;
|
||||
JS_ASSERT_IF(getter, VALUE_IS_FUNCTION(BOGUS_CX, getterVal));
|
||||
JS_ASSERT_IF(getter, HAS_FUNCTION_CLASS(JSVAL_TO_OBJECT(getterVal)));
|
||||
return getterVal;
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ struct JSScopeProperty {
|
||||
jsval setterValue() const {
|
||||
JS_ASSERT(attrs & JSPROP_SETTER);
|
||||
jsval setterVal = setter ? js_CastAsObjectJSVal(setter) : JSVAL_VOID;
|
||||
JS_ASSERT_IF(setter, VALUE_IS_FUNCTION(BOGUS_CX, setterVal));
|
||||
JS_ASSERT_IF(setter, HAS_FUNCTION_CLASS(JSVAL_TO_OBJECT(setterVal)));
|
||||
return setterVal;
|
||||
}
|
||||
|
||||
|
@ -88,10 +88,8 @@ using namespace nanojit;
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
#define RETURN_VALUE_IF_XML(val, ret) \
|
||||
JS_BEGIN_MACRO \
|
||||
if (!JSVAL_IS_PRIMITIVE(val) && \
|
||||
OBJECT_IS_XML(BOGUS_CX, JSVAL_TO_OBJECT(val))) { \
|
||||
if (!JSVAL_IS_PRIMITIVE(val) && JSVAL_TO_OBJECT(val)->isXML()) \
|
||||
RETURN_VALUE("xml detected", ret); \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
#else
|
||||
#define RETURN_IF_XML(val, ret) ((void) 0)
|
||||
@ -11881,7 +11879,7 @@ TraceRecorder::record_JSOP_GETELEM()
|
||||
}
|
||||
RETURN_STOP_A("can't reach arguments object's frame");
|
||||
}
|
||||
if (js_IsDenseArray(obj)) {
|
||||
if (obj->isDenseArray()) {
|
||||
// Fast path for dense arrays accessed with a integer index.
|
||||
jsval* vp;
|
||||
LIns* addr_ins;
|
||||
|
@ -169,13 +169,21 @@ extern JS_FRIEND_DATA(JSClass) js_AnyNameClass;
|
||||
extern JSClass js_XMLFilterClass;
|
||||
|
||||
/*
|
||||
* Macros to test whether an object or a value is of type "xml" (per typeof).
|
||||
* Methods to test whether an object or a value is of type "xml" (per typeof).
|
||||
* NB: jsobj.h must be included before any call to OBJECT_IS_XML, and jsapi.h
|
||||
* and jsobj.h must be included before any call to VALUE_IS_XML.
|
||||
*
|
||||
* FIXME: bogus cx parameters for OBJECT_IS_XML and VALUE_IS_XML.
|
||||
*/
|
||||
#define OBJECT_IS_XML(cx,obj) ((obj)->map->ops == &js_XMLObjectOps)
|
||||
inline bool
|
||||
JSObject::isXML() const
|
||||
{
|
||||
return map->ops == &js_XMLObjectOps;
|
||||
}
|
||||
|
||||
#define OBJECT_IS_XML(cx,obj) (obj)->isXML()
|
||||
#define VALUE_IS_XML(cx,v) (!JSVAL_IS_PRIMITIVE(v) && \
|
||||
OBJECT_IS_XML(cx, JSVAL_TO_OBJECT(v)))
|
||||
JSVAL_TO_OBJECT(v)->isXML())
|
||||
|
||||
extern JSObject *
|
||||
js_InitNamespaceClass(JSContext *cx, JSObject *obj);
|
||||
|
Loading…
Reference in New Issue
Block a user