Diff
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (179222 => 179223)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2015-01-27 22:56:00 UTC (rev 179223)
@@ -125,7 +125,6 @@
dfg/DFGAvailabilityMap.cpp
dfg/DFGBackwardsPropagationPhase.cpp
dfg/DFGBasicBlock.cpp
- dfg/DFGBinarySwitch.cpp
dfg/DFGBlockInsertionSet.cpp
dfg/DFGBlockSet.cpp
dfg/DFGBlockWorklist.cpp
@@ -327,6 +326,7 @@
jit/AccessorCallJITStubRoutine.cpp
jit/AssemblyHelpers.cpp
jit/ArityCheckFailReturnThunks.cpp
+ jit/BinarySwitch.cpp
jit/ClosureCallStubRoutine.cpp
jit/ExecutableAllocator.cpp
jit/ExecutableAllocatorFixedVMPool.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (179222 => 179223)
--- trunk/Source/_javascript_Core/ChangeLog 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-01-27 22:56:00 UTC (rev 179223)
@@ -1,3 +1,22 @@
+2015-01-27 Filip Pizlo <[email protected]>
+
+ Move DFGBinarySwitch out of the DFG so that all of the JITs can use it
+ https://bugs.webkit.org/show_bug.cgi?id=140959
+
+ Rubber stamped by Geoffrey Garen.
+
+ I want to use this for polymorphic stubs for https://bugs.webkit.org/show_bug.cgi?id=140660.
+ This code no longer has DFG dependencies so this is a very clean move.
+
+ * CMakeLists.txt:
+ * _javascript_Core.vcxproj/_javascript_Core.vcxproj:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * dfg/DFGBinarySwitch.cpp: Removed.
+ * dfg/DFGBinarySwitch.h: Removed.
+ * dfg/DFGSpeculativeJIT.cpp:
+ * jit/BinarySwitch.cpp: Copied from Source/_javascript_Core/dfg/DFGBinarySwitch.cpp.
+ * jit/BinarySwitch.h: Copied from Source/_javascript_Core/dfg/DFGBinarySwitch.h.
+
2015-01-27 Commit Queue <[email protected]>
Unreviewed, rolling out r179192.
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj (179222 => 179223)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_Core.vcxproj 2015-01-27 22:56:00 UTC (rev 179223)
@@ -370,7 +370,6 @@
<ClCompile Include="..\dfg\DFGAvailabilityMap.cpp" />
<ClCompile Include="..\dfg\DFGBackwardsPropagationPhase.cpp" />
<ClCompile Include="..\dfg\DFGBasicBlock.cpp" />
- <ClCompile Include="..\dfg\DFGBinarySwitch.cpp" />
<ClCompile Include="..\dfg\DFGBlockInsertionSet.cpp" />
<ClCompile Include="..\dfg\DFGBlockSet.cpp" />
<ClCompile Include="..\dfg\DFGBlockWorklist.cpp" />
@@ -598,6 +597,7 @@
<ClCompile Include="..\jit\AccessorCallJITStubRoutine.cpp" />
<ClCompile Include="..\jit\ArityCheckFailReturnThunks.cpp" />
<ClCompile Include="..\jit\AssemblyHelpers.cpp" />
+ <ClCompile Include="..\jit\BinarySwitch.cpp" />
<ClCompile Include="..\jit\ClosureCallStubRoutine.cpp" />
<ClCompile Include="..\jit\ExecutableAllocator.cpp" />
<ClCompile Include="..\jit\GCAwareJITStubRoutine.cpp" />
@@ -1015,7 +1015,6 @@
<ClInclude Include="..\dfg\DFGBackwardsPropagationPhase.h" />
<ClInclude Include="..\dfg\DFGBasicBlock.h" />
<ClInclude Include="..\dfg\DFGBasicBlockInlines.h" />
- <ClInclude Include="..\dfg\DFGBinarySwitch.h" />
<ClInclude Include="..\dfg\DFGBlockInsertionSet.h" />
<ClInclude Include="..\dfg\DFGBlockMap.h" />
<ClInclude Include="..\dfg\DFGBlockMapInlines.h" />
@@ -1332,6 +1331,7 @@
<ClInclude Include="..\jit\AccessorCallJITStubRoutine.h" />
<ClInclude Include="..\jit\ArityCheckFailReturnThunks.h" />
<ClInclude Include="..\jit\AssemblyHelpers.h" />
+ <ClInclude Include="..\jit\BinarySwitch.h" />
<ClInclude Include="..\jit\CCallHelpers.h" />
<ClInclude Include="..\jit\ClosureCallStubRoutine.h" />
<ClInclude Include="..\jit\CompactJITCodeMap.h" />
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (179222 => 179223)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2015-01-27 22:56:00 UTC (rev 179223)
@@ -353,6 +353,8 @@
0F63947815DCE34B006A597C /* DFGStructureAbstractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F63948415E48118006A597C /* DFGArrayMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F63948115E48114006A597C /* DFGArrayMode.cpp */; };
0F63948515E4811B006A597C /* DFGArrayMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F63948215E48114006A597C /* DFGArrayMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0F64B2711A784BAF006E4E66 /* BinarySwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */; };
+ 0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F64B2701A784BAF006E4E66 /* BinarySwitch.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F666EC0183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F666EC1183566F900D017F1 /* FullBytecodeLiveness.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F666EC61835672B00D017F1 /* DFGAvailability.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F666EC21835672B00D017F1 /* DFGAvailability.cpp */; };
@@ -1244,8 +1246,6 @@
A704D90717A0BAA8006BA554 /* DFGMergeMode.h in Headers */ = {isa = PBXBuildFile; fileRef = A704D90217A0BAA8006BA554 /* DFGMergeMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
A709F2F017A0AC0400512E98 /* SlowPathCall.h in Headers */ = {isa = PBXBuildFile; fileRef = A709F2EF17A0AC0400512E98 /* SlowPathCall.h */; settings = {ATTRIBUTES = (Private, ); }; };
A709F2F217A0AC2A00512E98 /* CommonSlowPaths.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A709F2F117A0AC2A00512E98 /* CommonSlowPaths.cpp */; };
- A70B083217A0B79B00DAF14B /* DFGBinarySwitch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */; };
- A70B083317A0B79B00DAF14B /* DFGBinarySwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */; };
A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */; };
A72028B61797601E0098028C /* JSCTestRunnerUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A72028B41797601E0098028C /* JSCTestRunnerUtils.cpp */; };
A72028B81797601E0098028C /* JSCTestRunnerUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = A72028B51797601E0098028C /* JSCTestRunnerUtils.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2023,6 +2023,8 @@
0F63947615DCE347006A597C /* DFGStructureAbstractValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGStructureAbstractValue.h; path = dfg/DFGStructureAbstractValue.h; sourceTree = "<group>"; };
0F63948115E48114006A597C /* DFGArrayMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGArrayMode.cpp; path = dfg/DFGArrayMode.cpp; sourceTree = "<group>"; };
0F63948215E48114006A597C /* DFGArrayMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGArrayMode.h; path = dfg/DFGArrayMode.h; sourceTree = "<group>"; };
+ 0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySwitch.cpp; sourceTree = "<group>"; };
+ 0F64B2701A784BAF006E4E66 /* BinarySwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySwitch.h; sourceTree = "<group>"; };
0F666EBE183566F900D017F1 /* BytecodeLivenessAnalysisInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeLivenessAnalysisInlines.h; sourceTree = "<group>"; };
0F666EBF183566F900D017F1 /* FullBytecodeLiveness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullBytecodeLiveness.h; sourceTree = "<group>"; };
0F666EC21835672B00D017F1 /* DFGAvailability.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGAvailability.cpp; path = dfg/DFGAvailability.cpp; sourceTree = "<group>"; };
@@ -2935,8 +2937,6 @@
A704D90217A0BAA8006BA554 /* DFGMergeMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGMergeMode.h; path = dfg/DFGMergeMode.h; sourceTree = "<group>"; };
A709F2EF17A0AC0400512E98 /* SlowPathCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlowPathCall.h; sourceTree = "<group>"; };
A709F2F117A0AC2A00512E98 /* CommonSlowPaths.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonSlowPaths.cpp; sourceTree = "<group>"; };
- A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGBinarySwitch.cpp; path = dfg/DFGBinarySwitch.cpp; sourceTree = "<group>"; };
- A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBinarySwitch.h; path = dfg/DFGBinarySwitch.h; sourceTree = "<group>"; };
A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITOpcodes32_64.cpp; sourceTree = "<group>"; };
A718F61A11754A21002465A7 /* RegExpJitTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpJitTables.h; sourceTree = "<group>"; };
A718F8211178EB4B002465A7 /* create_regex_tables */ = {isa = PBXFileReference; explicitFileType = text.script.python; fileEncoding = 4; path = create_regex_tables; sourceTree = "<group>"; };
@@ -3744,6 +3744,8 @@
0F6B1CC818641DF800845D97 /* ArityCheckFailReturnThunks.h */,
0F24E53B17EA9F5900ABB217 /* AssemblyHelpers.cpp */,
0F24E53C17EA9F5900ABB217 /* AssemblyHelpers.h */,
+ 0F64B26F1A784BAF006E4E66 /* BinarySwitch.cpp */,
+ 0F64B2701A784BAF006E4E66 /* BinarySwitch.h */,
0F24E53D17EA9F5900ABB217 /* CCallHelpers.h */,
0F73D7AB165A142A00ACAB71 /* ClosureCallStubRoutine.cpp */,
0F73D7AC165A142A00ACAB71 /* ClosureCallStubRoutine.h */,
@@ -3785,8 +3787,8 @@
14A6581A0F4E36F4000150FD /* JITStubs.h */,
FEF6835A174343CC00A32E25 /* JITStubsARM.h */,
FEF6835B174343CC00A32E25 /* JITStubsARMv7.h */,
+ FEF6835C174343CC00A32E25 /* JITStubsX86_64.h */,
FEF6835D174343CC00A32E25 /* JITStubsX86.h */,
- FEF6835C174343CC00A32E25 /* JITStubsX86_64.h */,
A7A4AE0C17973B4D005612B1 /* JITStubsX86Common.h */,
0F5EF91B16878F78003E5C25 /* JITThunks.cpp */,
0F5EF91C16878F78003E5C25 /* JITThunks.h */,
@@ -4655,8 +4657,6 @@
A7D89CE317A0B8CC00773AD8 /* DFGBasicBlock.cpp */,
0F620170143FCD2F0068B77C /* DFGBasicBlock.h */,
0FD5652216AB780A00197653 /* DFGBasicBlockInlines.h */,
- A70B083017A0B79B00DAF14B /* DFGBinarySwitch.cpp */,
- A70B083117A0B79B00DAF14B /* DFGBinarySwitch.h */,
A7D89CE417A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp */,
A7D89CE517A0B8CC00773AD8 /* DFGBlockInsertionSet.h */,
0FC3CCF519ADA410006AC72A /* DFGBlockMap.h */,
@@ -5555,7 +5555,6 @@
0F714CA516EA92F200F3EBEB /* DFGBackwardsPropagationPhase.h in Headers */,
0F620176143FCD3B0068B77C /* DFGBasicBlock.h in Headers */,
0FFB921A16D02EC50055A5DB /* DFGBasicBlockInlines.h in Headers */,
- A70B083317A0B79B00DAF14B /* DFGBinarySwitch.h in Headers */,
A7D89CF417A0B8CC00773AD8 /* DFGBlockInsertionSet.h in Headers */,
0F8364B7164B0C110053329A /* DFGBranchDirection.h in Headers */,
86EC9DC51328DF82002B2AD7 /* DFGByteCodeParser.h in Headers */,
@@ -5891,6 +5890,7 @@
0F9749711687ADE400A4FF6A /* JSCellInlines.h in Headers */,
0F1DD84A18A945BE0026F3FA /* JSCInlines.h in Headers */,
BC18C42B0E16F5CD00B34460 /* JSCJSValue.h in Headers */,
+ 0F64B2721A784BAF006E4E66 /* BinarySwitch.h in Headers */,
865A30F1135007E100CDB49E /* JSCJSValueInlines.h in Headers */,
BC18C41D0E16F5CD00B34460 /* JSClassRef.h in Headers */,
86E3C613167BABD7006D760A /* JSContext.h in Headers */,
@@ -6820,7 +6820,6 @@
0F714CA416EA92F000F3EBEB /* DFGBackwardsPropagationPhase.cpp in Sources */,
0F2B9CEC19D0BA7D00B1D1B5 /* DFGPromotedHeapLocation.cpp in Sources */,
A7D89CF217A0B8CC00773AD8 /* DFGBasicBlock.cpp in Sources */,
- A70B083217A0B79B00DAF14B /* DFGBinarySwitch.cpp in Sources */,
2A88067819107D5500CB0BBB /* DFGFunctionWhitelist.cpp in Sources */,
A7D89CF317A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp in Sources */,
86EC9DC41328DF82002B2AD7 /* DFGByteCodeParser.cpp in Sources */,
@@ -6995,6 +6994,7 @@
0FF0F19F16B72A17005DF95B /* FunctionExecutableDump.cpp in Sources */,
52B310FD1974AE870080857C /* FunctionHasExecutedCache.cpp in Sources */,
147F39CC107EC37600427A48 /* FunctionPrototype.cpp in Sources */,
+ 0F64B2711A784BAF006E4E66 /* BinarySwitch.cpp in Sources */,
0F766D2F15A8DCE0008F363E /* GCAwareJITStubRoutine.cpp in Sources */,
C2239D1A16262BDD005AC5FD /* GCThread.cpp in Sources */,
C21122E115DD9AB300790E3A /* GCThreadSharedData.cpp in Sources */,
Deleted: trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.cpp (179222 => 179223)
--- trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.cpp 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.cpp 2015-01-27 22:56:00 UTC (rev 179223)
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "config.h"
-#include "DFGBinarySwitch.h"
-
-#if ENABLE(DFG_JIT)
-
-#include "JSCInlines.h"
-
-namespace JSC { namespace DFG {
-
-BinarySwitch::BinarySwitch(GPRReg value, const Vector<int64_t>& cases, Type type)
- : m_value(value)
- , m_index(0)
- , m_caseIndex(UINT_MAX)
- , m_medianBias(0)
- , m_type(type)
-{
- if (cases.isEmpty())
- return;
-
- for (unsigned i = 0; i < cases.size(); ++i)
- m_cases.append(Case(cases[i], i));
- std::sort(m_cases.begin(), m_cases.end());
- build(0, m_cases.size());
-}
-
-bool BinarySwitch::advance(MacroAssembler& jit)
-{
- if (m_cases.isEmpty()) {
- m_fallThrough.append(jit.jump());
- return false;
- }
-
- if (m_index == m_branches.size()) {
- RELEASE_ASSERT(m_jumpStack.isEmpty());
- return false;
- }
-
- for (;;) {
- const BranchCode& code = m_branches[m_index++];
- switch (code.kind) {
- case NotEqualToFallThrough:
- switch (m_type) {
- case Int32:
- m_fallThrough.append(jit.branch32(
- MacroAssembler::NotEqual, m_value,
- MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
- break;
- case IntPtr:
- m_fallThrough.append(jit.branchPtr(
- MacroAssembler::NotEqual, m_value,
- MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
- break;
- }
- break;
- case NotEqualToPush:
- switch (m_type) {
- case Int32:
- m_jumpStack.append(jit.branch32(
- MacroAssembler::NotEqual, m_value,
- MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
- break;
- case IntPtr:
- m_jumpStack.append(jit.branchPtr(
- MacroAssembler::NotEqual, m_value,
- MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
- break;
- }
- break;
- case LessThanToPush:
- switch (m_type) {
- case Int32:
- m_jumpStack.append(jit.branch32(
- MacroAssembler::LessThan, m_value,
- MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
- break;
- case IntPtr:
- m_jumpStack.append(jit.branchPtr(
- MacroAssembler::LessThan, m_value,
- MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
- break;
- }
- break;
- case Pop:
- m_jumpStack.takeLast().link(&jit);
- break;
- case ExecuteCase:
- m_caseIndex = code.index;
- return true;
- }
- }
-}
-
-void BinarySwitch::build(unsigned start, unsigned end)
-{
- unsigned size = end - start;
-
- switch (size) {
- case 0: {
- RELEASE_ASSERT_NOT_REACHED();
- break;
- }
-
- case 1: {
- if (start
- && m_cases[start - 1].value == m_cases[start].value - 1
- && start + 1 < m_cases.size()
- && m_cases[start + 1].value == m_cases[start].value + 1) {
- m_branches.append(BranchCode(ExecuteCase, start));
- break;
- }
-
- m_branches.append(BranchCode(NotEqualToFallThrough, start));
- m_branches.append(BranchCode(ExecuteCase, start));
- break;
- }
-
- case 2: {
- if (m_cases[start].value + 1 == m_cases[start + 1].value
- && start
- && m_cases[start - 1].value == m_cases[start].value - 1
- && start + 2 < m_cases.size()
- && m_cases[start + 2].value == m_cases[start + 1].value + 1) {
- m_branches.append(BranchCode(NotEqualToPush, start));
- m_branches.append(BranchCode(ExecuteCase, start));
- m_branches.append(BranchCode(Pop));
- m_branches.append(BranchCode(ExecuteCase, start + 1));
- break;
- }
-
- unsigned firstCase = start;
- unsigned secondCase = start + 1;
- if (m_medianBias)
- std::swap(firstCase, secondCase);
- m_medianBias ^= 1;
-
- m_branches.append(BranchCode(NotEqualToPush, firstCase));
- m_branches.append(BranchCode(ExecuteCase, firstCase));
- m_branches.append(BranchCode(Pop));
- m_branches.append(BranchCode(NotEqualToFallThrough, secondCase));
- m_branches.append(BranchCode(ExecuteCase, secondCase));
- break;
- }
-
- default: {
- unsigned medianIndex = (start + end) / 2;
- if (!(size & 1)) {
- // Because end is exclusive, in the even case, this rounds up by
- // default. Hence median bias sometimes flips to subtracing one
- // in order to get round-down behavior.
- medianIndex -= m_medianBias;
- m_medianBias ^= 1;
- }
-
- RELEASE_ASSERT(medianIndex > start);
- RELEASE_ASSERT(medianIndex + 1 < end);
-
- m_branches.append(BranchCode(LessThanToPush, medianIndex));
- m_branches.append(BranchCode(NotEqualToPush, medianIndex));
- m_branches.append(BranchCode(ExecuteCase, medianIndex));
-
- m_branches.append(BranchCode(Pop));
- build(medianIndex + 1, end);
-
- m_branches.append(BranchCode(Pop));
- build(start, medianIndex);
- break;
- } }
-}
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
Deleted: trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.h (179222 => 179223)
--- trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.h 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.h 2015-01-27 22:56:00 UTC (rev 179223)
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2013 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 DFGBinarySwitch_h
-#define DFGBinarySwitch_h
-
-#if ENABLE(DFG_JIT)
-
-#include "GPRInfo.h"
-#include "MacroAssembler.h"
-
-namespace JSC { namespace DFG {
-
-// The BinarySwitch class makes it easy to emit a switch statement over either
-// 32-bit integers or pointers, where the switch uses a tree of branches
-// rather than a jump table. This makes it particularly useful if the case
-// values are too far apart to make a jump table practical, or if there are
-// sufficiently few cases that the total cost of log(numCases) branches is
-// less than the cost of an indirected jump.
-//
-// In an effort to simplify the logic of emitting code for each case, this
-// uses an iterator style, rather than a functor callback style. This makes
-// sense because even the iterator implementation found herein is relatively
-// simple, whereas the code it's used from is usually quite complex - one
-// example being the trie-of-trees string switch implementation, where the
-// code emitted for each case involves recursing to emit code for a sub-trie.
-//
-// Use this like so:
-//
-// BinarySwitch switch(valueReg, casesVector, BinarySwitch::Int32);
-// while (switch.advance(jit)) {
-// int value = switch.caseValue();
-// unsigned index = switch.caseIndex(); // index into casesVector, above
-// ... // generate code for this case
-// }
-// switch.fallThrough().link(&jit);
-
-class BinarySwitch {
-public:
- enum Type {
- Int32,
- IntPtr
- };
-
- BinarySwitch(GPRReg value, const Vector<int64_t>& cases, Type);
-
- unsigned caseIndex() const { return m_cases[m_caseIndex].index; }
- int64_t caseValue() const { return m_cases[m_caseIndex].value; }
-
- bool advance(MacroAssembler&);
-
- MacroAssembler::JumpList& fallThrough() { return m_fallThrough; }
-
-private:
- void build(unsigned start, unsigned end);
-
- GPRReg m_value;
-
- struct Case {
- Case() { }
-
- Case(int64_t value, unsigned index)
- : value(value)
- , index(index)
- {
- }
-
- bool operator<(const Case& other) const
- {
- return value < other.value;
- }
-
- int64_t value;
- unsigned index;
- };
-
- Vector<Case> m_cases;
-
- enum BranchKind {
- NotEqualToFallThrough,
- NotEqualToPush,
- LessThanToPush,
- Pop,
- ExecuteCase
- };
-
- struct BranchCode {
- BranchCode() { }
-
- BranchCode(BranchKind kind, unsigned index = UINT_MAX)
- : kind(kind)
- , index(index)
- {
- }
-
- BranchKind kind;
- unsigned index;
- };
-
- Vector<BranchCode> m_branches;
-
- unsigned m_index;
- unsigned m_caseIndex;
- Vector<MacroAssembler::Jump> m_jumpStack;
-
- MacroAssembler::JumpList m_fallThrough;
-
- unsigned m_medianBias;
-
- Type m_type;
-};
-
-} } // namespace JSC::DFG
-
-#endif // ENABLE(DFG_JIT)
-
-#endif // DFGBinarySwitch_h
-
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (179222 => 179223)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-01-27 22:49:55 UTC (rev 179222)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-01-27 22:56:00 UTC (rev 179223)
@@ -29,9 +29,9 @@
#if ENABLE(DFG_JIT)
#include "Arguments.h"
+#include "BinarySwitch.h"
#include "DFGAbstractInterpreterInlines.h"
#include "DFGArrayifySlowPathGenerator.h"
-#include "DFGBinarySwitch.h"
#include "DFGCallArrayAllocatorSlowPathGenerator.h"
#include "DFGMayExit.h"
#include "DFGSaneStringGetByValSlowPathGenerator.h"
Copied: trunk/Source/_javascript_Core/jit/BinarySwitch.cpp (from rev 179136, trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.cpp) (0 => 179223)
--- trunk/Source/_javascript_Core/jit/BinarySwitch.cpp (rev 0)
+++ trunk/Source/_javascript_Core/jit/BinarySwitch.cpp 2015-01-27 22:56:00 UTC (rev 179223)
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2013, 2015 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.
+ */
+
+#include "config.h"
+#include "BinarySwitch.h"
+
+#if ENABLE(JIT)
+
+#include "JSCInlines.h"
+
+namespace JSC {
+
+BinarySwitch::BinarySwitch(GPRReg value, const Vector<int64_t>& cases, Type type)
+ : m_value(value)
+ , m_index(0)
+ , m_caseIndex(UINT_MAX)
+ , m_medianBias(0)
+ , m_type(type)
+{
+ if (cases.isEmpty())
+ return;
+
+ for (unsigned i = 0; i < cases.size(); ++i)
+ m_cases.append(Case(cases[i], i));
+ std::sort(m_cases.begin(), m_cases.end());
+ build(0, m_cases.size());
+}
+
+bool BinarySwitch::advance(MacroAssembler& jit)
+{
+ if (m_cases.isEmpty()) {
+ m_fallThrough.append(jit.jump());
+ return false;
+ }
+
+ if (m_index == m_branches.size()) {
+ RELEASE_ASSERT(m_jumpStack.isEmpty());
+ return false;
+ }
+
+ for (;;) {
+ const BranchCode& code = m_branches[m_index++];
+ switch (code.kind) {
+ case NotEqualToFallThrough:
+ switch (m_type) {
+ case Int32:
+ m_fallThrough.append(jit.branch32(
+ MacroAssembler::NotEqual, m_value,
+ MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
+ break;
+ case IntPtr:
+ m_fallThrough.append(jit.branchPtr(
+ MacroAssembler::NotEqual, m_value,
+ MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
+ break;
+ }
+ break;
+ case NotEqualToPush:
+ switch (m_type) {
+ case Int32:
+ m_jumpStack.append(jit.branch32(
+ MacroAssembler::NotEqual, m_value,
+ MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
+ break;
+ case IntPtr:
+ m_jumpStack.append(jit.branchPtr(
+ MacroAssembler::NotEqual, m_value,
+ MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
+ break;
+ }
+ break;
+ case LessThanToPush:
+ switch (m_type) {
+ case Int32:
+ m_jumpStack.append(jit.branch32(
+ MacroAssembler::LessThan, m_value,
+ MacroAssembler::Imm32(static_cast<int32_t>(m_cases[code.index].value))));
+ break;
+ case IntPtr:
+ m_jumpStack.append(jit.branchPtr(
+ MacroAssembler::LessThan, m_value,
+ MacroAssembler::ImmPtr(bitwise_cast<const void*>(static_cast<intptr_t>(m_cases[code.index].value)))));
+ break;
+ }
+ break;
+ case Pop:
+ m_jumpStack.takeLast().link(&jit);
+ break;
+ case ExecuteCase:
+ m_caseIndex = code.index;
+ return true;
+ }
+ }
+}
+
+void BinarySwitch::build(unsigned start, unsigned end)
+{
+ unsigned size = end - start;
+
+ switch (size) {
+ case 0: {
+ RELEASE_ASSERT_NOT_REACHED();
+ break;
+ }
+
+ case 1: {
+ if (start
+ && m_cases[start - 1].value == m_cases[start].value - 1
+ && start + 1 < m_cases.size()
+ && m_cases[start + 1].value == m_cases[start].value + 1) {
+ m_branches.append(BranchCode(ExecuteCase, start));
+ break;
+ }
+
+ m_branches.append(BranchCode(NotEqualToFallThrough, start));
+ m_branches.append(BranchCode(ExecuteCase, start));
+ break;
+ }
+
+ case 2: {
+ if (m_cases[start].value + 1 == m_cases[start + 1].value
+ && start
+ && m_cases[start - 1].value == m_cases[start].value - 1
+ && start + 2 < m_cases.size()
+ && m_cases[start + 2].value == m_cases[start + 1].value + 1) {
+ m_branches.append(BranchCode(NotEqualToPush, start));
+ m_branches.append(BranchCode(ExecuteCase, start));
+ m_branches.append(BranchCode(Pop));
+ m_branches.append(BranchCode(ExecuteCase, start + 1));
+ break;
+ }
+
+ unsigned firstCase = start;
+ unsigned secondCase = start + 1;
+ if (m_medianBias)
+ std::swap(firstCase, secondCase);
+ m_medianBias ^= 1;
+
+ m_branches.append(BranchCode(NotEqualToPush, firstCase));
+ m_branches.append(BranchCode(ExecuteCase, firstCase));
+ m_branches.append(BranchCode(Pop));
+ m_branches.append(BranchCode(NotEqualToFallThrough, secondCase));
+ m_branches.append(BranchCode(ExecuteCase, secondCase));
+ break;
+ }
+
+ default: {
+ unsigned medianIndex = (start + end) / 2;
+ if (!(size & 1)) {
+ // Because end is exclusive, in the even case, this rounds up by
+ // default. Hence median bias sometimes flips to subtracing one
+ // in order to get round-down behavior.
+ medianIndex -= m_medianBias;
+ m_medianBias ^= 1;
+ }
+
+ RELEASE_ASSERT(medianIndex > start);
+ RELEASE_ASSERT(medianIndex + 1 < end);
+
+ m_branches.append(BranchCode(LessThanToPush, medianIndex));
+ m_branches.append(BranchCode(NotEqualToPush, medianIndex));
+ m_branches.append(BranchCode(ExecuteCase, medianIndex));
+
+ m_branches.append(BranchCode(Pop));
+ build(medianIndex + 1, end);
+
+ m_branches.append(BranchCode(Pop));
+ build(start, medianIndex);
+ break;
+ } }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
Copied: trunk/Source/_javascript_Core/jit/BinarySwitch.h (from rev 179136, trunk/Source/_javascript_Core/dfg/DFGBinarySwitch.h) (0 => 179223)
--- trunk/Source/_javascript_Core/jit/BinarySwitch.h (rev 0)
+++ trunk/Source/_javascript_Core/jit/BinarySwitch.h 2015-01-27 22:56:00 UTC (rev 179223)
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2013, 2015 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 BinarySwitch_h
+#define BinarySwitch_h
+
+#if ENABLE(JIT)
+
+#include "GPRInfo.h"
+#include "MacroAssembler.h"
+
+namespace JSC {
+
+// The BinarySwitch class makes it easy to emit a switch statement over either
+// 32-bit integers or pointers, where the switch uses a tree of branches
+// rather than a jump table. This makes it particularly useful if the case
+// values are too far apart to make a jump table practical, or if there are
+// sufficiently few cases that the total cost of log(numCases) branches is
+// less than the cost of an indirected jump.
+//
+// In an effort to simplify the logic of emitting code for each case, this
+// uses an iterator style, rather than a functor callback style. This makes
+// sense because even the iterator implementation found herein is relatively
+// simple, whereas the code it's used from is usually quite complex - one
+// example being the trie-of-trees string switch implementation, where the
+// code emitted for each case involves recursing to emit code for a sub-trie.
+//
+// Use this like so:
+//
+// BinarySwitch switch(valueReg, casesVector, BinarySwitch::Int32);
+// while (switch.advance(jit)) {
+// int value = switch.caseValue();
+// unsigned index = switch.caseIndex(); // index into casesVector, above
+// ... // generate code for this case
+// }
+// switch.fallThrough().link(&jit);
+
+class BinarySwitch {
+public:
+ enum Type {
+ Int32,
+ IntPtr
+ };
+
+ BinarySwitch(GPRReg value, const Vector<int64_t>& cases, Type);
+
+ unsigned caseIndex() const { return m_cases[m_caseIndex].index; }
+ int64_t caseValue() const { return m_cases[m_caseIndex].value; }
+
+ bool advance(MacroAssembler&);
+
+ MacroAssembler::JumpList& fallThrough() { return m_fallThrough; }
+
+private:
+ void build(unsigned start, unsigned end);
+
+ GPRReg m_value;
+
+ struct Case {
+ Case() { }
+
+ Case(int64_t value, unsigned index)
+ : value(value)
+ , index(index)
+ {
+ }
+
+ bool operator<(const Case& other) const
+ {
+ return value < other.value;
+ }
+
+ int64_t value;
+ unsigned index;
+ };
+
+ Vector<Case> m_cases;
+
+ enum BranchKind {
+ NotEqualToFallThrough,
+ NotEqualToPush,
+ LessThanToPush,
+ Pop,
+ ExecuteCase
+ };
+
+ struct BranchCode {
+ BranchCode() { }
+
+ BranchCode(BranchKind kind, unsigned index = UINT_MAX)
+ : kind(kind)
+ , index(index)
+ {
+ }
+
+ BranchKind kind;
+ unsigned index;
+ };
+
+ Vector<BranchCode> m_branches;
+
+ unsigned m_index;
+ unsigned m_caseIndex;
+ Vector<MacroAssembler::Jump> m_jumpStack;
+
+ MacroAssembler::JumpList m_fallThrough;
+
+ unsigned m_medianBias;
+
+ Type m_type;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // BinarySwitch_h
+