Bug 1530396 - Move the AutoFlushICache to the Linker. r=mgaudet
☠☠ backed out by 808c9111188b ☠ ☠
authorNicolas B. Pierron <nicolas.b.pierron@nbp.name>
Wed, 27 Feb 2019 16:53:51 +0000
changeset 519355 9970e92003a2ba84098ffab8531863051f800f46
parent 519354 08c00f2c0eaba54e7f99aa5b0024338187464e7e
child 519356 5943b02bfa38cc5a3724766d0f7e896ade3eb643
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1530396
milestone67.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 1530396 - Move the AutoFlushICache to the Linker. r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D21025
js/src/irregexp/NativeRegExpMacroAssembler.cpp
js/src/jit/BaselineCacheIRCompiler.cpp
js/src/jit/BaselineCompiler.cpp
js/src/jit/BaselineDebugModeOSR.cpp
js/src/jit/BaselineIC.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/Ion.cpp
js/src/jit/IonCacheIRCompiler.cpp
js/src/jit/Linker.h
js/src/jit/arm/Trampoline-arm.cpp
js/src/jit/arm64/Trampoline-arm64.cpp
js/src/jit/mips32/Trampoline-mips32.cpp
js/src/jit/mips64/Trampoline-mips64.cpp
js/src/jit/x64/Trampoline-x64.cpp
js/src/jit/x86/Trampoline-x86.cpp
js/src/jsapi-tests/testJitMacroAssembler.cpp
js/src/vm/UnboxedObject.cpp
--- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp
+++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp
@@ -500,18 +500,17 @@ NativeRegExpMacroAssembler::GenerateCode
         // If any of the code above needed to exit with an exception.
         masm.bind(&exit_with_exception_label_);
 
         // Exit with an error result to signal thrown exception.
         masm.movePtr(ImmWord(RegExpRunStatus_Error), temp0);
         masm.jump(&return_temp0);
     }
 
-    Linker linker(masm);
-    AutoFlushICache afc("RegExp");
+    Linker linker(masm, "RegExp");
     JitCode* code = linker.newCode(cx, CodeKind::RegExp);
     if (!code)
         return RegExpCode();
 
 #ifdef JS_ION_PERF
     writePerfSpewerJitCodeProfile(code, "RegExp");
 #endif
 
--- a/js/src/jit/BaselineCacheIRCompiler.cpp
+++ b/js/src/jit/BaselineCacheIRCompiler.cpp
@@ -214,18 +214,17 @@ JitCode* BaselineCacheIRCompiler::compil
   // Done emitting the main IC code. Now emit the failure paths.
   for (size_t i = 0; i < failurePaths.length(); i++) {
     if (!emitFailurePath(i)) {
       return nullptr;
     }
     EmitStubGuardFailure(masm);
   }
 
-  Linker linker(masm);
-  AutoFlushICache afc("getStubCode");
+  Linker linker(masm, "getStubCode");
   Rooted<JitCode*> newStubCode(cx_, linker.newCode(cx_, CodeKind::Baseline));
   if (!newStubCode) {
     cx_->recoverFromOutOfMemory();
     return nullptr;
   }
 
   return newStubCode;
 }
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -185,23 +185,22 @@ MethodStatus BaselineCompiler::compile()
   if (!emitEpilogue()) {
     return Method_Error;
   }
 
   if (!emitOutOfLinePostBarrierSlot()) {
     return Method_Error;
   }
 
-  Linker linker(masm);
+  Linker linker(masm, "Baseline");
   if (masm.oom()) {
     ReportOutOfMemory(cx);
     return Method_Error;
   }
 
-  AutoFlushICache afc("Baseline");
   JitCode* code = linker.newCode(cx, CodeKind::Baseline);
   if (!code) {
     return Method_Error;
   }
 
   Rooted<EnvironmentObject*> templateEnv(cx);
   if (script->functionNonDelazifying()) {
     RootedFunction fun(cx, script->functionNonDelazifying());
--- a/js/src/jit/BaselineDebugModeOSR.cpp
+++ b/js/src/jit/BaselineDebugModeOSR.cpp
@@ -1002,18 +1002,17 @@ JitCode* JitRuntime::generateBaselineDeb
   EmitBaselineDebugModeOSRHandlerTail(masm, temp,
                                       /* returnFromCallVM = */ false);
   masm.jump(&end);
   masm.bind(&returnFromCallVM);
   EmitBaselineDebugModeOSRHandlerTail(masm, temp,
                                       /* returnFromCallVM = */ true);
   masm.bind(&end);
 
-  Linker linker(masm);
-  AutoFlushICache afc("BaselineDebugModeOSRHandler");
+  Linker linker(masm, "BaselineDebugModeOSRHandler");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return nullptr;
   }
 
   *noFrameRegPopOffsetOut = noFrameRegPopOffset.offset();
 
 #ifdef JS_ION_PERF
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -1071,18 +1071,17 @@ JitCode* ICStubCompiler::getStubCode() {
 #endif
 #ifdef JS_CODEGEN_ARM
   masm.setSecondScratchReg(BaselineSecondScratchReg);
 #endif
 
   if (!generateStubCode(masm)) {
     return nullptr;
   }
-  Linker linker(masm);
-  AutoFlushICache afc("getStubCode");
+  Linker linker(masm, "getStubCode");
   Rooted<JitCode*> newStubCode(cx, linker.newCode(cx, CodeKind::Baseline));
   if (!newStubCode) {
     return nullptr;
   }
 
   // Cache newly compiled stubcode.
   if (!realm->putStubCode(cx, stubKey, newStubCode)) {
     return nullptr;
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -2299,18 +2299,17 @@ JitCode* JitRealm::generateRegExpMatcher
   masm.jump(&matchResultJoin);
 
   // Use an undefined value to signal to the caller that the OOL stub needs to
   // be called.
   masm.bind(&oolEntry);
   masm.moveValue(UndefinedValue(), result);
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("RegExpMatcherStub");
+  Linker linker(masm, "RegExpMatcherStub");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return nullptr;
   }
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(code, "RegExpMatcherStub");
 #endif
@@ -2485,18 +2484,17 @@ JitCode* JitRealm::generateRegExpSearche
   masm.bind(&notFound);
   masm.move32(Imm32(RegExpSearcherResultNotFound), result);
   masm.ret();
 
   masm.bind(&oolEntry);
   masm.move32(Imm32(RegExpSearcherResultFailed), result);
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("RegExpSearcherStub");
+  Linker linker(masm, "RegExpSearcherStub");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return nullptr;
   }
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(code, "RegExpSearcherStub");
 #endif
@@ -2628,18 +2626,17 @@ JitCode* JitRealm::generateRegExpTesterS
 
   masm.bind(&oolEntry);
   masm.move32(Imm32(RegExpTesterResultFailed), result);
 
   masm.bind(&done);
   masm.freeStack(sizeof(irregexp::InputOutputData));
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("RegExpTesterStub");
+  Linker linker(masm, "RegExpTesterStub");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return nullptr;
   }
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(code, "RegExpTesterStub");
 #endif
@@ -8760,18 +8757,17 @@ JitCode* JitRealm::generateStringConcatS
 
   masm.pop(temp2);
   masm.pop(temp1);
 
   masm.bind(&failure);
   masm.movePtr(ImmPtr(nullptr), output);
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("StringConcatStub");
+  Linker linker(masm, "StringConcatStub");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(code, "StringConcatStub");
 #endif
 #ifdef MOZ_VTUNE
   vtune::MarkStub(code, "StringConcatStub");
 #endif
@@ -10428,18 +10424,17 @@ bool CodeGenerator::link(JSContext* cx, 
     return false;
   }
   auto guardIonScript = mozilla::MakeScopeExit([&ionScript] {
     // Use js_free instead of IonScript::Destroy: the cache list is still
     // uninitialized.
     js_free(ionScript);
   });
 
