Commit 60cbb8bd authored by Jan de Mooij's avatar Jan de Mooij Committed by Georg Koppen
Browse files

Bug 1234246 - Don't reprotect JIT code more than once when linking. r=nbp

parent 63402331
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -465,8 +465,6 @@ NativeRegExpMacroAssembler::GenerateCode(JSContext* cx, bool match_only)
    writePerfSpewerJitCodeProfile(code, "RegExp");
#endif

    AutoWritableJitCode awjc(code);

    for (size_t i = 0; i < labelPatches.length(); i++) {
        LabelPatch& v = labelPatches[i];
        MOZ_ASSERT(!v.label);
+1 −3
Original line number Diff line number Diff line
@@ -238,14 +238,12 @@ BaselineCompiler::compile()

    // All barriers are emitted off-by-default, toggle them on if needed.
    if (cx->zone()->needsIncrementalBarrier())
        baselineScript->toggleBarriers(true);
        baselineScript->toggleBarriers(true, DontReprotect);

    // If profiler instrumentation is enabled, toggle instrumentation on.
    if (cx->runtime()->jitRuntime()->isProfilerInstrumentationEnabled(cx->runtime()))
        baselineScript->toggleProfilerInstrumentation(true);

    AutoWritableJitCode awjc(code);

    // Patch IC loads using IC entries.
    for (size_t i = 0; i < icLoadLabels_.length(); i++) {
        CodeOffset label = icLoadLabels_[i].label;
+5 −2
Original line number Diff line number Diff line
@@ -1028,8 +1028,6 @@ BaselineScript::toggleProfilerInstrumentation(bool enable)
    JitSpew(JitSpew_BaselineIC, "  toggling profiling %s for BaselineScript %p",
            enable ? "on" : "off", this);

    AutoWritableJitCode awjc(method());

    // Toggle the jump
    CodeLocationLabel enterToggleLocation(method_, CodeOffset(profilerEnterToggleOffset_));
    CodeLocationLabel exitToggleLocation(method_, CodeOffset(profilerExitToggleOffset_));
@@ -1141,11 +1139,16 @@ jit::AddSizeOfBaselineData(JSScript* script, mozilla::MallocSizeOf mallocSizeOf,
void
jit::ToggleBaselineProfiling(JSRuntime* runtime, bool enable)
{
    JitRuntime* jrt = runtime->jitRuntime();
    if (!jrt)
        return;

    for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
        for (gc::ZoneCellIter i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
            JSScript* script = i.get<JSScript>();
            if (!script->hasBaselineScript())
                continue;
            AutoWritableJitCode awjc(script->baselineScript()->method());
            script->baselineScript()->toggleProfilerInstrumentation(enable);
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -356,8 +356,8 @@ struct BaselineScript
        templateScope_ = templateScope;
    }

    void toggleBarriers(bool enabled) {
        method()->togglePreBarriers(enabled);
    void toggleBarriers(bool enabled, ReprotectCode reprotect = Reprotect) {
        method()->togglePreBarriers(enabled, reprotect);
    }

    bool containsCodeAddress(uint8_t* addr) const {
+45 −48
Original line number Diff line number Diff line
@@ -1446,7 +1446,7 @@ JitCompartment::generateRegExpExecStub(JSContext* cx)
#endif

    if (cx->zone()->needsIncrementalBarrier())
        code->togglePreBarriers(true);
        code->togglePreBarriers(true, DontReprotect);

    return code;
}
@@ -1579,7 +1579,7 @@ JitCompartment::generateRegExpTestStub(JSContext* cx)
#endif

    if (cx->zone()->needsIncrementalBarrier())
        code->togglePreBarriers(true);
        code->togglePreBarriers(true, DontReprotect);

    return code;
}
@@ -8259,8 +8259,6 @@ CodeGenerator::link(JSContext* cx, CompilerConstraintList* constraints)
    // Adopt fallback shared stubs from the compiler into the ion script.
    ionScript->adoptFallbackStubs(&stubSpace_);

    {
        AutoWritableJitCode awjc(code);
    Assembler::PatchDataWithValueCheck(CodeLocationLabel(code, invalidateEpilogueData_),
                                       ImmPtr(ionScript),
                                       ImmPtr((void*)-1));
@@ -8312,7 +8310,6 @@ CodeGenerator::link(JSContext* cx, CompilerConstraintList* constraints)
        ionScript->copyRuntimeData(&runtimeData_[0]);
    if (cacheList_.length())
        ionScript->copyCacheEntries(&cacheList_[0], masm);
    }

    JitSpew(JitSpew_Codegen, "Created IonScript %p (raw %p)",
            (void*) ionScript, (void*) code->raw());
@@ -8363,7 +8360,7 @@ CodeGenerator::link(JSContext* cx, CompilerConstraintList* constraints)
    // since a GC can occur during code generation. All barriers are emitted
    // off-by-default, and are toggled on here if necessary.
    if (cx->zone()->needsIncrementalBarrier())
        ionScript->toggleBarriers(true);
        ionScript->toggleBarriers(true, DontReprotect);

    // Attach any generated script counts to the script.
    if (IonScriptCounts* counts = extractScriptCounts())
Loading