Bug 1239666 - part 1, get rid of the default parameter. r=waldo
authorLars T Hansen <lhansen@mozilla.com>
Wed, 20 Jan 2016 15:03:16 +0100
changeset 280789 591c698895a24dee2387b5b8785e4a968941addf
parent 280788 9c8c14902800d80d248d8adf451c2f635fd611d2
child 280790 85f60fdd98facbcc80fa7edb22eca55ff534d68b
push id29922
push usercbook@mozilla.com
push dateThu, 21 Jan 2016 10:51:00 +0000
treeherdermozilla-central@977d78a8dd78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1239666
milestone46.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 1239666 - part 1, get rid of the default parameter. r=waldo
js/src/jsapi-tests/testArrayBufferView.cpp
js/src/jsapi-tests/testBug604087.cpp
js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
js/src/jsapi-tests/testChromeBuffer.cpp
js/src/jsapi-tests/testDebugger.cpp
js/src/jsapi-tests/testGCMarking.cpp
js/src/jsapi-tests/testMutedErrors.cpp
js/src/jsapi-tests/testStructuredClone.cpp
js/src/jsapi-tests/testUbiNode.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/shell/js.cpp
--- a/js/src/jsapi-tests/testArrayBufferView.cpp
+++ b/js/src/jsapi-tests/testArrayBufferView.cpp
@@ -132,17 +132,18 @@ bool TestViewType(JSContext* cx)
         uint32_t len;
         CHECK(obj == GetObjectAs(obj, &len, &shared2, &data2));
         CHECK(data1 == data2);
         CHECK(shared1 == shared2);
         CHECK(len == ExpectedLength);
     }
 
     JS::CompartmentOptions options;
-    JS::RootedObject otherGlobal(cx, JS_NewGlobalObject(cx, basicGlobalClass(), nullptr, JS::DontFireOnNewGlobalHook, options));
+    JS::RootedObject otherGlobal(cx, JS_NewGlobalObject(cx, basicGlobalClass(), nullptr,
+                                                        JS::DontFireOnNewGlobalHook, options));
     CHECK(otherGlobal);
 
     JS::Rooted<JSObject*> buffer(cx);
     {
         AutoCompartment ac(cx, otherGlobal);
         buffer = JS_NewArrayBuffer(cx, 8);
         CHECK(buffer);
         CHECK(buffer->as<ArrayBufferObject>().byteLength() == 8);
--- a/js/src/jsapi-tests/testBug604087.cpp
+++ b/js/src/jsapi-tests/testBug604087.cpp
@@ -55,19 +55,26 @@ static const JSWrapObjectCallbacks WrapO
 BEGIN_TEST(testBug604087)
 {
     js::SetWindowProxyClass(cx->runtime(), &OuterWrapperClass);
 
     js::WrapperOptions options;
     options.setClass(&OuterWrapperClass);
     options.setSingleton(true);
     JS::RootedObject outerObj(cx, js::Wrapper::New(cx, global, &js::Wrapper::singleton, options));
-    JS::RootedObject compartment2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
-    JS::RootedObject compartment3(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
-    JS::RootedObject compartment4(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
+    JS::CompartmentOptions globalOptions;
+    JS::RootedObject compartment2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+                                                         JS::FireOnNewGlobalHook, globalOptions));
+    CHECK(compartment2 != nullptr);
+    JS::RootedObject compartment3(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+                                                         JS::FireOnNewGlobalHook, globalOptions));
+    CHECK(compartment3 != nullptr);
+    JS::RootedObject compartment4(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+                                                         JS::FireOnNewGlobalHook, globalOptions));
+    CHECK(compartment4 != nullptr);
 
     JS::RootedObject c2wrapper(cx, wrap(cx, outerObj, compartment2));
     CHECK(c2wrapper);
     c2wrapper->as<js::ProxyObject>().setExtra(0, js::Int32Value(2));
 
     JS::RootedObject c3wrapper(cx, wrap(cx, outerObj, compartment3));
     CHECK(c3wrapper);
     c3wrapper->as<js::ProxyObject>().setExtra(0, js::Int32Value(3));