-  Linker linker(masm);
-  AutoFlushICache afc("IonLink");
+  Linker linker(masm, "IonLink");
   JitCode* code = linker.newCode(cx, CodeKind::Ion);
   if (!code) {
     return false;
   }
 
   // Encode native to bytecode map if profiling is enabled.
   if (isProfilerInstrumentationEnabled()) {
     // Generate native-to-bytecode main table.
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -300,18 +300,17 @@ bool JitRuntime::initialize(JSContext* c
   JitSpew(JitSpew_Codegen, "# Emitting profiler exit frame tail stub");
   Label profilerExitTail;
   generateProfilerExitFrameTailStub(masm, &profilerExitTail);
 
   JitSpew(JitSpew_Codegen, "# Emitting exception tail stub");
   void* handler = JS_FUNC_TO_DATA_PTR(void*, jit::HandleException);
   generateExceptionTailStub(masm, handler, &profilerExitTail);
 
-  Linker linker(masm);
-  AutoFlushICache afc("Trampolines");
+  Linker linker(masm, "Trampolines");
   trampolineCode_ = linker.newCode(cx, CodeKind::Other);
   if (!trampolineCode_) {
     return false;
   }
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(trampolineCode_, "Trampolines");
 #endif
--- a/js/src/jit/IonCacheIRCompiler.cpp
+++ b/js/src/jit/IonCacheIRCompiler.cpp
@@ -614,18 +614,17 @@ JitCode* IonCacheIRCompiler::compile() {
     Register scratch = ic_->scratchRegisterForEntryJump();
     CodeOffset offset = masm.movWithPatch(ImmWord(-1), scratch);
     masm.jump(Address(scratch, 0));
     if (!nextCodeOffsets_.append(offset)) {
       return nullptr;
     }
   }
 
-  Linker linker(masm);
-  AutoFlushICache afc("getStubCode");
+  Linker linker(masm, "getStubCode");
   Rooted<JitCode*> newStubCode(cx_, linker.newCode(cx_, CodeKind::Ion));
   if (!newStubCode) {
     cx_->recoverFromOutOfMemory();
     return nullptr;
   }
 
   rejoinOffset_.fixup(&masm);
   CodeLocationJump rejoinJump(newStubCode, rejoinOffset_);
--- a/js/src/jit/Linker.h
+++ b/js/src/jit/Linker.h
@@ -15,25 +15,30 @@
 #include "vm/Realm.h"
 
 namespace js {
 namespace jit {
 
 class Linker {
   MacroAssembler& masm;
   mozilla::Maybe<AutoWritableJitCodeFallible> awjcf;
+  AutoFlushICache afc;
 
   JitCode* fail(JSContext* cx) {
     ReportOutOfMemory(cx);
     return nullptr;
   }
 
  public:
   // Construct a linker with a rooted macro assembler.
-  explicit Linker(MacroAssembler& masm) : masm(masm) { masm.finish(); }
+  explicit Linker(MacroAssembler& masm, const char* name)
+      : masm(masm), afc(name)
+  {
+    masm.finish();
+  }
 
   // Create a new JitCode object and populate it with the contents of the
   // macro assember buffer.
   //
   // This method cannot GC. Errors are reported to the context.
   JitCode* newCode(JSContext* cx, CodeKind kind);
 };
 
--- a/js/src/jit/arm/Trampoline-arm.cpp
+++ b/js/src/jit/arm/Trampoline-arm.cpp
@@ -998,18 +998,17 @@ JitCode* JitRuntime::generateDebugTrapHa
     masm.branch32(Assembler::Equal, addressOfEnabled, Imm32(0),
                   &skipProfilingInstrumentation);
     masm.profilerExitFrame();
     masm.bind(&skipProfilingInstrumentation);
   }
 
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("DebugTrapHandler");
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 
   return codeDbg;
 }
--- a/js/src/jit/arm64/Trampoline-arm64.cpp
+++ b/js/src/jit/arm64/Trampoline-arm64.cpp
@@ -830,18 +830,17 @@ JitCode* JitRuntime::generateDebugTrapHa
       Address(BaselineFrameReg, BaselineFrame::reverseOffsetOfReturnValue()),
       JSReturnOperand);
   masm.Mov(masm.GetStackPointer64(), BaselineFrameReg64);
 
   masm.pop(BaselineFrameReg, lr);
   masm.syncStackPtr();
   masm.abiret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("DebugTrapHandler");
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 
   return codeDbg;
 }
