From 5d56ab31cd2673c870a3af2a23befd6c2fd131c5 Mon Sep 17 00:00:00 2001 From: Geoffroy Van Cutsem Date: Wed, 13 Mar 2013 06:50:24 +0100 Subject: [PATCH] Fix TIVI-504 (backport of trac.webkit.org/changeset/144137) Enable DFG JIT for x86 (performance improvement) Change-Id: I9568df72e6667afd62b1071a5b644fecbeff0116 Signed-off-by: Yuqiang Xian Signed-off-by: Geoffroy Van Cutsem --- Source/JavaScriptCore/dfg/DFGCapabilities.h | 2 +- Source/JavaScriptCore/dfg/DFGCommon.h | 2 +- Source/JavaScriptCore/jit/JIT.cpp | 6 ++++-- Source/JavaScriptCore/jit/JIT.h | 3 +++ Source/JavaScriptCore/jit/JITArithmetic.cpp | 4 ++++ Source/JavaScriptCore/jit/JITArithmetic32_64.cpp | 4 ++++ Source/JavaScriptCore/jit/JITCall.cpp | 2 +- Source/JavaScriptCore/jit/JITInlineMethods.h | 4 ++-- Source/JavaScriptCore/jit/JITOpcodes.cpp | 2 +- Source/JavaScriptCore/jit/JITPropertyAccess.cpp | 2 +- Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp | 2 +- Source/WTF/wtf/Platform.h | 2 +- 12 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Source/JavaScriptCore/dfg/DFGCapabilities.h b/Source/JavaScriptCore/dfg/DFGCapabilities.h index 694e886..d17b835 100644 --- a/Source/JavaScriptCore/dfg/DFGCapabilities.h +++ b/Source/JavaScriptCore/dfg/DFGCapabilities.h @@ -174,7 +174,7 @@ inline CapabilityLevel canCompileOpcode(OpcodeID opcodeID, CodeBlock*, Instructi return CanCompile; case op_call_varargs: - return ShouldProfile; + return MayInline; default: return CannotCompile; diff --git a/Source/JavaScriptCore/dfg/DFGCommon.h b/Source/JavaScriptCore/dfg/DFGCommon.h index b2e3bb4..d5dc380 100644 --- a/Source/JavaScriptCore/dfg/DFGCommon.h +++ b/Source/JavaScriptCore/dfg/DFGCommon.h @@ -140,7 +140,7 @@ namespace JSC { namespace DFG { // Put things here that must be defined even if ENABLE(DFG_JIT) is false. -enum CapabilityLevel { CannotCompile, ShouldProfile, CanCompile, CapabilityLevelNotSet }; +enum CapabilityLevel { CannotCompile, MayInline, CanCompile, CapabilityLevelNotSet }; } } // namespace JSC::DFG diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp index ff5615f..66d5a55 100644 --- a/Source/JavaScriptCore/jit/JIT.cpp +++ b/Source/JavaScriptCore/jit/JIT.cpp @@ -571,12 +571,14 @@ JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffo m_canBeOptimized = false; m_shouldEmitProfiling = false; break; - case DFG::ShouldProfile: + case DFG::MayInline: m_canBeOptimized = false; + m_canBeOptimizedOrInlined = true; m_shouldEmitProfiling = true; break; case DFG::CanCompile: m_canBeOptimized = true; + m_canBeOptimizedOrInlined = true; m_shouldEmitProfiling = true; break; default: @@ -743,7 +745,7 @@ JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffo } #if ENABLE(DFG_JIT) || ENABLE(LLINT) - if (canBeOptimized() + if (canBeOptimizedOrInlined() #if ENABLE(LLINT) || true #endif diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h index d114310..aeaea86 100644 --- a/Source/JavaScriptCore/jit/JIT.h +++ b/Source/JavaScriptCore/jit/JIT.h @@ -836,9 +836,11 @@ namespace JSC { #if ENABLE(DFG_JIT) bool canBeOptimized() { return m_canBeOptimized; } + bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; } bool shouldEmitProfiling() { return m_shouldEmitProfiling; } #else bool canBeOptimized() { return false; } + bool canBeOptimizedOrInlined() { return false; } // Enables use of value profiler with tiered compilation turned off, // in which case all code gets profiled. bool shouldEmitProfiling() { return true; } @@ -885,6 +887,7 @@ namespace JSC { #if ENABLE(VALUE_PROFILER) bool m_canBeOptimized; + bool m_canBeOptimizedOrInlined; bool m_shouldEmitProfiling; #endif } JIT_CLASS_ALIGNMENT; diff --git a/Source/JavaScriptCore/jit/JITArithmetic.cpp b/Source/JavaScriptCore/jit/JITArithmetic.cpp index b66e2cd..dfd2654 100644 --- a/Source/JavaScriptCore/jit/JITArithmetic.cpp +++ b/Source/JavaScriptCore/jit/JITArithmetic.cpp @@ -640,6 +640,8 @@ void JIT::emit_op_post_inc(Instruction* currentInstruction) emitFastArithIntToImmNoCheck(regT1, regT1); emitPutVirtualRegister(srcDst, regT1); emitPutVirtualRegister(result); + if (canBeOptimizedOrInlined()) + killLastResultRegister(); } void JIT::emitSlow_op_post_inc(Instruction* currentInstruction, Vector::iterator& iter) @@ -667,6 +669,8 @@ void JIT::emit_op_post_dec(Instruction* currentInstruction) emitFastArithIntToImmNoCheck(regT1, regT1); emitPutVirtualRegister(srcDst, regT1); emitPutVirtualRegister(result); + if (canBeOptimizedOrInlined()) + killLastResultRegister(); } void JIT::emitSlow_op_post_dec(Instruction* currentInstruction, Vector::iterator& iter) diff --git a/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp b/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp index 62a359e..4974f87 100644 --- a/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp +++ b/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp @@ -466,6 +466,8 @@ void JIT::emit_op_post_inc(Instruction* currentInstruction) emitStoreInt32(srcDst, regT2, true); emitStoreAndMapInt32(dst, regT1, regT0, false, OPCODE_LENGTH(op_post_inc)); + if (canBeOptimizedOrInlined()) + unmap(); } void JIT::emitSlow_op_post_inc(Instruction* currentInstruction, Vector::iterator& iter) @@ -501,6 +503,8 @@ void JIT::emit_op_post_dec(Instruction* currentInstruction) emitStoreInt32(srcDst, regT2, true); emitStoreAndMapInt32(dst, regT1, regT0, false, OPCODE_LENGTH(op_post_dec)); + if (canBeOptimizedOrInlined()) + unmap(); } void JIT::emitSlow_op_post_dec(Instruction* currentInstruction, Vector::iterator& iter) diff --git a/Source/JavaScriptCore/jit/JITCall.cpp b/Source/JavaScriptCore/jit/JITCall.cpp index 7664eb7..019618a 100644 --- a/Source/JavaScriptCore/jit/JITCall.cpp +++ b/Source/JavaScriptCore/jit/JITCall.cpp @@ -52,7 +52,7 @@ void JIT::emit_op_call_put_result(Instruction* instruction) int dst = instruction[1].u.operand; emitValueProfilingSite(); emitPutVirtualRegister(dst); - if (canBeOptimized()) + if (canBeOptimizedOrInlined()) killLastResultRegister(); // Make lastResultRegister tracking simpler in the DFG. } diff --git a/Source/JavaScriptCore/jit/JITInlineMethods.h b/Source/JavaScriptCore/jit/JITInlineMethods.h index 40985ac..6147b90 100644 --- a/Source/JavaScriptCore/jit/JITInlineMethods.h +++ b/Source/JavaScriptCore/jit/JITInlineMethods.h @@ -759,8 +759,8 @@ inline void JIT::map(unsigned bytecodeOffset, int virtualRegisterIndex, Register m_mappedTag = tag; m_mappedPayload = payload; - ASSERT(!canBeOptimized() || m_mappedPayload == regT0); - ASSERT(!canBeOptimized() || m_mappedTag == regT1); + ASSERT(!canBeOptimizedOrInlined() || m_mappedPayload == regT0); + ASSERT(!canBeOptimizedOrInlined() || m_mappedTag == regT1); } inline void JIT::unmap(RegisterID registerID) diff --git a/Source/JavaScriptCore/jit/JITOpcodes.cpp b/Source/JavaScriptCore/jit/JITOpcodes.cpp index aa2938c..fe75cb4 100644 --- a/Source/JavaScriptCore/jit/JITOpcodes.cpp +++ b/Source/JavaScriptCore/jit/JITOpcodes.cpp @@ -352,7 +352,7 @@ void JIT::emit_op_mov(Instruction* currentInstruction) int dst = currentInstruction[1].u.operand; int src = currentInstruction[2].u.operand; - if (canBeOptimized()) { + if (canBeOptimizedOrInlined()) { // Use simpler approach, since the DFG thinks that the last result register // is always set to the destination on every operation. emitGetVirtualRegister(src, regT0); diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp index 5d39735..80c1eba 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp @@ -513,7 +513,7 @@ void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure // If we succeed in all of our checks, and the code was optimizable, then make sure we // decrement the rare case counter. #if ENABLE(VALUE_PROFILER) - if (m_codeBlock->canCompileWithDFG() >= DFG::ShouldProfile) { + if (m_codeBlock->canCompileWithDFG() >= DFG::MayInline) { sub32( TrustedImm32(1), AbsoluteAddress(&m_codeBlock->rareCaseProfileForBytecodeOffset(stubInfo->bytecodeIndex)->m_counter)); diff --git a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp index bd57484..f0c40a7 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp @@ -479,7 +479,7 @@ void JIT::privateCompilePutByIdTransition(StructureStubInfo* stubInfo, Structure // If we succeed in all of our checks, and the code was optimizable, then make sure we // decrement the rare case counter. #if ENABLE(VALUE_PROFILER) - if (m_codeBlock->canCompileWithDFG() >= DFG::ShouldProfile) { + if (m_codeBlock->canCompileWithDFG() >= DFG::MayInline) { sub32( TrustedImm32(1), AbsoluteAddress(&m_codeBlock->rareCaseProfileForBytecodeOffset(stubInfo->bytecodeIndex)->m_counter)); diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h index 78af182..4fa99ab 100755 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -1403,7 +1403,7 @@ #if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) /* Enable the DFG JIT on X86 and X86_64. Only tested on Mac and GNU/Linux. */ -#if (CPU(X86) || CPU(X86_64)) && (PLATFORM(MAC) || OS(LINUX)) && !OS(TIZEN) +#if (CPU(X86) || CPU(X86_64)) && (PLATFORM(MAC) || OS(LINUX)) #define ENABLE_DFG_JIT 1 #endif /* Enable the DFG JIT on ARMv7. Only tested on iOS. */ -- 2.7.4