Backed out 2 changesets (bug 1224722, bug 1226551) for Linux x64 opt Valgrind failure. r=bustage
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 27 Nov 2015 00:45:05 +0100
changeset 274400 496bd6468e61d8de9c8bc0e61bb641e3ed007a0a
parent 274399 e9fee5618ac1e94d66faab5885a35a71e19c2867
child 274401 d28a15be2c516718cf9ff1be064881455fb643b0
push id68569
push userarchaeopteryx@coole-files.de
push dateThu, 26 Nov 2015 23:45:26 +0000
treeherdermozilla-inbound@496bd6468e61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1224722, 1226551
milestone45.0a1
backs out5966ace0c93292c6a2dbca3eeedcbaa9b2dae701
f477eb89443b7daffb2a0bbda72fbfa2977b7f32
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
Backed out 2 changesets (bug 1224722, bug 1226551) for Linux x64 opt Valgrind failure. r=bustage Backed out changeset 5966ace0c932 (bug 1226551) Backed out changeset f477eb89443b (bug 1224722)
js/src/builtin/TestingFunctions.cpp
js/src/jsapi-tests/moz.build
js/src/jsapi-tests/testEvaluateSelfHosted.cpp
js/src/jsapi-tests/testStructuredClone.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsatom.cpp
js/src/jscntxt.cpp
js/src/jsscript.cpp
js/src/shell/js.cpp
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
js/src/vm/SelfHosting.cpp
js/src/vm/SelfHosting.h
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -3072,32 +3072,16 @@ GetModuleEnvironmentValue(JSContext* cx,
     RootedString name(cx, args[1].toString());
     RootedId id(cx);
     if (!JS_StringToId(cx, name, &id))
         return false;
 
     return GetProperty(cx, env, env, id, args.rval());
 }
 
-static bool
-GetSelfHostedValue(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-
-    if (args.length() != 1 || !args[0].isString()) {
-        JS_ReportError(cx, "First and only argument should be a string");
-        return false;
-    }
-    RootedAtom srcAtom(cx, ToAtom<CanGC>(cx, args[0]));
-    if (!srcAtom)
-        return false;
-    RootedPropertyName srcName(cx, srcAtom->asPropertyName());
-    return cx->runtime()->cloneSelfHostedValue(cx, srcName, args.rval());
-}
-
 static const JSFunctionSpecWithHelp TestingFunctions[] = {
     JS_FN_HELP("gc", ::GC, 0, 0,
 "gc([obj] | 'compartment' [, 'shrinking'])",
 "  Run the garbage collector. When obj is given, GC only its compartment.\n"
 "  If 'compartment' is given, GC any compartments that were scheduled for\n"
 "  GC via schedulegc.\n"
 "  If 'shrinking' is passed as the optional second argument, perform a\n"
 "  shrinking GC rather than a normal GC."),
@@ -3571,22 +3555,16 @@ gc::ZealModeHelpText),
     JS_FN_HELP("getModuleEnvironmentNames", GetModuleEnvironmentNames, 1, 0,
 "getModuleEnvironmentNames(module)",
 "  Get the list of a module environment's bound names for a specified module.\n"),
 
     JS_FN_HELP("getModuleEnvironmentValue", GetModuleEnvironmentValue, 2, 0,
 "getModuleEnvironmentValue(module, name)",
 "  Get the value of a bound name in a module environment.\n"),
 
-JS_FN_HELP("getSelfHostedValue", GetSelfHostedValue, 1, 0,
-"getSelfHostedValue()",
-"  Get a self-hosted value by its name. Note that these values don't get \n"
-"  cached, so repeatedly getting the same value creates multiple distinct clones."),
-
-
     JS_FS_HELP_END
 };
 
 static const JSPropertySpec TestingProperties[] = {
     JS_PSG("timesAccessed", TimesAccessed, 0),
     JS_PS_END
 };
 
