Snippefy bitwise operators for the baseline JIT.
https://bugs.webkit.org/show_bug.cgi?id=151680
Reviewed by Geoffrey Garen.
This patch has passed the JSC tests on x86 and x86_64. It has also passed the
layout tests on x86_64.
With the DFG enabled, perf is neutral on x86_64 and x86.
With the DFG disabled on x86_64, some AsmBench tests are showing progressions e.g.
gcc-loops.cpp 1.0269x faster
stepanov_container.cpp 1.0180x faster
With the DFG disabled on x86, perf is neutral.
* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::moveValueRegs):
(JSC::AssemblyHelpers::branchIfNotInt32):
* jit/JIT.h:
* jit/JITArithmetic.cpp:
(JSC::JIT::emitBitwiseBinaryOpFastPath):
- Template for the bitwise operations.
(JSC::JIT::emit_op_bitand):
(JSC::JIT::emit_op_bitor):
(JSC::JIT::emit_op_bitxor):
- Specializes emitBitwiseBinaryOpFastPath() with the respective snippet generators.
(JSC::JIT::emitSlow_op_bitand):
(JSC::JIT::emitSlow_op_bitor):
(JSC::JIT::emitSlow_op_bitxor):
- Implement respective slow paths.
* jit/JITArithmetic32_64.cpp:
(JSC::JIT::emit_op_bitand): Deleted.
(JSC::JIT::emitSlow_op_bitand): Deleted.
(JSC::JIT::emit_op_bitor): Deleted.
(JSC::JIT::emitSlow_op_bitor): Deleted.
(JSC::JIT::emit_op_bitxor): Deleted.
(JSC::JIT::emitSlow_op_bitxor): Deleted.
- Now unified with the 64-bit version using snippets.
* jit/JITBitAndGenerator.cpp: Added.
(JSC::JITBitAndGenerator::generateFastPath):
* jit/JITBitAndGenerator.h: Added.
(JSC::JITBitAndGenerator::JITBitAndGenerator):
* jit/JITBitOrGenerator.cpp: Added.
(JSC::JITBitOrGenerator::generateFastPath):
* jit/JITBitOrGenerator.h: Added.
(JSC::JITBitOrGenerator::JITBitOrGenerator):
* jit/JITBitXorGenerator.cpp: Added.
(JSC::JITBitXorGenerator::generateFastPath):
* jit/JITBitXorGenerator.h: Added.
(JSC::JITBitXorGenerator::JITBitXorGenerator):
* jit/JITBitwiseBinaryOpGenerator.h: Added.
(JSC::JITBitwiseBinaryOpGenerator::JITBitwiseBinaryOpGenerator):
(JSC::JITBitwiseBinaryOpGenerator::didEmitFastPath):
(JSC::JITBitwiseBinaryOpGenerator::endJumpList):
(JSC::JITBitwiseBinaryOpGenerator::slowPathJumpList):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_bitxor): Deleted.
(JSC::JIT::emit_op_bitor): Deleted.
(JSC::JIT::emitSlow_op_bitxor): Deleted.
(JSC::JIT::emitSlow_op_bitor): Deleted.
* jit/SnippetOperand.h:
(JSC::SnippetOperand::SnippetOperand):
* tests/stress/op_bitand.js:
* tests/stress/op_bitor.js:
* tests/stress/op_bitxor.js:
- Fix a test value typo: it's supposed to be 0x7fffffff, not 0x7ffffff.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@193471 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
index 6d98bc3..9ca2c7d 100644
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -452,6 +452,9 @@
jit/JITAddGenerator.cpp
jit/JITArithmetic.cpp
jit/JITArithmetic32_64.cpp
+ jit/JITBitAndGenerator.cpp
+ jit/JITBitOrGenerator.cpp
+ jit/JITBitXorGenerator.cpp
jit/JITCall.cpp
jit/JITCall32_64.cpp
jit/JITCode.cpp
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 4432237..80e3a07 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,81 @@
+2015-12-04 Mark Lam <mark.lam@apple.com>
+
+ Snippefy bitwise operators for the baseline JIT.
+ https://bugs.webkit.org/show_bug.cgi?id=151680
+
+ Reviewed by Geoffrey Garen.
+
+ This patch has passed the JSC tests on x86 and x86_64. It has also passed the
+ layout tests on x86_64.
+
+ With the DFG enabled, perf is neutral on x86_64 and x86.
+ With the DFG disabled on x86_64, some AsmBench tests are showing progressions e.g.
+ gcc-loops.cpp 1.0269x faster
+ stepanov_container.cpp 1.0180x faster
+
+ With the DFG disabled on x86, perf is neutral.
+
+ * CMakeLists.txt:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+
+ * jit/AssemblyHelpers.h:
+ (JSC::AssemblyHelpers::moveValueRegs):
+ (JSC::AssemblyHelpers::branchIfNotInt32):
+ * jit/JIT.h:
+ * jit/JITArithmetic.cpp:
+ (JSC::JIT::emitBitwiseBinaryOpFastPath):
+ - Template for the bitwise operations.
+ (JSC::JIT::emit_op_bitand):
+ (JSC::JIT::emit_op_bitor):
+ (JSC::JIT::emit_op_bitxor):
+ - Specializes emitBitwiseBinaryOpFastPath() with the respective snippet generators.
+ (JSC::JIT::emitSlow_op_bitand):
+ (JSC::JIT::emitSlow_op_bitor):
+ (JSC::JIT::emitSlow_op_bitxor):
+ - Implement respective slow paths.
+
+ * jit/JITArithmetic32_64.cpp:
+ (JSC::JIT::emit_op_bitand): Deleted.
+ (JSC::JIT::emitSlow_op_bitand): Deleted.
+ (JSC::JIT::emit_op_bitor): Deleted.
+ (JSC::JIT::emitSlow_op_bitor): Deleted.
+ (JSC::JIT::emit_op_bitxor): Deleted.
+ (JSC::JIT::emitSlow_op_bitxor): Deleted.
+ - Now unified with the 64-bit version using snippets.
+
+ * jit/JITBitAndGenerator.cpp: Added.
+ (JSC::JITBitAndGenerator::generateFastPath):
+ * jit/JITBitAndGenerator.h: Added.
+ (JSC::JITBitAndGenerator::JITBitAndGenerator):
+ * jit/JITBitOrGenerator.cpp: Added.
+ (JSC::JITBitOrGenerator::generateFastPath):
+ * jit/JITBitOrGenerator.h: Added.
+ (JSC::JITBitOrGenerator::JITBitOrGenerator):
+ * jit/JITBitXorGenerator.cpp: Added.
+ (JSC::JITBitXorGenerator::generateFastPath):
+ * jit/JITBitXorGenerator.h: Added.
+ (JSC::JITBitXorGenerator::JITBitXorGenerator):
+ * jit/JITBitwiseBinaryOpGenerator.h: Added.
+ (JSC::JITBitwiseBinaryOpGenerator::JITBitwiseBinaryOpGenerator):
+ (JSC::JITBitwiseBinaryOpGenerator::didEmitFastPath):
+ (JSC::JITBitwiseBinaryOpGenerator::endJumpList):
+ (JSC::JITBitwiseBinaryOpGenerator::slowPathJumpList):
+
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_bitxor): Deleted.
+ (JSC::JIT::emit_op_bitor): Deleted.
+ (JSC::JIT::emitSlow_op_bitxor): Deleted.
+ (JSC::JIT::emitSlow_op_bitor): Deleted.
+ * jit/SnippetOperand.h:
+ (JSC::SnippetOperand::SnippetOperand):
+
+ * tests/stress/op_bitand.js:
+ * tests/stress/op_bitor.js:
+ * tests/stress/op_bitxor.js:
+ - Fix a test value typo: it's supposed to be 0x7fffffff, not 0x7ffffff.
+
2015-12-04 Filip Pizlo <fpizlo@apple.com>
Having a bad time has a really awful time when it runs at the same time as the JIT
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
index 62d21d2..606eeef 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
@@ -644,6 +644,9 @@
<ClCompile Include="..\jit\JITAddGenerator.cpp" />
<ClCompile Include="..\jit\JITArithmetic.cpp" />
<ClCompile Include="..\jit\JITArithmetic32_64.cpp" />
+ <ClCompile Include="..\jit\JITBitAndGenerator.cpp" />
+ <ClCompile Include="..\jit\JITBitOrGenerator.cpp" />
+ <ClCompile Include="..\jit\JITBitXorGenerator.cpp" />
<ClCompile Include="..\jit\JITCall.cpp" />
<ClCompile Include="..\jit\JITCall32_64.cpp" />
<ClCompile Include="..\jit\JITCode.cpp" />
@@ -1472,6 +1475,10 @@
<ClInclude Include="..\jit\HostCallReturnValue.h" />
<ClInclude Include="..\jit\JIT.h" />
<ClInclude Include="..\jit\JITAddGenerator.h" />
+ <ClInclude Include="..\jit\JITBitAndGenerator.h" />
+ <ClInclude Include="..\jit\JITBitOrGenerator.h" />
+ <ClInclude Include="..\jit\JITBitXorGenerator.h" />
+ <ClInclude Include="..\jit\JITBitwiseBinaryOpGenerator.h" />
<ClInclude Include="..\jit\JITCode.h" />
<ClInclude Include="..\jit\JITCompilationEffort.h" />
<ClInclude Include="..\jit\JITDisassembler.h" />
diff --git a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
index b900af0..275e3e7 100644
--- a/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
+++ b/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
@@ -429,6 +429,15 @@
<ClCompile Include="..\jit\JITArithmetic32_64.cpp">
<Filter>jit</Filter>
</ClCompile>
+ <ClCompile Include="..\jit\JITBitAndGenerator.cpp">
+ <Filter>jit</Filter>
+ </ClCompile>
+ <ClCompile Include="..\jit\JITBitOrGenerator.cpp">
+ <Filter>jit</Filter>
+ </ClCompile>
+ <ClCompile Include="..\jit\JITBitXorGenerator.cpp">
+ <Filter>jit</Filter>
+ </ClCompile>
<ClCompile Include="..\jit\JITCall.cpp">
<Filter>jit</Filter>
</ClCompile>
@@ -2528,6 +2537,18 @@
<ClInclude Include="..\jit\JITAddGenerator.h">
<Filter>jit</Filter>
</ClInclude>
+ <ClInclude Include="..\jit\JITBitAndGenerator.h">
+ <Filter>jit</Filter>
+ </ClInclude>
+ <ClInclude Include="..\jit\JITBitOrGenerator.h">
+ <Filter>jit</Filter>
+ </ClInclude>
+ <ClInclude Include="..\jit\JITBitXorGenerator.h">
+ <Filter>jit</Filter>
+ </ClInclude>
+ <ClInclude Include="..\jit\JITBitwiseBinaryOpGenerator.h">
+ <Filter>jit</Filter>
+ </ClInclude>
<ClInclude Include="..\jit\JITCode.h">
<Filter>jit</Filter>
</ClInclude>
diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 912dbb0..0cae581 100644
--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -2007,6 +2007,13 @@
FE3913541B794F6E00EDAF71 /* LiveObjectList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3913521B794AC900EDAF71 /* LiveObjectList.cpp */; };
FE3913551B794F8A00EDAF71 /* LiveObjectData.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3913511B794AC900EDAF71 /* LiveObjectData.h */; settings = {ATTRIBUTES = (Private, ); }; };
FE3913561B794F8F00EDAF71 /* LiveObjectList.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3913531B794AC900EDAF71 /* LiveObjectList.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ FE3A06A61C10B72D00390FDD /* JITBitOrGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A41C10B70800390FDD /* JITBitOrGenerator.h */; settings = {ASSET_TAGS = (); }; };
+ FE3A06A81C10BC8100390FDD /* JITBitwiseBinaryOpGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06A71C10BC7400390FDD /* JITBitwiseBinaryOpGenerator.h */; settings = {ASSET_TAGS = (); }; };
+ FE3A06AC1C10C39E00390FDD /* JITBitOrGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06A31C10B70800390FDD /* JITBitOrGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
+ FE3A06B11C10CB8400390FDD /* JITBitAndGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
+ FE3A06B21C10CB8900390FDD /* JITBitAndGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */; settings = {ASSET_TAGS = (); }; };
+ FE3A06B31C10CB8E00390FDD /* JITBitXorGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE3A06AF1C10CB6F00390FDD /* JITBitXorGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
+ FE3A06B41C10CB9300390FDD /* JITBitXorGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B01C10CB6F00390FDD /* JITBitXorGenerator.h */; settings = {ASSET_TAGS = (); }; };
FE4238901BE18C3C00514737 /* JITSubGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE42388F1BE18C1200514737 /* JITSubGenerator.cpp */; };
FE4BFF2B1AD476E700088F87 /* FunctionOverrides.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */; };
FE4BFF2C1AD476E700088F87 /* FunctionOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */; };
@@ -4172,6 +4179,13 @@
FE3913511B794AC900EDAF71 /* LiveObjectData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveObjectData.h; sourceTree = "<group>"; };
FE3913521B794AC900EDAF71 /* LiveObjectList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiveObjectList.cpp; sourceTree = "<group>"; };
FE3913531B794AC900EDAF71 /* LiveObjectList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiveObjectList.h; sourceTree = "<group>"; };
+ FE3A06A31C10B70800390FDD /* JITBitOrGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITBitOrGenerator.cpp; sourceTree = "<group>"; };
+ FE3A06A41C10B70800390FDD /* JITBitOrGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITBitOrGenerator.h; sourceTree = "<group>"; };
+ FE3A06A71C10BC7400390FDD /* JITBitwiseBinaryOpGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITBitwiseBinaryOpGenerator.h; sourceTree = "<group>"; };
+ FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITBitAndGenerator.cpp; sourceTree = "<group>"; };
+ FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITBitAndGenerator.h; sourceTree = "<group>"; };
+ FE3A06AF1C10CB6F00390FDD /* JITBitXorGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITBitXorGenerator.cpp; sourceTree = "<group>"; };
+ FE3A06B01C10CB6F00390FDD /* JITBitXorGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITBitXorGenerator.h; sourceTree = "<group>"; };
FE42388F1BE18C1200514737 /* JITSubGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITSubGenerator.cpp; sourceTree = "<group>"; };
FE4BFF291AD476E700088F87 /* FunctionOverrides.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionOverrides.cpp; sourceTree = "<group>"; };
FE4BFF2A1AD476E700088F87 /* FunctionOverrides.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionOverrides.h; sourceTree = "<group>"; };
@@ -4842,6 +4856,13 @@
FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */,
86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */,
A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */,
+ FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */,
+ FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */,
+ FE3A06A31C10B70800390FDD /* JITBitOrGenerator.cpp */,
+ FE3A06A41C10B70800390FDD /* JITBitOrGenerator.h */,
+ FE3A06AF1C10CB6F00390FDD /* JITBitXorGenerator.cpp */,
+ FE3A06B01C10CB6F00390FDD /* JITBitXorGenerator.h */,
+ FE3A06A71C10BC7400390FDD /* JITBitwiseBinaryOpGenerator.h */,
86CC85A20EE79B7400288682 /* JITCall.cpp */,
146FE51111A710430087AE66 /* JITCall32_64.cpp */,
0F8F94431667635200D61971 /* JITCode.cpp */,
@@ -6847,6 +6868,7 @@
0F338E111BF0276C0013C88F /* B3OpaqueByproduct.h in Headers */,
99DA00AA1BD5993100F4575C /* builtins_generate_separate_implementation.py in Headers */,
99DA00A31BD5993100F4575C /* builtins_generator.py in Headers */,
+ FE3A06A61C10B72D00390FDD /* JITBitOrGenerator.h in Headers */,
99DA00A41BD5993100F4575C /* builtins_model.py in Headers */,
99DA00A51BD5993100F4575C /* builtins_templates.py in Headers */,
41DEA1321B9F3163006D65DD /* BuiltinUtils.h in Headers */,
@@ -7112,6 +7134,7 @@
0FD8A32817D51F5700CA2C40 /* DFGTierUpCheckInjectionPhase.h in Headers */,
0FD8A32A17D51F5700CA2C40 /* DFGToFTLDeferredCompilationCallback.h in Headers */,
0FD8A32C17D51F5700CA2C40 /* DFGToFTLForOSREntryDeferredCompilationCallback.h in Headers */,
+ FE3A06B41C10CB9300390FDD /* JITBitXorGenerator.h in Headers */,
0FE7211E193B9C590031F6ED /* DFGTransition.h in Headers */,
0F63943F15C75F19006A597C /* DFGTypeCheckHoistingPhase.h in Headers */,
0FBE0F7716C1DB120082C5E8 /* DFGUnificationPhase.h in Headers */,
@@ -7365,6 +7388,7 @@
86CCEFDE0F413F8900FD7F9E /* JITCode.h in Headers */,
0F0776BF14FF002B00102332 /* JITCompilationEffort.h in Headers */,
0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */,
+ FE3A06A81C10BC8100390FDD /* JITBitwiseBinaryOpGenerator.h in Headers */,
0F46808214BA572D00BFE272 /* JITExceptions.h in Headers */,
0FB14E1F18124ACE009B6B4D /* JITInlineCacheGenerator.h in Headers */,
86CC85A10EE79A4700288682 /* JITInlines.h in Headers */,
@@ -7653,6 +7677,7 @@
0FB1058C1675483300F8AB6E /* ProfilerOSRExit.h in Headers */,
0FB1058E1675483A00F8AB6E /* ProfilerOSRExitSite.h in Headers */,
0F13912C16771C3D009CCB07 /* ProfilerProfiledBytecodes.h in Headers */,
+ FE3A06B21C10CB8900390FDD /* JITBitAndGenerator.h in Headers */,
0FD3E40E1B618B6600C80E1E /* PropertyCondition.h in Headers */,
A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */,
BC95437D0EBA70FD0072B6D3 /* PropertyMapHashTable.h in Headers */,
@@ -8591,6 +8616,7 @@
0FC09791146A6F7100CF2442 /* DFGOSRExit.cpp in Sources */,
0F235BEB17178E7300690C7F /* DFGOSRExitBase.cpp in Sources */,
0FC09792146A6F7300CF2442 /* DFGOSRExitCompiler.cpp in Sources */,
+ FE3A06B11C10CB8400390FDD /* JITBitAndGenerator.cpp in Sources */,
0FC09776146943B000CF2442 /* DFGOSRExitCompiler32_64.cpp in Sources */,
0FC0977214693AF900CF2442 /* DFGOSRExitCompiler64.cpp in Sources */,
0F7025A91714B0FA00382C0E /* DFGOSRExitCompilerCommon.cpp in Sources */,
@@ -8755,6 +8781,7 @@
A593CF7C1840360300BFCE27 /* InspectorBackendDispatcher.cpp in Sources */,
A532438718568335002ED692 /* InspectorBackendDispatchers.cpp in Sources */,
A5FD0081189B191A00633231 /* InspectorConsoleAgent.cpp in Sources */,
+ FE3A06B31C10CB8E00390FDD /* JITBitXorGenerator.cpp in Sources */,
A57D23E51890CEBF0031C7FA /* InspectorDebuggerAgent.cpp in Sources */,
A532438918568335002ED692 /* InspectorFrontendDispatchers.cpp in Sources */,
99F1A6FE1B8E6D9400463B26 /* InspectorFrontendRouter.cpp in Sources */,
@@ -8930,6 +8957,7 @@
A729009C17976C6000317298 /* MacroAssemblerARMv7.cpp in Sources */,
FE68C6381B90DE0B0042BCB3 /* MacroAssemblerPrinter.cpp in Sources */,
A7A4AE0817973B26005612B1 /* MacroAssemblerX86Common.cpp in Sources */,
+ FE3A06AC1C10C39E00390FDD /* JITBitOrGenerator.cpp in Sources */,
A700873917CBE85300C3E643 /* MapConstructor.cpp in Sources */,
A74DEF93182D991400522C22 /* MapIteratorPrototype.cpp in Sources */,
A700873D17CBE8D300C3E643 /* MapPrototype.cpp in Sources */,
diff --git a/Source/JavaScriptCore/jit/AssemblyHelpers.h b/Source/JavaScriptCore/jit/AssemblyHelpers.h
index ef4b880..2b44cd9 100644
--- a/Source/JavaScriptCore/jit/AssemblyHelpers.h
+++ b/Source/JavaScriptCore/jit/AssemblyHelpers.h
@@ -149,6 +149,14 @@
#endif
}
+ void moveValueRegs(JSValueRegs srcRegs, JSValueRegs destRegs)
+ {
+#if USE(JSVALUE32_64)
+ move(srcRegs.tagGPR(), destRegs.tagGPR());
+#endif
+ move(srcRegs.payloadGPR(), destRegs.payloadGPR());
+ }
+
void moveValue(JSValue value, JSValueRegs regs)
{
#if USE(JSVALUE64)
@@ -685,13 +693,20 @@
return branch32(Equal, regs.tagGPR(), TrustedImm32(JSValue::Int32Tag));
#endif
}
-
+
+#if USE(JSVALUE64)
+ Jump branchIfNotInt32(GPRReg gpr, TagRegistersMode mode = HaveTagRegisters)
+ {
+ if (mode == HaveTagRegisters)
+ return branch64(Below, gpr, GPRInfo::tagTypeNumberRegister);
+ return branch64(Below, gpr, TrustedImm64(TagTypeNumber));
+ }
+#endif
+
Jump branchIfNotInt32(JSValueRegs regs, TagRegistersMode mode = HaveTagRegisters)
{
#if USE(JSVALUE64)
- if (mode == HaveTagRegisters)
- return branch64(Below, regs.gpr(), GPRInfo::tagTypeNumberRegister);
- return branch64(Below, regs.gpr(), TrustedImm64(TagTypeNumber));
+ return branchIfNotInt32(regs.gpr(), mode);
#else
UNUSED_PARAM(mode);
return branch32(NotEqual, regs.tagGPR(), TrustedImm32(JSValue::Int32Tag));
diff --git a/Source/JavaScriptCore/jit/JIT.h b/Source/JavaScriptCore/jit/JIT.h
index 2b46e82..d4b82e7 100755
--- a/Source/JavaScriptCore/jit/JIT.h
+++ b/Source/JavaScriptCore/jit/JIT.h
@@ -826,6 +826,9 @@
MacroAssembler::Call callOperation(J_JITOperation_EJscCJ, int, GPRReg, JSCell*, GPRReg, GPRReg);
#endif
+ template<typename SnippetGenerator>
+ void emitBitwiseBinaryOpFastPath(Instruction* currentInstruction);
+
Jump checkStructure(RegisterID reg, Structure* structure);
void updateTopCallFrame();
diff --git a/Source/JavaScriptCore/jit/JITArithmetic.cpp b/Source/JavaScriptCore/jit/JITArithmetic.cpp
index 3c34951..091dee4 100644
--- a/Source/JavaScriptCore/jit/JITArithmetic.cpp
+++ b/Source/JavaScriptCore/jit/JITArithmetic.cpp
@@ -30,6 +30,9 @@
#include "CodeBlock.h"
#include "JITAddGenerator.h"
+#include "JITBitAndGenerator.h"
+#include "JITBitOrGenerator.h"
+#include "JITBitXorGenerator.h"
#include "JITDivGenerator.h"
#include "JITInlines.h"
#include "JITMulGenerator.h"
@@ -525,42 +528,6 @@
}
}
-void JIT::emit_op_bitand(Instruction* currentInstruction)
-{
- int result = currentInstruction[1].u.operand;
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- if (isOperandConstantInt(op1)) {
- emitGetVirtualRegister(op2, regT0);
- emitJumpSlowCaseIfNotInt(regT0);
- int32_t imm = getOperandConstantInt(op1);
- and64(Imm32(imm), regT0);
- if (imm >= 0)
- emitTagInt(regT0, regT0);
- } else if (isOperandConstantInt(op2)) {
- emitGetVirtualRegister(op1, regT0);
- emitJumpSlowCaseIfNotInt(regT0);
- int32_t imm = getOperandConstantInt(op2);
- and64(Imm32(imm), regT0);
- if (imm >= 0)
- emitTagInt(regT0, regT0);
- } else {
- emitGetVirtualRegisters(op1, regT0, op2, regT1);
- and64(regT1, regT0);
- emitJumpSlowCaseIfNotInt(regT0);
- }
- emitPutVirtualRegister(result);
-}
-
-void JIT::emitSlow_op_bitand(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- linkSlowCase(iter);
-
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitand);
- slowPathCall.call();
-}
-
void JIT::emit_op_inc(Instruction* currentInstruction)
{
int srcDst = currentInstruction[1].u.operand;
@@ -664,6 +631,100 @@
#endif // USE(JSVALUE64)
+template<typename SnippetGenerator>
+void JIT::emitBitwiseBinaryOpFastPath(Instruction* currentInstruction)
+{
+ int result = currentInstruction[1].u.operand;
+ int op1 = currentInstruction[2].u.operand;
+ int op2 = currentInstruction[3].u.operand;
+
+#if USE(JSVALUE64)
+ JSValueRegs leftRegs = JSValueRegs(GPRInfo::regT0);
+ JSValueRegs rightRegs = JSValueRegs(GPRInfo::regT1);
+ JSValueRegs resultRegs = leftRegs;
+ GPRReg scratchGPR = GPRInfo::regT2;
+#else
+ JSValueRegs leftRegs = JSValueRegs(GPRInfo::regT1, GPRInfo::regT0);
+ JSValueRegs rightRegs = JSValueRegs(GPRInfo::regT3, GPRInfo::regT2);
+ JSValueRegs resultRegs = leftRegs;
+ GPRReg scratchGPR = InvalidGPRReg;
+#endif
+
+ SnippetOperand leftOperand;
+ SnippetOperand rightOperand;
+
+ if (isOperandConstantInt(op1))
+ leftOperand.setConstInt32(getOperandConstantInt(op1));
+ if (isOperandConstantInt(op2))
+ rightOperand.setConstInt32(getOperandConstantInt(op2));
+
+ RELEASE_ASSERT(!leftOperand.isConst() || !rightOperand.isConst());
+
+ if (!leftOperand.isConst())
+ emitGetVirtualRegister(op1, leftRegs);
+ if (!rightOperand.isConst())
+ emitGetVirtualRegister(op2, rightRegs);
+
+ SnippetGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs, scratchGPR);
+
+ gen.generateFastPath(*this);
+
+ if (gen.didEmitFastPath()) {
+ gen.endJumpList().link(this);
+#if USE(JSVALUE32_64)
+ emitStoreInt32(result, resultRegs.payloadGPR(), op1 == result || op2 == result);
+#else
+ emitPutVirtualRegister(result, resultRegs);
+#endif
+
+ addSlowCase(gen.slowPathJumpList());
+ } else {
+ ASSERT(gen.endJumpList().empty());
+ ASSERT(gen.slowPathJumpList().empty());
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
+ slowPathCall.call();
+ }
+}
+
+void JIT::emit_op_bitand(Instruction* currentInstruction)
+{
+ emitBitwiseBinaryOpFastPath<JITBitAndGenerator>(currentInstruction);
+}
+
+void JIT::emitSlow_op_bitand(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
+
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitand);
+ slowPathCall.call();
+}
+
+void JIT::emit_op_bitor(Instruction* currentInstruction)
+{
+ emitBitwiseBinaryOpFastPath<JITBitOrGenerator>(currentInstruction);
+}
+
+void JIT::emitSlow_op_bitor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
+
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitor);
+ slowPathCall.call();
+}
+
+void JIT::emit_op_bitxor(Instruction* currentInstruction)
+{
+ emitBitwiseBinaryOpFastPath<JITBitXorGenerator>(currentInstruction);
+}
+
+void JIT::emitSlow_op_bitxor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
+
+ JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitxor);
+ slowPathCall.call();
+}
+
void JIT::emit_op_add(Instruction* currentInstruction)
{
int result = currentInstruction[1].u.operand;
diff --git a/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp b/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp
index 8a5324c..d9e4276 100644
--- a/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp
+++ b/Source/JavaScriptCore/jit/JITArithmetic32_64.cpp
@@ -324,120 +324,6 @@
slowPathCall.call();
}
-// BitAnd (&)
-
-void JIT::emit_op_bitand(Instruction* currentInstruction)
-{
- int dst = currentInstruction[1].u.operand;
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- int op;
- int32_t constant;
- if (getOperandConstantInt(op1, op2, op, constant)) {
- emitLoad(op, regT1, regT0);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- and32(Imm32(constant), regT0);
- emitStoreInt32(dst, regT0, dst == op);
- return;
- }
-
- emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- addSlowCase(branch32(NotEqual, regT3, TrustedImm32(JSValue::Int32Tag)));
- and32(regT2, regT0);
- emitStoreInt32(dst, regT0, op1 == dst || op2 == dst);
-}
-
-void JIT::emitSlow_op_bitand(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- if (!isOperandConstantInt(op1) && !isOperandConstantInt(op2))
- linkSlowCase(iter); // int32 check
- linkSlowCase(iter); // int32 check
-
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitand);
- slowPathCall.call();
-}
-
-// BitOr (|)
-
-void JIT::emit_op_bitor(Instruction* currentInstruction)
-{
- int dst = currentInstruction[1].u.operand;
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- int op;
- int32_t constant;
- if (getOperandConstantInt(op1, op2, op, constant)) {
- emitLoad(op, regT1, regT0);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- or32(Imm32(constant), regT0);
- emitStoreInt32(dst, regT0, op == dst);
- return;
- }
-
- emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- addSlowCase(branch32(NotEqual, regT3, TrustedImm32(JSValue::Int32Tag)));
- or32(regT2, regT0);
- emitStoreInt32(dst, regT0, op1 == dst || op2 == dst);
-}
-
-void JIT::emitSlow_op_bitor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- if (!isOperandConstantInt(op1) && !isOperandConstantInt(op2))
- linkSlowCase(iter); // int32 check
- linkSlowCase(iter); // int32 check
-
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitor);
- slowPathCall.call();
-}
-
-// BitXor (^)
-
-void JIT::emit_op_bitxor(Instruction* currentInstruction)
-{
- int dst = currentInstruction[1].u.operand;
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- int op;
- int32_t constant;
- if (getOperandConstantInt(op1, op2, op, constant)) {
- emitLoad(op, regT1, regT0);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- xor32(Imm32(constant), regT0);
- emitStoreInt32(dst, regT0, op == dst);
- return;
- }
-
- emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
- addSlowCase(branch32(NotEqual, regT1, TrustedImm32(JSValue::Int32Tag)));
- addSlowCase(branch32(NotEqual, regT3, TrustedImm32(JSValue::Int32Tag)));
- xor32(regT2, regT0);
- emitStoreInt32(dst, regT0, op1 == dst || op2 == dst);
-}
-
-void JIT::emitSlow_op_bitxor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- int op1 = currentInstruction[2].u.operand;
- int op2 = currentInstruction[3].u.operand;
-
- if (!isOperandConstantInt(op1) && !isOperandConstantInt(op2))
- linkSlowCase(iter); // int32 check
- linkSlowCase(iter); // int32 check
-
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitxor);
- slowPathCall.call();
-}
-
void JIT::emit_op_inc(Instruction* currentInstruction)
{
int srcDst = currentInstruction[1].u.operand;
diff --git a/Source/JavaScriptCore/jit/JITBitAndGenerator.cpp b/Source/JavaScriptCore/jit/JITBitAndGenerator.cpp
new file mode 100644
index 0000000..8aa6157
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitAndGenerator.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 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 "JITBitAndGenerator.h"
+
+#if ENABLE(JIT)
+
+namespace JSC {
+
+void JITBitAndGenerator::generateFastPath(CCallHelpers& jit)
+{
+#if USE(JSVALUE64)
+ ASSERT(m_scratchGPR != InvalidGPRReg);
+ ASSERT(m_scratchGPR != m_left.payloadGPR());
+ ASSERT(m_scratchGPR != m_right.payloadGPR());
+#else
+ UNUSED_PARAM(m_scratchGPR);
+#endif
+
+ ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
+
+ m_didEmitFastPath = true;
+
+ if (m_leftOperand.isConstInt32() || m_rightOperand.isConstInt32()) {
+ JSValueRegs var = m_leftOperand.isConstInt32() ? m_right : m_left;
+ SnippetOperand& constOpr = m_leftOperand.isConstInt32() ? m_leftOperand : m_rightOperand;
+
+ // Try to do intVar & intConstant.
+ m_slowPathJumpList.append(jit.branchIfNotInt32(var));
+
+ jit.moveValueRegs(var, m_result);
+#if USE(JSVALUE64)
+ jit.and64(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+ if (constOpr.asConstInt32() >= 0)
+ jit.or64(GPRInfo::tagTypeNumberRegister, m_result.payloadGPR());
+#else
+ jit.and32(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+#endif
+
+ } else {
+ ASSERT(!m_leftOperand.isConstInt32() && !m_rightOperand.isConstInt32());
+
+ // Try to do intVar & intVar.
+#if USE(JSVALUE64)
+ jit.move(m_left.payloadGPR(), m_scratchGPR);
+ jit.and64(m_right.payloadGPR(), m_scratchGPR);
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_scratchGPR));
+ jit.move(m_scratchGPR, m_result.payloadGPR());
+#else
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_left));
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_right));
+ jit.moveValueRegs(m_left, m_result);
+ jit.and32(m_right.payloadGPR(), m_result.payloadGPR());
+#endif
+ }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
diff --git a/Source/JavaScriptCore/jit/JITBitAndGenerator.h b/Source/JavaScriptCore/jit/JITBitAndGenerator.h
new file mode 100644
index 0000000..dbdb63f
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitAndGenerator.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 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 JITBitAndGenerator_h
+#define JITBitAndGenerator_h
+
+#if ENABLE(JIT)
+
+#include "JITBitwiseBinaryOpGenerator.h"
+
+namespace JSC {
+
+class JITBitAndGenerator : public JITBitwiseBinaryOpGenerator {
+public:
+ JITBitAndGenerator(const SnippetOperand& leftOperand, const SnippetOperand& rightOperand,
+ JSValueRegs result, JSValueRegs left, JSValueRegs right, GPRReg scratchGPR)
+ : JITBitwiseBinaryOpGenerator(leftOperand, rightOperand, result, left, right, scratchGPR)
+ { }
+
+ void generateFastPath(CCallHelpers&);
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITBitAndGenerator_h
diff --git a/Source/JavaScriptCore/jit/JITBitOrGenerator.cpp b/Source/JavaScriptCore/jit/JITBitOrGenerator.cpp
new file mode 100644
index 0000000..3a2ecb0
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitOrGenerator.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 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 "JITBitOrGenerator.h"
+
+#if ENABLE(JIT)
+
+namespace JSC {
+
+void JITBitOrGenerator::generateFastPath(CCallHelpers& jit)
+{
+ ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
+
+ m_didEmitFastPath = true;
+
+ if (m_leftOperand.isConstInt32() || m_rightOperand.isConstInt32()) {
+ JSValueRegs var = m_leftOperand.isConstInt32() ? m_right : m_left;
+ SnippetOperand& constOpr = m_leftOperand.isConstInt32() ? m_leftOperand : m_rightOperand;
+
+ // Try to do intVar & intConstant.
+ m_slowPathJumpList.append(jit.branchIfNotInt32(var));
+
+ jit.moveValueRegs(var, m_result);
+#if USE(JSVALUE64)
+ jit.or32(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+ jit.or64(GPRInfo::tagTypeNumberRegister, m_result.payloadGPR());
+#else
+ jit.or32(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+#endif
+
+ } else {
+ ASSERT(!m_leftOperand.isConstInt32() && !m_rightOperand.isConstInt32());
+
+ // Try to do intVar & intVar.
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_left));
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_right));
+
+ jit.moveValueRegs(m_left, m_result);
+#if USE(JSVALUE64)
+ jit.or64(m_right.payloadGPR(), m_result.payloadGPR());
+#else
+ jit.or32(m_right.payloadGPR(), m_result.payloadGPR());
+#endif
+ }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
diff --git a/Source/JavaScriptCore/jit/JITBitOrGenerator.h b/Source/JavaScriptCore/jit/JITBitOrGenerator.h
new file mode 100644
index 0000000..84bc7ce
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitOrGenerator.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 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 JITBitOrGenerator_h
+#define JITBitOrGenerator_h
+
+#if ENABLE(JIT)
+
+#include "JITBitwiseBinaryOpGenerator.h"
+
+namespace JSC {
+
+class JITBitOrGenerator : public JITBitwiseBinaryOpGenerator {
+public:
+ JITBitOrGenerator(const SnippetOperand& leftOperand, const SnippetOperand& rightOperand,
+ JSValueRegs result, JSValueRegs left, JSValueRegs right, GPRReg unused = InvalidGPRReg)
+ : JITBitwiseBinaryOpGenerator(leftOperand, rightOperand, result, left, right, unused)
+ { }
+
+ void generateFastPath(CCallHelpers&);
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITBitOrGenerator_h
diff --git a/Source/JavaScriptCore/jit/JITBitXorGenerator.cpp b/Source/JavaScriptCore/jit/JITBitXorGenerator.cpp
new file mode 100644
index 0000000..d6cfdd6
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitXorGenerator.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 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 "JITBitXorGenerator.h"
+
+#if ENABLE(JIT)
+
+namespace JSC {
+
+void JITBitXorGenerator::generateFastPath(CCallHelpers& jit)
+{
+ ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
+
+ m_didEmitFastPath = true;
+
+ if (m_leftOperand.isConstInt32() || m_rightOperand.isConstInt32()) {
+ JSValueRegs var = m_leftOperand.isConstInt32() ? m_right : m_left;
+ SnippetOperand& constOpr = m_leftOperand.isConstInt32() ? m_leftOperand : m_rightOperand;
+
+ // Try to do intVar & intConstant.
+ m_slowPathJumpList.append(jit.branchIfNotInt32(var));
+
+ jit.moveValueRegs(var, m_result);
+#if USE(JSVALUE64)
+ jit.xor32(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+ jit.or64(GPRInfo::tagTypeNumberRegister, m_result.payloadGPR());
+#else
+ jit.xor32(CCallHelpers::Imm32(constOpr.asConstInt32()), m_result.payloadGPR());
+#endif
+
+ } else {
+ ASSERT(!m_leftOperand.isConstInt32() && !m_rightOperand.isConstInt32());
+
+ // Try to do intVar & intVar.
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_left));
+ m_slowPathJumpList.append(jit.branchIfNotInt32(m_right));
+
+ jit.moveValueRegs(m_left, m_result);
+#if USE(JSVALUE64)
+ jit.xor64(m_right.payloadGPR(), m_result.payloadGPR());
+ jit.or64(GPRInfo::tagTypeNumberRegister, m_result.payloadGPR());
+#else
+ jit.xor32(m_right.payloadGPR(), m_result.payloadGPR());
+#endif
+ }
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
diff --git a/Source/JavaScriptCore/jit/JITBitXorGenerator.h b/Source/JavaScriptCore/jit/JITBitXorGenerator.h
new file mode 100644
index 0000000..e812d51
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitXorGenerator.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 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 JITBitXorGenerator_h
+#define JITBitXorGenerator_h
+
+#if ENABLE(JIT)
+
+#include "JITBitwiseBinaryOpGenerator.h"
+
+namespace JSC {
+
+class JITBitXorGenerator : public JITBitwiseBinaryOpGenerator {
+public:
+ JITBitXorGenerator(const SnippetOperand& leftOperand, const SnippetOperand& rightOperand,
+ JSValueRegs result, JSValueRegs left, JSValueRegs right, GPRReg unused = InvalidGPRReg)
+ : JITBitwiseBinaryOpGenerator(leftOperand, rightOperand, result, left, right, unused)
+ { }
+
+ void generateFastPath(CCallHelpers&);
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITBitOrGenerator_h
diff --git a/Source/JavaScriptCore/jit/JITBitwiseBinaryOpGenerator.h b/Source/JavaScriptCore/jit/JITBitwiseBinaryOpGenerator.h
new file mode 100644
index 0000000..0081aa5
--- /dev/null
+++ b/Source/JavaScriptCore/jit/JITBitwiseBinaryOpGenerator.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 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 JITBitwiseBinaryOpGenerator_h
+#define JITBitwiseBinaryOpGenerator_h
+
+#if ENABLE(JIT)
+
+#include "CCallHelpers.h"
+#include "SnippetOperand.h"
+
+namespace JSC {
+
+class JITBitwiseBinaryOpGenerator {
+public:
+ JITBitwiseBinaryOpGenerator(const SnippetOperand& leftOperand, const SnippetOperand& rightOperand,
+ JSValueRegs result, JSValueRegs left, JSValueRegs right, GPRReg scratchGPR)
+ : m_leftOperand(leftOperand)
+ , m_rightOperand(rightOperand)
+ , m_result(result)
+ , m_left(left)
+ , m_right(right)
+ , m_scratchGPR(scratchGPR)
+ {
+ ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
+ }
+
+ bool didEmitFastPath() const { return m_didEmitFastPath; }
+ CCallHelpers::JumpList& endJumpList() { return m_endJumpList; }
+ CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
+
+protected:
+ SnippetOperand m_leftOperand;
+ SnippetOperand m_rightOperand;
+ JSValueRegs m_result;
+ JSValueRegs m_left;
+ JSValueRegs m_right;
+ GPRReg m_scratchGPR;
+ bool m_didEmitFastPath { false };
+
+ CCallHelpers::JumpList m_endJumpList;
+ CCallHelpers::JumpList m_slowPathJumpList;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // JITBitwiseBinaryOpGenerator_h
diff --git a/Source/JavaScriptCore/jit/JITOpcodes.cpp b/Source/JavaScriptCore/jit/JITOpcodes.cpp
index 1f3115a..a1bc16c 100755
--- a/Source/JavaScriptCore/jit/JITOpcodes.cpp
+++ b/Source/JavaScriptCore/jit/JITOpcodes.cpp
@@ -401,23 +401,6 @@
}
-void JIT::emit_op_bitxor(Instruction* currentInstruction)
-{
- emitGetVirtualRegisters(currentInstruction[2].u.operand, regT0, currentInstruction[3].u.operand, regT1);
- emitJumpSlowCaseIfNotInt(regT0, regT1, regT2);
- xor64(regT1, regT0);
- emitTagInt(regT0, regT0);
- emitPutVirtualRegister(currentInstruction[1].u.operand);
-}
-
-void JIT::emit_op_bitor(Instruction* currentInstruction)
-{
- emitGetVirtualRegisters(currentInstruction[2].u.operand, regT0, currentInstruction[3].u.operand, regT1);
- emitJumpSlowCaseIfNotInt(regT0, regT1, regT2);
- or64(regT1, regT0);
- emitPutVirtualRegister(currentInstruction[1].u.operand);
-}
-
void JIT::emit_op_throw(Instruction* currentInstruction)
{
ASSERT(regT0 == returnValueGPR);
@@ -819,20 +802,6 @@
emitJumpSlowToHot(branchTest32(NonZero, returnValueGPR), currentInstruction[2].u.operand);
}
-void JIT::emitSlow_op_bitxor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- linkSlowCase(iter);
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitxor);
- slowPathCall.call();
-}
-
-void JIT::emitSlow_op_bitor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- linkSlowCase(iter);
- JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitor);
- slowPathCall.call();
-}
-
void JIT::emitSlow_op_eq(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
{
linkSlowCase(iter);
diff --git a/Source/JavaScriptCore/jit/SnippetOperand.h b/Source/JavaScriptCore/jit/SnippetOperand.h
index 957cfe4..67884b3 100644
--- a/Source/JavaScriptCore/jit/SnippetOperand.h
+++ b/Source/JavaScriptCore/jit/SnippetOperand.h
@@ -40,6 +40,10 @@
};
public:
+ SnippetOperand()
+ : m_resultType(ResultType::unknownType())
+ { }
+
SnippetOperand(ResultType resultType)
: m_resultType(resultType)
{ }
diff --git a/Source/JavaScriptCore/tests/stress/op_bitand.js b/Source/JavaScriptCore/tests/stress/op_bitand.js
index d511a2a..b8d93e9 100644
--- a/Source/JavaScriptCore/tests/stress/op_bitand.js
+++ b/Source/JavaScriptCore/tests/stress/op_bitand.js
@@ -43,8 +43,8 @@
'-0x7fff',
'0x10000',
'-0x10000',
- '0x7ffffff',
- '-0x7ffffff',
+ '0x7fffffff',
+ '-0x7fffffff',
'0xa5a5a5a5',
'0x100000000',
'-0x100000000',
@@ -54,8 +54,8 @@
'"-0"',
'"1"',
'"-1"',
- '"0x7ffffff"',
- '"-0x7ffffff"',
+ '"0x7fffffff"',
+ '"-0x7fffffff"',
'"0xa5a5a5a5"',
'"0x100000000"',
'"-0x100000000"',
diff --git a/Source/JavaScriptCore/tests/stress/op_bitor.js b/Source/JavaScriptCore/tests/stress/op_bitor.js
index 594c14b..6ddcad8 100644
--- a/Source/JavaScriptCore/tests/stress/op_bitor.js
+++ b/Source/JavaScriptCore/tests/stress/op_bitor.js
@@ -43,8 +43,8 @@
'-0x7fff',
'0x10000',
'-0x10000',
- '0x7ffffff',
- '-0x7ffffff',
+ '0x7fffffff',
+ '-0x7fffffff',
'0xa5a5a5a5',
'0x100000000',
'-0x100000000',
@@ -54,8 +54,8 @@
'"-0"',
'"1"',
'"-1"',
- '"0x7ffffff"',
- '"-0x7ffffff"',
+ '"0x7fffffff"',
+ '"-0x7fffffff"',
'"0xa5a5a5a5"',
'"0x100000000"',
'"-0x100000000"',
diff --git a/Source/JavaScriptCore/tests/stress/op_bitxor.js b/Source/JavaScriptCore/tests/stress/op_bitxor.js
index 4d15904..a6285bc 100644
--- a/Source/JavaScriptCore/tests/stress/op_bitxor.js
+++ b/Source/JavaScriptCore/tests/stress/op_bitxor.js
@@ -43,8 +43,8 @@
'-0x7fff',
'0x10000',
'-0x10000',
- '0x7ffffff',
- '-0x7ffffff',
+ '0x7fffffff',
+ '-0x7fffffff',
'0xa5a5a5a5',
'0x100000000',
'-0x100000000',
@@ -54,8 +54,8 @@
'"-0"',
'"1"',
'"-1"',
- '"0x7ffffff"',
- '"-0x7ffffff"',
+ '"0x7fffffff"',
+ '"-0x7fffffff"',
'"0xa5a5a5a5"',
'"0x100000000"',
'"-0x100000000"',