Bug 1326453 - Part 5: Remove no longer used ListIterator implementation

This commit is contained in:
janekptacijarabaci 2018-04-14 08:55:29 +02:00 committed by Roy Tam
commit e82ffc59bb
8 changed files with 0 additions and 107 deletions

View file

@ -84,44 +84,3 @@ function LegacyIteratorShim() {
function LegacyGeneratorIteratorShim() {
return NewLegacyIterator(ToObject(this), LegacyGeneratorIterator);
}
// 7.4.8 CreateListIterator()
function CreateListIterator(array) {
let iterator = NewListIterator();
UnsafeSetReservedSlot(iterator, ITERATOR_SLOT_TARGET, array);
UnsafeSetReservedSlot(iterator, ITERATOR_SLOT_NEXT_INDEX, 0);
// 7.4.8.1 ListIterator next()
// The spec requires that we use a new next function per iterator object.
let next = function() {
if (!IsObject(this) || !IsListIterator(this))
return callFunction(CallListIteratorMethodIfWrapped, this, "ListIteratorNext");
if (ActiveFunction() !== UnsafeGetReservedSlot(this, ITERATOR_SLOT_NEXT_METHOD))
ThrowTypeError(JSMSG_INCOMPATIBLE_METHOD, "next", "method", ToString(this));
let array = UnsafeGetObjectFromReservedSlot(this, ITERATOR_SLOT_TARGET);
let index = UnsafeGetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX);
if (index >= ToLength(array.length)) {
UnsafeSetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX, 1/0);
return { value: undefined, done: true };
}
UnsafeSetReservedSlot(this, ITERATOR_SLOT_NEXT_INDEX, index + 1);
return { value: array[index], done: false };
};
UnsafeSetReservedSlot(iterator, ITERATOR_SLOT_NEXT_METHOD, next);
iterator.next = next;
iterator[std_iterator] = ListIteratorIdentity;
return iterator;
}
function ListIteratorIdentity() {
if (!IsObject(this) || !IsListIterator(this))
return callFunction(CallListIteratorMethodIfWrapped, this, "ListIteratorIdentity");
return this;
}

View file

@ -71,8 +71,6 @@
// Used for list, i.e. Array and String, iterators.
#define ITERATOR_SLOT_NEXT_INDEX 1
#define ITERATOR_SLOT_ITEM_KIND 2
// Used for ListIterator.
#define ITERATOR_SLOT_NEXT_METHOD 2
#define ITEM_KIND_KEY 0
#define ITEM_KIND_VALUE 1

View file

@ -1,3 +0,0 @@
iter = getSelfHostedValue("CreateListIterator")([]);
iter.next();
iter.next();

View file

@ -119,7 +119,6 @@
_(IntrinsicGuardToArrayIterator) \
_(IntrinsicGuardToMapIterator) \
_(IntrinsicGuardToSetIterator) \
_(IntrinsicIsListIterator) \
_(IntrinsicGuardToStringIterator) \
\
_(IntrinsicGuardToMapObject) \

View file

@ -285,8 +285,6 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target)
return inlineGuardToClass(callInfo, &SetIteratorObject::class_);
case InlinableNative::IntrinsicGuardToStringIterator:
return inlineGuardToClass(callInfo, &StringIteratorObject::class_);
case InlinableNative::IntrinsicIsListIterator:
return inlineHasClass(callInfo, &ListIteratorObject::class_);
case InlinableNative::IntrinsicDefineDataProperty:
return inlineDefineDataProperty(callInfo);
case InlinableNative::IntrinsicObjectHasPrototype:

View file

@ -1135,18 +1135,6 @@ static const JSFunctionSpec string_iterator_methods[] = {
JS_FS_END
};
enum {
ListIteratorSlotIteratedObject,
ListIteratorSlotNextIndex,
ListIteratorSlotNextMethod,
ListIteratorSlotCount
};
const Class ListIteratorObject::class_ = {
"List Iterator",
JSCLASS_HAS_RESERVED_SLOTS(ListIteratorSlotCount)
};
JSObject*
js::ValueToIterator(JSContext* cx, unsigned flags, HandleValue vp)
{

View file

@ -151,12 +151,6 @@ class StringIteratorObject : public JSObject
static const Class class_;
};
class ListIteratorObject : public JSObject
{
public:
static const Class class_;
};
bool
GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleObject objp);

View file

@ -856,37 +856,6 @@ intrinsic_NewStringIterator(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
intrinsic_NewListIterator(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 0);
RootedObject proto(cx, GlobalObject::getOrCreateIteratorPrototype(cx, cx->global()));
if (!proto)
return false;
RootedObject iterator(cx);
iterator = NewObjectWithGivenProto(cx, &ListIteratorObject::class_, proto);
if (!iterator)
return false;
args.rval().setObject(*iterator);
return true;
}
static bool
intrinsic_ActiveFunction(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 0);
ScriptFrameIter iter(cx);
MOZ_ASSERT(iter.isFunctionFrame());
args.rval().setObject(*iter.callee(cx));
return true;
}
static bool
intrinsic_SetCanonicalName(JSContext* cx, unsigned argc, Value* vp)
{
@ -2290,11 +2259,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("CallArrayIteratorMethodIfWrapped",
CallNonGenericSelfhostedMethod<Is<ArrayIteratorObject>>, 2,0),
JS_FN("NewListIterator", intrinsic_NewListIterator, 0,0),
JS_FN("CallListIteratorMethodIfWrapped",
CallNonGenericSelfhostedMethod<Is<ListIteratorObject>>, 2,0),
JS_FN("ActiveFunction", intrinsic_ActiveFunction, 0,0),
JS_FN("_SetCanonicalName", intrinsic_SetCanonicalName, 2,0),
JS_INLINABLE_FN("GuardToArrayIterator",
@ -2309,9 +2273,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_INLINABLE_FN("GuardToStringIterator",
intrinsic_GuardToBuiltin<StringIteratorObject>, 1,0,
IntrinsicGuardToStringIterator),
JS_INLINABLE_FN("IsListIterator",
intrinsic_IsInstanceOfBuiltin<ListIteratorObject>, 1,0,
IntrinsicIsListIterator),
JS_FN("_CreateMapIterationResultPair", intrinsic_CreateMapIterationResultPair, 0, 0),
JS_INLINABLE_FN("_GetNextMapEntryForIterator", intrinsic_GetNextMapEntryForIterator, 2,0,
@ -2533,7 +2494,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
intrinsic_InstantiateModuleFunctionDeclarations, 1, 0),
JS_FN("SetModuleState", intrinsic_SetModuleState, 1, 0),
JS_FN("EvaluateModule", intrinsic_EvaluateModule, 1, 0),
JS_FN("IsModuleNamespace", intrinsic_IsInstanceOfBuiltin<ModuleNamespaceObject>, 1, 0),
JS_FN("NewModuleNamespace", intrinsic_NewModuleNamespace, 2, 0),
JS_FN("AddModuleNamespaceBinding", intrinsic_AddModuleNamespaceBinding, 4, 0),
JS_FN("ModuleNamespaceExports", intrinsic_ModuleNamespaceExports, 1, 0),