Use the JITAddGenerator snippet in the DFG.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 21:55:33 +0000 (21:55 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Nov 2015 21:55:33 +0000 (21:55 +0000)
commit93635c4effc168d38480143656fc705469b572ce
tree37957a07fdf95d7192cf3f8b792cd071c3ffe1e9
parent0ce658631f9da13528611966ec5dc6960d4be79e
Use the JITAddGenerator snippet in the DFG.
https://bugs.webkit.org/show_bug.cgi?id=151266

Reviewed by Geoffrey Garen.

No tests added because the op_add.js stress test already tests for correctness
(using the LLINT as a reference).

Performance-wise, the difference from the pre-existing DFG implementation is
insignificant (at least as measured on x86 and x86_64).  We're moving forward
with adopting this implementation because it unifies the 32-bit and 64-bit
implementations, as well as lays ground work for a repatching inline cache
implementation of op_add later.

* dfg/DFGAbstractValue.cpp:
(JSC::DFG::AbstractValue::resultType):
- Made an assertion less restrictive.  For ValueAdd operands, the DFG thinks that
  the operand can also be empty (though we should never see this in practice).

* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
- Add fallback to unused type operands.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileValueAdd):
- Introduce a common function to compile the ValueAdd node.

* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::JSValueOperand::JSValueOperand):
- Add the forwarding constructor so that we can use Optional<JSValueOperand>.

* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
- Changed to use the common compileValueAdd().

* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::moveValue):
- Similar to moveTrustedValue() but used for untrusted constants.

* jit/JITAddGenerator.cpp:
(JSC::JITAddGenerator::generateFastPath):
* jit/JITAddGenerator.h:
(JSC::JITAddGenerator::JITAddGenerator):
- Updated to take the left or right operand as a constant.  This is necessary
  because the client should not be making assumptions about whether the snippet
  will determine the operation to be commutative or not.  Instead, the client
  should just pass in the operands and let the snippet do any operand order
  swapping if necessary.

* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_add):
- Updated to use the new JITAddGenerator interface.

* tests/stress/op_add.js:
(stringifyIfNeeded):
(runTest):
- Made test output more clear about when string results are expected.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGAbstractValue.cpp
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
Source/JavaScriptCore/jit/AssemblyHelpers.h
Source/JavaScriptCore/jit/JITAddGenerator.cpp
Source/JavaScriptCore/jit/JITAddGenerator.h
Source/JavaScriptCore/jit/JITArithmetic.cpp
Source/JavaScriptCore/tests/stress/op_add.js