Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (104773 => 104774)
--- trunk/Source/_javascript_Core/ChangeLog 2012-01-12 01:17:47 UTC (rev 104773)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-01-12 01:23:49 UTC (rev 104774)
@@ -1,3 +1,22 @@
+2012-01-11 Filip Pizlo <[email protected]>
+
+ Code duplication for invoking the JIT and DFG should be reduced
+ https://bugs.webkit.org/show_bug.cgi?id=76117
+ <rdar://problem/10680189>
+
+ Rubber stamped by Geoff Garen.
+
+ * GNUmakefile.list.am:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * jit/JITDriver.h: Added.
+ (JSC::jitCompileIfAppropriate):
+ (JSC::jitCompileFunctionIfAppropriate):
+ * runtime/Executable.cpp:
+ (JSC::EvalExecutable::compileInternal):
+ (JSC::ProgramExecutable::compileInternal):
+ (JSC::FunctionExecutable::compileForCallInternal):
+ (JSC::FunctionExecutable::compileForConstructInternal):
+
2012-01-11 Geoffrey Garen <[email protected]>
Bytecode dumping is broken for call opcodes (due to two new operands)
Modified: trunk/Source/_javascript_Core/GNUmakefile.list.am (104773 => 104774)
--- trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-01-12 01:17:47 UTC (rev 104773)
+++ trunk/Source/_javascript_Core/GNUmakefile.list.am 2012-01-12 01:23:49 UTC (rev 104774)
@@ -268,6 +268,7 @@
Source/_javascript_Core/jit/JITCall32_64.cpp \
Source/_javascript_Core/jit/JITCall.cpp \
Source/_javascript_Core/jit/JITCode.h \
+ Source/_javascript_Core/jit/JITDriver.h \
Source/_javascript_Core/jit/JIT.cpp \
Source/_javascript_Core/jit/JIT.h \
Source/_javascript_Core/jit/JITExceptions.cpp \
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (104773 => 104774)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-01-12 01:17:47 UTC (rev 104773)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2012-01-12 01:23:49 UTC (rev 104774)
@@ -60,6 +60,7 @@
0F0B83B914BCF95F00885B4F /* CallReturnOffsetToBytecodeOffset.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0B83B814BCF95B00885B4F /* CallReturnOffsetToBytecodeOffset.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F16D726142C39C000CF784A /* BitVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F16D724142C39A200CF784A /* BitVector.cpp */; };
+ 0F21C26814BE5F6800ADC64B /* JITDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F21C26614BE5F5E00ADC64B /* JITDriver.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F242DA713F3B1E8007ADD4C /* WeakReferenceHarvester.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F2C556F14738F3100121E4F /* DFGCodeBlocks.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F2C557014738F3500121E4F /* DFGCodeBlocks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */; };
@@ -827,6 +828,7 @@
0F0B83B814BCF95B00885B4F /* CallReturnOffsetToBytecodeOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallReturnOffsetToBytecodeOffset.h; sourceTree = "<group>"; };
0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonSlowPaths.h; sourceTree = "<group>"; };
0F16D724142C39A200CF784A /* BitVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitVector.cpp; sourceTree = "<group>"; };
+ 0F21C26614BE5F5E00ADC64B /* JITDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITDriver.h; sourceTree = "<group>"; };
0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakReferenceHarvester.h; sourceTree = "<group>"; };
0F2C556D14738F2E00121E4F /* DFGCodeBlocks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFGCodeBlocks.cpp; sourceTree = "<group>"; };
0F2C556E14738F2E00121E4F /* DFGCodeBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFGCodeBlocks.h; sourceTree = "<group>"; };
@@ -1707,6 +1709,7 @@
86CC85A20EE79B7400288682 /* JITCall.cpp */,
146FE51111A710430087AE66 /* JITCall32_64.cpp */,
86CCEFDD0F413F8900FD7F9E /* JITCode.h */,
+ 0F21C26614BE5F5E00ADC64B /* JITDriver.h */,
86CC85A00EE79A4700288682 /* JITInlineMethods.h */,
BCDD51E90FB8DF74004A8BDC /* JITOpcodes.cpp */,
A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */,
@@ -3021,6 +3024,7 @@
0F0B83B514BCF86200885B4F /* MethodCallLinkInfo.h in Headers */,
0F0B83B714BCF8E100885B4F /* GlobalResolveInfo.h in Headers */,
0F0B83B914BCF95F00885B4F /* CallReturnOffsetToBytecodeOffset.h in Headers */,
+ 0F21C26814BE5F6800ADC64B /* JITDriver.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Source/_javascript_Core/jit/JITDriver.h (0 => 104774)
--- trunk/Source/_javascript_Core/jit/JITDriver.h (rev 0)
+++ trunk/Source/_javascript_Core/jit/JITDriver.h 2012-01-12 01:23:49 UTC (rev 104774)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JITDriver_h
+#define JITDriver_h
+
+#include <wtf/Platform.h>
+
+#if ENABLE(JIT)
+
+#include "BytecodeGenerator.h"
+#include "DFGDriver.h"
+#include "JIT.h"
+
+namespace JSC {
+
+template<typename CodeBlockType>
+inline bool jitCompileIfAppropriate(ExecState* exec, OwnPtr<CodeBlockType>& codeBlock, JITCode& jitCode, JITCode::JITType jitType)
+{
+ if (!exec->globalData().canUseJIT())
+ return true;
+
+ bool dfgCompiled = false;
+ if (jitType == JITCode::DFGJIT)
+ dfgCompiled = DFG::tryCompile(exec, codeBlock.get(), jitCode);
+ if (dfgCompiled) {
+ if (codeBlock->alternative())
+ codeBlock->alternative()->unlinkIncomingCalls();
+ } else {
+ if (codeBlock->alternative()) {
+ codeBlock = static_pointer_cast<CodeBlockType>(codeBlock->releaseAlternative());
+ return false;
+ }
+ jitCode = JIT::compile(&exec->globalData(), codeBlock.get());
+ }
+#if !ENABLE(OPCODE_SAMPLING)
+ if (!BytecodeGenerator::dumpsGeneratedCode())
+ codeBlock->handleBytecodeDiscardingOpportunity();
+#endif
+ codeBlock->setJITCode(jitCode, MacroAssemblerCodePtr());
+
+ return true;
+}
+
+inline bool jitCompileFunctionIfAppropriate(ExecState* exec, OwnPtr<FunctionCodeBlock>& codeBlock, JITCode& jitCode, MacroAssemblerCodePtr& jitCodeWithArityCheck, SharedSymbolTable*& symbolTable, JITCode::JITType jitType)
+{
+ JSGlobalData& globalData = exec->globalData();
+ if (!globalData.canUseJIT())
+ return true;
+
+ bool dfgCompiled = false;
+ if (jitType == JITCode::DFGJIT)
+ dfgCompiled = DFG::tryCompileFunction(exec, codeBlock.get(), jitCode, jitCodeWithArityCheck);
+ if (dfgCompiled) {
+ if (codeBlock->alternative())
+ codeBlock->alternative()->unlinkIncomingCalls();
+ } else {
+ if (codeBlock->alternative()) {
+ codeBlock = static_pointer_cast<FunctionCodeBlock>(codeBlock->releaseAlternative());
+ symbolTable = codeBlock->sharedSymbolTable();
+ return false;
+ }
+ jitCode = JIT::compile(&globalData, codeBlock.get(), &jitCodeWithArityCheck);
+ }
+#if !ENABLE(OPCODE_SAMPLING)
+ if (!BytecodeGenerator::dumpsGeneratedCode())
+ codeBlock->handleBytecodeDiscardingOpportunity();
+#endif
+
+ codeBlock->setJITCode(jitCode, jitCodeWithArityCheck);
+
+ return true;
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITDriver_h
+
Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (104773 => 104774)
--- trunk/Source/_javascript_Core/runtime/Executable.cpp 2012-01-12 01:17:47 UTC (rev 104773)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp 2012-01-12 01:23:49 UTC (rev 104774)
@@ -30,6 +30,7 @@
#include "CodeBlock.h"
#include "DFGDriver.h"
#include "JIT.h"
+#include "JITDriver.h"
#include "Parser.h"
#include "UStringBuilder.h"
#include "Vector.h"
@@ -209,28 +210,9 @@
}
#if ENABLE(JIT)
- if (exec->globalData().canUseJIT()) {
- bool dfgCompiled = false;
- if (jitType == JITCode::DFGJIT)
- dfgCompiled = DFG::tryCompile(exec, m_evalCodeBlock.get(), m_jitCodeForCall);
- if (dfgCompiled)
- ASSERT(!m_evalCodeBlock->alternative() || !m_evalCodeBlock->alternative()->hasIncomingCalls());
- else {
- if (m_evalCodeBlock->alternative()) {
- // There is already an alternative piece of code compiled with a different
- // JIT, so we can silently fail.
- m_evalCodeBlock = static_pointer_cast<EvalCodeBlock>(m_evalCodeBlock->releaseAlternative());
- return 0;
- }
- m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_evalCodeBlock.get());
- }
-#if !ENABLE(OPCODE_SAMPLING)
- if (!BytecodeGenerator::dumpsGeneratedCode())
- m_evalCodeBlock->handleBytecodeDiscardingOpportunity();
+ if (!jitCompileIfAppropriate(exec, m_evalCodeBlock, m_jitCodeForCall, jitType))
+ return 0;
#endif
- m_evalCodeBlock->setJITCode(m_jitCodeForCall, MacroAssemblerCodePtr());
- }
-#endif
#if ENABLE(JIT)
#if ENABLE(INTERPRETER)
@@ -354,27 +336,9 @@
}
#if ENABLE(JIT)
- if (exec->globalData().canUseJIT()) {
- bool dfgCompiled = false;
- if (jitType == JITCode::DFGJIT)
- dfgCompiled = DFG::tryCompile(exec, m_programCodeBlock.get(), m_jitCodeForCall);
- if (dfgCompiled) {
- if (m_programCodeBlock->alternative())
- m_programCodeBlock->alternative()->unlinkIncomingCalls();
- } else {
- if (m_programCodeBlock->alternative()) {
- m_programCodeBlock = static_pointer_cast<ProgramCodeBlock>(m_programCodeBlock->releaseAlternative());
- return 0;
- }
- m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, m_programCodeBlock.get());
- }
-#if !ENABLE(OPCODE_SAMPLING)
- if (!BytecodeGenerator::dumpsGeneratedCode())
- m_programCodeBlock->handleBytecodeDiscardingOpportunity();
+ if (!jitCompileIfAppropriate(exec, m_programCodeBlock, m_jitCodeForCall, jitType))
+ return 0;
#endif
- m_programCodeBlock->setJITCode(m_jitCodeForCall, MacroAssemblerCodePtr());
- }
-#endif
#if ENABLE(JIT)
#if ENABLE(INTERPRETER)
@@ -540,30 +504,9 @@
m_symbolTable = m_codeBlockForCall->sharedSymbolTable();
#if ENABLE(JIT)
- JSGlobalData* globalData = scopeChainNode->globalData;
- if (globalData->canUseJIT()) {
- bool dfgCompiled = false;
- if (jitType == JITCode::DFGJIT)
- dfgCompiled = DFG::tryCompileFunction(exec, m_codeBlockForCall.get(), m_jitCodeForCall, m_jitCodeForCallWithArityCheck);
- if (dfgCompiled) {
- if (m_codeBlockForCall->alternative())
- m_codeBlockForCall->alternative()->unlinkIncomingCalls();
- } else {
- if (m_codeBlockForCall->alternative()) {
- m_codeBlockForCall = static_pointer_cast<FunctionCodeBlock>(m_codeBlockForCall->releaseAlternative());
- m_symbolTable = m_codeBlockForCall->sharedSymbolTable();
- return 0;
- }
- m_jitCodeForCall = JIT::compile(globalData, m_codeBlockForCall.get(), &m_jitCodeForCallWithArityCheck);
- }
-#if !ENABLE(OPCODE_SAMPLING)
- if (!BytecodeGenerator::dumpsGeneratedCode())
- m_codeBlockForCall->handleBytecodeDiscardingOpportunity();
+ if (!jitCompileFunctionIfAppropriate(exec, m_codeBlockForCall, m_jitCodeForCall, m_jitCodeForCallWithArityCheck, m_symbolTable, jitType))
+ return 0;
#endif
-
- m_codeBlockForCall->setJITCode(m_jitCodeForCall, m_jitCodeForCallWithArityCheck);
- }
-#endif
#if ENABLE(JIT)
#if ENABLE(INTERPRETER)
@@ -603,30 +546,9 @@
m_symbolTable = m_codeBlockForConstruct->sharedSymbolTable();
#if ENABLE(JIT)
- JSGlobalData* globalData = scopeChainNode->globalData;
- if (globalData->canUseJIT()) {
- bool dfgCompiled = false;
- if (jitType == JITCode::DFGJIT)
- dfgCompiled = DFG::tryCompileFunction(exec, m_codeBlockForConstruct.get(), m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck);
- if (dfgCompiled) {
- if (m_codeBlockForConstruct->alternative())
- m_codeBlockForConstruct->alternative()->unlinkIncomingCalls();
- } else {
- if (m_codeBlockForConstruct->alternative()) {
- m_codeBlockForConstruct = static_pointer_cast<FunctionCodeBlock>(m_codeBlockForConstruct->releaseAlternative());
- m_symbolTable = m_codeBlockForConstruct->sharedSymbolTable();
- return 0;
- }
- m_jitCodeForConstruct = JIT::compile(globalData, m_codeBlockForConstruct.get(), &m_jitCodeForConstructWithArityCheck);
- }
-#if !ENABLE(OPCODE_SAMPLING)
- if (!BytecodeGenerator::dumpsGeneratedCode())
- m_codeBlockForConstruct->handleBytecodeDiscardingOpportunity();
+ if (!jitCompileFunctionIfAppropriate(exec, m_codeBlockForConstruct, m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck, m_symbolTable, jitType))
+ return 0;
#endif
-
- m_codeBlockForConstruct->setJITCode(m_jitCodeForConstruct, m_jitCodeForConstructWithArityCheck);
- }
-#endif
#if ENABLE(JIT)
#if ENABLE(INTERPRETER)