--- a/js/src/jsapi-tests/moz.build
+++ b/js/src/jsapi-tests/moz.build
@@ -22,17 +22,16 @@ UNIFIED_SOURCES += [
     'testDebugger.cpp',
     'testDeepFreeze.cpp',
     'testDefineGetterSetterNonEnumerable.cpp',
     'testDefineProperty.cpp',
     'testDefinePropertyIgnoredAttributes.cpp',
     'testDifferentNewTargetInvokeConstructor.cpp',
     'testEnclosingFunction.cpp',
     'testErrorCopying.cpp',
-    'testEvaluateSelfHosted.cpp',
     'testException.cpp',
     'testExternalStrings.cpp',
     'testFindSCCs.cpp',
     'testForOfIterator.cpp',
     'testForwardSetProperty.cpp',
     'testFreshGlobalEvalRedefinition.cpp',
     'testFunctionProperties.cpp',
     'testGCAllocator.cpp',
deleted file mode 100644
--- a/js/src/jsapi-tests/testEvaluateSelfHosted.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "builtin/TestingFunctions.h"
-
-#include "jsapi-tests/tests.h"
-
-static int32_t contentGlobalFunctionCallResult = 0;
-
-static bool
-IntrinsicFunction(JSContext* cx, unsigned argc, JS::Value* vp)
-{
-    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-    args.rval().setInt32(42);
-    return true;
-}
-
-static bool
-ContentGlobalFunction(JSContext* cx, unsigned argc, JS::Value* vp)
-{
-    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-    MOZ_ASSERT(args.length() == 1);
-    contentGlobalFunctionCallResult = args[0].toInt32();
-    args.rval().setUndefined();
-    return true;
-}
-
-static const JSFunctionSpec intrinsic_functions[] = {
-    JS_FN("intrinsicFunction", IntrinsicFunction, 0,0),
-    JS_FS_END
-};
-
-BEGIN_TEST(testEvaluateSelfHosted)
-{
-    CHECK(js::DefineTestingFunctions(cx, global, false, false));
-    CHECK(JS_DefineFunction(cx, global, "contentGlobalFunction", ContentGlobalFunction, 0, 0));
-
-    JS::RootedValue v(cx);
-    EVAL("getSelfHostedValue('customSelfHostedFunction')();", &v);
-    CHECK(!JS_IsExceptionPending(cx));
-    CHECK(contentGlobalFunctionCallResult == 42);
-
-    return true;
-}
-
-virtual JSContext* createContext() override {
-    JSContext* cx = JS_NewContext(rt, 8192);
-    if (!cx)
-        return nullptr;
-    const char *selfHostedCode = "function customSelfHostedFunction() {"
-                                 "let intrinsicResult = intrinsicFunction();"
-                                 "callFunction(global.contentGlobalFunction, global,"
-                                 "             intrinsicResult);"
-                                 "}";
-    if (!JS::AddSelfHostingIntrinsics(rt, intrinsic_functions) ||
-        !JS::EvaluateSelfHosted(rt, selfHostedCode, strlen(selfHostedCode), "testing-sh"))
-    {
-        return nullptr;
-    }
-    return cx;
-}
-END_TEST(testEvaluateSelfHosted)
--- a/js/src/jsapi-tests/testStructuredClone.cpp
+++ b/js/src/jsapi-tests/testStructuredClone.cpp
@@ -209,20 +209,20 @@ BEGIN_TEST(testStructuredClone_SavedFram
             } else {
                 // For our singleton principals, we should always get the same
                 // pointer back.
                 CHECK(js::ReconstructedSavedFramePrincipals::is(pp->principals) ||
                       pp->principals == nullptr);
                 CHECK(f.getPrincipals() == pp->principals);
             }
 
-            CHECK(js::EqualStrings(f.getSource(), srcFrame->getSource()));
+            CHECK(EqualStrings(f.getSource(), srcFrame->getSource()));
             CHECK(f.getLine() == srcFrame->getLine());
             CHECK(f.getColumn() == srcFrame->getColumn());
-            CHECK(js::EqualStrings(f.getFunctionDisplayName(), srcFrame->getFunctionDisplayName()));
+            CHECK(EqualStrings(f.getFunctionDisplayName(), srcFrame->getFunctionDisplayName()));
 
             srcFrame = srcFrame->getParent();
         }
 
         // Four function frames + one global frame.
         CHECK(framesCopied == 4);
     }
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1829,21 +1829,16 @@ JS::CompartmentOptionsRef(JSContext* cx)
 JS_PUBLIC_API(JSObject*)
 JS_NewGlobalObject(JSContext* cx, const JSClass* clasp, JSPrincipals* principals,
                    JS::OnNewGlobalHookOption hookOption,
                    const JS::CompartmentOptions& options /* = JS::CompartmentOptions() */)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
 
