Commit e3ad4f13 authored by neis's avatar neis Committed by Commit bot

[modules] Remove @@iterator on namespace objects.

TC39 decided at their last meeting to remove this feature.

R=adamk@chromium.org
TBR=ulan@chromium.org
BUG=v8:1569

Review-Url: https://codereview.chromium.org/2578053003
Cr-Commit-Position: refs/heads/master@{#41745}
parent 6932ea59
......@@ -209,7 +209,6 @@ AstType::bitset AstBitsetType::Lub(i::Map* map) {
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_FIXED_ARRAY_ITERATOR_TYPE:
case JS_ARRAY_BUFFER_TYPE:
case JS_ARRAY_TYPE:
case JS_REGEXP_TYPE: // TODO(rossberg): there should be a RegExp type.
......
......@@ -2475,7 +2475,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<Map> map =
factory->NewMap(JS_MODULE_NAMESPACE_TYPE, JSModuleNamespace::kSize);
Map::SetPrototype(map, isolate->factory()->null_value());
Map::EnsureDescriptorSlack(map, 2);
Map::EnsureDescriptorSlack(map, 1);
native_context()->set_js_module_namespace_map(*map);
{ // Install @@toStringTag.
......@@ -2486,16 +2486,6 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
attribs);
map->AppendDescriptor(&d);
}
{ // Install @@iterator.
Handle<JSFunction> iterator = SimpleCreateFunction(
isolate, factory->NewStringFromAsciiChecked("[Symbol.iterator]"),
Builtins::kModuleNamespaceIterator, 0, true);
iterator->shared()->set_native(true);
// TODO(neis): Is this really supposed to be writable?
DataConstantDescriptor d(factory->iterator_symbol(), iterator, DONT_ENUM);
map->AppendDescriptor(&d);
}
}
{ // -- I t e r a t o r R e s u l t
......@@ -3091,25 +3081,6 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
*generator_function_function);
}
{ // -- F i x e d A r r a y I t e r a t o r
int size = JSFixedArrayIterator::kHeaderSize +
JSFixedArrayIterator::kInObjectPropertyCount * kPointerSize;
Handle<Map> map = factory->NewMap(JS_FIXED_ARRAY_ITERATOR_TYPE, size);
Map::SetPrototype(map, iterator_prototype);
Map::EnsureDescriptorSlack(map,
JSFixedArrayIterator::kInObjectPropertyCount);
map->SetInObjectProperties(JSFixedArrayIterator::kInObjectPropertyCount);
map->SetConstructor(native_context->object_function());
{ // next
DataDescriptor d(factory->next_string(), JSFixedArrayIterator::kNextIndex,
DONT_ENUM, Representation::Tagged());
map->AppendDescriptor(&d);
}
native_context->set_fixed_array_iterator_map(*map);
}
{ // -- S e t I t e r a t o r
Handle<JSObject> set_iterator_prototype =
isolate->factory()->NewJSObject(isolate->object_function(), TENURED);
......
......@@ -16,55 +16,5 @@ void Builtins::Generate_IteratorPrototypeIterator(
assembler.Return(assembler.Parameter(0));
}
BUILTIN(ModuleNamespaceIterator) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
Handle<Object> receiver = args.at<Object>(0);
if (!receiver->IsJSModuleNamespace()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
isolate->factory()->iterator_symbol(), receiver));
}
auto ns = Handle<JSModuleNamespace>::cast(receiver);
Handle<FixedArray> names =
KeyAccumulator::GetKeys(ns, KeyCollectionMode::kOwnOnly, SKIP_SYMBOLS)
.ToHandleChecked();
return *isolate->factory()->NewJSFixedArrayIterator(names);
}
BUILTIN(FixedArrayIteratorNext) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
Handle<Object> receiver = args.at<Object>(0);
// It is an error if this function is called on anything other than the
// particular iterator object for which the function was created.
if (!receiver->IsJSFixedArrayIterator() ||
Handle<JSFixedArrayIterator>::cast(receiver)->initial_next() !=
*args.target()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
isolate->factory()->next_string(), receiver));
}
auto iterator = Handle<JSFixedArrayIterator>::cast(receiver);
Handle<Object> value;
bool done;
int index = iterator->index();
if (index < iterator->array()->length()) {
value = handle(iterator->array()->get(index), isolate);
done = false;
iterator->set_index(index + 1);
} else {
value = isolate->factory()->undefined_value();
done = true;
}
return *isolate->factory()->NewJSIteratorResult(value, done);
}
} // namespace internal
} // namespace v8
......@@ -711,9 +711,6 @@ namespace internal {
TFJ(TypedArrayPrototypeKeys, 0) \
/* ES6 #sec-%typedarray%.prototype.values */ \
TFJ(TypedArrayPrototypeValues, 0) \
\
CPP(ModuleNamespaceIterator) \
CPP(FixedArrayIteratorNext)
#define IGNORE_BUILTIN(...)
......
......@@ -214,7 +214,6 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_FIXED_ARRAY_ITERATOR_TYPE:
case JS_ARRAY_BUFFER_TYPE:
case JS_ARRAY_TYPE:
case JS_REGEXP_TYPE: // TODO(rossberg): there should be a RegExp type.
......
......@@ -231,7 +231,6 @@ enum ContextLookupFlags {
V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \
V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_INDEX, FixedArray, \
fast_template_instantiations_cache) \
V(FIXED_ARRAY_ITERATOR_MAP_INDEX, Map, fixed_array_iterator_map) \
V(FLOAT32_ARRAY_FUN_INDEX, JSFunction, float32_array_fun) \
V(FLOAT32X4_FUNCTION_INDEX, JSFunction, float32x4_function) \
V(FLOAT64_ARRAY_FUN_INDEX, JSFunction, float64_array_fun) \
......
......@@ -2764,26 +2764,5 @@ void Factory::SetClassFunctionInstanceDescriptor(Handle<Map> map) {
}
}
Handle<JSFixedArrayIterator> Factory::NewJSFixedArrayIterator(
Handle<FixedArray> array) {
// Create the "next" function (must be unique per iterator object).
Handle<Code> code(
isolate()->builtins()->builtin(Builtins::kFixedArrayIteratorNext));
// TODO(neis): Don't create a new SharedFunctionInfo each time.
Handle<JSFunction> next = isolate()->factory()->NewFunctionWithoutPrototype(
isolate()->factory()->next_string(), code, false);
next->shared()->set_native(true);
// Create the iterator.
Handle<Map> map(isolate()->native_context()->fixed_array_iterator_map());
Handle<JSFixedArrayIterator> iterator =
Handle<JSFixedArrayIterator>::cast(NewJSObjectFromMap(map));
iterator->set_initial_next(*next);
iterator->set_array(*array);
iterator->set_index(0);
iterator->InObjectPropertyAtPut(JSFixedArrayIterator::kNextIndex, *next);
return iterator;
}
} // namespace internal
} // namespace v8
......@@ -543,9 +543,6 @@ class V8_EXPORT_PRIVATE Factory final {
Handle<JSMapIterator> NewJSMapIterator();
Handle<JSSetIterator> NewJSSetIterator();
Handle<JSFixedArrayIterator> NewJSFixedArrayIterator(
Handle<FixedArray> array);
// Allocates a bound function.
MaybeHandle<JSBoundFunction> NewJSBoundFunction(
Handle<JSReceiver> target_function, Handle<Object> bound_this,
......
......@@ -107,7 +107,6 @@ StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId(
case JS_ARGUMENTS_TYPE:
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_FIXED_ARRAY_ITERATOR_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_VALUE_TYPE:
case JS_DATE_TYPE:
......
......@@ -469,7 +469,6 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3) {
case JS_DATE_TYPE:
case JS_ARRAY_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_FIXED_ARRAY_ITERATOR_TYPE:
case JS_TYPED_ARRAY_TYPE:
case JS_DATA_VIEW_TYPE:
case JS_SET_TYPE:
......
......@@ -142,9 +142,6 @@ void HeapObject::HeapObjectVerify() {
case JS_MODULE_NAMESPACE_TYPE:
JSModuleNamespace::cast(this)->JSModuleNamespaceVerify();
break;
case JS_FIXED_ARRAY_ITERATOR_TYPE:
JSFixedArrayIterator::cast(this)->JSFixedArrayIteratorVerify();
break;
case JS_SET_TYPE:
JSSet::cast(this)->JSSetVerify();
break;
......@@ -1039,16 +1036,6 @@ void JSModuleNamespace::JSModuleNamespaceVerify() {
VerifyPointer(module());
}
void JSFixedArrayIterator::JSFixedArrayIteratorVerify() {
CHECK(IsJSFixedArrayIterator());
VerifyPointer(array());
VerifyPointer(initial_next());
VerifySmiField(kIndexOffset);
CHECK_LE(index(), array()->length());
}
void ModuleInfoEntry::ModuleInfoEntryVerify() {
Isolate* isolate = GetIsolate();
CHECK(IsModuleInfoEntry());
......
......@@ -708,7 +708,6 @@ TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
TYPE_CHECKER(WeakFixedArray, FIXED_ARRAY_TYPE)
TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
TYPE_CHECKER(JSStringIterator, JS_STRING_ITERATOR_TYPE)
TYPE_CHECKER(JSFixedArrayIterator, JS_FIXED_ARRAY_ITERATOR_TYPE)
bool HeapObject::IsJSWeakCollection() const {
return IsJSWeakMap() || IsJSWeakSet();
......@@ -2106,8 +2105,6 @@ int JSObject::GetHeaderSize(InstanceType type) {
return JSObject::kHeaderSize;
case JS_STRING_ITERATOR_TYPE:
return JSStringIterator::kSize;
case JS_FIXED_ARRAY_ITERATOR_TYPE:
return JSFixedArrayIterator::kHeaderSize;
case JS_MODULE_NAMESPACE_TYPE:
return JSModuleNamespace::kSize;
default:
......@@ -3319,7 +3316,6 @@ CAST_ACCESSOR(JSMap)
CAST_ACCESSOR(JSMapIterator)
CAST_ACCESSOR(JSMessageObject)
CAST_ACCESSOR(JSModuleNamespace)
CAST_ACCESSOR(JSFixedArrayIterator)
CAST_ACCESSOR(JSObject)
CAST_ACCESSOR(JSProxy)
CAST_ACCESSOR(JSReceiver)
......@@ -5812,10 +5808,6 @@ ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
ACCESSORS(JSModuleNamespace, module, Module, kModuleOffset)
ACCESSORS(JSFixedArrayIterator, array, FixedArray, kArrayOffset)
SMI_ACCESSORS(JSFixedArrayIterator, index, kIndexOffset)
ACCESSORS(JSFixedArrayIterator, initial_next, JSFunction, kNextOffset)
ACCESSORS(Module, code, Object, kCodeOffset)
ACCESSORS(Module, exports, ObjectHashTable, kExportsOffset)
ACCESSORS(Module, regular_exports, FixedArray, kRegularExportsOffset)
......
......@@ -235,9 +235,6 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case JS_TYPED_ARRAY_TYPE:
JSTypedArray::cast(this)->JSTypedArrayPrint(os);
break;
case JS_FIXED_ARRAY_ITERATOR_TYPE:
JSFixedArrayIterator::cast(this)->JSFixedArrayIteratorPrint(os);
break;
case JS_DATA_VIEW_TYPE:
JSDataView::cast(this)->JSDataViewPrint(os);
break;
......@@ -1013,15 +1010,6 @@ void JSArrayIterator::JSArrayIteratorPrint(std::ostream& os) { // NOLING
JSObjectPrintBody(os, this);
}
void JSFixedArrayIterator::JSFixedArrayIteratorPrint(
std::ostream& os) { // NOLINT
JSObjectPrintHeader(os, this, "JSFixedArrayIterator");
os << "\n - array = " << Brief(array());
os << "\n - index = " << index();
os << "\n - initial_next = " << Brief(initial_next());
JSObjectPrintBody(os, this);
}
void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT
JSObjectPrintHeader(os, this, "JSDataView");
os << "\n - buffer =" << Brief(buffer());
......
......@@ -72,7 +72,6 @@
// - JSDate
// - JSMessageObject
// - JSModuleNamespace
// - JSFixedArrayIterator
// - JSProxy
// - FixedArrayBase
// - ByteArray
......@@ -410,7 +409,6 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
V(JS_GENERATOR_OBJECT_TYPE) \
V(JS_MODULE_NAMESPACE_TYPE) \
V(JS_FIXED_ARRAY_ITERATOR_TYPE) \
V(JS_GLOBAL_OBJECT_TYPE) \
V(JS_GLOBAL_PROXY_TYPE) \
V(JS_API_OBJECT_TYPE) \
......@@ -763,7 +761,6 @@ enum InstanceType {
JS_CONTEXT_EXTENSION_OBJECT_TYPE,
JS_GENERATOR_OBJECT_TYPE,
JS_MODULE_NAMESPACE_TYPE,
JS_FIXED_ARRAY_ITERATOR_TYPE,
JS_ARRAY_TYPE,
JS_ARRAY_BUFFER_TYPE,
JS_TYPED_ARRAY_TYPE,
......@@ -1072,7 +1069,6 @@ template <class C> inline bool Is(Object* obj);
V(JSContextExtensionObject) \
V(JSGeneratorObject) \
V(JSModuleNamespace) \
V(JSFixedArrayIterator) \
V(Map) \
V(DescriptorArray) \
V(FrameArray) \
......@@ -10931,37 +10927,6 @@ class JSStringIterator : public JSObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSStringIterator);
};
// A JS iterator over the elements of a FixedArray.
// This corresponds to ListIterator in ecma262/#sec-createlistiterator.
class JSFixedArrayIterator : public JSObject {
public:
DECLARE_CAST(JSFixedArrayIterator)
DECLARE_PRINTER(JSFixedArrayIterator)
DECLARE_VERIFIER(JSFixedArrayIterator)
// The array over which the iterator iterates.
DECL_ACCESSORS(array, FixedArray)
// The index of the array element that will be returned next.
DECL_INT_ACCESSORS(index)
// The initial value of the object's "next" property.
DECL_ACCESSORS(initial_next, JSFunction)
static const int kArrayOffset = JSObject::kHeaderSize;
static const int kIndexOffset = kArrayOffset + kPointerSize;
static const int kNextOffset = kIndexOffset + kPointerSize;
static const int kHeaderSize = kNextOffset + kPointerSize;
enum InObjectPropertyIndex {
kNextIndex,
kInObjectPropertyCount // Dummy.
};
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSFixedArrayIterator);
};
// OrderedHashTableIterator is an iterator that iterates over the keys and
// values of an OrderedHashTable.
//
......
......@@ -79,7 +79,7 @@ bytecodes: [
B(Star), R(0),
B(CreateArrayLiteral), U8(0), U8(0), U8(9),
B(Star), R(1),
B(CallJSRuntime), U8(157), R(0), U8(2),
B(CallJSRuntime), U8(156), R(0), U8(2),
/* 44 S> */ B(Return),
]
constant pool: [
......
......@@ -126,14 +126,14 @@ bytecodes: [
B(LdaUndefined),
B(Star), R(7),
B(Mov), R(2), R(8),
/* 152 E> */ B(CallJSRuntime), U8(157), R(7), U8(2),
/* 152 E> */ B(CallJSRuntime), U8(156), R(7), U8(2),
B(Star), R(7),
B(CreateArrayLiteral), U8(1), U8(1), U8(9),
B(Star), R(8),
B(CallJSRuntime), U8(156), R(5), U8(4),
B(CallJSRuntime), U8(155), R(5), U8(4),
B(Star), R(5),
B(Mov), R(0), R(6),
/* 140 E> */ B(CallJSRuntime), U8(153), R(3), U8(4),
/* 140 E> */ B(CallJSRuntime), U8(152), R(3), U8(4),
B(Star), R(3),
B(Ldar), R(this),
B(JumpIfNotHole), U8(4),
......
......@@ -22,8 +22,7 @@ assertTrue(Reflect.setPrototypeOf(foo, null));
assertFalse(Reflect.setPrototypeOf(foo, {}));
assertSame(null, Reflect.getPrototypeOf(foo));
assertEquals(
["bla", "foo_again", "yo", Symbol.toStringTag, Symbol.iterator],
Reflect.ownKeys(foo));
["bla", "foo_again", "yo", Symbol.toStringTag], Reflect.ownKeys(foo));
// Its "yo" property.
assertEquals(
......@@ -50,40 +49,6 @@ assertEquals(
{value: "Module", configurable: true, writable: false, enumerable: false},
Reflect.getOwnPropertyDescriptor(foo, Symbol.toStringTag));
// Its @@iterator property.
assertTrue(Reflect.has(foo, Symbol.iterator));
assertEquals("function", typeof Reflect.get(foo, Symbol.iterator));
assertEquals("[Symbol.iterator]", foo[Symbol.iterator].name);
assertEquals(0, foo[Symbol.iterator].length);
assertSame(Function.prototype, foo[Symbol.iterator].__proto__);
assertEquals(
{value: foo[Symbol.iterator],
configurable: true, writable: true, enumerable: false},
Reflect.getOwnPropertyDescriptor(foo, Symbol.iterator));
assertEquals(["bla", "foo_again", "yo"], [...foo]);
assertThrows(() => (42, foo[Symbol.iterator])(), TypeError);
{
let it = foo[Symbol.iterator]();
assertSame(it.__proto__, ([][Symbol.iterator]()).__proto__.__proto__);
assertEquals(["next"], Reflect.ownKeys(it));
assertEquals(
{value: it.next, configurable: true, writable: true, enumerable: false},
Reflect.getOwnPropertyDescriptor(it, "next"));
assertEquals("function", typeof it.next);
assertEquals("next", it.next.name);
assertEquals(0, it.next.length);
assertSame(Function.prototype, it.next.__proto__);
assertFalse(it === foo[Symbol.iterator]());
assertFalse(it.next === foo[Symbol.iterator]().next);
assertThrows(() => (42, it.next)(), TypeError);
assertThrows(() => it.next.call(foo[Symbol.iterator]()), TypeError);
let next = it.next;
assertEquals(42, (it.next = 42, it.next));
assertEquals(43, (it.bla = 43, it.bla));
assertTrue(delete it.next);
assertThrows(() => next.call(foo[Symbol.iterator]()), TypeError);
}
// TODO(neis): Clarify spec w.r.t. other symbols.
// Nonexistant properties.
......
......@@ -5,10 +5,8 @@
// MODULE
assertEquals(
["b", "c", "get_a", "ns2", "set_a", "zzz",
Symbol.toStringTag, Symbol.iterator],
["b", "c", "get_a", "ns2", "set_a", "zzz", Symbol.toStringTag],
Reflect.ownKeys(ns));
assertEquals(["b", "c", "get_a", "ns2", "set_a", "zzz"], [...ns]);
import * as foo from "modules-skip-1.js";
assertSame(foo.a, ns.b);
......
......@@ -450,6 +450,14 @@
'language/module-code/namespace/internals/set': [FAIL],
'language/module-code/namespace/internals/define-own-property': [FAIL],
# Symbol.iterator on namespace objects was removed, tests need to be updated.
'language/module-code/namespace/Symbol.iterator/*': [SKIP],
'language/module-code/namespace/internals/get-own-property-sym': [SKIP],
'language/module-code/namespace/internals/get-sym-found': [SKIP],
'language/module-code/namespace/internals/has-property-sym-found': [SKIP],
'language/module-code/namespace/internals/own-property-keys-binding-types': [SKIP],
'language/module-code/namespace/internals/own-property-keys-sort': [SKIP],
######################## NEEDS INVESTIGATION ###########################
# These test failures are specific to the intl402 suite and need investigation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment