From: Geoffroy Van Cutsem Date: Wed, 13 Mar 2013 05:50:24 +0000 (+0100) Subject: Fix TIVI-504 (backport of trac.webkit.org/changeset/144137) X-Git-Tag: accepted/2.0/20130322.003418~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a9af8a03cefc0f0df9cd1cfaa5077a6c7a0696a8;p=profile%2Fivi%2Fwebkit-efl.git 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 --- diff --git a/Source/JavaScriptCore/dfg/DFGCapabilities.h b/Source/JavaScriptCore/dfg/DFGCapabilities.h index 2bc9b29..87306ae 100644 --- a/Source/JavaScriptCore/dfg/DFGCapabilities.h +++ b/Source/JavaScriptCore/dfg/DFGCapabilities.h @@ -180,7 +180,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 1a64a24..5bf0b2e 100644 --- a/Source/JavaScriptCore/dfg/DFGCommon.h +++ b/Source/JavaScriptCore/dfg/DFGCommon.h @@ -147,7 +147,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 52a7158..4280672 100644 --- a/Source/JavaScriptCore/jit/JIT.cpp +++ b/Source/JavaScriptCore/jit/JIT.cpp @@ -583,12 +583,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: @@ -753,7 +755,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 5529551..40b214d 100644 --- a/Source/JavaScriptCore/jit/JIT.h +++ b/Source/JavaScriptCore/jit/JIT.h @@ -852,9 +852,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; } @@ -901,6 +903,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 e68ecbe..e715369 100644 --- a/Source/JavaScriptCore/jit/JITInlineMethods.h +++ b/Source/JavaScriptCore/jit/JITInlineMethods.h @@ -724,8 +724,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 eda050b..17c9441 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 dfb2dc8..b981bed 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess.cpp @@ -549,7 +549,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 b506f4e..1aa36c1 100644 --- a/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp +++ b/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp @@ -493,7 +493,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 4a2003a..8f1fd6d 100755 --- a/Source/WTF/wtf/Platform.h +++ b/Source/WTF/wtf/Platform.h @@ -1369,7 +1369,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. */