--- a/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
+++ b/js/src/jsapi-tests/testCallNonGenericMethodOnProxy.cpp
@@ -32,17 +32,19 @@ CustomMethod(JSContext* cx, unsigned arg
 {
   CallArgs args = CallArgsFromVp(argc, vp);
   return CallNonGenericMethod(cx, IsCustomClass, CustomMethodImpl, args);
 }
 
 BEGIN_TEST(test_CallNonGenericMethodOnProxy)
 {
   // Create the first global object and compartment
-  JS::RootedObject globalA(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
+  JS::CompartmentOptions options;
+  JS::RootedObject globalA(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+						  JS::FireOnNewGlobalHook, options));
   CHECK(globalA);
 
   JS::RootedObject customA(cx, JS_NewObject(cx, &CustomClass));
   CHECK(customA);
   JS_SetReservedSlot(customA, CUSTOM_SLOT, Int32Value(17));
 
   JS::RootedFunction customMethodA(cx, JS_NewFunction(cx, CustomMethod, 0, 0,
                                                       "customMethodA"));
@@ -50,17 +52,19 @@ BEGIN_TEST(test_CallNonGenericMethodOnPr
 
   JS::RootedValue rval(cx);
   CHECK(JS_CallFunction(cx, customA, customMethodA, JS::HandleValueArray::empty(),
                         &rval));
   CHECK_SAME(rval, Int32Value(17));
 
   // Now create the second global object and compartment...
   {
-    JS::RootedObject globalB(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
+    JS::CompartmentOptions options;
+    JS::RootedObject globalB(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+						    JS::FireOnNewGlobalHook, options));
     CHECK(globalB);
 
     // ...and enter it.
     JSAutoCompartment enter(cx, globalB);
     JS::RootedObject customB(cx, JS_NewObject(cx, &CustomClass));
     CHECK(customB);
     JS_SetReservedSlot(customB, CUSTOM_SLOT, Int32Value(42));
 
--- a/js/src/jsapi-tests/testChromeBuffer.cpp
+++ b/js/src/jsapi-tests/testChromeBuffer.cpp
@@ -45,18 +45,19 @@ CallTrusted(JSContext* cx, unsigned argc
     JS_RestoreFrameChain(cx);
     return ok;
 }
 
 BEGIN_TEST(testChromeBuffer)
 {
     JS_SetTrustedPrincipals(rt, &system_principals);
 
+    JS::CompartmentOptions options;
     trusted_glob.init(cx, JS_NewGlobalObject(cx, &global_class, &system_principals,
-                                             JS::FireOnNewGlobalHook));
+                                             JS::FireOnNewGlobalHook, options));
     CHECK(trusted_glob);
 
     JS::RootedFunction fun(cx);
 
     /*
      * Check that, even after untrusted content has exhausted the stack, code
      * compiled with "trusted principals" can run using reserved trusted-only
      * buffer space.
--- a/js/src/jsapi-tests/testDebugger.cpp
+++ b/js/src/jsapi-tests/testDebugger.cpp
@@ -10,17 +10,19 @@
 #include "jsapi-tests/tests.h"
 
 using namespace js;
 
 BEGIN_TEST(testDebugger_newScriptHook)
 {
     // Test that top-level indirect eval fires the newScript hook.
     CHECK(JS_DefineDebuggerObject(cx, global));
-    JS::RootedObject g(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
+    JS::CompartmentOptions options;
+    JS::RootedObject g(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+                                              JS::FireOnNewGlobalHook, options));
     CHECK(g);
     {
         JSAutoCompartment ae(cx, g);
         CHECK(JS_InitStandardClasses(cx, g));
     }
 
     JS::RootedObject gWrapper(cx, g);
     CHECK(JS_WrapObject(cx, &gWrapper));
--- a/js/src/jsapi-tests/testGCMarking.cpp
+++ b/js/src/jsapi-tests/testGCMarking.cpp
@@ -37,18 +37,19 @@ class CCWTestTracer : public JS::Callbac
 };
 
 BEGIN_TEST(testTracingIncomingCCWs)
 {
     // Get two globals, in two different zones.
 
     JS::RootedObject global1(cx, JS::CurrentGlobalOrNull(cx));
     CHECK(global1);
+    JS::CompartmentOptions options;
     JS::RootedObject global2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
-                                                    JS::FireOnNewGlobalHook));
+                                                    JS::FireOnNewGlobalHook, options));
     CHECK(global2);
     CHECK(global1->zone() != global2->zone());
 
     // Define an object in one zone, that is wrapped by a CCW in another zone.
 
     JS::RootedObject obj(cx, JS_NewPlainObject(cx));
     CHECK(obj->zone() == global1->zone());
 
--- a/js/src/jsapi-tests/testMutedErrors.cpp
+++ b/js/src/jsapi-tests/testMutedErrors.cpp
@@ -45,17 +45,19 @@ bool
 eval(const char* asciiChars, bool mutedErrors, JS::MutableHandleValue rval)
 {
     size_t len = strlen(asciiChars);
     mozilla::UniquePtr<char16_t[]> chars(new char16_t[len+1]);
     for (size_t i = 0; i < len; ++i)
         chars[i] = asciiChars[i];
     chars[len] = 0;
 
-    JS::RootedObject global(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
+    JS::CompartmentOptions globalOptions;
+    JS::RootedObject global(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
+						   JS::FireOnNewGlobalHook, globalOptions));
     CHECK(global);
     JSAutoCompartment ac(cx, global);
     CHECK(JS_InitStandardClasses(cx, global));
 
 
     JS::CompileOptions options(cx);
     options.setMutedErrors(mutedErrors)
            .setFileAndLine("", 0);
--- a/js/src/jsapi-tests/testStructuredClone.cpp
+++ b/js/src/jsapi-tests/testStructuredClone.cpp
@@ -150,18 +150,19 @@ BEGIN_TEST(testStructuredClone_SavedFram
         { "DONE", DONE }
     };
 
     const char* FILENAME = "filename.js";
 
     for (auto* pp = principalsToTest; pp->principals != DONE; pp++) {
         fprintf(stderr, "Testing with principals '%s'\n", pp->name);
 
+	JS::CompartmentOptions options;
         JS::RootedObject g(cx, JS_NewGlobalObject(cx, getGlobalClass(), pp->principals,
-                                                  JS::FireOnNewGlobalHook));
+                                                  JS::FireOnNewGlobalHook, options));
         CHECK(g);
         JSAutoCompartment ac(cx, g);
 
         CHECK(js::DefineTestingFunctions(cx, g, false, false));
 
         JS::RootedValue srcVal(cx);
         CHECK(evaluate("(function one() {                      \n"  // 1
                        "  return (function two() {             \n"  // 2
--- a/js/src/jsapi-tests/testUbiNode.cpp
+++ b/js/src/jsapi-tests/testUbiNode.cpp
@@ -60,18 +60,19 @@ const char16_t Concrete<FakeNode>::concr
 
 // ubi::Node::zone works
 BEGIN_TEST(test_ubiNodeZone)
 {
     RootedObject global1(cx, JS::CurrentGlobalOrNull(cx));
     CHECK(global1);
     CHECK(JS::ubi::Node(global1).zone() == cx->zone());
 
+    JS::CompartmentOptions globalOptions;
     RootedObject global2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
-                                                JS::FireOnNewGlobalHook));
+                                                JS::FireOnNewGlobalHook, globalOptions));
     CHECK(global2);
     CHECK(global1->zone() != global2->zone());
     CHECK(JS::ubi::Node(global2).zone() == global2->zone());
     CHECK(JS::ubi::Node(global2).zone() != global1->zone());
 
     JS::CompileOptions options(cx);
 
     // Create a string and a script in the original zone...
@@ -103,18 +104,19 @@ END_TEST(test_ubiNodeZone)
 
 // ubi::Node::compartment works
 BEGIN_TEST(test_ubiNodeCompartment)
 {
     RootedObject global1(cx, JS::CurrentGlobalOrNull(cx));
     CHECK(global1);
     CHECK(JS::ubi::Node(global1).compartment() == cx->compartment());
 
+    JS::CompartmentOptions globalOptions;
     RootedObject global2(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr,
-                                                JS::FireOnNewGlobalHook));
+                                                JS::FireOnNewGlobalHook, globalOptions));
     CHECK(global2);
     CHECK(global1->compartment() != global2->compartment());
     CHECK(JS::ubi::Node(global2).compartment() == global2->compartment());
     CHECK(JS::ubi::Node(global2).compartment() != global1->compartment());
 
     JS::CompileOptions options(cx);
 
     // Create a script in the original compartment...
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1874,17 +1874,17 @@ JS::CompartmentBehaviors&
 JS::CompartmentBehaviorsRef(JSContext* cx)
 {
     return cx->compartment()->behaviors();
 }
 
 JS_PUBLIC_API(JSObject*)
 JS_NewGlobalObject(JSContext* cx, const JSClass* clasp, JSPrincipals* principals,
                    JS::OnNewGlobalHookOption hookOption,
-                   const JS::CompartmentOptions& options /* = JS::CompartmentOptions() */)
+                   const JS::CompartmentOptions& options)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
 
     return GlobalObject::new_(cx, Valueify(clasp), principals, hookOption, options);
 }
 
 JS_PUBLIC_API(void)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2453,17 +2453,17 @@ enum OnNewGlobalHookOption {
     DontFireOnNewGlobalHook
 };
 
 } /* namespace JS */
 
 extern JS_PUBLIC_API(JSObject*)
 JS_NewGlobalObject(JSContext* cx, const JSClass* clasp, JSPrincipals* principals,
                    JS::OnNewGlobalHookOption hookOption,
-                   const JS::CompartmentOptions& options = JS::CompartmentOptions());
+                   const JS::CompartmentOptions& options);
 /**
  * Spidermonkey does not have a good way of keeping track of what compartments should be marked on
  * their own. We can mark the roots unconditionally, but marking GC things only relevant in live
  * compartments is hard. To mitigate this, we create a static trace hook, installed on each global
  * object, from which we can be sure the compartment is relevant, and mark it.
  *
  * It is still possible to specify custom trace hooks for global object classes. They can be
  * provided via the CompartmentOptions passed to JS_NewGlobalObject.
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2624,18 +2624,20 @@ SetStandardCompartmentOptions(JS::Compar
 {
     options.behaviors().setVersion(JSVERSION_DEFAULT);
     options.creationOptions().setSharedMemoryAndAtomicsEnabled(enableSharedMemory);
 }
 
 static JSObject*
 NewSandbox(JSContext* cx, bool lazy)
 {
+    JS::CompartmentOptions options;
+    SetStandardCompartmentOptions(options);
     RootedObject obj(cx, JS_NewGlobalObject(cx, &sandbox_class, nullptr,
-                                            JS::DontFireOnNewGlobalHook));
+                                            JS::DontFireOnNewGlobalHook, options));
     if (!obj)
         return nullptr;
 
     {
         JSAutoCompartment ac(cx, obj);
         if (!lazy && !JS_InitStandardClasses(cx, obj))
             return nullptr;