Changeset 120244 in webkit for trunk/Source/JavaScriptCore/ChangeLog
- Timestamp:
- Jun 13, 2012, 1:53:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r120175 r120244 1 2012-06-13 Filip Pizlo <[email protected]> 2 3 DFG should be able to set watchpoints on global variables 4 https://bugs.webkit.org/show_bug.cgi?id=88692 5 6 Reviewed by Geoffrey Garen. 7 8 Rolling back in after fixing Windows build issues, and implementing 9 branchTest8 for the Qt port's strange assemblers. 10 11 This implements global variable constant folding by allowing the optimizing 12 compiler to set a "watchpoint" on globals that it wishes to constant fold. 13 If the watchpoint fires, then an OSR exit is forced by overwriting the 14 machine code that the optimizing compiler generated with a jump. 15 16 As such, this patch is adding quite a bit of stuff: 17 18 - Jump replacement on those hardware targets supported by the optimizing 19 JIT. It is now possible to patch in a jump instruction over any recorded 20 watchpoint label. The jump must be "local" in the sense that it must be 21 within the range of the largest jump distance supported by a one 22 instruction jump. 23 24 - WatchpointSets and Watchpoints. A Watchpoint is a doubly-linked list node 25 that records the location where a jump must be inserted and the 26 destination to which it should jump. Watchpoints can be added to a 27 WatchpointSet. The WatchpointSet can be fired all at once, which plants 28 all jumps. WatchpointSet also remembers if it had ever been invalidated, 29 which allows for monotonicity: we typically don't want to optimize using 30 watchpoints on something for which watchpoints had previously fired. The 31 act of notifying a WatchpointSet has a trivial fast path in case no 32 Watchpoints are registered (one-byte load+branch). 33 34 - SpeculativeJIT::speculationWatchpoint(). It's like speculationCheck(), 35 except that you don't have to emit branches. But, you need to know what 36 WatchpointSet to add the resulting Watchpoint to. Not everything that 37 you could write a speculationCheck() for will have a WatchpointSet that 38 would get notified if the condition you were speculating against became 39 invalid. 40 41 - SymbolTableEntry now has the ability to refer to a WatchpointSet. It can 42 do so without incurring any space overhead for those entries that don't 43 have WatchpointSets. 44 45 - The bytecode generator infers all global function variables to be 46 watchable, and makes all stores perform the WatchpointSet's write check, 47 and marks all loads as being potentially watchable (i.e. you can compile 48 them to a watchpoint and a constant). 49 50 Put together, this allows for fully sleazy inlining of calls to globally 51 declared functions. The inline prologue will no longer contain the load of 52 the function, or any checks of the function you're calling. I.e. it's 53 pretty much like the kind of inlining you would see in Java or C++. 54 Furthermore, the watchpointing functionality is built to be fairly general, 55 and should allow setting watchpoints on all sorts of interesting things 56 in the future. 57 58 The sleazy inlining means that we will now sometimes inline in code paths 59 that have never executed. Previously, to inline we would have either had 60 to have executed the call (to read the call's inline cache) or have 61 executed the method check (to read the method check's inline cache). Now, 62 we might inline when the callee is a watched global variable. This 63 revealed some humorous bugs. First, constant folding disagreed with CFA 64 over what kinds of operations can clobber (example: code path A is dead 65 but stores a String into variable X, all other code paths store 0 into 66 X, and then you do CompareEq(X, 0) - CFA will say that this is a non- 67 clobbering constant, but constant folding thought it was clobbering 68 because it saw the String prediction). Second, inlining would crash if 69 the inline callee had not been compiled. This patch fixes both bugs, 70 since otherwise run-javascriptcore-tests would report regressions. 71 72 * CMakeLists.txt: 73 * GNUmakefile.list.am: 74 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 75 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 76 * JavaScriptCore.xcodeproj/project.pbxproj: 77 * Target.pri: 78 * assembler/ARMv7Assembler.h: 79 (ARMv7Assembler): 80 (JSC::ARMv7Assembler::ARMv7Assembler): 81 (JSC::ARMv7Assembler::labelForWatchpoint): 82 (JSC::ARMv7Assembler::label): 83 (JSC::ARMv7Assembler::replaceWithJump): 84 (JSC::ARMv7Assembler::maxJumpReplacementSize): 85 * assembler/AbstractMacroAssembler.h: 86 (JSC): 87 (AbstractMacroAssembler): 88 (Label): 89 (JSC::AbstractMacroAssembler::watchpointLabel): 90 (JSC::AbstractMacroAssembler::readPointer): 91 * assembler/AssemblerBuffer.h: 92 * assembler/MacroAssemblerARM.h: 93 (JSC::MacroAssemblerARM::branchTest8): 94 (MacroAssemblerARM): 95 (JSC::MacroAssemblerARM::replaceWithJump): 96 (JSC::MacroAssemblerARM::maxJumpReplacementSize): 97 * assembler/MacroAssemblerARMv7.h: 98 (JSC::MacroAssemblerARMv7::load8Signed): 99 (JSC::MacroAssemblerARMv7::load16Signed): 100 (MacroAssemblerARMv7): 101 (JSC::MacroAssemblerARMv7::replaceWithJump): 102 (JSC::MacroAssemblerARMv7::maxJumpReplacementSize): 103 (JSC::MacroAssemblerARMv7::branchTest8): 104 (JSC::MacroAssemblerARMv7::jump): 105 (JSC::MacroAssemblerARMv7::makeBranch): 106 * assembler/MacroAssemblerMIPS.h: 107 (JSC::MacroAssemblerMIPS::branchTest8): 108 (MacroAssemblerMIPS): 109 (JSC::MacroAssemblerMIPS::replaceWithJump): 110 (JSC::MacroAssemblerMIPS::maxJumpReplacementSize): 111 * assembler/MacroAssemblerSH4.h: 112 (JSC::MacroAssemblerSH4::branchTest8): 113 (MacroAssemblerSH4): 114 (JSC::MacroAssemblerSH4::replaceWithJump): 115 (JSC::MacroAssemblerSH4::maxJumpReplacementSize): 116 * assembler/MacroAssemblerX86.h: 117 (MacroAssemblerX86): 118 (JSC::MacroAssemblerX86::branchTest8): 119 * assembler/MacroAssemblerX86Common.h: 120 (JSC::MacroAssemblerX86Common::replaceWithJump): 121 (MacroAssemblerX86Common): 122 (JSC::MacroAssemblerX86Common::maxJumpReplacementSize): 123 * assembler/MacroAssemblerX86_64.h: 124 (MacroAssemblerX86_64): 125 (JSC::MacroAssemblerX86_64::branchTest8): 126 * assembler/X86Assembler.h: 127 (JSC::X86Assembler::X86Assembler): 128 (X86Assembler): 129 (JSC::X86Assembler::cmpb_im): 130 (JSC::X86Assembler::testb_im): 131 (JSC::X86Assembler::labelForWatchpoint): 132 (JSC::X86Assembler::label): 133 (JSC::X86Assembler::replaceWithJump): 134 (JSC::X86Assembler::maxJumpReplacementSize): 135 (JSC::X86Assembler::X86InstructionFormatter::memoryModRM): 136 * bytecode/CodeBlock.cpp: 137 (JSC): 138 (JSC::CodeBlock::printGetByIdCacheStatus): 139 (JSC::CodeBlock::dump): 140 * bytecode/CodeBlock.h: 141 (JSC::CodeBlock::appendOSRExit): 142 (JSC::CodeBlock::appendSpeculationRecovery): 143 (CodeBlock): 144 (JSC::CodeBlock::appendWatchpoint): 145 (JSC::CodeBlock::numberOfWatchpoints): 146 (JSC::CodeBlock::watchpoint): 147 (DFGData): 148 * bytecode/DFGExitProfile.h: 149 (JSC::DFG::exitKindToString): 150 (JSC::DFG::exitKindIsCountable): 151 * bytecode/GetByIdStatus.cpp: 152 (JSC::GetByIdStatus::computeForChain): 153 * bytecode/Instruction.h: 154 (Instruction): 155 (JSC::Instruction::Instruction): 156 * bytecode/Opcode.h: 157 (JSC): 158 (JSC::padOpcodeName): 159 * bytecode/Watchpoint.cpp: Added. 160 (JSC): 161 (JSC::Watchpoint::~Watchpoint): 162 (JSC::Watchpoint::correctLabels): 163 (JSC::Watchpoint::fire): 164 (JSC::WatchpointSet::WatchpointSet): 165 (JSC::WatchpointSet::~WatchpointSet): 166 (JSC::WatchpointSet::add): 167 (JSC::WatchpointSet::notifyWriteSlow): 168 (JSC::WatchpointSet::fireAllWatchpoints): 169 * bytecode/Watchpoint.h: Added. 170 (JSC): 171 (Watchpoint): 172 (JSC::Watchpoint::Watchpoint): 173 (JSC::Watchpoint::setDestination): 174 (WatchpointSet): 175 (JSC::WatchpointSet::isStillValid): 176 (JSC::WatchpointSet::hasBeenInvalidated): 177 (JSC::WatchpointSet::startWatching): 178 (JSC::WatchpointSet::notifyWrite): 179 (JSC::WatchpointSet::addressOfIsWatched): 180 * bytecompiler/BytecodeGenerator.cpp: 181 (JSC::ResolveResult::checkValidity): 182 (JSC::BytecodeGenerator::addGlobalVar): 183 (JSC::BytecodeGenerator::BytecodeGenerator): 184 (JSC::BytecodeGenerator::resolve): 185 (JSC::BytecodeGenerator::emitResolve): 186 (JSC::BytecodeGenerator::emitResolveWithBase): 187 (JSC::BytecodeGenerator::emitResolveWithThis): 188 (JSC::BytecodeGenerator::emitGetStaticVar): 189 (JSC::BytecodeGenerator::emitPutStaticVar): 190 * bytecompiler/BytecodeGenerator.h: 191 (BytecodeGenerator): 192 * bytecompiler/NodesCodegen.cpp: 193 (JSC::FunctionCallResolveNode::emitBytecode): 194 (JSC::PostfixResolveNode::emitBytecode): 195 (JSC::PrefixResolveNode::emitBytecode): 196 (JSC::ReadModifyResolveNode::emitBytecode): 197 (JSC::AssignResolveNode::emitBytecode): 198 (JSC::ConstDeclNode::emitCodeSingle): 199 * dfg/DFGAbstractState.cpp: 200 (JSC::DFG::AbstractState::execute): 201 (JSC::DFG::AbstractState::clobberStructures): 202 * dfg/DFGAbstractState.h: 203 (AbstractState): 204 (JSC::DFG::AbstractState::didClobber): 205 * dfg/DFGByteCodeParser.cpp: 206 (JSC::DFG::ByteCodeParser::handleInlining): 207 (JSC::DFG::ByteCodeParser::parseBlock): 208 * dfg/DFGCCallHelpers.h: 209 (CCallHelpers): 210 (JSC::DFG::CCallHelpers::setupArguments): 211 * dfg/DFGCSEPhase.cpp: 212 (JSC::DFG::CSEPhase::globalVarWatchpointElimination): 213 (CSEPhase): 214 (JSC::DFG::CSEPhase::globalVarStoreElimination): 215 (JSC::DFG::CSEPhase::performNodeCSE): 216 * dfg/DFGCapabilities.h: 217 (JSC::DFG::canCompileOpcode): 218 * dfg/DFGConstantFoldingPhase.cpp: 219 (JSC::DFG::ConstantFoldingPhase::run): 220 * dfg/DFGCorrectableJumpPoint.h: 221 (JSC::DFG::CorrectableJumpPoint::isSet): 222 (CorrectableJumpPoint): 223 * dfg/DFGJITCompiler.cpp: 224 (JSC::DFG::JITCompiler::linkOSRExits): 225 (JSC::DFG::JITCompiler::link): 226 * dfg/DFGNode.h: 227 (JSC::DFG::Node::hasIdentifierNumberForCheck): 228 (Node): 229 (JSC::DFG::Node::identifierNumberForCheck): 230 (JSC::DFG::Node::hasRegisterPointer): 231 * dfg/DFGNodeType.h: 232 (DFG): 233 * dfg/DFGOSRExit.cpp: 234 (JSC::DFG::OSRExit::OSRExit): 235 * dfg/DFGOSRExit.h: 236 (OSRExit): 237 * dfg/DFGOperations.cpp: 238 * dfg/DFGOperations.h: 239 * dfg/DFGPredictionPropagationPhase.cpp: 240 (JSC::DFG::PredictionPropagationPhase::propagate): 241 * dfg/DFGSpeculativeJIT.h: 242 (JSC::DFG::SpeculativeJIT::callOperation): 243 (JSC::DFG::SpeculativeJIT::appendCall): 244 (SpeculativeJIT): 245 (JSC::DFG::SpeculativeJIT::speculationWatchpoint): 246 * dfg/DFGSpeculativeJIT32_64.cpp: 247 (JSC::DFG::SpeculativeJIT::compile): 248 * dfg/DFGSpeculativeJIT64.cpp: 249 (JSC::DFG::SpeculativeJIT::compile): 250 * interpreter/Interpreter.cpp: 251 (JSC::Interpreter::privateExecute): 252 * jit/JIT.cpp: 253 (JSC::JIT::privateCompileMainPass): 254 (JSC::JIT::privateCompileSlowCases): 255 * jit/JIT.h: 256 * jit/JITPropertyAccess.cpp: 257 (JSC::JIT::emit_op_put_global_var_check): 258 (JSC): 259 (JSC::JIT::emitSlow_op_put_global_var_check): 260 * jit/JITPropertyAccess32_64.cpp: 261 (JSC::JIT::emit_op_put_global_var_check): 262 (JSC): 263 (JSC::JIT::emitSlow_op_put_global_var_check): 264 * jit/JITStubs.cpp: 265 (JSC::DEFINE_STUB_FUNCTION): 266 (JSC): 267 * jit/JITStubs.h: 268 * llint/LLIntSlowPaths.cpp: 269 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 270 (LLInt): 271 * llint/LLIntSlowPaths.h: 272 (LLInt): 273 * llint/LowLevelInterpreter32_64.asm: 274 * llint/LowLevelInterpreter64.asm: 275 * runtime/JSObject.cpp: 276 (JSC::JSObject::removeDirect): 277 * runtime/JSObject.h: 278 (JSObject): 279 * runtime/JSSymbolTableObject.h: 280 (JSC::symbolTableGet): 281 (JSC::symbolTablePut): 282 (JSC::symbolTablePutWithAttributes): 283 * runtime/SymbolTable.cpp: Added. 284 (JSC): 285 (JSC::SymbolTableEntry::copySlow): 286 (JSC::SymbolTableEntry::freeFatEntrySlow): 287 (JSC::SymbolTableEntry::couldBeWatched): 288 (JSC::SymbolTableEntry::attemptToWatch): 289 (JSC::SymbolTableEntry::addressOfIsWatched): 290 (JSC::SymbolTableEntry::addWatchpoint): 291 (JSC::SymbolTableEntry::notifyWriteSlow): 292 (JSC::SymbolTableEntry::inflateSlow): 293 * runtime/SymbolTable.h: 294 (JSC): 295 (SymbolTableEntry): 296 (Fast): 297 (JSC::SymbolTableEntry::Fast::Fast): 298 (JSC::SymbolTableEntry::Fast::isNull): 299 (JSC::SymbolTableEntry::Fast::getIndex): 300 (JSC::SymbolTableEntry::Fast::isReadOnly): 301 (JSC::SymbolTableEntry::Fast::getAttributes): 302 (JSC::SymbolTableEntry::Fast::isFat): 303 (JSC::SymbolTableEntry::SymbolTableEntry): 304 (JSC::SymbolTableEntry::~SymbolTableEntry): 305 (JSC::SymbolTableEntry::operator=): 306 (JSC::SymbolTableEntry::isNull): 307 (JSC::SymbolTableEntry::getIndex): 308 (JSC::SymbolTableEntry::getFast): 309 (JSC::SymbolTableEntry::getAttributes): 310 (JSC::SymbolTableEntry::isReadOnly): 311 (JSC::SymbolTableEntry::watchpointSet): 312 (JSC::SymbolTableEntry::notifyWrite): 313 (FatEntry): 314 (JSC::SymbolTableEntry::FatEntry::FatEntry): 315 (JSC::SymbolTableEntry::isFat): 316 (JSC::SymbolTableEntry::fatEntry): 317 (JSC::SymbolTableEntry::inflate): 318 (JSC::SymbolTableEntry::bits): 319 (JSC::SymbolTableEntry::freeFatEntry): 320 (JSC::SymbolTableEntry::pack): 321 (JSC::SymbolTableEntry::isValidIndex): 322 1 323 2012-06-13 Sheriff Bot <[email protected]> 2 324
Note:
See TracChangeset
for help on using the changeset viewer.