Bug 1165052 - Part 7: Implement native ArraySpeciesCreate wrapper. r=efaust
☠☠ backed out by eab50485823b ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Dec 2015 13:30:12 +0900
changeset 290612 aa59399ae8e09a153b63210b966c6364376c1e0c
parent 290611 0344adae92f3c3fe026a7c365689343cde287fe1
child 290613 0c725d3463f112ca08e0c0a05537a6077a915723
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1165052
milestone48.0a1
Bug 1165052 - Part 7: Implement native ArraySpeciesCreate wrapper. r=efaust
js/src/jsarray.cpp
js/src/vm/CommonPropertyNames.h
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -920,16 +920,37 @@ IsArraySpecies(JSContext* cx, HandleObje
     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);
 }
 
+/* static */ bool
+ArraySpeciesCreate(JSContext* cx, HandleObject origArray, uint32_t length, MutableHandleObject arr)
+{
+    RootedId createId(cx, NameToId(cx->names().ArraySpeciesCreate));
+    RootedFunction create(cx, JS::GetSelfHostedFunction(cx, "ArraySpeciesCreate", createId, 2));
+
+    FixedInvokeArgs<2> args(cx);
+
+    args.setCallee(ObjectValue(*create));
+    args.setThis(UndefinedValue());
+    args[0].setObject(*origArray);
+    args[1].set(NumberValue(length));
+
+    if (!Invoke(cx, args))
+        return false;
+
+    MOZ_ASSERT(args.rval().isObject());
+    arr.set(&args.rval().toObject());
+    return true;
+}
+
 #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);
 
--- a/js/src/vm/CommonPropertyNames.h
+++ b/js/src/vm/CommonPropertyNames.h
@@ -17,16 +17,17 @@
     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(ArraySpeciesCreate, ArraySpeciesCreate, "ArraySpeciesCreate") \
     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") \