author | Jan de Mooij <jdemooij@mozilla.com> |
Thu, 02 Nov 2017 13:56:53 +0100 | |
changeset 440610 | 0ad4e37c81f648b398f09fd1aaef90ff4b9839b6 |
parent 440609 | f7b7b510805eef3d86e884fc6c8ead9902894b5a |
child 440611 | efaccf22b2533dc2f58382649c72de56e0545b3f |
push id | 8118 |
push user | ryanvm@gmail.com |
push date | Fri, 03 Nov 2017 00:38:34 +0000 |
treeherder | mozilla-beta@1c336e874ae8 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | anba |
bugs | 1083482 |
milestone | 58.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/js/src/builtin/Iterator.js +++ b/js/src/builtin/Iterator.js @@ -1,73 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ function IteratorIdentity() { return this; } - -var LegacyIteratorWrapperMap = new std_WeakMap(); - -function LegacyIteratorNext(arg) { - var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this); - try { - return { value: callContentFunction(iter.next, iter, arg), done: false }; - } catch (e) { - if (e instanceof std_StopIteration) - return { value: undefined, done: true }; - throw e; - } -} - -function LegacyIteratorThrow(exn) { - var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this); - try { - return { value: callContentFunction(iter.throw, iter, exn), done: false }; - } catch (e) { - if (e instanceof std_StopIteration) - return { value: undefined, done: true }; - throw e; - } -} - -function LegacyGeneratorIterator(iter) { - callFunction(std_WeakMap_set, LegacyIteratorWrapperMap, this, iter); -} - -var LegacyIteratorsInitialized = std_Object_create(null); - -function InitLegacyIterators() { - var props = std_Object_create(null); - - props.next = std_Object_create(null); - props.next.value = LegacyIteratorNext; - props.next.enumerable = false; - props.next.configurable = true; - props.next.writable = true; - - props[std_iterator] = std_Object_create(null); - props[std_iterator].value = IteratorIdentity; - props[std_iterator].enumerable = false; - props[std_iterator].configurable = true; - props[std_iterator].writable = true; - - props.throw = std_Object_create(null); - props.throw.value = LegacyIteratorThrow; - props.throw.enumerable = false; - props.throw.configurable = true; - props.throw.writable = true; - - var LegacyGeneratorIteratorProto = std_Object_create(GetIteratorPrototype(), props); - MakeConstructible(LegacyGeneratorIterator, LegacyGeneratorIteratorProto); - - LegacyIteratorsInitialized.initialized = true; -} - -function LegacyGeneratorIteratorShim() { - var iter = ToObject(this); - - if (!LegacyIteratorsInitialized.initialized) - InitLegacyIterators(); - - return new LegacyGeneratorIterator(iter); -}
--- a/js/src/builtin/Utilities.js +++ b/js/src/builtin/Utilities.js @@ -48,20 +48,16 @@ // code are installed via the std_functions JSFunctionSpec[] in // SelfHosting.cpp. // // Do not create an alias to a self-hosted builtin, otherwise it will be cloned // twice. // // Symbol is a bare constructor without properties or methods. var std_Symbol = Symbol; -// WeakMap is a bare constructor without properties or methods. -var std_WeakMap = WeakMap; -// StopIteration is a bare constructor without properties or methods. -var std_StopIteration = StopIteration; /********** List specification type **********/ /* Spec: ECMAScript Language Specification, 5.1 edition, 8.8 */ function List() { this.length = 0; }
--- a/js/src/builtin/WeakMapObject.cpp +++ b/js/src/builtin/WeakMapObject.cpp @@ -69,18 +69,18 @@ WeakMap_get_impl(JSContext* cx, const Ca return true; } } args.rval().setUndefined(); return true; } -bool -js::WeakMap_get(JSContext* cx, unsigned argc, Value* vp) +static bool +WeakMap_get(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); return CallNonGenericMethod<IsWeakMap, WeakMap_get_impl>(cx, args); } MOZ_ALWAYS_INLINE bool WeakMap_delete_impl(JSContext* cx, const CallArgs& args) { @@ -125,18 +125,18 @@ WeakMap_set_impl(JSContext* cx, const Ca Rooted<WeakMapObject*> map(cx, &args.thisv().toObject().as<WeakMapObject>()); if (!WeakCollectionPutEntryInternal(cx, map, key, args.get(1))) return false; args.rval().set(args.thisv()); return true; } -bool -js::WeakMap_set(JSContext* cx, unsigned argc, Value* vp) +static bool +WeakMap_set(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); return CallNonGenericMethod<IsWeakMap, WeakMap_set_impl>(cx, args); } bool WeakCollectionObject::nondeterministicGetKeys(JSContext* cx, Handle<WeakCollectionObject*> obj, MutableHandleObject ret) @@ -290,18 +290,18 @@ const Class WeakMapObject::class_ = { static const JSFunctionSpec weak_map_methods[] = { JS_FN("has", WeakMap_has, 1, 0), JS_FN("get", WeakMap_get, 1, 0), JS_FN("delete", WeakMap_delete, 1, 0), JS_FN("set", WeakMap_set, 2, 0), JS_FS_END }; -static JSObject* -InitWeakMapClass(JSContext* cx, HandleObject obj, bool defineMembers) +JSObject* +js::InitWeakMapClass(JSContext* cx, HandleObject obj) { MOZ_ASSERT(obj->isNative()); Handle<GlobalObject*> global = obj.as<GlobalObject>(); RootedPlainObject proto(cx, NewBuiltinClassInstance<PlainObject>(cx)); if (!proto) return nullptr; @@ -309,32 +309,17 @@ InitWeakMapClass(JSContext* cx, HandleOb RootedFunction ctor(cx, GlobalObject::createConstructor(cx, WeakMap_construct, cx->names().WeakMap, 0)); if (!ctor) return nullptr; if (!LinkConstructorAndPrototype(cx, ctor, proto)) return nullptr; - if (defineMembers) { - if (!DefinePropertiesAndFunctions(cx, proto, nullptr, weak_map_methods)) - return nullptr; - if (!DefineToStringTag(cx, proto, cx->names().WeakMap)) - return nullptr; - } + if (!DefinePropertiesAndFunctions(cx, proto, nullptr, weak_map_methods)) + return nullptr; + if (!DefineToStringTag(cx, proto, cx->names().WeakMap)) + return nullptr; if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_WeakMap, ctor, proto)) return nullptr; return proto; } - -JSObject* -js::InitWeakMapClass(JSContext* cx, HandleObject obj) -{ - return InitWeakMapClass(cx, obj, true); -} - -JSObject* -js::InitBareWeakMapCtor(JSContext* cx, HandleObject obj) -{ - return InitWeakMapClass(cx, obj, false); -} -
--- a/js/src/builtin/WeakMapObject.h +++ b/js/src/builtin/WeakMapObject.h @@ -27,25 +27,14 @@ class WeakCollectionObject : public Nati }; class WeakMapObject : public WeakCollectionObject { public: static const Class class_; }; -// WeakMap methods exposed so they can be installed in the self-hosting global. - -extern bool -WeakMap_get(JSContext* cx, unsigned argc, Value* vp); - -extern bool -WeakMap_set(JSContext* cx, unsigned argc, Value* vp); - -extern JSObject* -InitBareWeakMapCtor(JSContext* cx, HandleObject obj); - extern JSObject* InitWeakMapClass(JSContext* cx, HandleObject obj); } // namespace js #endif /* builtin_WeakMapObject_h */
--- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -516,18 +516,16 @@ GlobalObject::initSelfHostingBuiltins(JS return false; } return InitBareBuiltinCtor(cx, global, JSProto_Array) && InitBareBuiltinCtor(cx, global, JSProto_TypedArray) && InitBareBuiltinCtor(cx, global, JSProto_Uint8Array) && InitBareBuiltinCtor(cx, global, JSProto_Int32Array) && InitBareSymbolCtor(cx, global) && - InitBareWeakMapCtor(cx, global) && - InitStopIterationClass(cx, global) && DefineFunctions(cx, global, builtins, AsIntrinsic); } /* static */ bool GlobalObject::isRuntimeCodeGenEnabled(JSContext* cx, Handle<GlobalObject*> global) { HeapSlot& v = global->getSlotRef(RUNTIME_CODEGEN_ENABLED); if (v.isUndefined()) {
--- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -722,30 +722,16 @@ intrinsic_IsPackedArray(JSContext* cx, u { CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 1); MOZ_ASSERT(args[0].isObject()); args.rval().setBoolean(IsPackedArray(&args[0].toObject())); return true; } -static bool -intrinsic_GetIteratorPrototype(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - MOZ_ASSERT(args.length() == 0); - - JSObject* obj = GlobalObject::getOrCreateIteratorPrototype(cx, cx->global()); - if (!obj) - return false; - - args.rval().setObject(*obj); - return true; -} - bool js::intrinsic_NewArrayIterator(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 0); JSObject* obj = NewArrayIteratorObject(cx); if (!obj) @@ -871,24 +857,16 @@ js::intrinsic_IsSuspendedStarGenerator(J } StarGeneratorObject& genObj = args[0].toObject().as<StarGeneratorObject>(); args.rval().setBoolean(!genObj.isClosed() && genObj.isSuspended()); return true; } static bool -intrinsic_ThrowStopIteration(JSContext* cx, unsigned argc, Value* vp) -{ - MOZ_ASSERT(CallArgsFromVp(argc, vp).length() == 0); - - return ThrowStopIteration(cx); -} - -static bool intrinsic_GeneratorIsRunning(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 1); MOZ_ASSERT(args[0].isObject()); GeneratorObject* genObj = &args[0].toObject().as<GeneratorObject>(); args.rval().setBoolean(genObj->isRunning() || genObj->isClosing()); @@ -2283,19 +2261,16 @@ static const JSFunctionSpec intrinsic_fu JS_FN("std_String_localeCompare", str_localeCompare, 1,0), #else JS_FN("std_String_normalize", str_normalize, 0,0), #endif JS_FN("std_String_concat", str_concat, 1,0), JS_FN("std_TypedArray_buffer", js::TypedArray_bufferGetter, 1,0), - JS_FN("std_WeakMap_get", WeakMap_get, 1,0), - JS_FN("std_WeakMap_set", WeakMap_set, 2,0), - JS_FN("std_SIMD_Int8x16_extractLane", simd_int8x16_extractLane, 2,0), JS_FN("std_SIMD_Int16x8_extractLane", simd_int16x8_extractLane, 2,0), JS_INLINABLE_FN("std_SIMD_Int32x4_extractLane", simd_int32x4_extractLane, 2,0, SimdInt32x4_extractLane), JS_FN("std_SIMD_Uint8x16_extractLane", simd_uint8x16_extractLane, 2,0), JS_FN("std_SIMD_Uint16x8_extractLane", simd_uint16x8_extractLane, 2,0), JS_FN("std_SIMD_Uint32x4_extractLane", simd_uint32x4_extractLane, 2,0), JS_INLINABLE_FN("std_SIMD_Float32x4_extractLane", simd_float32x4_extractLane,2,0, SimdFloat32x4_extractLane), JS_FN("std_SIMD_Float64x2_extractLane", simd_float64x2_extractLane, 2,0), @@ -2357,18 +2332,16 @@ static const JSFunctionSpec intrinsic_fu JS_INLINABLE_FN("UnsafeGetStringFromReservedSlot", intrinsic_UnsafeGetStringFromReservedSlot, 2,0, IntrinsicUnsafeGetStringFromReservedSlot), JS_INLINABLE_FN("UnsafeGetBooleanFromReservedSlot", intrinsic_UnsafeGetBooleanFromReservedSlot,2,0, IntrinsicUnsafeGetBooleanFromReservedSlot), JS_INLINABLE_FN("IsPackedArray", intrinsic_IsPackedArray, 1,0, IntrinsicIsPackedArray), - JS_FN("GetIteratorPrototype", intrinsic_GetIteratorPrototype, 0,0), - JS_INLINABLE_FN("NewArrayIterator", intrinsic_NewArrayIterator, 0,0, IntrinsicNewArrayIterator), JS_FN("CallArrayIteratorMethodIfWrapped", CallNonGenericSelfhostedMethod<Is<ArrayIteratorObject>>, 2,0), JS_FN("_SetCanonicalName", intrinsic_SetCanonicalName, 2,0), @@ -2403,18 +2376,16 @@ static const JSFunctionSpec intrinsic_fu JS_FN("CallStringIteratorMethodIfWrapped", CallNonGenericSelfhostedMethod<Is<StringIteratorObject>>, 2,0), JS_FN("IsStarGeneratorObject", intrinsic_IsInstanceOfBuiltin<StarGeneratorObject>, 1,0), JS_FN("StarGeneratorObjectIsClosed", intrinsic_StarGeneratorObjectIsClosed, 1,0), JS_FN("IsSuspendedStarGenerator",intrinsic_IsSuspendedStarGenerator,1,0), - JS_FN("ThrowStopIteration", intrinsic_ThrowStopIteration, 0,0), - JS_FN("GeneratorIsRunning", intrinsic_GeneratorIsRunning, 1,0), JS_FN("GeneratorSetClosed", intrinsic_GeneratorSetClosed, 1,0), JS_FN("IsArrayBuffer", intrinsic_IsInstanceOfBuiltin<ArrayBufferObject>, 1,0), JS_FN("IsSharedArrayBuffer", intrinsic_IsInstanceOfBuiltin<SharedArrayBufferObject>, 1,0), JS_FN("IsWrappedArrayBuffer",