Bug 1464134 part 4 - Rename CompileCompartment to CompileRealm. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 30 May 2018 16:53:49 +0200
changeset 420459 8af7dd4fb5e201208f018e484c93b101e2fa3212
parent 420458 bdadfc22d3fe4e60abf1847c8f01f4eb6e7238a6
child 420460 361cba5c46e680d199c38222c494e0d5cf1bebcb
push id103816
push userjandemooij@gmail.com
push dateWed, 30 May 2018 14:56:56 +0000
treeherdermozilla-inbound@8af7dd4fb5e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1464134
milestone62.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 1464134 part 4 - Rename CompileCompartment to CompileRealm. r=evilpie
js/src/jit/CodeGenerator.cpp
js/src/jit/CompileWrappers.cpp
js/src/jit/CompileWrappers.h
js/src/jit/EagerSimdUnbox.cpp
js/src/jit/Ion.cpp
js/src/jit/Ion.h
js/src/jit/IonAnalysis.cpp
js/src/jit/IonBuilder.cpp
js/src/jit/IonBuilder.h
js/src/jit/MCallOptimize.cpp
js/src/jit/MIRGenerator.h
js/src/jit/MIRGraph.cpp
js/src/jit/MacroAssembler-inl.h
js/src/jit/MacroAssembler.cpp
js/src/jit/shared/Assembler-shared.h
js/src/jit/shared/CodeGenerator-shared-inl.h
js/src/jsapi-tests/testJitMinimalFunc.h
js/src/vm/HelperThreads.cpp
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -2213,17 +2213,17 @@ CodeGenerator::visitRegExpMatcher(LRegEx
     MOZ_ASSERT(RegExpMatcherLastIndexReg != JSReturnReg);
 #endif
 
     masm.reserveStack(RegExpReservedStack);
 
     OutOfLineRegExpMatcher* ool = new(alloc()) OutOfLineRegExpMatcher(lir);
     addOutOfLineCode(ool, lir->mir());
 
-    const JitRealm* jitRealm = gen->compartment->jitRealm();
+    const JitRealm* jitRealm = gen->realm->jitRealm();
     JitCode* regExpMatcherStub = jitRealm->regExpMatcherStubNoBarrier(&realmStubsToReadBarrier_);
     masm.call(regExpMatcherStub);
     masm.branchTestUndefined(Assembler::Equal, JSReturnOperand, ool->entry());
     masm.bind(ool->rejoin());
 
     masm.freeStack(RegExpReservedStack);
 }
 
@@ -2363,17 +2363,17 @@ CodeGenerator::visitRegExpSearcher(LRegE
     MOZ_ASSERT(RegExpTesterStringReg != ReturnReg);
     MOZ_ASSERT(RegExpTesterLastIndexReg != ReturnReg);
 
     masm.reserveStack(RegExpReservedStack);
 
     OutOfLineRegExpSearcher* ool = new(alloc()) OutOfLineRegExpSearcher(lir);
     addOutOfLineCode(ool, lir->mir());
 
-    const JitRealm* jitRealm = gen->compartment->jitRealm();
+    const JitRealm* jitRealm = gen->realm->jitRealm();
     JitCode* regExpSearcherStub = jitRealm->regExpSearcherStubNoBarrier(&realmStubsToReadBarrier_);
     masm.call(regExpSearcherStub);
     masm.branch32(Assembler::Equal, ReturnReg, Imm32(RegExpSearcherResultFailed), ool->entry());
     masm.bind(ool->rejoin());
 
     masm.freeStack(RegExpReservedStack);
 }
 
@@ -2500,17 +2500,17 @@ CodeGenerator::visitRegExpTester(LRegExp
 
     MOZ_ASSERT(RegExpTesterRegExpReg != ReturnReg);
     MOZ_ASSERT(RegExpTesterStringReg != ReturnReg);
     MOZ_ASSERT(RegExpTesterLastIndexReg != ReturnReg);
 
     OutOfLineRegExpTester* ool = new(alloc()) OutOfLineRegExpTester(lir);
     addOutOfLineCode(ool, lir->mir());
 
-    const JitRealm* jitRealm = gen->compartment->jitRealm();
+    const JitRealm* jitRealm = gen->realm->jitRealm();
     JitCode* regExpTesterStub = jitRealm->regExpTesterStubNoBarrier(&realmStubsToReadBarrier_);
     masm.call(regExpTesterStub);
 
     masm.branch32(Assembler::Equal, ReturnReg, Imm32(RegExpTesterResultFailed), ool->entry());
     masm.bind(ool->rejoin());
 }
 
 class OutOfLineRegExpPrototypeOptimizable : public OutOfLineCodeBase<CodeGenerator>
@@ -4042,20 +4042,20 @@ CodeGenerator::maybeEmitGlobalBarrierChe
     // compartment, because we bake in a pointer to realm->globalWriteBarriered
     // and doing that would be invalid for other realms because they could be
     // collected before the Ion code is discarded.
 
     if (!maybeGlobal->isConstant())
         return;
 
     JSObject* obj = &maybeGlobal->toConstant()->toObject();
-    if (gen->compartment->maybeGlobal() != obj)
+    if (gen->realm->maybeGlobal() != obj)
         return;
 
