Bug 1165053 - Part 5: Add native SpeciesConstructor wrapper. r=lth
☠☠ backed out by 02e1bd9d6ee4 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Sun, 20 Dec 2015 19:15:09 +0900
changeset 290599 71ef5f8009ec19ad4bfdbf009bfc0b11ffd788d2
parent 290598 fdef3048ed7784fd5d8ea97ebd92bc1946ce175c
child 290600 27189d8e678de79cb4b8e00ec6230cd82442e831
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)
reviewerslth
bugs1165053
milestone48.0a1
Bug 1165053 - Part 5: Add native SpeciesConstructor wrapper. r=lth
js/src/jsobj.cpp
js/src/jsobj.h
js/src/vm/CommonPropertyNames.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3856,8 +3856,29 @@ JSObject::constructorDisplayAtom(JSConte
 
 JSAtom*
 JSObject::maybeConstructorDisplayAtom() const
 {
     if (hasLazyGroup())
         return nullptr;
     return displayAtomFromObjectGroup(*group());
 }
+
+bool
+js::SpeciesConstructor(JSContext* cx, HandleObject obj, HandleValue defaultCtor, MutableHandleValue pctor)
+{
+    HandlePropertyName shName = cx->names().SpeciesConstructor;
+    RootedValue func(cx);
+    if (!GlobalObject::getSelfHostedFunction(cx, cx->global(), shName, shName, 2, &func))
+        return false;
+    InvokeArgs args(cx);
+    if (!args.init(2))
+        return false;
+    args.setCallee(func);
+    args.setThis(UndefinedValue());
+    args[0].setObject(*obj);
+    args[1].set(defaultCtor);
+    if (!Invoke(cx, args))
+        return false;
+
+    pctor.set(args.rval());
+    return true;
+}
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1329,11 +1329,14 @@ FreezeObject(JSContext* cx, HandleObject
 
 /*
  * ES6 rev 29 (6 Dec 2014) 7.3.14. Code shared by Object.isSealed and
  * Object.isFrozen.
  */
 extern bool
 TestIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level, bool* resultp);
 
+extern bool
+SpeciesConstructor(JSContext* cx, HandleObject obj, HandleValue defaultCtor, MutableHandleValue pctor);
+
 }  /* namespace js */
 
 #endif /* jsobj_h */
--- a/js/src/vm/CommonPropertyNames.h
+++ b/js/src/vm/CommonPropertyNames.h
@@ -227,16 +227,17 @@
     macro(scripts, scripts, "scripts") \
     macro(second, second, "second") \
     macro(sensitivity, sensitivity, "sensitivity") \
     macro(separator, separator, "separator") \
     macro(set, set, "set") \
     macro(shape, shape, "shape") \
     macro(size, size, "size") \
     macro(source, source, "source") \
+    macro(SpeciesConstructor, SpeciesConstructor, "SpeciesConstructor") \
     macro(stack, stack, "stack") \
     macro(star, star, "*") \
     macro(starDefaultStar, starDefaultStar, "*default*") \
     macro(startTimestamp, startTimestamp, "startTimestamp") \
     macro(static, static_, "static") \
     macro(sticky, sticky, "sticky") \
     macro(strings, strings, "strings") \
     macro(StructType, StructType, "StructType") \