Bug 1165053 - Part 5: Add native SpeciesConstructor wrapper. r=lth
authorTooru Fujisawa <arai_a@mac.com>
Sun, 20 Dec 2015 19:15:09 +0900
changeset 292146 2fc8c19b6821e2916f8c0b29ecac2373747df57b
parent 292145 35e1fd91ca8900481a4dfc7be0110f619d3ca1e9
child 292147 9811622a5e7c878809e1155f3c088e13f9cb9128
push id74764
push userarai_a@mac.com
push dateThu, 07 Apr 2016 10:49:15 +0000
treeherdermozilla-inbound@4d0f975a2311 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1165053
milestone48.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
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
@@ -3846,8 +3846,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
@@ -1331,11 +1331,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
@@ -230,16 +230,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") \