author | Tooru Fujisawa <arai_a@mac.com> |
Wed, 23 Dec 2015 12:43:15 +0900 | |
changeset 292155 | f15991a13732a4d966fad452bfc8f769fb258859 |
parent 292154 | 35b9afd414ed452fdfee91b89a6dc51de9e3868c |
child 292156 | ae46f7e09a221fa5006e4abd2ba458998328d5c4 |
push id | 74764 |
push user | arai_a@mac.com |
push date | Thu, 07 Apr 2016 10:49:15 +0000 |
treeherder | mozilla-inbound@4d0f975a2311 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | efaust |
bugs | 1165052 |
milestone | 48.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
|
js/src/jsarray.cpp | file | annotate | diff | comparison | revisions | |
js/src/vm/CommonPropertyNames.h | file | annotate | diff | comparison | revisions |
--- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -27,16 +27,17 @@ #include "ds/Sort.h" #include "gc/Heap.h" #include "jit/InlinableNatives.h" #include "js/Class.h" #include "js/Conversions.h" #include "vm/ArgumentsObject.h" #include "vm/Interpreter.h" +#include "vm/SelfHosting.h" #include "vm/Shape.h" #include "vm/StringBuffer.h" #include "vm/TypedArrayCommon.h" #include "jsatominlines.h" #include "vm/ArgumentsObject-inl.h" #include "vm/ArrayObject-inl.h" @@ -861,16 +862,47 @@ AddLengthProperty(ExclusiveContext* cx, MOZ_ASSERT(!obj->lookup(cx, lengthId)); return NativeObject::addProperty(cx, obj, lengthId, array_length_getter, array_length_setter, SHAPE_INVALID_SLOT, JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_SHADOWABLE, 0, /* allowDictionary = */ false); } +static bool +IsArrayConstructor(const Value& v) +{ + // This must only return true if v is *the* Array constructor for the + // current compartment; we rely on the fact that any other Array + // constructor would be represented as a wrapper. + return v.isObject() && + v.toObject().is<JSFunction>() && + v.toObject().as<JSFunction>().isNative() && + v.toObject().as<JSFunction>().native() == ArrayConstructor; +} + +/* static */ bool +IsArraySpecies(JSContext* cx, HandleObject origArray) +{ + RootedValue ctor(cx); + if (!GetPropertyPure(cx, origArray, NameToId(cx->names().constructor), ctor.address())) + return false; + + if (!IsArrayConstructor(ctor)) + return false; + + RootedObject ctorObj(cx, &ctor.toObject()); + RootedId speciesId(cx, SYMBOL_TO_JSID(cx->wellKnownSymbols().species)); + JSFunction* getter; + if (!GetGetterPure(cx, ctorObj, speciesId, &getter)) + return false; + + return IsSelfHostedFunctionWithName(getter, cx->names().ArraySpecies); +} + #if JS_HAS_TOSOURCE static bool array_toSource(JSContext* cx, unsigned argc, Value* vp) { JS_CHECK_RECURSION(cx, return false); CallArgs args = CallArgsFromVp(argc, vp); @@ -2835,28 +2867,16 @@ array_isArray(JSContext* cx, unsigned ar if (!IsArray(cx, obj, &isArray)) return false; } args.rval().setBoolean(isArray); return true; } static bool -IsArrayConstructor(const Value& v) -{ - // This must only return true if v is *the* Array constructor for the - // current compartment; we rely on the fact that any other Array - // constructor would be represented as a wrapper. - return v.isObject() && - v.toObject().is<JSFunction>() && - v.toObject().as<JSFunction>().isNative() && - v.toObject().as<JSFunction>().native() == ArrayConstructor; -} - -static bool ArrayFromCallArgs(JSContext* cx, CallArgs& args, HandleObject proto = nullptr) { JSObject* obj = NewCopiedArrayForCallingAllocationSite(cx, args.array(), args.length(), proto); if (!obj) return false; args.rval().setObject(*obj); return true;
--- a/js/src/vm/CommonPropertyNames.h +++ b/js/src/vm/CommonPropertyNames.h @@ -16,16 +16,17 @@ macro(allowContentSpread, allowContentSpread, "allowContentSpread") \ macro(anonymous, anonymous, "anonymous") \ macro(Any, Any, "Any") \ macro(apply, apply, "apply") \ macro(arguments, arguments, "arguments") \ macro(as, as, "as") \ macro(ArrayBufferSpecies, ArrayBufferSpecies, "ArrayBufferSpecies") \ macro(ArrayIteratorNext, ArrayIteratorNext, "ArrayIteratorNext") \ + macro(ArraySpecies, ArraySpecies, "ArraySpecies") \ macro(ArrayType, ArrayType, "ArrayType") \ macro(ArrayValues, ArrayValues, "ArrayValues") \ macro(ArrayValuesAt, ArrayValuesAt, "ArrayValuesAt") \ macro(Async, Async, "Async") \ macro(Bool8x16, Bool8x16, "Bool8x16") \ macro(Bool16x8, Bool16x8, "Bool16x8") \ macro(Bool32x4, Bool32x4, "Bool32x4") \ macro(Bool64x2, Bool64x2, "Bool64x2") \