Bug 1635839 - Part 2: Add a temporary testing function to create PrivateName symbols. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 02 Jun 2020 20:57:42 +0000
changeset 597699 e739f15aeaf8997dc22a28131b754c1a001e1deb
parent 597698 0880c9f6821008953ea4f4f12d2d6ee84767a636
child 597700 2b34ab462221a4721c8ae08cc24e2b019c61a74a
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1635839
milestone79.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 1635839 - Part 2: Add a temporary testing function to create PrivateName symbols. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D74103
js/src/builtin/TestingFunctions.cpp
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -6166,16 +6166,36 @@ static bool BaselineCompile(JSContext* c
 
 static bool ClearKeptObjects(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
   JS::ClearKeptObjects(cx);
   args.rval().setUndefined();
   return true;
 }
 
+static bool NewPrivateName(JSContext* cx, unsigned argc, Value* vp) {
+  CallArgs args = CallArgsFromVp(argc, vp);
+  if (!args.requireAtLeast(cx, "newPrivateName", 1)) {
+    return false;
+  }
+
+  RootedString desc(cx, ToString(cx, args[0]));
+  if (!desc) {
+    return false;
+  }
+
+  auto* sym = JS::Symbol::new_(cx, JS::SymbolCode::PrivateNameSymbol, desc);
+  if (!sym) {
+    return false;
+  }
+
+  args.rval().setSymbol(sym);
+  return true;
+}
+
 static bool PCCountProfiling_Start(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
 
   js::StartPCCountProfiling(cx);
 
   args.rval().setUndefined();
   return true;
 }
@@ -7105,16 +7125,20 @@ gc::ZealModeHelpText),
 
    JS_FN_HELP("clearKeptObjects", ClearKeptObjects, 0, 0,
 "clearKeptObjects()",
 "Perform the ECMAScript ClearKeptObjects operation, clearing the list of\n"
 "observed WeakRef targets that are kept alive until the next synchronous\n"
 "sequence of ECMAScript execution completes. This is used for testing\n"
 "WeakRefs.\n"),
 
+  JS_FN_HELP("newPrivateName", NewPrivateName, 1, 0,
+"newPrivateName(desc)",
+"Create a new PrivateName symbol."),
+
     JS_FS_HELP_END
 };
 // clang-format on
 
 // clang-format off
 static const JSFunctionSpecWithHelp FuzzingUnsafeTestingFunctions[] = {
 #if defined(DEBUG) && !defined(ENABLE_NEW_REGEXP)
     JS_FN_HELP("parseRegExp", ParseRegExp, 3, 0,