-    auto addr = AbsoluteAddress(gen->compartment->addressOfGlobalWriteBarriered());
+    auto addr = AbsoluteAddress(gen->realm->addressOfGlobalWriteBarriered());
     masm.branch32(Assembler::NotEqual, addr, Imm32(0), ool->rejoin());
 }
 
 template <class LPostBarrierType, MIRType nurseryType>
 void
 CodeGenerator::visitPostWriteBarrierCommon(LPostBarrierType* lir, OutOfLineCode* ool)
 {
     addOutOfLineCode(ool, lir->mir());
@@ -5629,17 +5629,17 @@ CodeGenerator::emitDebugForceBailing(LIn
     if (!lir->snapshot())
         return;
     if (lir->isStart())
         return;
     if (lir->isOsiPoint())
         return;
 
     masm.comment("emitDebugForceBailing");
-    const void* bailAfterAddr = gen->compartment->zone()->addressOfIonBailAfter();
+    const void* bailAfterAddr = gen->realm->zone()->addressOfIonBailAfter();
 
     AllocatableGeneralRegisterSet regs(GeneralRegisterSet::All());
 
     Label done, notBail, bail;
     masm.branch32(Assembler::Equal, AbsoluteAddress(bailAfterAddr), Imm32(0), &done);
     {
         Register temp = regs.takeAny();
 
@@ -8198,17 +8198,17 @@ static const VMFunction ConcatStringsInf
     FunctionInfo<ConcatStringsFn>(ConcatStrings<CanGC>, "ConcatStrings");
 
 void
 CodeGenerator::emitConcat(LInstruction* lir, Register lhs, Register rhs, Register output)
 {
     OutOfLineCode* ool = oolCallVM(ConcatStringsInfo, lir, ArgList(lhs, rhs),
                                    StoreRegisterTo(output));
 
-    const JitRealm* jitRealm = gen->compartment->jitRealm();
+    const JitRealm* jitRealm = gen->realm->jitRealm();
     JitCode* stringConcatStub = jitRealm->stringConcatStubNoBarrier(&realmStubsToReadBarrier_);
     masm.call(stringConcatStub);
     masm.branchTestPtr(Assembler::Zero, output, output, ool->entry());
 
     masm.bind(ool->rejoin());
 }
 
 void
@@ -10290,17 +10290,17 @@ CodeGenerator::link(JSContext* cx, Compi
     // removed from the relevant lists by this point. Don't allow GC here.
     JS::AutoAssertNoGC nogc(cx);
 
     RootedScript script(cx, gen->info().script());
     OptimizationLevel optimizationLevel = gen->optimizationInfo().level();
 
     // Perform any read barriers which were skipped while compiling the
     // script, which may have happened off-thread.
-    const JitRealm* jr = gen->compartment->jitRealm();
+    const JitRealm* jr = gen->realm->jitRealm();
     jr->performStubReadBarriers(realmStubsToReadBarrier_);
     jr->performSIMDTemplateReadBarriers(simdTemplatesToReadBarrier_);
 
     // We finished the new IonScript. Invalidate the current active IonScript,
     // so we can replace it with this new (probably higher optimized) version.
     if (script->hasIonScript()) {
         MOZ_ASSERT(script->ionScript()->isRecompiling());
         // Do a normal invalidate, except don't cancel offThread compilations,
@@ -13220,17 +13220,17 @@ CodeGenerator::visitRandom(LRandom* ins)
 #ifdef JS_PUNBOX64
     Register64 s0Reg(ToRegister(ins->temp1()));
     Register64 s1Reg(ToRegister(ins->temp2()));
 #else
     Register64 s0Reg(ToRegister(ins->temp1()), ToRegister(ins->temp2()));
     Register64 s1Reg(ToRegister(ins->temp3()), ToRegister(ins->temp4()));
 #endif
 
-    const void* rng = gen->compartment->addressOfRandomNumberGenerator();
+    const void* rng = gen->realm->addressOfRandomNumberGenerator();
     masm.movePtr(ImmPtr(rng), tempReg);
 
     static_assert(sizeof(XorShift128PlusRNG) == 2 * sizeof(uint64_t),
                   "Code below assumes XorShift128PlusRNG contains two uint64_t values");
 
     Address state0Addr(tempReg, XorShift128PlusRNG::offsetOfState0());
     Address state1Addr(tempReg, XorShift128PlusRNG::offsetOfState1());
 
--- a/js/src/jit/CompileWrappers.cpp
+++ b/js/src/jit/CompileWrappers.cpp
@@ -225,84 +225,84 @@ CompileZone::nurseryExists()
 void
 CompileZone::setMinorGCShouldCancelIonCompilations()
 {
     MOZ_ASSERT(CurrentThreadCanAccessZone(zone()));
     JSRuntime* rt = zone()->runtimeFromMainThread();
     rt->gc.storeBuffer().setShouldCancelIonCompilations();
 }
 
-JSCompartment*
-CompileCompartment::compartment()
+JS::Realm*
+CompileRealm::realm()
 {
-    return reinterpret_cast<JSCompartment*>(this);
+    return reinterpret_cast<JS::Realm*>(this);
 }
 
-/* static */ CompileCompartment*
-CompileCompartment::get(JSCompartment* comp)
+/* static */ CompileRealm*
+CompileRealm::get(JS::Realm* realm)
 {
-    return reinterpret_cast<CompileCompartment*>(comp);
+    return reinterpret_cast<CompileRealm*>(realm);
 }
 
 CompileZone*
-CompileCompartment::zone()
+CompileRealm::zone()
 {
-    return CompileZone::get(compartment()->zone());
+    return CompileZone::get(realm()->zone());
 }
 
 CompileRuntime*
-CompileCompartment::runtime()
+CompileRealm::runtime()
 {
-    return CompileRuntime::get(compartment()->runtimeFromAnyThread());
+    return CompileRuntime::get(realm()->runtimeFromAnyThread());
 }
 
 const void*
-CompileCompartment::addressOfRandomNumberGenerator()
+CompileRealm::addressOfRandomNumberGenerator()
 {
-    return JS::GetRealmForCompartment(compartment())->addressOfRandomNumberGenerator();
+    return realm()->addressOfRandomNumberGenerator();
 }
 
 const JitRealm*
-CompileCompartment::jitRealm()
+CompileRealm::jitRealm()
 {
-    return JS::GetRealmForCompartment(compartment())->jitRealm();
+    return realm()->jitRealm();
 }
 
 const GlobalObject*
-CompileCompartment::maybeGlobal()
+CompileRealm::maybeGlobal()
 {
     // This uses unsafeUnbarrieredMaybeGlobal() so as not to trigger the read
     // barrier on the global from off thread.  This is safe because we
     // abort Ion compilation when we GC.
-    return JS::GetRealmForCompartment(compartment())->unsafeUnbarrieredMaybeGlobal();
+    return realm()->unsafeUnbarrieredMaybeGlobal();
 }
 
 const uint32_t*
-CompileCompartment::addressOfGlobalWriteBarriered()
+CompileRealm::addressOfGlobalWriteBarriered()
 {
-    return &JS::GetRealmForCompartment(compartment())->globalWriteBarriered;
+    return &realm()->globalWriteBarriered;
 }
 
 bool
-CompileCompartment::hasAllocationMetadataBuilder()
+CompileRealm::hasAllocationMetadataBuilder()
 {
-    return JS::GetRealmForCompartment(compartment())->hasAllocationMetadataBuilder();
+    return realm()->hasAllocationMetadataBuilder();
 }
 
 // Note: This function is thread-safe because setSingletonAsValue sets a boolean
 // variable to false, and this boolean variable has no way to be resetted to
 // true. So even if there is a concurrent write, this concurrent write will
 // always have the same value.  If there is a concurrent read, then we will
 // clone a singleton instead of using the value which is baked in the JSScript,
 // and this would be an unfortunate allocation, but this will not change the
 // semantics of the JavaScript code which is executed.
 void
-CompileCompartment::setSingletonsAsValues()
+CompileRealm::setSingletonsAsValues()
 {
-    JS::GetRealmForCompartment(compartment())->behaviors().setSingletonsAsValues();
+    realm()->behaviors().setSingletonsAsValues();
 }
 
 JitCompileOptions::JitCompileOptions()
   : cloneSingletons_(false),
     profilerSlowAssertionsEnabled_(false),
     offThreadCompilationAvailable_(false)
 {
 }
--- a/js/src/jit/CompileWrappers.h
+++ b/js/src/jit/CompileWrappers.h
@@ -84,22 +84,22 @@ class CompileZone
 
     bool nurseryExists();
     bool canNurseryAllocateStrings();
     void setMinorGCShouldCancelIonCompilations();
 };
 
 class JitRealm;
 
-class CompileCompartment
+class CompileRealm
 {
-    JSCompartment* compartment();
+    JS::Realm* realm();
 
   public:
-    static CompileCompartment* get(JSCompartment* comp);
+    static CompileRealm* get(JS::Realm* realm);
 
     CompileZone* zone();
     CompileRuntime* runtime();
 
     const void* addressOfRandomNumberGenerator();
 
     const JitRealm* jitRealm();
 
--- a/js/src/jit/EagerSimdUnbox.cpp
+++ b/js/src/jit/EagerSimdUnbox.cpp
@@ -95,17 +95,17 @@ UnboxSimdPhi(const JitRealm* jitRealm, M
 
         use->replaceProducer(box);
     }
 }
 
 bool
 EagerSimdUnbox(MIRGenerator* mir, MIRGraph& graph)
 {
-    const JitRealm* jitRealm = mir->compartment->jitRealm();
+    const JitRealm* jitRealm = mir->realm->jitRealm();
     for (PostorderIterator block = graph.poBegin(); block != graph.poEnd(); block++) {
         if (mir->shouldCancel("Eager Simd Unbox"))
             return false;
 
         for (MInstructionReverseIterator ins = block->rbegin(); ins != block->rend(); ins++) {
             if (!ins->isSimdUnbox())
                 continue;
 
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -98,32 +98,32 @@ jit::GetJitContext()
 }
 
 JitContext*
 jit::MaybeGetJitContext()
 {
     return CurrentJitContext();
 }
 
-JitContext::JitContext(CompileRuntime* rt, CompileCompartment* comp, TempAllocator* temp)
+JitContext::JitContext(CompileRuntime* rt, CompileRealm* realm, TempAllocator* temp)
   : cx(nullptr),
     temp(temp),
     runtime(rt),
-    compartment(comp),
+    realm(realm),
     prev_(CurrentJitContext()),
     assemblerCount_(0)
 {
     SetJitContext(this);
 }
 
 JitContext::JitContext(JSContext* cx, TempAllocator* temp)
   : cx(cx),
     temp(temp),
     runtime(CompileRuntime::get(cx->runtime())),
-    compartment(CompileCompartment::get(cx->compartment())),
+    realm(CompileRealm::get(cx->realm())),
     prev_(CurrentJitContext()),
     assemblerCount_(0)
 {
     SetJitContext(this);
 }
 
 JitContext::JitContext(TempAllocator* temp)
   : JitContext(nullptr, nullptr, temp)
@@ -2086,17 +2086,17 @@ IonCompile(JSContext* cx, JSScript* scri
     CompilerConstraintList* constraints = NewCompilerConstraintList(*temp);
     if (!constraints)
         return AbortReason::Alloc;
 
     const OptimizationInfo* optimizationInfo = IonOptimizations.get(optimizationLevel);
     const JitCompileOptions options(cx);
 
     IonBuilder* builder = alloc->new_<IonBuilder>((JSContext*) nullptr,
-                                                  CompileCompartment::get(cx->compartment()),
+                                                  CompileRealm::get(cx->realm()),
                                                   options, temp, graph, constraints,
                                                   inspector, info, optimizationInfo,
                                                   baselineFrameInspector);
     if (!builder)
         return AbortReason::Alloc;
 
     if (cx->runtime()->gc.storeBuffer().cancelIonCompilations())
         builder->setNotSafeForMinorGC();
--- a/js/src/jit/Ion.h
+++ b/js/src/jit/Ion.h
@@ -44,39 +44,39 @@ using mozilla::Ok;
 
 static_assert(sizeof(AbortReasonOr<Ok>) <= sizeof(uintptr_t),
     "Unexpected size of AbortReasonOr<Ok>");
 static_assert(sizeof(AbortReasonOr<bool>) <= sizeof(uintptr_t),
     "Unexpected size of AbortReasonOr<bool>");
 
 // A JIT context is needed to enter into either an JIT method or an instance
 // of a JIT compiler. It points to a temporary allocator and the active
-// JSContext, either of which may be nullptr, and the active compartment, which
+// JSContext, either of which may be nullptr, and the active realm, which
 // will not be nullptr.
 
 class JitContext
 {
   public:
     JitContext(JSContext* cx, TempAllocator* temp);
-    JitContext(CompileRuntime* rt, CompileCompartment* comp, TempAllocator* temp);
+    JitContext(CompileRuntime* rt, CompileRealm* realm, TempAllocator* temp);
     explicit JitContext(TempAllocator* temp);
     JitContext();
     ~JitContext();
 
     // Running context when executing on the main thread. Not available during
     // compilation.
     JSContext* cx;
 
     // Allocator for temporary memory during compilation.
     TempAllocator* temp;
 
-    // Wrappers with information about the current runtime/compartment for use
+    // Wrappers with information about the current runtime/realm for use
     // during compilation.
     CompileRuntime* runtime;
-    CompileCompartment* compartment;
+    CompileRealm* realm;
 
     int getNextAssemblerId() {
         return assemblerCount_++;
     }
   private:
     JitContext* prev_;
     int assemblerCount_;
 };
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -4242,17 +4242,17 @@ jit::AnalyzeNewScriptDefiniteProperties(
     if (!constraints) {
         ReportOutOfMemory(cx);
         return false;
     }
 
     BaselineInspector inspector(script);
     const JitCompileOptions options(cx);
 
-    IonBuilder builder(cx, CompileCompartment::get(cx->compartment()), options, &temp, &graph, constraints,
+    IonBuilder builder(cx, CompileRealm::get(cx->realm()), options, &temp, &graph, constraints,
                        &inspector, &info, optimizationInfo, /* baselineFrame = */ nullptr);
 
     AbortReasonOr<Ok> buildResult = builder.build();
     if (buildResult.isErr()) {
         AbortReason reason = buildResult.unwrapErr();
         if (cx->isThrowingOverRecursed() || cx->isThrowingOutOfMemory())
             return false;
         if (reason == AbortReason::Alloc) {
@@ -4488,17 +4488,17 @@ jit::AnalyzeArgumentsUsage(JSContext* cx
     if (!constraints) {
         ReportOutOfMemory(cx);
         return false;
     }
 
     BaselineInspector inspector(script);
     const JitCompileOptions options(cx);
 
-    IonBuilder builder(nullptr, CompileCompartment::get(cx->compartment()), options, &temp, &graph, constraints,
+    IonBuilder builder(nullptr, CompileRealm::get(cx->realm()), options, &temp, &graph, constraints,
                        &inspector, &info, optimizationInfo, /* baselineFrame = */ nullptr);
 
     AbortReasonOr<Ok> buildResult = builder.build();
     if (buildResult.isErr()) {
         AbortReason reason = buildResult.unwrapErr();
         if (cx->isThrowingOverRecursed() || cx->isThrowingOutOfMemory())
             return false;
         if (reason == AbortReason::Alloc) {
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -110,24 +110,24 @@ jit::NewBaselineFrameInspector(TempAlloc
     for (size_t i = 0; i < frame->numValueSlots(); i++) {
         TypeSet::Type type = TypeSet::GetMaybeUntrackedValueType(*frame->valueSlot(i));
         inspector->varTypes.infallibleAppend(type);
     }
 
     return inspector;
 }
 
-IonBuilder::IonBuilder(JSContext* analysisContext, CompileCompartment* comp,
+IonBuilder::IonBuilder(JSContext* analysisContext, CompileRealm* realm,
                        const JitCompileOptions& options, TempAllocator* temp,
                        MIRGraph* graph, CompilerConstraintList* constraints,
                        BaselineInspector* inspector, CompileInfo* info,
                        const OptimizationInfo* optimizationInfo,
                        BaselineFrameInspector* baselineFrame, size_t inliningDepth,
                        uint32_t loopDepth)
-  : MIRGenerator(comp, options, temp, graph, info, optimizationInfo),
+  : MIRGenerator(realm, options, temp, graph, info, optimizationInfo),
     backgroundCodegen_(nullptr),
     actionableAbortScript_(nullptr),
     actionableAbortPc_(nullptr),
     actionableAbortMessage_(nullptr),
     rootList_(nullptr),
     analysisContext(analysisContext),
     baselineFrame_(baselineFrame),
     constraints_(constraints),
@@ -1871,17 +1871,17 @@ IonBuilder::inspectOpcode(JSOp op)
         return Ok();
 
       case JSOP_STRING:
         pushConstant(StringValue(info().getAtom(pc)));
         return Ok();
 
       case JSOP_SYMBOL: {
         unsigned which = GET_UINT8(pc);
-        JS::Symbol* sym = compartment->runtime()->wellKnownSymbols().get(which);
+        JS::Symbol* sym = realm->runtime()->wellKnownSymbols().get(which);
         pushConstant(SymbolValue(sym));
         return Ok();
       }
 
       case JSOP_ZERO:
         pushConstant(Int32Value(0));
         return Ok();
 
@@ -3788,17 +3788,17 @@ IonBuilder::inlineScriptedCall(CallInfo&
                                                      inlineScriptTree);
     if (!info)
         return abort(AbortReason::Alloc);
 
     MIRGraphReturns returns(alloc());
     AutoAccumulateReturns aar(graph(), returns);
 
     // Build the graph.
-    IonBuilder inlineBuilder(analysisContext, compartment, options, &alloc(), &graph(), constraints(),
+    IonBuilder inlineBuilder(analysisContext, realm, options, &alloc(), &graph(), constraints(),
                              &inspector, info, &optimizationInfo(), nullptr, inliningDepth_ + 1,
                              loopDepth_);
     AbortReasonOr<Ok> result = inlineBuilder.buildInline(this, outerResumePoint, callInfo);
     if (result.isErr()) {
         if (analysisContext && analysisContext->isExceptionPending()) {
             JitSpew(JitSpew_IonAbort, "Inline builder raised exception.");
             MOZ_ASSERT(result.unwrapErr() == AbortReason::Error);
             return Err(result.unwrapErr());
@@ -4960,17 +4960,17 @@ IonBuilder::createThisScriptedBaseline(M
         return nullptr;
 
     JSObject* templateObject = inspector->getTemplateObject(pc);
     if (!templateObject)
         return nullptr;
     if (!templateObject->is<PlainObject>() && !templateObject->is<UnboxedPlainObject>())
         return nullptr;
 
-    Shape* shape = target->lookupPure(compartment->runtime()->names().prototype);
+    Shape* shape = target->lookupPure(realm->runtime()->names().prototype);
     if (!shape || !shape->isDataProperty())
         return nullptr;
 
     Value protov = target->getSlot(shape->slot());
     if (!protov.isObject())
         return nullptr;
 
     JSObject* proto = checkNurseryObject(&protov.toObject());
@@ -5448,17 +5448,17 @@ IonBuilder::testShouldDOMCall(TypeSet* i
 {
     if (!func->isNative() || !func->hasJitInfo())
         return false;
 
     // If all the DOM objects flowing through are legal with this
     // property, we can bake in a call to the bottom half of the DOM
     // accessor
     DOMInstanceClassHasProtoAtDepth instanceChecker =
-        compartment->runtime()->DOMcallbacks()->instanceClassMatchesProto;
+        realm->runtime()->DOMcallbacks()->instanceClassMatchesProto;
 
     const JSJitInfo* jinfo = func->jitInfo();
     if (jinfo->type() != opType)
         return false;
 
     for (unsigned i = 0; i < inTypes->getObjectCount(); i++) {
         TypeSet::ObjectKey* key = inTypes->getObject(i);
         if (!key)
@@ -6973,31 +6973,31 @@ ClassHasEffectlessLookup(const Class* cl
     return (clasp == &UnboxedPlainObject::class_) ||
            IsTypedObjectClass(clasp) ||
            (clasp->isNative() && !clasp->getOpsLookupProperty());
 }
 
 // Return whether an object might have a property for name which is not
 // accounted for by type information.
 static bool
-ObjectHasExtraOwnProperty(CompileCompartment* comp, TypeSet::ObjectKey* object, jsid id)
+ObjectHasExtraOwnProperty(CompileRealm* realm, TypeSet::ObjectKey* object, jsid id)
 {
     // Some typed object properties are not reflected in type information.
     if (object->isGroup() && object->group()->maybeTypeDescr())
-        return object->group()->typeDescr().hasProperty(comp->runtime()->names(), id);
+        return object->group()->typeDescr().hasProperty(realm->runtime()->names(), id);
 
     const Class* clasp = object->clasp();
 
     // Array |length| properties are not reflected in type information.
     if (clasp == &ArrayObject::class_)
-        return JSID_IS_ATOM(id, comp->runtime()->names().length);
+        return JSID_IS_ATOM(id, realm->runtime()->names().length);
 
     // Resolve hooks can install new properties on objects on demand.
     JSObject* singleton = object->isSingleton() ? object->singleton() : nullptr;
-    return ClassMayResolveId(comp->runtime()->names(), clasp, id, singleton);
+    return ClassMayResolveId(realm->runtime()->names(), clasp, id, singleton);
 }
 
 void
 IonBuilder::insertRecompileCheck()
 {
     // No need for recompile checks if this is the highest optimization level.
     OptimizationLevel curLevel = optimizationInfo().level();
     if (IonOptimizations.isLastLevel(curLevel))
@@ -7049,17 +7049,17 @@ IonBuilder::testSingletonProperty(JSObje
 
         HeapTypeSetKey property = objKey->property(id);
         if (property.isOwnProperty(constraints())) {
             if (obj->isSingleton())
                 return property.singleton(constraints());
             return nullptr;
         }
 
-        if (ObjectHasExtraOwnProperty(compartment, objKey, id))
+        if (ObjectHasExtraOwnProperty(realm, objKey, id))
             return nullptr;
 
         obj = checkNurseryObject(obj->staticPrototype());
     }
 
     return nullptr;
 }
 
@@ -7111,17 +7111,17 @@ IonBuilder::testSingletonPropertyTypes(M
         for (unsigned i = 0; i < types->getObjectCount(); i++) {
             TypeSet::ObjectKey* key = types->getObject(i);
             if (!key)
                 continue;
             if (analysisContext)
                 key->ensureTrackedProperty(analysisContext, id);
 
             const Class* clasp = key->clasp();
-            if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(compartment, key, id))
+            if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(realm, key, id))
                 return nullptr;
             if (key->unknownProperties())
                 return nullptr;
             HeapTypeSetKey property = key->property(id);
             if (property.isOwnProperty(constraints()))
                 return nullptr;
 
             if (JSObject* proto = checkNurseryObject(key->proto().toObjectOrNull())) {
@@ -7167,17 +7167,17 @@ IonBuilder::testNotDefinedProperty(MDefi
         while (true) {
             if (!alloc().ensureBallast())
                 return abort(AbortReason::Alloc);
 
             if (!key->hasStableClassAndProto(constraints()) || key->unknownProperties())
                 return false;
 
             const Class* clasp = key->clasp();
-            if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(compartment, key, id))
+            if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(realm, key, id))
                 return false;
 
             // If the object is a singleton, we can do a lookup now to avoid
             // unnecessary invalidations later on, in case the property types
             // have not yet been instantiated.
             if (key->isSingleton() &&
                 key->singleton()->is<NativeObject>() &&
                 key->singleton()->as<NativeObject>().lookupPure(id))
@@ -7444,17 +7444,17 @@ IonBuilder::loadStaticSlot(JSObject* sta
 
     return loadSlot(obj, slot, NumFixedSlots(staticObject), rvalType, barrier, types);
 }
 
 // Whether a write of the given value may need a post-write barrier for GC purposes.
 bool
 IonBuilder::needsPostBarrier(MDefinition* value)
 {
-    CompileZone* zone = compartment->zone();
+    CompileZone* zone = realm->zone();
     if (!zone->nurseryExists())
         return false;
     if (value->mightBeType(MIRType::Object))
         return true;
     if (value->mightBeType(MIRType::String) && zone->canNurseryAllocateStrings())
         return true;
     return false;
 }
@@ -7571,21 +7571,21 @@ IonBuilder::jsop_getgname(PropertyName* 
     // cases *exactly* like Baseline, because it's invalid to add an Ion IC or
     // VM call (that might trigger invalidation) if there's no Baseline IC for
     // this op.
     if (name == names().undefined) {
         pushConstant(UndefinedValue());
         return Ok();
     }
     if (name == names().NaN) {
-        pushConstant(compartment->runtime()->NaNValue());
+        pushConstant(realm->runtime()->NaNValue());
         return Ok();
     }
     if (name == names().Infinity) {
-        pushConstant(compartment->runtime()->positiveInfinityValue());
+        pushConstant(realm->runtime()->positiveInfinityValue());
         return Ok();
     }
 
     if (JSObject* obj = testGlobalLexicalBinding(name)) {
         bool emitted = false;
         MOZ_TRY(getStaticName(&emitted, obj, name));
         if (emitted)
             return Ok();
@@ -9771,17 +9771,17 @@ IonBuilder::commonPrototypeWithGetterSet
         while (key) {
             if (key->unknownProperties())
                 return nullptr;
 
             const Class* clasp = key->clasp();
             if (!ClassHasEffectlessLookup(clasp))
                 return nullptr;
             JSObject* singleton = key->isSingleton() ? key->singleton() : nullptr;
-            if (ObjectHasExtraOwnProperty(compartment, key, NameToId(name))) {
+            if (ObjectHasExtraOwnProperty(realm, key, NameToId(name))) {
                 if (!singleton || !singleton->is<GlobalObject>())
                     return nullptr;
                 *guardGlobal = true;
             }
 
             // Look for a getter/setter on the class itself which may need
             // to be called.
             if (isGetter && clasp->getOpsGetProperty())
@@ -9978,17 +9978,17 @@ IonBuilder::annotateGetPropertyCache(MDe
         if (!group)
             continue;
         TypeSet::ObjectKey* key = TypeSet::ObjectKey::get(group);
         if (key->unknownProperties() || !key->proto().isObject())
             continue;
         JSObject* proto = checkNurseryObject(key->proto().toObject());
 
         const Class* clasp = key->clasp();
-        if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(compartment, key, NameToId(name)))
+        if (!ClassHasEffectlessLookup(clasp) || ObjectHasExtraOwnProperty(realm, key, NameToId(name)))
             continue;
 
         HeapTypeSetKey ownTypes = key->property(NameToId(name));
         if (ownTypes.isOwnProperty(constraints()))
             continue;
 
         JSObject* singleton = testSingletonProperty(proto, NameToId(name));
         if (!singleton || !singleton->is<JSFunction>())
@@ -12113,17 +12113,17 @@ IonBuilder::jsop_object(JSObject* obj)
 {
     if (options.cloneSingletons()) {
         MCloneLiteral* clone = MCloneLiteral::New(alloc(), constant(ObjectValue(*obj)));
         current->add(clone);
         current->push(clone);
         return resumeAfter(clone);
     }
 
-    compartment->setSingletonsAsValues();
+    realm->setSingletonsAsValues();
     pushConstant(ObjectValue(*obj));
     return Ok();
 }
 
 AbortReasonOr<Ok>
 IonBuilder::jsop_classconstructor()
 {
     MClassConstructor* constructor = MClassConstructor::New(alloc(), pc);
@@ -13037,17 +13037,17 @@ IonBuilder::jsop_instanceof()
 
         Value funProto = script()->global().getPrototype(JSProto_Function);
         if (!funProto.isObject() || rhsObject->staticPrototype() != &funProto.toObject())
             break;
 
         // If the user has supplied their own @@hasInstance method we shouldn't
         // clobber it.
         JSFunction* fun = &rhsObject->as<JSFunction>();
-        const WellKnownSymbols* symbols = &compartment->runtime()->wellKnownSymbols();
+        const WellKnownSymbols* symbols = &realm->runtime()->wellKnownSymbols();
         if (!js::FunctionHasDefaultHasInstance(fun, *symbols))
             break;
 
         // Ensure that we will bail if the @@hasInstance property or [[Prototype]]
         // change.
         TypeSet::ObjectKey* rhsKey = TypeSet::ObjectKey::get(rhsObject);
         if (!rhsKey->hasStableClassAndProto(constraints()))
             break;
@@ -13624,17 +13624,17 @@ IonBuilder::setPropTryReferenceTypedObje
 JSObject*
 IonBuilder::checkNurseryObject(JSObject* obj)
 {
     // If we try to use any nursery pointers during compilation, make sure that
     // the main thread will cancel this compilation before performing a minor
     // GC. All constants used during compilation should either go through this
     // function or should come from a type set (which has a similar barrier).
     if (obj && IsInsideNursery(obj)) {
-        compartment->zone()->setMinorGCShouldCancelIonCompilations();
+        realm->zone()->setMinorGCShouldCancelIonCompilations();
         IonBuilder* builder = this;
         while (builder) {
             builder->setNotSafeForMinorGC();
             builder = builder->callerBuilder_;
         }
     }
 
     return obj;
@@ -13736,17 +13736,17 @@ IonBuilder::convertToBoolean(MDefinition
     current->add(result);
 
     return result;
 }
 
 void
 IonBuilder::trace(JSTracer* trc)
 {
-    if (!compartment->runtime()->runtimeMatches(trc->runtime()))
+    if (!realm->runtime()->runtimeMatches(trc->runtime()))
         return;
 
     MOZ_ASSERT(rootList_);
     rootList_->trace(trc);
 }
 
 size_t
 IonBuilder::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -40,17 +40,17 @@ NewBaselineFrameInspector(TempAllocator*
 using CallTargets = Vector<JSFunction*, 6, JitAllocPolicy>;
 
 class IonBuilder
   : public MIRGenerator,
     public mozilla::LinkedListElement<IonBuilder>
 {
 
   public:
-    IonBuilder(JSContext* analysisContext, CompileCompartment* comp,
+    IonBuilder(JSContext* analysisContext, CompileRealm* realm,
                const JitCompileOptions& options, TempAllocator* temp,
                MIRGraph* graph, CompilerConstraintList* constraints,
                BaselineInspector* inspector, CompileInfo* info,
                const OptimizationInfo* optimizationInfo, BaselineFrameInspector* baselineFrame,
                size_t inliningDepth = 0, uint32_t loopDepth = 0);
 
     // Callers of build() and buildInline() should always check whether the
     // call overrecursed, if false is returned.  Overrecursion is not
@@ -963,17 +963,17 @@ class IonBuilder
     CompilerConstraintList* constraints() {
         return constraints_;
     }
 
     bool isInlineBuilder() const {
         return callerBuilder_ != nullptr;
     }
 
-    const JSAtomState& names() { return compartment->runtime()->names(); }
+    const JSAtomState& names() { return realm->runtime()->names(); }
 
     bool hadActionableAbort() const {
         MOZ_ASSERT(!actionableAbortScript_ ||
                    (actionableAbortPc_ && actionableAbortMessage_));
         return actionableAbortScript_ != nullptr;
     }
 
     TraceLoggerThread *traceLogger() {
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -2572,17 +2572,17 @@ IonBuilder::inlineObjectToString(CallInf
         return InliningStatus_NotInlined;
 
     // Don't optimize if this might be a proxy.
     using ForAllResult = TemporaryTypeSet::ForAllResult;
     if (types->forAllClasses(constraints(), IsProxyClass) != ForAllResult::ALL_FALSE)
         return InliningStatus_NotInlined;
 
     // Make sure there's no Symbol.toStringTag property.
-    jsid toStringTag = SYMBOL_TO_JSID(compartment->runtime()->wellKnownSymbols().toStringTag);
+    jsid toStringTag = SYMBOL_TO_JSID(realm->runtime()->wellKnownSymbols().toStringTag);
     bool res;
     MOZ_TRY_VAR(res, testNotDefinedProperty(arg, toStringTag));
     if (!res)
         return InliningStatus_NotInlined;
 
     // At this point we know we're going to inline this.
     callInfo.setImplicitlyUsedUnchecked();
 
--- a/js/src/jit/MIRGenerator.h
+++ b/js/src/jit/MIRGenerator.h
@@ -29,17 +29,17 @@ namespace js {
 namespace jit {
 
 class MIRGraph;
 class OptimizationInfo;
 
 class MIRGenerator
 {
   public:
-    MIRGenerator(CompileCompartment* compartment, const JitCompileOptions& options,
+    MIRGenerator(CompileRealm* realm, const JitCompileOptions& options,
                  TempAllocator* alloc, MIRGraph* graph,
                  const CompileInfo* info, const OptimizationInfo* optimizationInfo);
 
     void initMinWasmHeapLength(uint32_t init) {
         minWasmHeapLength_ = init;
     }
 
     TempAllocator& alloc() {
@@ -170,17 +170,17 @@ class MIRGenerator
 
     // When aborting with AbortReason::PreliminaryObjects, all groups with
     // preliminary objects which haven't been analyzed yet.
     const ObjectGroupVector& abortedPreliminaryGroups() const {
         return abortedPreliminaryGroups_;
     }
 
   public:
-    CompileCompartment* compartment;
+    CompileRealm* realm;
     CompileRuntime* runtime;
 
   protected:
     const CompileInfo* info_;
     const OptimizationInfo* optimizationInfo_;
     TempAllocator* alloc_;
     MIRGraph* graph_;
     AbortReasonOr<Ok> offThreadStatus_;
--- a/js/src/jit/MIRGraph.cpp
+++ b/js/src/jit/MIRGraph.cpp
@@ -12,38 +12,38 @@
 #include "jit/MIR.h"
 #include "jit/MIRGenerator.h"
 #include "wasm/WasmTypes.h"
 
 using namespace js;
 using namespace js::jit;
 using mozilla::Swap;
 
-MIRGenerator::MIRGenerator(CompileCompartment* compartment, const JitCompileOptions& options,
+MIRGenerator::MIRGenerator(CompileRealm* realm, const JitCompileOptions& options,
                            TempAllocator* alloc, MIRGraph* graph, const CompileInfo* info,
                            const OptimizationInfo* optimizationInfo)
-  : compartment(compartment),
-    runtime(compartment ? compartment->runtime() : nullptr),
+  : realm(realm),
+    runtime(realm ? realm->runtime() : nullptr),
     info_(info),
     optimizationInfo_(optimizationInfo),
     alloc_(alloc),
     graph_(graph),
     offThreadStatus_(Ok()),
     abortedPreliminaryGroups_(*alloc_),
     cancelBuild_(false),
     wasmMaxStackArgBytes_(0),
     needsOverrecursedCheck_(false),
     needsStaticStackAlignment_(false),
     usesSimd_(false),
     cachedUsesSimd_(false),
     modifiesFrameArguments_(false),
     instrumentedProfiling_(false),
     instrumentedProfilingIsCached_(false),
     safeForMinorGC_(true),
-    stringsCanBeInNursery_(compartment ? compartment->zone()->canNurseryAllocateStrings() : false),
+    stringsCanBeInNursery_(realm ? realm->zone()->canNurseryAllocateStrings() : false),
     minWasmHeapLength_(0),
     options(options),
     gs_(alloc)
 { }
 
 bool
 MIRGenerator::usesSimd()
 {
--- a/js/src/jit/MacroAssembler-inl.h
+++ b/js/src/jit/MacroAssembler-inl.h
@@ -630,17 +630,17 @@ MacroAssembler::branchTestProxyHandlerFa
     Address familyAddr(scratch, BaseProxyHandler::offsetOfFamily());
     branchPtr(cond, familyAddr, ImmPtr(handlerp), label);
 }
 
 void
 MacroAssembler::branchTestNeedsIncrementalBarrier(Condition cond, Label* label)
 {
     MOZ_ASSERT(cond == Zero || cond == NonZero);
-    CompileZone* zone = GetJitContext()->compartment->zone();
+    CompileZone* zone = GetJitContext()->realm->zone();
     AbsoluteAddress needsBarrierAddr(zone->addressOfNeedsIncrementalBarrier());
     branchTest32(cond, needsBarrierAddr, Imm32(0x1), label);
 }
 
 void
 MacroAssembler::branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why,
                                      Label* label)
 {
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -818,19 +818,19 @@ MacroAssembler::checkAllocatorState(Labe
 
 #ifdef JS_GC_ZEAL
     // Don't execute the inline path if gc zeal or tracing are active.
     branch32(Assembler::NotEqual,
              AbsoluteAddress(GetJitContext()->runtime->addressOfGCZealModeBits()), Imm32(0),
              fail);
 #endif
 
-    // Don't execute the inline path if the compartment has an object metadata callback,
+    // Don't execute the inline path if the realm has an object metadata callback,
     // as the metadata to use for the object may vary between executions of the op.
-    if (GetJitContext()->compartment->hasAllocationMetadataBuilder())
+    if (GetJitContext()->realm->hasAllocationMetadataBuilder())
         jump(fail);
 }
 
 bool
 MacroAssembler::shouldNurseryAllocate(gc::AllocKind allocKind, gc::InitialHeap initialHeap)
 {
     // Note that Ion elides barriers on writes to objects known to be in the
     // nursery, so any allocation that can be made into the nursery must be made
@@ -854,17 +854,17 @@ MacroAssembler::nurseryAllocateObject(Re
     // interpreter.
     if (nDynamicSlots >= Nursery::MaxNurseryBufferSize / sizeof(Value)) {
         jump(fail);
         return;
     }
 
     // No explicit check for nursery.isEnabled() is needed, as the comparison
     // with the nursery's end will always fail in such cases.
-    CompileZone* zone = GetJitContext()->compartment->zone();
+    CompileZone* zone = GetJitContext()->realm->zone();
     int thingSize = int(gc::Arena::thingSize(allocKind));
     int totalSize = thingSize + nDynamicSlots * sizeof(HeapSlot);
     MOZ_ASSERT(totalSize % gc::CellAlignBytes == 0);
     loadPtr(AbsoluteAddress(zone->addressOfNurseryPosition()), result);
     computeEffectiveAddress(Address(result, totalSize), temp);
     branchPtr(Assembler::Below, AbsoluteAddress(zone->addressOfNurseryCurrentEnd()), temp, fail);
     storePtr(temp, AbsoluteAddress(zone->addressOfNurseryPosition()));
 
@@ -873,17 +873,17 @@ MacroAssembler::nurseryAllocateObject(Re
         storePtr(temp, Address(result, NativeObject::offsetOfSlots()));
     }
 }
 
 // Inlined version of FreeSpan::allocate. This does not fill in slots_.
 void
 MacroAssembler::freeListAllocate(Register result, Register temp, gc::AllocKind allocKind, Label* fail)
 {
-    CompileZone* zone = GetJitContext()->compartment->zone();
+    CompileZone* zone = GetJitContext()->realm->zone();
     int thingSize = int(gc::Arena::thingSize(allocKind));
 
     Label fallback;
     Label success;
 
     // Load the first and last offsets of |zone|'s free list for |allocKind|.
     // If there is no room remaining in the span, fall back to get the next one.
     loadPtr(AbsoluteAddress(zone->addressOfFreeList(allocKind)), temp);
@@ -927,17 +927,17 @@ MacroAssembler::callMallocStub(size_t nb
     MOZ_ASSERT(nbytes <= INT32_MAX);
 
     if (regZone != result)
         push(regZone);
     if (regNBytes != result)
         push(regNBytes);
 
     move32(Imm32(nbytes), regNBytes);
-    movePtr(ImmPtr(GetJitContext()->compartment->zone()), regZone);
+    movePtr(ImmPtr(GetJitContext()->realm->zone()), regZone);
     call(GetJitContext()->runtime->jitRuntime()->mallocStub());
     if (regReturn != result)
         movePtr(regReturn, result);
 
     if (regNBytes != result)
         pop(regNBytes);
     if (regZone != result)
         pop(regZone);
@@ -1036,17 +1036,17 @@ void
 MacroAssembler::nurseryAllocateString(Register result, Register temp, gc::AllocKind allocKind,
                                       Label* fail)
 {
     MOZ_ASSERT(IsNurseryAllocable(allocKind));
 
     // No explicit check for nursery.isEnabled() is needed, as the comparison
     // with the nursery's end will always fail in such cases.
 
-    CompileZone* zone = GetJitContext()->compartment->zone();
+    CompileZone* zone = GetJitContext()->realm->zone();
     int thingSize = int(gc::Arena::thingSize(allocKind));
     int totalSize = js::Nursery::stringHeaderSize() + thingSize;
     MOZ_ASSERT(totalSize % gc::CellAlignBytes == 0);
 
     // The nursery position (allocation pointer) and the nursery end are stored
     // very close to each other. In practice, the zone will probably be close
     // (within 32 bits) as well. If so, use relative offsets between them, to
     // avoid multiple 64-bit immediate loads.
--- a/js/src/jit/shared/Assembler-shared.h
+++ b/js/src/jit/shared/Assembler-shared.h
@@ -152,18 +152,18 @@ struct Imm64
     inline Imm32 firstHalf() const;
     inline Imm32 secondHalf() const;
 };
 
 #ifdef DEBUG
 static inline bool
 IsCompilingWasm()
 {
-    // wasm compilation pushes a JitContext with a null JSCompartment.
-    return GetJitContext()->compartment == nullptr;
+    // wasm compilation pushes a JitContext with a null Realm.
+    return GetJitContext()->realm == nullptr;
 }
 #endif
 
 // Pointer to be embedded as an immediate in an instruction.
 struct ImmPtr
 {
     void* value;
 
--- a/js/src/jit/shared/CodeGenerator-shared-inl.h
+++ b/js/src/jit/shared/CodeGenerator-shared-inl.h
@@ -408,16 +408,16 @@ CodeGeneratorShared::verifyStoreDisassem
     verifyHeapAccessDisassembly(begin, end, false, type, mem, alloc);
 }
 
 inline bool
 CodeGeneratorShared::isGlobalObject(JSObject* object)
 {
     // Calling object->is<GlobalObject>() is racy because this relies on
     // checking the group and this can be changed while we are compiling off the
-    // main thread.
-    return object == gen->compartment->maybeGlobal();
+    // main thread. Note that we only check for the script realm's global here.
+    return object == gen->realm->maybeGlobal();
 }
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_shared_CodeGenerator_shared_inl_h */
--- a/js/src/jsapi-tests/testJitMinimalFunc.h
+++ b/js/src/jsapi-tests/testJitMinimalFunc.h
@@ -38,17 +38,17 @@ struct MinimalFunc : MinimalAlloc
     MIRGraph graph;
     MIRGenerator mir;
     uint32_t numParams;
 
     MinimalFunc()
       : options(),
         info(0),
         graph(&alloc),
-        mir(static_cast<CompileCompartment*>(nullptr), options, &alloc, &graph,
+        mir(static_cast<CompileRealm*>(nullptr), options, &alloc, &graph,
             &info, static_cast<const OptimizationInfo*>(nullptr)),
         numParams(0)
     { }
 
     MBasicBlock* createEntryBlock()
     {
         MBasicBlock* block = MBasicBlock::New(graph, info, nullptr, MBasicBlock::NORMAL);
         graph.addBlock(block);
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1966,17 +1966,17 @@ HelperThread::handleIonWorkload(AutoLock
 
         TraceLoggerThread* logger = TraceLoggerForCurrentThread();
         TraceLoggerEvent event(TraceLogger_AnnotateScripts, builder->script());
         AutoTraceLog logScript(logger, event);
         AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
 
         AutoSetContextRuntime ascr(rt);
         jit::JitContext jctx(jit::CompileRuntime::get(rt),
-                             jit::CompileCompartment::get(builder->script()->compartment()),
+                             jit::CompileRealm::get(builder->script()->realm()),
                              &builder->alloc());
         builder->setBackgroundCodegen(jit::CompileBackEnd(builder));
     }
 
     FinishOffThreadIonCompile(builder, locked);
 
     // Ping the main thread so that the compiled code can be incorporated at the
     // next interrupt callback.