Changeset 135330 in webkit
- Timestamp:
- Nov 20, 2012, 4:22:08 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r135286 r135330 1 2012-11-20 Filip Pizlo <fpizlo@apple.com> 2 3 DFG should be able to cache closure calls (part 1/2) 4 https://bugs.webkit.org/show_bug.cgi?id=102662 5 6 Reviewed by Gavin Barraclough. 7 8 Add ability to revert a jump replacement back to 9 branchPtrWithPatch(Condition, RegisterID, TrustedImmPtr). This is meant to be 10 a mandatory piece of functionality for all assemblers. I also renamed some of 11 the functions for reverting jump replacements back to 12 patchableBranchPtrWithPatch(Condition, Address, TrustedImmPtr), so as to avoid 13 confusion. 14 15 * assembler/ARMv7Assembler.h: 16 (JSC::ARMv7Assembler::BadReg): 17 (ARMv7Assembler): 18 (JSC::ARMv7Assembler::revertJumpTo_movT3): 19 * assembler/LinkBuffer.h: 20 (JSC): 21 * assembler/MacroAssemblerARMv7.h: 22 (JSC::MacroAssemblerARMv7::startOfBranchPtrWithPatchOnRegister): 23 (MacroAssemblerARMv7): 24 (JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch): 25 (JSC::MacroAssemblerARMv7::startOfPatchableBranchPtrWithPatchOnAddress): 26 * assembler/MacroAssemblerX86.h: 27 (JSC::MacroAssemblerX86::startOfBranchPtrWithPatchOnRegister): 28 (MacroAssemblerX86): 29 (JSC::MacroAssemblerX86::startOfPatchableBranchPtrWithPatchOnAddress): 30 (JSC::MacroAssemblerX86::revertJumpReplacementToBranchPtrWithPatch): 31 * assembler/MacroAssemblerX86_64.h: 32 (JSC::MacroAssemblerX86_64::startOfBranchPtrWithPatchOnRegister): 33 (JSC::MacroAssemblerX86_64::startOfPatchableBranchPtrWithPatchOnAddress): 34 (MacroAssemblerX86_64): 35 (JSC::MacroAssemblerX86_64::revertJumpReplacementToBranchPtrWithPatch): 36 * assembler/RepatchBuffer.h: 37 (JSC::RepatchBuffer::startOfBranchPtrWithPatchOnRegister): 38 (RepatchBuffer): 39 (JSC::RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress): 40 (JSC::RepatchBuffer::revertJumpReplacementToBranchPtrWithPatch): 41 * assembler/X86Assembler.h: 42 (JSC::X86Assembler::revertJumpTo_cmpl_ir_force32): 43 (X86Assembler): 44 * dfg/DFGRepatch.cpp: 45 (JSC::DFG::replaceWithJump): 46 (JSC::DFG::dfgResetGetByID): 47 (JSC::DFG::dfgResetPutByID): 48 1 49 2012-11-20 Yong Li <yoli@rim.com> 2 50 -
trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h
r135286 r135330 1 1 /* 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 University of Szeged 4 4 * … … 508 508 509 509 // ARMv7, Appx-A.6.3 510 bool BadReg(RegisterID reg)510 static bool BadReg(RegisterID reg) 511 511 { 512 512 return (reg == ARMRegisters::sp) || (reg == ARMRegisters::pc); … … 1262 1262 m_formatter.twoWordOp5i6Imm4Reg4EncodedImm(OP_MOV_imm_T3, imm.m_value.imm4, rd, imm); 1263 1263 } 1264 1265 static void revertJumpTo_movT3(void* instructionStart, RegisterID rd, ARMThumbImmediate imm) 1266 { 1267 ASSERT(imm.isValid()); 1268 ASSERT(!imm.isEncodedImm()); 1269 ASSERT(!BadReg(rd)); 1270 1271 uint16_t* address = static_cast<uint16_t*>(instructionStart); 1272 address[0] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, imm); 1273 address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(rd, imm); 1274 cacheFlush(address, sizeof(uint16_t) * 2); 1275 } 1264 1276 1265 1277 ALWAYS_INLINE void mov(RegisterID rd, ARMThumbImmediate imm) -
trunk/Source/JavaScriptCore/assembler/LinkBuffer.h
r129272 r135330 289 289 290 290 #define FINALIZE_DFG_CODE(linkBufferReference, dataLogArgumentsForHeading) \ 291 FINALIZE_CODE_IF( Options::showDFGDisassembly(), linkBufferReference, dataLogArgumentsForHeading)291 FINALIZE_CODE_IF((Options::showDisassembly() || Options::showDFGDisassembly()), linkBufferReference, dataLogArgumentsForHeading) 292 292 293 293 } // namespace JSC -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
r134358 r135330 1762 1762 static bool canJumpReplacePatchableBranchPtrWithPatch() { return false; } 1763 1763 1764 static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr) 1764 static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) 1765 { 1766 const unsigned twoWordOpSize = 4; 1767 return label.labelAtOffset(-twoWordOpSize * 2); 1768 } 1769 1770 static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue) 1771 { 1772 ARMv7Assembler::revertJumpTo_movT3(instructionStart.dataLocation(), dataTempRegister, ARMThumbImmediate::makeUInt16(reinterpret_cast<uintptr_t>(initialValue) & 0xffff)); 1773 } 1774 1775 static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr) 1765 1776 { 1766 1777 UNREACHABLE_FOR_PLATFORM(); -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h
r134332 r135330 256 256 static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; } 257 257 258 static CodeLocationLabel startOfPatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label) 258 static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) 259 { 260 const int opcodeBytes = 1; 261 const int modRMBytes = 1; 262 const int immediateBytes = 4; 263 const int totalBytes = opcodeBytes + modRMBytes + immediateBytes; 264 ASSERT(totalBytes >= maxJumpReplacementSize()); 265 return label.labelAtOffset(-totalBytes); 266 } 267 268 static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label) 259 269 { 260 270 const int opcodeBytes = 1; … … 267 277 } 268 278 279 static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID reg, void* initialValue) 280 { 281 X86Assembler::revertJumpTo_cmpl_ir_force32(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), reg); 282 } 283 269 284 static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address address, void* initialValue) 270 285 { -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
r134332 r135330 588 588 static bool canJumpReplacePatchableBranchPtrWithPatch() { return true; } 589 589 590 static CodeLocationLabel startOf PatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)590 static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) 591 591 { 592 592 const int rexBytes = 1; … … 598 598 } 599 599 600 static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label) 601 { 602 return startOfBranchPtrWithPatchOnRegister(label); 603 } 604 600 605 static void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, Address, void* initialValue) 606 { 607 X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister); 608 } 609 610 static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue) 601 611 { 602 612 X86Assembler::revertJumpTo_movq_i64r(instructionStart.executableAddress(), reinterpret_cast<intptr_t>(initialValue), scratchRegister); -
trunk/Source/JavaScriptCore/assembler/RepatchBuffer.h
r134332 r135330 142 142 } 143 143 144 static CodeLocationLabel startOf PatchableBranchPtrWithPatch(CodeLocationDataLabelPtr label)144 static CodeLocationLabel startOfBranchPtrWithPatchOnRegister(CodeLocationDataLabelPtr label) 145 145 { 146 return MacroAssembler::startOfPatchableBranchPtrWithPatch(label); 146 return MacroAssembler::startOfBranchPtrWithPatchOnRegister(label); 147 } 148 149 static CodeLocationLabel startOfPatchableBranchPtrWithPatchOnAddress(CodeLocationDataLabelPtr label) 150 { 151 return MacroAssembler::startOfPatchableBranchPtrWithPatchOnAddress(label); 147 152 } 148 153 … … 155 160 // immediate after calling this. But I'm fine with that, since this just feels 156 161 // less yucky. 162 void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::RegisterID reg, void* value) 163 { 164 MacroAssembler::revertJumpReplacementToBranchPtrWithPatch(instructionStart, reg, value); 165 } 166 157 167 void revertJumpReplacementToPatchableBranchPtrWithPatch(CodeLocationLabel instructionStart, MacroAssembler::Address address, void* value) 158 168 { -
trunk/Source/JavaScriptCore/assembler/X86Assembler.h
r134332 r135330 1904 1904 #endif 1905 1905 1906 static void revertJumpTo_cmpl_ir_force32(void* instructionStart, int32_t imm, RegisterID dst) 1907 { 1908 const int opcodeBytes = 1; 1909 const int modRMBytes = 1; 1910 ASSERT(opcodeBytes + modRMBytes <= maxJumpReplacementSize()); 1911 uint8_t* ptr = reinterpret_cast<uint8_t*>(instructionStart); 1912 ptr[0] = OP_GROUP1_EvIz; 1913 ptr[1] = (X86InstructionFormatter::ModRmRegister << 6) | (GROUP1_OP_CMP << 3) | dst; 1914 union { 1915 uint32_t asWord; 1916 uint8_t asBytes[4]; 1917 } u; 1918 u.asWord = imm; 1919 for (unsigned i = opcodeBytes + modRMBytes; i < static_cast<unsigned>(maxJumpReplacementSize()); ++i) 1920 ptr[i] = u.asBytes[i - opcodeBytes - modRMBytes]; 1921 } 1922 1906 1923 static void revertJumpTo_cmpl_im_force32(void* instructionStart, int32_t imm, int offset, RegisterID dst) 1907 1924 { -
trunk/Source/JavaScriptCore/dfg/DFGRepatch.cpp
r134332 r135330 119 119 if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) { 120 120 repatchBuffer.replaceWithJump( 121 RepatchBuffer::startOfPatchableBranchPtrWithPatch (121 RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress( 122 122 stubInfo.callReturnLocation.dataLabelPtrAtOffset( 123 123 -(intptr_t)stubInfo.patch.dfg.deltaCheckImmToCall)), … … 1143 1143 if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) { 1144 1144 repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch( 1145 RepatchBuffer::startOfPatchableBranchPtrWithPatch (structureLabel),1145 RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel), 1146 1146 MacroAssembler::Address( 1147 1147 static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR), … … 1177 1177 if (MacroAssembler::canJumpReplacePatchableBranchPtrWithPatch()) { 1178 1178 repatchBuffer.revertJumpReplacementToPatchableBranchPtrWithPatch( 1179 RepatchBuffer::startOfPatchableBranchPtrWithPatch (structureLabel),1179 RepatchBuffer::startOfPatchableBranchPtrWithPatchOnAddress(structureLabel), 1180 1180 MacroAssembler::Address( 1181 1181 static_cast<MacroAssembler::RegisterID>(stubInfo.patch.dfg.baseGPR),
Note:
See TracChangeset
for help on using the changeset viewer.