FTL should use a simple optimization pipeline by default
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Nov 2013 02:24:51 +0000 (02:24 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Nov 2013 02:24:51 +0000 (02:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123638

Reviewed by Geoffrey Garen.

20% speed-up on imagine-gaussian-blur, when combined with --ftlUsesStackmaps=true.

* ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* runtime/Options.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158482 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/ftl/FTLCompile.cpp
Source/JavaScriptCore/runtime/Options.h

index a3f9f8a..22c1b4a 100644 (file)
@@ -1,3 +1,16 @@
+2013-11-01  Filip Pizlo  <fpizlo@apple.com>
+
+        FTL should use a simple optimization pipeline by default
+        https://bugs.webkit.org/show_bug.cgi?id=123638
+
+        Reviewed by Geoffrey Garen.
+        
+        20% speed-up on imagine-gaussian-blur, when combined with --ftlUsesStackmaps=true.
+
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::compile):
+        * runtime/Options.h:
+
 2013-11-01  Andreas Kling  <akling@apple.com>
 
         Neuter WTF_MAKE_FAST_ALLOCATED in GLOBAL_FASTMALLOC_NEW builds.
index 5fb793b..0dbc0e7 100644 (file)
@@ -260,26 +260,42 @@ void compile(State& state)
         CRASH();
     }
 
-    LLVMPassManagerBuilderRef passBuilder = llvm->PassManagerBuilderCreate();
-    llvm->PassManagerBuilderSetOptLevel(passBuilder, Options::llvmOptimizationLevel());
-    llvm->PassManagerBuilderSetSizeLevel(passBuilder, Options::llvmSizeLevel());
+    LLVMPassManagerRef functionPasses = 0;
+    LLVMPassManagerRef modulePasses;
     
-    LLVMPassManagerRef functionPasses = llvm->CreateFunctionPassManagerForModule(state.module);
-    LLVMPassManagerRef modulePasses = llvm->CreatePassManager();
-    
-    llvm->AddTargetData(llvm->GetExecutionEngineTargetData(engine), modulePasses);
-    
-    llvm->PassManagerBuilderPopulateFunctionPassManager(passBuilder, functionPasses);
-    llvm->PassManagerBuilderPopulateModulePassManager(passBuilder, modulePasses);
-    
-    llvm->PassManagerBuilderDispose(passBuilder);
-
-    llvm->InitializeFunctionPassManager(functionPasses);
-    for (LValue function = llvm->GetFirstFunction(state.module); function; function = llvm->GetNextFunction(function))
-        llvm->RunFunctionPassManager(functionPasses, function);
-    llvm->FinalizeFunctionPassManager(functionPasses);
-    
-    llvm->RunPassManager(modulePasses, state.module);
+    if (Options::llvmSimpleOpt()) {
+        modulePasses = llvm->CreatePassManager();
+        llvm->AddTargetData(llvm->GetExecutionEngineTargetData(engine), modulePasses);
+        llvm->AddPromoteMemoryToRegisterPass(modulePasses);
+        llvm->AddConstantPropagationPass(modulePasses);
+        llvm->AddInstructionCombiningPass(modulePasses);
+        llvm->AddBasicAliasAnalysisPass(modulePasses);
+        llvm->AddTypeBasedAliasAnalysisPass(modulePasses);
+        llvm->AddGVNPass(modulePasses);
+        llvm->AddCFGSimplificationPass(modulePasses);
+        llvm->RunPassManager(modulePasses, state.module);
+    } else {
+        LLVMPassManagerBuilderRef passBuilder = llvm->PassManagerBuilderCreate();
+        llvm->PassManagerBuilderSetOptLevel(passBuilder, Options::llvmOptimizationLevel());
+        llvm->PassManagerBuilderSetSizeLevel(passBuilder, Options::llvmSizeLevel());
+        
+        functionPasses = llvm->CreateFunctionPassManagerForModule(state.module);
+        modulePasses = llvm->CreatePassManager();
+        
+        llvm->AddTargetData(llvm->GetExecutionEngineTargetData(engine), modulePasses);
+        
+        llvm->PassManagerBuilderPopulateFunctionPassManager(passBuilder, functionPasses);
+        llvm->PassManagerBuilderPopulateModulePassManager(passBuilder, modulePasses);
+        
+        llvm->PassManagerBuilderDispose(passBuilder);
+        
+        llvm->InitializeFunctionPassManager(functionPasses);
+        for (LValue function = llvm->GetFirstFunction(state.module); function; function = llvm->GetNextFunction(function))
+            llvm->RunFunctionPassManager(functionPasses, function);
+        llvm->FinalizeFunctionPassManager(functionPasses);
+        
+        llvm->RunPassManager(modulePasses, state.module);
+    }
 
     if (DFG::shouldShowDisassembly() || DFG::verboseCompilationEnabled())
         state.dumpState("after optimization");
@@ -287,7 +303,8 @@ void compile(State& state)
     // FIXME: Need to add support for the case where JIT memory allocation failed.
     // https://bugs.webkit.org/show_bug.cgi?id=113620
     state.generatedFunction = reinterpret_cast<GeneratedFunction>(llvm->GetPointerToGlobal(engine, state.function));
-    llvm->DisposePassManager(functionPasses);
+    if (functionPasses)
+        llvm->DisposePassManager(functionPasses);
     llvm->DisposePassManager(modulePasses);
     llvm->DisposeExecutionEngine(engine);
 
index e800af4..3d9b43e 100644 (file)
@@ -131,6 +131,7 @@ typedef OptionRange optionRange;
     v(bool, dumpLLVMIR, false) \
     v(bool, llvmAlwaysFailsBeforeCompile, false) \
     v(bool, llvmAlwaysFailsBeforeLink, false) \
+    v(bool, llvmSimpleOpt, true) \
     v(unsigned, llvmBackendOptimizationLevel, 2) \
     v(unsigned, llvmOptimizationLevel, 2) \
     v(unsigned, llvmSizeLevel, 0) \