Backout changeset 3a488b71b69a (bug 725907 part 1) under the suspicion of breaking Linux32 mochitest-chrome without framepointers
This commit is contained in:
@@ -43,7 +43,6 @@
|
||||
#include "jsinferinlines.h"
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
#include "builtin/Iterator-inl.h"
|
||||
#include "vm/MethodGuard-inl.h"
|
||||
#include "vm/Stack-inl.h"
|
||||
#include "vm/String-inl.h"
|
||||
@@ -52,8 +51,36 @@ using namespace mozilla;
|
||||
using namespace js;
|
||||
using namespace js::gc;
|
||||
|
||||
static void iterator_finalize(FreeOp *fop, JSObject *obj);
|
||||
static void iterator_trace(JSTracer *trc, JSObject *obj);
|
||||
static JSObject *iterator_iterator(JSContext *cx, HandleObject obj, JSBool keysonly);
|
||||
|
||||
Class js::IteratorClass = {
|
||||
"Iterator",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS |
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Iterator),
|
||||
JS_PropertyStub, /* addProperty */
|
||||
JS_PropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
JS_StrictPropertyStub, /* setProperty */
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
iterator_finalize,
|
||||
NULL, /* checkAccess */
|
||||
NULL, /* call */
|
||||
NULL, /* construct */
|
||||
NULL, /* hasInstance */
|
||||
iterator_trace,
|
||||
{
|
||||
NULL, /* equality */
|
||||
NULL, /* outerObject */
|
||||
NULL, /* innerObject */
|
||||
iterator_iterator,
|
||||
NULL /* unused */
|
||||
}
|
||||
};
|
||||
|
||||
Class js::ElementIteratorClass = {
|
||||
"ElementIterator",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(ElementIteratorObject::NumSlots),
|
||||
@@ -90,6 +117,27 @@ NativeIterator::mark(JSTracer *trc)
|
||||
MarkObject(trc, &obj, "obj");
|
||||
}
|
||||
|
||||
static void
|
||||
iterator_finalize(FreeOp *fop, JSObject *obj)
|
||||
{
|
||||
JS_ASSERT(obj->isIterator());
|
||||
|
||||
NativeIterator *ni = obj->getNativeIterator();
|
||||
if (ni) {
|
||||
obj->setPrivate(NULL);
|
||||
fop->free_(ni);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
iterator_trace(JSTracer *trc, JSObject *obj)
|
||||
{
|
||||
NativeIterator *ni = obj->getNativeIterator();
|
||||
|
||||
if (ni)
|
||||
ni->mark(trc);
|
||||
}
|
||||
|
||||
struct IdHashPolicy {
|
||||
typedef jsid Lookup;
|
||||
static HashNumber hash(jsid id) {
|
||||
@@ -431,8 +479,8 @@ Compare(T *a, T *b, size_t c)
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline PropertyIteratorObject *
|
||||
NewPropertyIteratorObject(JSContext *cx, unsigned flags)
|
||||
static inline JSObject *
|
||||
NewIteratorObject(JSContext *cx, unsigned flags)
|
||||
{
|
||||
if (flags & JSITER_ENUMERATE) {
|
||||
RootedTypeObject type(cx);
|
||||
@@ -441,8 +489,8 @@ NewPropertyIteratorObject(JSContext *cx, unsigned flags)
|
||||
return NULL;
|
||||
|
||||
RootedShape emptyEnumeratorShape(cx);
|
||||
emptyEnumeratorShape = EmptyShape::getInitialShape(cx, &PropertyIteratorObject::class_,
|
||||
NULL, NULL, ITERATOR_FINALIZE_KIND);
|
||||
emptyEnumeratorShape = EmptyShape::getInitialShape(cx, &IteratorClass, NULL, NULL,
|
||||
ITERATOR_FINALIZE_KIND);
|
||||
if (!emptyEnumeratorShape)
|
||||
return NULL;
|
||||
|
||||
@@ -452,10 +500,10 @@ NewPropertyIteratorObject(JSContext *cx, unsigned flags)
|
||||
return NULL;
|
||||
|
||||
JS_ASSERT(obj->numFixedSlots() == JSObject::ITER_CLASS_NFIXED_SLOTS);
|
||||
return &obj->asPropertyIterator();
|
||||
return obj;
|
||||
}
|
||||
|
||||
return &NewBuiltinClassInstance(cx, &PropertyIteratorObject::class_)->asPropertyIterator();
|
||||
return NewBuiltinClassInstance(cx, &IteratorClass);
|
||||
}
|
||||
|
||||
NativeIterator *
|
||||
@@ -493,7 +541,7 @@ NativeIterator::init(JSObject *obj, unsigned flags, uint32_t slength, uint32_t k
|
||||
}
|
||||
|
||||
static inline void
|
||||
RegisterEnumerator(JSContext *cx, PropertyIteratorObject *iterobj, NativeIterator *ni)
|
||||
RegisterEnumerator(JSContext *cx, JSObject *iterobj, NativeIterator *ni)
|
||||
{
|
||||
/* Register non-escaping native enumerators (for-in) with the current context. */
|
||||
if (ni->flags & JSITER_ENUMERATE) {
|
||||
@@ -517,7 +565,7 @@ VectorToKeyIterator(JSContext *cx, HandleObject obj, unsigned flags, AutoIdVecto
|
||||
types::MarkTypeObjectFlags(cx, obj, types::OBJECT_FLAG_ITERATED);
|
||||
}
|
||||
|
||||
Rooted<PropertyIteratorObject *> iterobj(cx, NewPropertyIteratorObject(cx, flags));
|
||||
RootedObject iterobj(cx, NewIteratorObject(cx, flags));
|
||||
if (!iterobj)
|
||||
return false;
|
||||
|
||||
@@ -570,7 +618,7 @@ VectorToValueIterator(JSContext *cx, HandleObject obj, unsigned flags, AutoIdVec
|
||||
types::MarkTypeObjectFlags(cx, obj, types::OBJECT_FLAG_ITERATED);
|
||||
}
|
||||
|
||||
PropertyIteratorObject *iterobj = NewPropertyIteratorObject(cx, flags);
|
||||
JSObject *iterobj = NewIteratorObject(cx, flags);
|
||||
if (!iterobj)
|
||||
return false;
|
||||
|
||||
@@ -639,7 +687,7 @@ GetIterator(JSContext *cx, HandleObject obj, unsigned flags, Value *vp)
|
||||
* objects here, as they are not inserted into the cache and
|
||||
* will result in a miss.
|
||||
*/
|
||||
PropertyIteratorObject *last = cx->runtime->nativeIterCache.last;
|
||||
JSObject *last = cx->runtime->nativeIterCache.last;
|
||||
JSObject *proto = obj->getProto();
|
||||
if (last) {
|
||||
NativeIterator *lastni = last->getNativeIterator();
|
||||
@@ -678,7 +726,7 @@ GetIterator(JSContext *cx, HandleObject obj, unsigned flags, Value *vp)
|
||||
pobj = pobj->getProto();
|
||||
} while (pobj);
|
||||
|
||||
PropertyIteratorObject *iterobj = cx->runtime->nativeIterCache.get(key);
|
||||
JSObject *iterobj = cx->runtime->nativeIterCache.get(key);
|
||||
if (iterobj) {
|
||||
NativeIterator *ni = iterobj->getNativeIterator();
|
||||
if (!(ni->flags & (JSITER_ACTIVE|JSITER_UNREUSABLE)) &&
|
||||
@@ -725,7 +773,7 @@ GetIterator(JSContext *cx, HandleObject obj, unsigned flags, Value *vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
PropertyIteratorObject *iterobj = &vp->toObject().asPropertyIterator();
|
||||
JSObject *iterobj = &vp->toObject();
|
||||
|
||||
/* Cache the iterator object if possible. */
|
||||
if (shapes.length())
|
||||
@@ -781,11 +829,8 @@ iterator_next(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
RootedObject thisObj(cx);
|
||||
if (!NonGenericMethodGuard(cx, args, iterator_next, &PropertyIteratorObject::class_,
|
||||
thisObj.address()))
|
||||
{
|
||||
if (!NonGenericMethodGuard(cx, args, iterator_next, &IteratorClass, thisObj.address()))
|
||||
return false;
|
||||
}
|
||||
if (!thisObj)
|
||||
return true;
|
||||
|
||||
@@ -807,49 +852,6 @@ static JSFunctionSpec iterator_methods[] = {
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
void
|
||||
PropertyIteratorObject::trace(JSTracer *trc, JSObject *obj)
|
||||
{
|
||||
if (NativeIterator *ni = obj->asPropertyIterator().getNativeIterator())
|
||||
ni->mark(trc);
|
||||
}
|
||||
|
||||
void
|
||||
PropertyIteratorObject::finalize(FreeOp *fop, JSObject *obj)
|
||||
{
|
||||
if (NativeIterator *ni = obj->asPropertyIterator().getNativeIterator()) {
|
||||
obj->asPropertyIterator().setNativeIterator(NULL);
|
||||
fop->free_(ni);
|
||||
}
|
||||
}
|
||||
|
||||
Class PropertyIteratorObject::class_ = {
|
||||
"Iterator",
|
||||
JSCLASS_IMPLEMENTS_BARRIERS |
|
||||
JSCLASS_HAS_CACHED_PROTO(JSProto_Iterator) |
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, /* addProperty */
|
||||
JS_PropertyStub, /* delProperty */
|
||||
JS_PropertyStub, /* getProperty */
|
||||
JS_StrictPropertyStub, /* setProperty */
|
||||
JS_EnumerateStub,
|
||||
JS_ResolveStub,
|
||||
JS_ConvertStub,
|
||||
finalize,
|
||||
NULL, /* checkAccess */
|
||||
NULL, /* call */
|
||||
NULL, /* construct */
|
||||
NULL, /* hasInstance */
|
||||
trace,
|
||||
{
|
||||
NULL, /* equality */
|
||||
NULL, /* outerObject */
|
||||
NULL, /* innerObject */
|
||||
iterator_iterator,
|
||||
NULL /* unused */
|
||||
}
|
||||
};
|
||||
|
||||
#if JS_HAS_GENERATORS
|
||||
static JSBool
|
||||
CloseGenerator(JSContext *cx, JSObject *genobj);
|
||||
@@ -903,9 +905,9 @@ js::CloseIterator(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
cx->iterValue.setMagic(JS_NO_ITER_VALUE);
|
||||
|
||||
if (obj->isPropertyIterator()) {
|
||||
if (obj->isIterator()) {
|
||||
/* Remove enumerators from the active list, which is a stack. */
|
||||
NativeIterator *ni = obj->asPropertyIterator().getNativeIterator();
|
||||
NativeIterator *ni = obj->getNativeIterator();
|
||||
|
||||
if (ni->flags & JSITER_ENUMERATE) {
|
||||
JS_ASSERT(cx->enumerators == obj);
|
||||
@@ -943,8 +945,8 @@ js::UnwindIteratorForException(JSContext *cx, JSObject *obj)
|
||||
void
|
||||
js::UnwindIteratorForUncatchableException(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
if (obj->isPropertyIterator()) {
|
||||
NativeIterator *ni = obj->asPropertyIterator().getNativeIterator();
|
||||
if (obj->isIterator()) {
|
||||
NativeIterator *ni = obj->getNativeIterator();
|
||||
if (ni->flags & JSITER_ENUMERATE) {
|
||||
JS_ASSERT(cx->enumerators == obj);
|
||||
cx->enumerators = ni->next;
|
||||
@@ -973,7 +975,7 @@ template<typename StringPredicate>
|
||||
static bool
|
||||
SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate predicate)
|
||||
{
|
||||
PropertyIteratorObject *iterobj = cx->enumerators;
|
||||
JSObject *iterobj = cx->enumerators;
|
||||
while (iterobj) {
|
||||
again:
|
||||
NativeIterator *ni = iterobj->getNativeIterator();
|
||||
@@ -1170,9 +1172,9 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, Value *rval)
|
||||
{
|
||||
/* Fast path for native iterators */
|
||||
NativeIterator *ni = NULL;
|
||||
if (iterobj->isPropertyIterator()) {
|
||||
if (iterobj->isIterator()) {
|
||||
/* Key iterators are handled by fast-paths. */
|
||||
ni = iterobj->asPropertyIterator().getNativeIterator();
|
||||
ni = iterobj->getNativeIterator();
|
||||
bool more = ni->props_cursor < ni->props_end;
|
||||
if (ni->isKeyIter() || !more) {
|
||||
rval->setBoolean(more);
|
||||
@@ -1246,12 +1248,12 @@ JSBool
|
||||
js_IteratorNext(JSContext *cx, JSObject *iterobj, Value *rval)
|
||||
{
|
||||
/* Fast path for native iterators */
|
||||
if (iterobj->isPropertyIterator()) {
|
||||
if (iterobj->isIterator()) {
|
||||
/*
|
||||
* Implement next directly as all the methods of the native iterator are
|
||||
* read-only and permanent.
|
||||
*/
|
||||
NativeIterator *ni = iterobj->asPropertyIterator().getNativeIterator();
|
||||
NativeIterator *ni = iterobj->getNativeIterator();
|
||||
if (ni->isKeyIter()) {
|
||||
JS_ASSERT(ni->props_cursor < ni->props_end);
|
||||
*rval = StringValue(*ni->current());
|
||||
@@ -1546,7 +1548,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
|
||||
gen->regs = cx->regs();
|
||||
|
||||
cx->enterGenerator(gen); /* OOM check above. */
|
||||
PropertyIteratorObject *enumerators = cx->enumerators;
|
||||
JSObject *enumerators = cx->enumerators;
|
||||
cx->enumerators = gen->enumerators;
|
||||
|
||||
ok = RunScript(cx, fp->script(), fp);
|
||||
@@ -1701,8 +1703,7 @@ static JSFunctionSpec generator_methods[] = {
|
||||
static bool
|
||||
InitIteratorClass(JSContext *cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
Rooted<JSObject*> iteratorProto(cx,
|
||||
global->createBlankPrototype(cx, &PropertyIteratorObject::class_));
|
||||
RootedObject iteratorProto(cx, global->createBlankPrototype(cx, &IteratorClass));
|
||||
if (!iteratorProto)
|
||||
return false;
|
||||
|
||||
@@ -1712,7 +1713,7 @@ InitIteratorClass(JSContext *cx, Handle<GlobalObject*> global)
|
||||
return false;
|
||||
ni->init(NULL, 0 /* flags */, 0, 0);
|
||||
|
||||
iteratorProto->asPropertyIterator().setNativeIterator(ni);
|
||||
iteratorProto->setNativeIterator(ni);
|
||||
|
||||
RootedFunction ctor(cx);
|
||||
ctor = global->createConstructor(cx, Iterator, CLASS_NAME(cx, Iterator), 2);
|
||||
|
||||
Reference in New Issue
Block a user