-    if (!cx->runtime()->hasContentGlobals) {
-        if (!cx->runtime()->completeInitialization(cx))
-            return nullptr;
-    }
-
     return GlobalObject::new_(cx, Valueify(clasp), principals, hookOption, options);
 }
 
 JS_PUBLIC_API(void)
 JS_GlobalObjectTraceHook(JSTracer* trc, JSObject* global)
 {
     MOZ_ASSERT(global->is<GlobalObject>());
 
@@ -4402,17 +4397,16 @@ JS_DecompileFunction(JSContext* cx, Hand
     assertSameCompartment(cx, fun);
     return FunctionToString(cx, fun, !(indent & JS_DONT_PRETTY_PRINT));
 }
 
 MOZ_NEVER_INLINE static bool
 ExecuteScript(JSContext* cx, HandleObject scope, HandleScript script, Value* rval)
 {
     MOZ_ASSERT(!cx->runtime()->isAtomsCompartment(cx->compartment()));
-    MOZ_ASSERT(!cx->runtime()->isSelfHostingCompartment(cx->compartment()));
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, scope, script);
     MOZ_ASSERT_IF(!IsGlobalLexicalScope(scope), script->hasNonSyntacticScope());
     AutoLastFrameCheck lfc(cx);
     return Execute(cx, script, *scope, rval);
 }
 
@@ -4615,53 +4609,16 @@ JS::Evaluate(JSContext* cx, AutoObjectVe
 
 JS_PUBLIC_API(bool)
 JS::Evaluate(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
              const char* filename, MutableHandleValue rval)
 {
     return ::Evaluate(cx, optionsArg, filename, rval);
 }
 
-JS_PUBLIC_API(bool)
-JS::EvaluateSelfHosted(JSRuntime* rt, const char16_t* chars, size_t length, const char* filename)
-{
-    return rt->evaluateSelfHosted(chars, length, filename);
-}
-
-JS_PUBLIC_API(bool)
-JS::EvaluateSelfHosted(JSRuntime* rt, const char* bytes, size_t length, const char* filename)
-{
-    JSContext* cx = rt->contextList.getFirst();
-    char16_t* chars = UTF8CharsToNewTwoByteCharsZ(cx, JS::UTF8Chars(bytes, length), &length).get();
-    if (!chars)
-        return false;
-    return EvaluateSelfHosted(rt, chars, length, filename);
-}
-
-JS_PUBLIC_API(bool)
-JS::EvaluateSelfHosted(JSRuntime* rt, const char* filename)
-{
-    JSContext* cx = rt->contextList.getFirst();
-    FileContents buffer(cx);
-    {
-        AutoFile file;
-        if (!file.open(cx, filename) || !file.readAll(cx, buffer))
-            return false;
-    }
-    char* bytes = buffer.begin();
-    size_t length = buffer.length();
-    return EvaluateSelfHosted(rt, bytes, length, filename);
-}
-
-JS_PUBLIC_API(bool)
-JS::AddSelfHostingIntrinsics(JSRuntime* rt, const JSFunctionSpec* intrinsicFunctions)
-{
-    return rt->addSelfHostingIntrinsics(intrinsicFunctions);
-}
-
 static JSObject*
 JS_NewHelper(JSContext* cx, HandleObject ctor, const JS::HandleValueArray& inputArgs)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, ctor, inputArgs);
 
     RootedValue ctorVal(cx, ObjectValue(*ctor));
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4117,53 +4117,16 @@ Evaluate(JSContext* cx, const ReadOnlyCo
 
 /**
  * Evaluate the given file in the scope of the current global of cx.
  */
 extern JS_PUBLIC_API(bool)
 Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options,
          const char* filename, JS::MutableHandleValue rval);
 
