Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (135329 => 135330)
--- trunk/Source/_javascript_Core/ChangeLog 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-11-21 00:22:08 UTC (rev 135330)
@@ -1,3 +1,51 @@
+2012-11-20 Filip Pizlo <fpi...@apple.com>
+
+ DFG should be able to cache closure calls (part 1/2)
+ https://bugs.webkit.org/show_bug.cgi?id=102662
+
+ Reviewed by Gavin Barraclough.
+
+ Add ability to revert a jump replacement back to
+ branchPtrWithPatch(Condition, RegisterID, TrustedImmPtr). This is meant to be
+ a mandatory piece of functionality for all assemblers. I also renamed some of
+ the functions for reverting jump replacements back to
+ patchableBranchPtrWithPatch(Condition, Address, TrustedImmPtr), so as to avoid
+ confusion.
+
+ * assembler/ARMv7Assembler.h:
+ (JSC::ARMv7Assembler::BadReg):
+ (ARMv7Assembler):
+ (JSC::ARMv7Assembler::revertJumpTo_movT3):
+ * assembler/LinkBuffer.h:
+ (JSC):
+ * assembler/MacroAssemblerARMv7.h:
+ (JSC::MacroAssemblerARMv7::startOfBranchPtrWithPatchOnRegister):
+ (MacroAssemblerARMv7):
+ (JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch):
+ (JSC::MacroAssemblerARMv7::startOfPatchableBranchPtrWithPatchOnAddress):
+ * assembler/MacroAssemblerX86.h:
+ (JSC::MacroAssemblerX86::startOfBranchPtrWithPatchOnRegister):
+ (MacroAssemblerX86):
+ (JSC::MacroAssemblerX86::startOfPatchableBranchPtrWithPatchOnAddress):
+ (JSC::MacroAssemblerX86::revertJumpReplacementToBranchPtrWithPatch):
+ * assembler/MacroAssemblerX86_64.h:
+ (JSC::MacroAssemblerX86_64::startOfBranchPtrWithPatchOnRegister):
+ (JSC::MacroAssemblerX86_64::startOfPatchableBranchPtrWithPatchOnAddress):
+ (MacroAssemblerX86_64):
+ (JSC::MacroAssemblerX86_64::revertJumpReplacementToBranchPtrWithPatch):
+ * assembler/RepatchBuffer.h:
+ (JSC::RepatchBuffer::startOfBranchPtrWithPatchOnRegister):
+ (RepatchBuffer):
+ (JSC::RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress):
+ (JSC::RepatchBuffer::revertJumpReplacementToBranchPtrWithPatch):
+ * assembler/X86Assembler.h:
+ (JSC::X86Assembler::revertJumpTo_cmpl_ir_force32):
+ (X86Assembler):
+ * dfg/DFGRepatch.cpp:
+ (JSC::DFG::replaceWithJump):
+ (JSC::DFG::dfgResetGetByID):
+ (JSC::DFG::dfgResetPutByID):
+
2012-11-20 Yong Li <y...@rim.com>
[ARMv7] Neither linkCall() nor linkPointer() should flush code.
Modified: trunk/Source/_javascript_Core/assembler/ARMv7Assembler.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/ARMv7Assembler.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/ARMv7Assembler.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2010 University of Szeged
*
* Redistribution and use in source and binary forms, with or without
@@ -507,7 +507,7 @@
private:
// ARMv7, Appx-A.6.3
- bool BadReg(RegisterID reg)
+ static bool BadReg(RegisterID reg)
{
return (reg == ARMRegisters::sp) || (reg == ARMRegisters::pc);
}
@@ -1261,6 +1261,18 @@
m_formatter.twoWordOp5i6Imm4Reg4EncodedImm(OP_MOV_imm_T3, imm.m_value.imm4, rd, imm);
}
+
+ static void revertJumpTo_movT3(void* instructionStart, RegisterID rd, ARMThumbImmediate imm)
+ {
+ ASSERT(imm.isValid());
+ ASSERT(!imm.isEncodedImm());
+ ASSERT(!BadReg(rd));
+
+ uint16_t* address = static_cast<uint16_t*>(instructionStart);
+ address[0] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, imm);
+ address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(rd, imm);
+ cacheFlush(address, sizeof(uint16_t) * 2);
+ }
ALWAYS_INLINE void mov(RegisterID rd, ARMThumbImmediate imm)
{
Modified: trunk/Source/_javascript_Core/assembler/LinkBuffer.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/LinkBuffer.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/LinkBuffer.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -288,7 +288,7 @@
FINALIZE_CODE_IF(Options::showDisassembly(), linkBufferReference, dataLogArgumentsForHeading)
#define FINALIZE_DFG_CODE(linkBufferReference, dataLogArgumentsForHeading) \
- FINALIZE_CODE_IF(Options::showDFGDisassembly(), linkBufferReference, dataLogArgumentsForHeading)
+ FINALIZE_CODE_IF((Options::showDisassembly() || Options::showDFGDisassembly()), linkBufferReference, dataLogArgumentsForHeading)
} // namespace JSC
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARMv7.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -1761,8 +1761,19 @@
static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; }
- static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr)
+ static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
{
+ const unsigned twoWordOpSize = 4;
+ return label.labelAtOffset(-twoWordOpSize * 2);
+ }
+
+ static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
+ {
+ ARMv7Assembler::revertJumpTo_movT3(instructionStart.dataLocation(), dataTempRegister, ARMThumbImmediate::makeUInt16(reinterpret_cast<uintptr_t>(initialValue) & 0xffff));
+ }
+
+ static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr)
+ {
UNREACHABLE_FOR_PLATFORM();
return CodeLocationLabel();
}
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -255,10 +255,20 @@
static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; }
- static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
+ static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
{
const int opcodeBytes = 1;
const int modRMBytes = 1;
+ const int immediateBytes = 4;
+ const int totalBytes = opcodeBytes + modRMBytes + immediateBytes;
+ ASSERT(totalBytes >= maxJumpReplacementSize());
+ return label.labelAtOffset(-totalBytes);
+ }
+
+ static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
+ {
+ const int opcodeBytes = 1;
+ const int modRMBytes = 1;
const int offsetBytes = 0;
const int immediateBytes = 4;
const int totalBytes = opcodeBytes + modRMBytes + offsetBytes + immediateBytes;
@@ -266,6 +276,11 @@
return label.labelAtOffset(-totalBytes);
}
+ static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue)
+ {
+ X86Assembler::revertJumpTo_cmpl_ir_force32(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), reg);
+ }
+
static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address address, void* initialValue)
{
ASSERT(!address.offset);
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86_64.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -587,7 +587,7 @@
static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; }
- static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
+ static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
{
const int rexBytes = 1;
const int opcodeBytes = 1;
@@ -597,11 +597,21 @@
return label.labelAtOffset(-totalBytes);
}
+ static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
+ {
+ return startOfBranchPtrWithPatchOnRegister(label);
+ }
+
static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address, void* initialValue)
{
X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister);
}
+ static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
+ {
+ X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister);
+ }
+
private:
friend class LinkBuffer;
friend class RepatchBuffer;
Modified: trunk/Source/_javascript_Core/assembler/RepatchBuffer.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/RepatchBuffer.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/RepatchBuffer.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -141,11 +141,16 @@
replaceWithAddressComputation(label);
}
- static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)
+ static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label)
{
- return MacroAssembler::startOfPatchableBranchPtrWithPatch(label);
+ return MacroAssembler::startOfBranchPtrWithPatchOnRegister(label);
}
+ static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label)
+ {
+ return MacroAssembler::startOfPatchableBranchPtrWithPatchOnAddress(label);
+ }
+
void replaceWithJump(CodeLocationLabel instructionStart, CodeLocationLabel destination)
{
MacroAssembler::replaceWithJump(instructionStart, destination);
@@ -154,6 +159,11 @@
// This is a *bit* of a silly API, since we currently always also repatch the
// immediate after calling this. But I'm fine with that, since this just feels
// less yucky.
+ void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::RegisterID reg, void* value)
+ {
+ MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(instructionStart, reg, value);
+ }
+
void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::Address address, void* value)
{
MacroAssembler::revertJumpReplacementToPatchableBranchPtrWithPatch(instructionStart, address, value);
Modified: trunk/Source/_javascript_Core/assembler/X86Assembler.h (135329 => 135330)
--- trunk/Source/_javascript_Core/assembler/X86Assembler.h 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/assembler/X86Assembler.h 2012-11-21 00:22:08 UTC (rev 135330)
@@ -1903,6 +1903,23 @@
}
#endif
+ static void revertJumpTo_cmpl_ir_force32(void* instructionStart, int32_t imm, RegisterID dst)
+ {
+ const int opcodeBytes = 1;
+ const int modRMBytes = 1;
+ ASSERT(opcodeBytes + modRMBytes <= maxJumpReplacementSize());
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart);
+ ptr[0] = OP_GROUP1_EvIz;
+ ptr[1] = (X86InstructionFormatter::ModRmRegister << 6) | (GROUP1_OP_CMP << 3) | dst;
+ union {
+ uint32_t asWord;
+ uint8_t asBytes[4];
+ } u;
+ u.asWord = imm;
+ for (unsigned i = opcodeBytes + modRMBytes; i < static_cast<unsigned>(maxJumpReplacementSize()); ++i)
+ ptr[i] = u.asBytes[i - opcodeBytes - modRMBytes];
+ }
+
static void revertJumpTo_cmpl_im_force32(void* instructionStart, int32_t imm, int offset, RegisterID dst)
{
ASSERT_UNUSED(offset, !offset);
Modified: trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp (135329 => 135330)
--- trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp 2012-11-21 00:20:12 UTC (rev 135329)
+++ trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp 2012-11-21 00:22:08 UTC (rev 135330)
@@ -118,7 +118,7 @@
{
if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
repatchBuffer.replaceWithJump(
- RepatchBuffer::startOfPatchableBranchPtrWithPatch(
+ RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(
stubInfo.callReturnLocation.dataLabelPtrAtOffset(
-(intptr_t)stubInfo.patch.dfg.deltaCheckImmToCall)),
CodeLocationLabel(target));
@@ -1142,7 +1142,7 @@
CodeLocationDataLabelPtr structureLabel = stubInfo.callReturnLocation.dataLabelPtrAtOffset(-(intptr_t)stubInfo.patch.dfg.deltaCheckImmToCall);
if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch(
- RepatchBuffer::startOfPatchableBranchPtrWithPatch(structureLabel),
+ RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel),
MacroAssembler::Address(
static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR),
JSCell::structureOffset()),
@@ -1176,7 +1176,7 @@
CodeLocationDataLabelPtr structureLabel = stubInfo.callReturnLocation.dataLabelPtrAtOffset(-(intptr_t)stubInfo.patch.dfg.deltaCheckImmToCall);
if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) {
repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch(
- RepatchBuffer::startOfPatchableBranchPtrWithPatch(structureLabel),
+ RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel),
MacroAssembler::Address(
static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR),
JSCell::structureOffset()),