--- a/js/src/jit/mips32/Trampoline-mips32.cpp
+++ b/js/src/jit/mips32/Trampoline-mips32.cpp
@@ -988,18 +988,17 @@ JitCode* JitRuntime::generateDebugTrapHa
     masm.branch32(Assembler::Equal, addressOfEnabled, Imm32(0),
                   &skipProfilingInstrumentation);
     masm.profilerExitFrame();
     masm.bind(&skipProfilingInstrumentation);
   }
 
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("DebugTrapHandler");
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 
   return codeDbg;
 }
--- a/js/src/jit/mips64/Trampoline-mips64.cpp
+++ b/js/src/jit/mips64/Trampoline-mips64.cpp
@@ -938,18 +938,17 @@ JitCode* JitRuntime::generateDebugTrapHa
     masm.branch32(Assembler::Equal, addressOfEnabled, Imm32(0),
                   &skipProfilingInstrumentation);
     masm.profilerExitFrame();
     masm.bind(&skipProfilingInstrumentation);
   }
 
   masm.ret();
 
-  Linker linker(masm);
-  AutoFlushICache afc("DebugTrapHandler");
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 
   return codeDbg;
 }
--- a/js/src/jit/x64/Trampoline-x64.cpp
+++ b/js/src/jit/x64/Trampoline-x64.cpp
@@ -879,17 +879,17 @@ JitCode* JitRuntime::generateDebugTrapHa
     masm.branch32(Assembler::Equal, addressOfEnabled, Imm32(0),
                   &skipProfilingInstrumentation);
     masm.profilerExitFrame();
     masm.bind(&skipProfilingInstrumentation);
   }
 
   masm.ret();
 
-  Linker linker(masm);
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 #ifdef MOZ_VTUNE
   vtune::MarkStub(codeDbg, "DebugTrapHandler");
 #endif
--- a/js/src/jit/x86/Trampoline-x86.cpp
+++ b/js/src/jit/x86/Trampoline-x86.cpp
@@ -898,17 +898,17 @@ JitCode* JitRuntime::generateDebugTrapHa
     masm.branch32(Assembler::Equal, addressOfEnabled, Imm32(0),
                   &skipProfilingInstrumentation);
     masm.profilerExitFrame();
     masm.bind(&skipProfilingInstrumentation);
   }
 
   masm.ret();
 
-  Linker linker(masm);
+  Linker linker(masm, "DebugTrapHandler");
   JitCode* codeDbg = linker.newCode(cx, CodeKind::Other);
 
 #ifdef JS_ION_PERF
   writePerfSpewerJitCodeProfile(codeDbg, "DebugTrapHandler");
 #endif
 #ifdef MOZ_VTUNE
   vtune::MarkStub(codeDbg, "DebugTrapHandler");
 #endif
--- a/js/src/jsapi-tests/testJitMacroAssembler.cpp
+++ b/js/src/jsapi-tests/testJitMacroAssembler.cpp
@@ -39,17 +39,17 @@ static bool Execute(JSContext* cx, Macro
   LiveRegisterSet save(regs.asLiveSet());
   masm.PopRegsInMask(save);
   masm.ret();  // Add return statement to be sure.
 
   if (masm.oom()) {
     return false;
   }
 
-  Linker linker(masm);
+  Linker linker(masm, "Test");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return false;
   }
   if (!ExecutableAllocator::makeExecutable(code->raw(), code->bufferSize())) {
     return false;
   }
 
--- a/js/src/vm/UnboxedObject.cpp
+++ b/js/src/vm/UnboxedObject.cpp
@@ -319,18 +319,17 @@ static const uintptr_t CLEAR_CONSTRUCTOR
 
   // Initialize the object so it is safe for GC.
   masm.initUnboxedObjectContents(object,
                                  templateObject->layoutDontCheckGeneration());
 
   masm.movePtr(ImmWord(CLEAR_CONSTRUCTOR_CODE_TOKEN), object);
   masm.jump(&done);
 
-  Linker linker(masm);
-  AutoFlushICache afc("UnboxedObject");
+  Linker linker(masm, "UnboxedObject");
   JitCode* code = linker.newCode(cx, CodeKind::Other);
   if (!code) {
     return false;
   }
 
   layout.setConstructorCode(code);
   return true;
 }