Commit d8b90842 authored by barraclough@apple.com's avatar barraclough@apple.com

Bug 56273 - Add three operand forms to MacroAssember operations.

Reviewed by Sam Weinig.

Adding for X86(_64) for now, should be rolled out to other backends as necessary.
These may allow more efficient code generation in some cases, avoiding the need
for unnecessary register-register move instructions.

* assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::Jump::link):
(JSC::AbstractMacroAssembler::Jump::linkTo):
    - marked these methods const.
(JSC::AbstractMacroAssembler::Jump::isSet):
    - add a method to check whether a Jump object has been set to
      reference an instruction, or is in a null, unset state. 
* assembler/MacroAssemblerCodeRef.h:
(JSC::FunctionPtr::FunctionPtr):
    - add non-explicit constructor, for FunctionPtr's to C/C++ functions.
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::and32):
(JSC::MacroAssemblerX86Common::lshift32):
(JSC::MacroAssemblerX86Common::or32):
(JSC::MacroAssemblerX86Common::rshift32):
(JSC::MacroAssemblerX86Common::urshift32):
(JSC::MacroAssemblerX86Common::xor32):
(JSC::MacroAssemblerX86Common::moveDouble):
(JSC::MacroAssemblerX86Common::addDouble):
(JSC::MacroAssemblerX86Common::divDouble):
(JSC::MacroAssemblerX86Common::subDouble):
(JSC::MacroAssemblerX86Common::mulDouble):
(JSC::MacroAssemblerX86Common::branchTruncateDoubleToInt32):
(JSC::MacroAssemblerX86Common::branchTest32):
(JSC::MacroAssemblerX86Common::branchTest8):
(JSC::MacroAssemblerX86Common::branchAdd32):
(JSC::MacroAssemblerX86Common::branchMul32):
(JSC::MacroAssemblerX86Common::branchSub32):
    - add three operand forms of these instructions.
* assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::addDouble):
(JSC::MacroAssemblerX86_64::convertInt32ToDouble):
(JSC::MacroAssemblerX86_64::loadPtr):
(JSC::MacroAssemblerX86_64::branchTestPtr):
* assembler/X86Assembler.h:
(JSC::X86Assembler::JmpSrc::isSet):
    - add a method to check whether a JmpSrc object has been set to
      reference an instruction, or is in a null, unset state. 
(JSC::X86Assembler::movsd_rr):
    - added FP register-register move.
(JSC::X86Assembler::linkJump):
    - Add an assert to check jumps aren't linked more than once.
* jit/JITInlineMethods.h:
(JSC::JIT::emitLoadInt32ToDouble):
    - load integers to the FPU via regsiters on x86-64.