-/**
- * Evaluate the given character buffer as self-hosted JS.
- *
- * Can only be used in a process' main runtime and before the first global
- * object is created, because the self-hosting compartment is shared between
- * all runtimes in a process, and frozen upon creation of the first content
- * global in the main runtime.
- */
-extern JS_PUBLIC_API(bool)
-EvaluateSelfHosted(JSRuntime* rt, const char16_t* chars, size_t length, const char* filename);
-
-/**
- * Evaluate the given byte buffer as UTF8-encoded self-hosted JS.
- *
- * See comment in the char16_t buffer-taking overload above.
- */
-extern JS_PUBLIC_API(bool)
-EvaluateSelfHosted(JSRuntime* rt, const char* bytes, size_t length, const char* filename);
-
-/**
- * Load and evaluate the given file path as UTF8-encoded self-hosted JS.
- *
- * See comment in the char16_t buffer-taking overload above.
- */
-extern JS_PUBLIC_API(bool)
-EvaluateSelfHosted(JSRuntime* rt, const char* filename);
-
-/**
- * Add functions available to self-hosted code.
- *
- * Must be called before the self-hosted code using it is run with
- * EvaluateSelfHosted, and thus has the same restrictions regarding when it
- * can be used.
- */
-extern JS_PUBLIC_API(bool)
-AddSelfHostingIntrinsics(JSRuntime* rt, const JSFunctionSpec* intrinsicFunctions);
-
 } /* namespace JS */
 
 extern JS_PUBLIC_API(bool)
 JS_CheckForInterrupt(JSContext* cx);
 
 /*
  * These functions allow setting an interrupt callback that will be called
  * from the JS thread some time after any thread triggered the callback using
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -290,25 +290,24 @@ AtomIsPinned(JSContext* cx, JSAtom* atom
 {
     /* We treat static strings as interned because they're never collected. */
     if (StaticStrings::isStatic(atom))
         return true;
 
     AtomHasher::Lookup lookup(atom);
 
     /* Likewise, permanent strings are considered to be interned. */
-    if (cx->isPermanentAtomsInitialized()) {
-        AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
-        if (p)
-            return true;
-    }
+    MOZ_ASSERT(cx->isPermanentAtomsInitialized());
+    AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
+    if (p)
+        return true;
 
     AutoLockForExclusiveAccess lock(cx);
 
-    AtomSet::Ptr p = cx->runtime()->atoms().lookup(lookup);
+    p = cx->runtime()->atoms().lookup(lookup);
     if (!p)
         return false;
 
     return p->isPinned();
 }
 
 /* |tbchars| must not point into an inline or short string. */
 template <typename CharT>
@@ -380,25 +379,24 @@ js::AtomizeString(ExclusiveContext* cx, 
         JSAtom& atom = str->asAtom();
         /* N.B. static atoms are effectively always interned. */
         if (pin != PinAtom || js::StaticStrings::isStatic(&atom))
             return &atom;
 
         AtomHasher::Lookup lookup(&atom);
 
         /* Likewise, permanent atoms are always interned. */
-        if (cx->isPermanentAtomsInitialized()) {
-            AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
-            if (p)
-                return &atom;
-        }
+        MOZ_ASSERT(cx->isPermanentAtomsInitialized());
+        AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
+        if (p)
+            return &atom;
 
         AutoLockForExclusiveAccess lock(cx);
 
-        AtomSet::Ptr p = cx->atoms().lookup(lookup);
+        p = cx->atoms().lookup(lookup);
         MOZ_ASSERT(p); /* Non-static atom must exist in atom state set. */
         MOZ_ASSERT(p->asPtr() == &atom);
         MOZ_ASSERT(pin == PinAtom);
         p->setPinned(bool(pin));
         return &atom;
     }
 
     JSLinearString* linear = str->ensureLinear(cx);
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -115,16 +115,20 @@ js::NewContext(JSRuntime* rt, size_t sta
      * state, with zeroes and nulls stored in the default-initialized remainder
      * of the struct.
      */
     if (!rt->haveCreatedContext) {
         JS_BeginRequest(cx);
         bool ok = rt->initializeAtoms(cx);
         if (ok)
             ok = rt->initSelfHosting(cx);
+
+        if (ok && !rt->parentRuntime)
+            ok = rt->transformToPermanentAtoms(cx);
+
         JS_EndRequest(cx);
 
         if (!ok) {
             DestroyContext(cx, DCM_NEW_FAILED);
             return nullptr;
         }
 
         rt->haveCreatedContext = true;
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3610,17 +3610,17 @@ CreateEmptyScriptForClone(JSContext* cx,
      * Wrap the script source object as needed. Self-hosted scripts may be
      * in another runtime, so lazily create a new script source object to
      * use for them.
      */
     RootedObject sourceObject(cx);
     if (cx->runtime()->isSelfHostingCompartment(src->compartment())) {
         if (!cx->compartment()->selfHostingScriptSource) {
             CompileOptions options(cx);
-            FillSelfHostingCompileOptions(options, "self-hosted");
+            FillSelfHostingCompileOptions(options);
 
             ScriptSourceObject* obj = frontend::CreateScriptSourceObject(cx, options);
             if (!obj)
                 return nullptr;
             cx->compartment()->selfHostingScriptSource.set(obj);
         }
         sourceObject = cx->compartment()->selfHostingScriptSource;
     } else {
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -604,24 +604,16 @@ RunModule(JSContext* cx, const char* fil
 
     RootedValue value(cx);
     if (!JS_CallFunction(cx, loaderObj, importFun, args, &value)) {
         sr->exitCode = EXITCODE_RUNTIME_ERROR;
         return;
     }
 }
 
-static void
-RunSelfHosted(JSContext* cx, const char* filename)
-{
-    ShellRuntime* sr = GetShellRuntime(cx);
-    if (!JS::EvaluateSelfHosted(cx->runtime(), filename))
-        sr->exitCode = EXITCODE_RUNTIME_ERROR;
-}
-
 static bool
 EvalAndPrint(JSContext* cx, const char* bytes, size_t length,
              int lineno, bool compileOnly, FILE* out)
 {
     // Eval.
     JS::CompileOptions options(cx);
     options.setIntroductionType("js shell interactive")
            .setUTF8(true)
@@ -4032,16 +4024,33 @@ ObjectEmulatingUndefined(JSContext* cx, 
 
     RootedObject obj(cx, JS_NewObject(cx, &cls));
     if (!obj)
         return false;
     args.rval().setObject(*obj);
     return true;
 }
 
+static bool
+GetSelfHostedValue(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+
+    if (args.length() != 1 || !args[0].isString()) {
+        JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS,
+                             "getSelfHostedValue");
+        return false;
+    }
+    RootedAtom srcAtom(cx, ToAtom<CanGC>(cx, args[0]));
+    if (!srcAtom)
+        return false;
+    RootedPropertyName srcName(cx, srcAtom->asPropertyName());
+    return cx->runtime()->cloneSelfHostedValue(cx, srcName, args.rval());
+}
+
 class ShellSourceHook: public SourceHook {
     // The function we should call to lazily retrieve source code.
     PersistentRootedFunction fun;
 
   public:
     ShellSourceHook(JSContext* cx, JSFunction& fun) : fun(cx, &fun) {}
 
     bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) {
@@ -5133,16 +5142,21 @@ static const JSFunctionSpecWithHelp shel
     JS_FS_HELP_END
 };
 
 static const JSFunctionSpecWithHelp fuzzing_unsafe_functions[] = {
     JS_FN_HELP("clone", Clone, 1, 0,
 "clone(fun[, scope])",
 "  Clone function object."),
 
+    JS_FN_HELP("getSelfHostedValue", GetSelfHostedValue, 1, 0,
+"getSelfHostedValue()",
+"  Get a self-hosted value by its name. Note that these values don't get \n"
+"  cached, so repeatedly getting the same value creates multiple distinct clones."),
+
     JS_FN_HELP("line2pc", LineToPC, 0, 0,
 "line2pc([fun,] line)",
 "  Map line number to PC."),
 
     JS_FN_HELP("pc2line", PCToLine, 0, 0,
 "pc2line(fun[, pc])",
 "  Map PC to line number."),
 
@@ -6482,26 +6496,16 @@ Shell(JSContext* cx, OptionParser* op, c
     if (op->getBoolOption("fuzzing-safe"))
         fuzzingSafe = true;
     else
         fuzzingSafe = (getenv("MOZ_FUZZING_SAFE") && getenv("MOZ_FUZZING_SAFE")[0] != '0');
 
     if (op->getBoolOption("disable-oom-functions"))
         disableOOMFunctions = true;
 
-    ShellRuntime* sr = GetShellRuntime(cx);
-    MultiStringRange selfHostedPaths = op->getMultiStringOption("self-hosted");
-    while (!selfHostedPaths.empty()) {
-        char* path = selfHostedPaths.front();
-        RunSelfHosted(cx, path);
-        if (sr->exitCode)
-            return sr->exitCode;
-        selfHostedPaths.popFront();
-    }
-
     RootedObject glob(cx);
     JS::CompartmentOptions options;
     options.setVersion(JSVERSION_DEFAULT);
     glob = NewGlobalObject(cx, options, nullptr);
     if (!glob)
         return 1;
 
     JSAutoCompartment ac(cx, glob);
@@ -6585,17 +6589,16 @@ main(int argc, char** argv, char** envp)
         "all options have been processed. Just-In-Time compilation modes may be enabled via "
         "command line options.");
     op.setDescriptionWidth(72);
     op.setHelpWidth(80);
     op.setVersion(JS_GetImplementationVersion());
 
     if (!op.addMultiStringOption('f', "file", "PATH", "File path to run")
         || !op.addMultiStringOption('m', "module", "PATH", "Module path to run")
-        || !op.addMultiStringOption('\0', "self-hosted", "PATH", "File path to run as self-hosted")
         || !op.addMultiStringOption('e', "execute", "CODE", "Inline code to run")
         || !op.addBoolOption('i', "shell", "Enter prompt after running code")
         || !op.addBoolOption('c', "compileonly", "Only compile, don't run (syntax checking mode)")
         || !op.addBoolOption('w', "warnings", "Emit warnings")
         || !op.addBoolOption('W', "nowarnings", "Don't emit warnings")
         || !op.addBoolOption('s', "strict", "Check strictness")
         || !op.addBoolOption('D', "dump-bytecode", "Dump bytecode with exec count for all scripts")
         || !op.addBoolOption('b', "print-timing", "Print sub-ms runtime for each file that's run")
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -185,17 +185,16 @@ JSRuntime::JSRuntime(JSRuntime* parentRu
     positiveInfinityValue(DoubleValue(PositiveInfinity<double>())),
     emptyString(nullptr),
     spsProfiler(thisFromCtor()),
     profilingScripts(false),
     suppressProfilerSampling(false),
     hadOutOfMemory(false),
     handlingInitFailure(false),
     haveCreatedContext(false),
-    hasContentGlobals(false),
     allowRelazificationForTesting(false),
     data(nullptr),
     signalHandlersInstalled_(false),
     canUseSignalHandlers_(false),
     defaultFreeOp_(thisFromCtor()),
     debuggerMutations(0),
     securityCallbacks(const_cast<JSSecurityCallbacks*>(&NullSecurityCallbacks)),
     DOMcallbacks(nullptr),
@@ -351,31 +350,16 @@ JSRuntime::init(uint32_t maxbytes, uint3
         return false;
 
     if (!fx.initInstance())
         return false;
 
     return true;
 }
 
-bool
-JSRuntime::completeInitialization(JSContext* cx)
-{
-    MOZ_ASSERT(!hasContentGlobals);
-    hasContentGlobals = true;
-    if (parentRuntime)
-        return true;
-
-    MOZ_ASSERT(!parentRuntime);
-    MOZ_ASSERT(!permanentAtoms);
-    MOZ_ASSERT(selfHostingGlobal_);
-    JSAutoRequest ar(cx);
-    return transformToPermanentAtoms(cx);
-}
-
 JSRuntime::~JSRuntime()
 {
     MOZ_ASSERT(!isHeapBusy());
 
     fx.destroyInstance();
 
     if (gcInitialized) {
         /* Free source hook early, as its destructor may want to delete roots. */
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -922,17 +922,18 @@ struct JSRuntime : public JS::shadow::Ru
     js::jit::JitRuntime* jitRuntime_;
 
     /*
      * Self-hosting state cloned on demand into other compartments. Shared with the parent
      * runtime if there is one.
      */
     js::NativeObject* selfHostingGlobal_;
 
-    static js::GlobalObject* createSelfHostingGlobal(JSContext* cx);
+    static js::GlobalObject*
+    createSelfHostingGlobal(JSContext* cx);
 
     /* Space for interpreter frames. */
     js::InterpreterStack interpreterStack_;
 
     js::jit::JitRuntime* createJitRuntime(JSContext* cx);
 
   public:
     js::jit::JitRuntime* getJitRuntime(JSContext* cx) {
@@ -948,27 +949,17 @@ struct JSRuntime : public JS::shadow::Ru
         return interpreterStack_;
     }
 
     //-------------------------------------------------------------------------
     // Self-hosting support
     //-------------------------------------------------------------------------
 
     bool initSelfHosting(JSContext* cx);
-    bool evaluateSelfHosted(const char16_t* chars, size_t length, const char* filename);
-    bool addSelfHostingIntrinsics(const JSFunctionSpec* intrinsicFunctions);
     void finishSelfHosting();
-    /*
-     * Completes the runtime's initialization by freezing the initial set of
-     * atoms. To be invoked before creating the first content global, and
-     * delayed until then to enable execution of multiple self-hosted scripts
-     * before the self-hosting compartment is frozen to be shared with child
-     * runtimes.
-     */
-    bool completeInitialization(JSContext* cx);
     void markSelfHostingGlobal(JSTracer* trc);
     bool isSelfHostingGlobal(JSObject* global) {
         return global == selfHostingGlobal_;
     }
     bool isSelfHostingCompartment(JSCompartment* comp) const;
     bool isSelfHostingZone(const JS::Zone* zone) const;
     bool cloneSelfHostedFunctionScript(JSContext* cx, js::Handle<js::PropertyName*> name,
                                        js::Handle<JSFunction*> targetFun);
@@ -1112,19 +1103,16 @@ struct JSRuntime : public JS::shadow::Ru
     bool                hadOutOfMemory;
 
     /* We are currently deleting an object due to an initialization failure. */
     mozilla::DebugOnly<bool> handlingInitFailure;
 
     /* A context has been created on this runtime. */
     bool                haveCreatedContext;
 
-    /* At least one content global has been created on this runtime. */
-    bool                hasContentGlobals;
-
     /*
      * Allow relazifying functions in compartments that are active. This is
      * only used by the relazifyFunctions() testing function.
      */
     bool                allowRelazificationForTesting;
 
     /* Linked list of all Debugger objects in the runtime. */
     mozilla::LinkedList<js::Debugger> debuggerList;
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -1649,34 +1649,34 @@ static const JSFunctionSpec intrinsic_fu
     JS_FN("NewModuleNamespace", intrinsic_NewModuleNamespace, 2, 0),
     JS_FN("AddModuleNamespaceBinding", intrinsic_AddModuleNamespaceBinding, 4, 0),
     JS_FN("ModuleNamespaceExports", intrinsic_ModuleNamespaceExports, 1, 0),
 
     JS_FS_END
 };
 
 void
-js::FillSelfHostingCompileOptions(CompileOptions& options, const char* filename)
+js::FillSelfHostingCompileOptions(CompileOptions& options)
 {
     /*
      * In self-hosting mode, scripts use JSOP_GETINTRINSIC instead of
      * JSOP_GETNAME or JSOP_GETGNAME to access unbound variables.
      * JSOP_GETINTRINSIC does a name lookup on a special object, whose
      * properties are filled in lazily upon first access for a given global.
      *
      * As that object is inaccessible to client code, the lookups are
      * guaranteed to return the original objects, ensuring safe implementation
      * of self-hosted builtins.
      *
      * Additionally, the special syntax callFunction(fun, receiver, ...args)
      * is supported, for which bytecode is emitted that invokes |fun| with
      * |receiver| as the this-object and ...args as the arguments.
      */
     options.setIntroductionType("self-hosted");
-    options.setFileAndLine(filename, 1);
+    options.setFileAndLine("self-hosted", 1);
     options.setSelfHostingMode(true);
     options.setCanLazilyParse(false);
     options.setVersion(JSVERSION_LATEST);
     options.werrorOption = true;
     options.strictOption = true;
 
 #ifdef DEBUG
     options.extraWarningsOption = true;
@@ -1721,91 +1721,67 @@ JSRuntime::createSelfHostingGlobal(JSCon
 
     return shg;
 }
 
 bool
 JSRuntime::initSelfHosting(JSContext* cx)
 {
     MOZ_ASSERT(!selfHostingGlobal_);
-    MOZ_ASSERT(!hasContentGlobals);
 
     if (cx->runtime()->parentRuntime) {
         selfHostingGlobal_ = cx->runtime()->parentRuntime->selfHostingGlobal_;
         return true;
     }
 
     /*
      * Self hosted state can be accessed from threads for other runtimes
      * parented to this one, so cannot include state in the nursery.
      */
     JS::AutoDisableGenerationalGC disable(cx->runtime());
 
     Rooted<GlobalObject*> shg(cx, JSRuntime::createSelfHostingGlobal(cx));
     if (!shg)
         return false;
 
-    char* filename = getenv("MOZ_SELFHOSTEDJS");
-    if (filename)
-        return JS::EvaluateSelfHosted(this, filename);
-
-    uint32_t srcLen = GetRawScriptsSize();
-    const unsigned char* compressed = compressedSources;
-    uint32_t compressedLen = GetCompressedSize();
-    ScopedJSFreePtr<char> src(selfHostingGlobal_->zone()->pod_malloc<char>(srcLen));
-    if (!src || !DecompressString(compressed, compressedLen,
-                                  reinterpret_cast<unsigned char*>(src.get()), srcLen))
-    {
-        return false;
-    }
-    return JS::EvaluateSelfHosted(this, src, srcLen, "self-hosted");
-}
-
-bool
-JSRuntime::evaluateSelfHosted(const char16_t* chars, size_t length, const char* filename)
-{
-    MOZ_ASSERT(hasContexts());
-    MOZ_ASSERT(selfHostingGlobal_);
-    MOZ_ASSERT(!parentRuntime);
-    MOZ_ASSERT(!hasContentGlobals);
-
-    JSContext* cx = this->contextList.getFirst();
-    JSAutoRequest ar(cx);
-    JSAutoCompartment ac(cx, selfHostingGlobal_);
+    JSAutoCompartment ac(cx, shg);
 
     CompileOptions options(cx);
-    FillSelfHostingCompileOptions(options, filename);
+    FillSelfHostingCompileOptions(options);
 
     /*
      * Set a temporary error reporter printing to stderr because it is too
      * early in the startup process for any other reporter to be registered
      * and we don't want errors in self-hosted code to be silently swallowed.
      */
-    JSErrorReporter oldReporter = JS_SetErrorReporter(this, selfHosting_ErrorReporter);
-
+    JSErrorReporter oldReporter = JS_SetErrorReporter(cx->runtime(), selfHosting_ErrorReporter);
     RootedValue rv(cx);
-    bool ok = Evaluate(cx, options, chars, length, &rv);
+    bool ok = true;
 
-    JS_SetErrorReporter(this, oldReporter);
-    return ok;
-}
+    char* filename = getenv("MOZ_SELFHOSTEDJS");
+    if (filename) {
+        RootedScript script(cx);
+        if (Compile(cx, options, filename, &script))
+            ok = Execute(cx, script, *shg.get(), rv.address());
+    } else {
+        uint32_t srcLen = GetRawScriptsSize();
 
-bool
-JSRuntime::addSelfHostingIntrinsics(const JSFunctionSpec* intrinsicFunctions)
-{
-    MOZ_ASSERT(hasContexts());
-    MOZ_ASSERT(selfHostingGlobal_);
-    MOZ_ASSERT(!parentRuntime);
-    MOZ_ASSERT(!hasContentGlobals);
+        const unsigned char* compressed = compressedSources;
+        uint32_t compressedLen = GetCompressedSize();
+        ScopedJSFreePtr<char> src(selfHostingGlobal_->zone()->pod_malloc<char>(srcLen));
+        if (!src || !DecompressString(compressed, compressedLen,
+                                      reinterpret_cast<unsigned char*>(src.get()), srcLen))
+        {
+            ok = false;
+        }
 
-    JSContext* cx = this->contextList.getFirst();
-    JSAutoRequest ar(cx);
-    JSAutoCompartment ac(cx, selfHostingGlobal_);
-    RootedObject global(cx, selfHostingGlobal_);
-    return JS_DefineFunctions(cx, global, intrinsicFunctions);
+        ok = ok && Evaluate(cx, options, src, srcLen, &rv);
+    }
+    JS_SetErrorReporter(cx->runtime(), oldReporter);
+    return ok;
 }
 
 void
 JSRuntime::finishSelfHosting()
 {
     selfHostingGlobal_ = nullptr;
 }
 
--- a/js/src/vm/SelfHosting.h
+++ b/js/src/vm/SelfHosting.h
@@ -16,13 +16,13 @@ namespace js {
 /*
  * Check whether the given JSFunction is a self-hosted function whose
  * self-hosted name is the given name.
  */
 bool IsSelfHostedFunctionWithName(JSFunction* fun, JSAtom* name);
 
 /* Get the compile options used when compiling self hosted code. */
 void
-FillSelfHostingCompileOptions(JS::CompileOptions& options, const char* filename);
+FillSelfHostingCompileOptions(JS::CompileOptions& options);
 
 } /* namespace js */
 
 #endif /* vm_SelfHosting_h_ */