git-svn-id: svn://svn.chromium.org/blink/trunk@80972 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cdf56833
2011-03-13 Gavin Barraclough <barraclough@apple.com>
Reviewed by Sam Weinig.
Bug 56273 - Add three operand forms to MacroAssember operations.
Adding for X86(_64) for now, should be rolled out to other backends as necessary.
These may allow more efficient code generation in some cases, avoiding the need
for unnecessary register-register move instructions.
* assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::Jump::link):
(JSC::AbstractMacroAssembler::Jump::linkTo):
- marked these methods const.
(JSC::AbstractMacroAssembler::Jump::isSet):
- add a method to check whether a Jump object has been set to
reference an instruction, or is in a null, unset state.
* assembler/MacroAssemblerCodeRef.h:
(JSC::FunctionPtr::FunctionPtr):
- add non-explicit constructor, for FunctionPtr's to C/C++ functions.
* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::and32):
(JSC::MacroAssemblerX86Common::lshift32):
(JSC::MacroAssemblerX86Common::or32):
(JSC::MacroAssemblerX86Common::rshift32):
(JSC::MacroAssemblerX86Common::urshift32):
(JSC::MacroAssemblerX86Common::xor32):
(JSC::MacroAssemblerX86Common::moveDouble):
(JSC::MacroAssemblerX86Common::addDouble):
(JSC::MacroAssemblerX86Common::divDouble):
(JSC::MacroAssemblerX86Common::subDouble):
(JSC::MacroAssemblerX86Common::mulDouble):
(JSC::MacroAssemblerX86Common::branchTruncateDoubleToInt32):
(JSC::MacroAssemblerX86Common::branchTest32):
(JSC::MacroAssemblerX86Common::branchTest8):
(JSC::MacroAssemblerX86Common::branchAdd32):
(JSC::MacroAssemblerX86Common::branchMul32):
(JSC::MacroAssemblerX86Common::branchSub32):
- add three operand forms of these instructions.
* assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::addDouble):
(JSC::MacroAssemblerX86_64::convertInt32ToDouble):
(JSC::MacroAssemblerX86_64::loadPtr):
(JSC::MacroAssemblerX86_64::branchTestPtr):
* assembler/X86Assembler.h:
(JSC::X86Assembler::JmpSrc::isSet):
- add a method to check whether a JmpSrc object has been set to
reference an instruction, or is in a null, unset state.
(JSC::X86Assembler::movsd_rr):
- added FP register-register move.
(JSC::X86Assembler::linkJump):
- Add an assert to check jumps aren't linked more than once.
* jit/JITInlineMethods.h:
(JSC::JIT::emitLoadInt32ToDouble):
- load integers to the FPU via regsiters on x86-64.
2011-03-13 Gavin Barraclough <barraclough@apple.com>
ARM build fix.
......
......@@ -358,16 +358,18 @@ public:
{
}
void link(AbstractMacroAssembler<AssemblerType>* masm)
void link(AbstractMacroAssembler<AssemblerType>* masm) const
{
masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label());
}
void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm)
void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) const
{
masm->m_assembler.linkJump(m_jmp, label.m_label);
}
bool isSet() const { return m_jmp.isSet(); }
private:
JmpSrc m_jmp;
};
......
......@@ -65,15 +65,47 @@ public:
{
}
template<typename returnType>
FunctionPtr(returnType(*value)())
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
template<typename returnType, typename argType1>
FunctionPtr(returnType(*value)(argType1))
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
template<typename returnType, typename argType1, typename argType2>
FunctionPtr(returnType(*value)(argType1, argType2))
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
template<typename returnType, typename argType1, typename argType2, typename argType3>
FunctionPtr(returnType(*value)(argType1, argType2, argType3))
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
template<typename returnType, typename argType1, typename argType2, typename argType3, typename argType4>
FunctionPtr(returnType(*value)(argType1, argType2, argType3, argType4))
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
template<typename FunctionType>
explicit FunctionPtr(FunctionType* value)
#if COMPILER(RVCT)
// RVTC compiler needs C-style cast as it fails with the following error
// Error: #694: reinterpret_cast cannot cast away const or other type qualifiers
: m_value((void*)(value))
#else
: m_value(reinterpret_cast<void*>(value))
#endif
// Using a C-ctyle cast here to avoid compiler error on RVTC:
// Error: #694: reinterpret_cast cannot cast away const or other type qualifiers
// (I guess on RVTC function pointers have a different constness to GCC/MSVC?)
: m_value((void*)value)
{
ASSERT_VALID_CODE_POINTER(m_value);
}
......
......@@ -48,6 +48,7 @@ public:
using MacroAssemblerX86Common::load32;
using MacroAssemblerX86Common::store32;
using MacroAssemblerX86Common::call;
using MacroAssemblerX86Common::addDouble;
using MacroAssemblerX86Common::loadDouble;
using MacroAssemblerX86Common::convertInt32ToDouble;
......@@ -92,9 +93,15 @@ public:
loadDouble(scratchRegister, dest);
}
void convertInt32ToDouble(AbsoluteAddress src, FPRegisterID dest)
void addDouble(AbsoluteAddress address, FPRegisterID dest)
{
move(Imm32(*static_cast<const int32_t*>(src.m_ptr)), scratchRegister);
move(ImmPtr(address.m_ptr), scratchRegister);
m_assembler.addsd_mr(0, scratchRegister, dest);
}
void convertInt32ToDouble(Imm32 imm, FPRegisterID dest)
{
move(imm, scratchRegister);
m_assembler.cvtsi2sd_rr(scratchRegister, dest);
}
......@@ -227,7 +234,7 @@ public:
m_assembler.movq_mr(address.offset, address.base, address.index, address.scale, dest);
}
void loadPtr(void* address, RegisterID dest)
void loadPtr(const void* address, RegisterID dest)
{
if (dest == X86Registers::eax)
m_assembler.movq_mEAX(address);
......@@ -351,6 +358,12 @@ public:
return Jump(m_assembler.jCC(x86Condition(cond)));
}
Jump branchTestPtr(Condition cond, AbsoluteAddress address, Imm32 mask = Imm32(-1))
{
loadPtr(address.m_ptr, scratchRegister);
return branchTestPtr(cond, scratchRegister, mask);
}
Jump branchTestPtr(Condition cond, Address address, Imm32 mask = Imm32(-1))
{
if (mask.m_value == -1)
......
......@@ -228,6 +228,8 @@ public:
{
}
bool isSet() const { return (m_offset != -1); }
private:
JmpSrc(int offset)
: m_offset(offset)
......@@ -1398,6 +1400,12 @@ public:
}
#endif
void movsd_rr(XMMRegisterID src, XMMRegisterID dst)
{
m_formatter.prefix(PRE_SSE_F2);
m_formatter.twoByteOp(OP2_MOVSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
}
void movsd_rm(XMMRegisterID src, int offset, RegisterID base)
{
m_formatter.prefix(PRE_SSE_F2);
......@@ -1536,6 +1544,7 @@ public:
ASSERT(to.m_offset != -1);
char* code = reinterpret_cast<char*>(m_formatter.data());
ASSERT(!reinterpret_cast<int32_t*>(code + from.m_offset)[-1]);
setRel32(code + from.m_offset, code + to.m_offset);
}
......
......@@ -710,8 +710,8 @@ inline void JIT::emitLoadDouble(unsigned index, FPRegisterID value)
inline void JIT::emitLoadInt32ToDouble(unsigned index, FPRegisterID value)
{
if (m_codeBlock->isConstantRegisterIndex(index)) {
WriteBarrier<Unknown>& inConstantPool = m_codeBlock->constantRegister(index);
convertInt32ToDouble(AbsoluteAddress(&inConstantPool), value);
ASSERT(isOperandConstantImmediateInt(index));
convertInt32ToDouble(Imm32(getConstantOperand(index).asInt32()), value);
} else
convertInt32ToDouble(addressFor(index), value);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment