|
| 1 | +2013-08-02 Mark Hahnenberg <mhahnenberg@apple.com> |
| 2 | + |
| 3 | + CodeBlocks should be able to determine bytecode liveness |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=118546 |
| 5 | + |
| 6 | + Reviewed by Filip Pizlo. |
| 7 | + |
| 8 | + This will simplify some things in the DFG related to OSR exits and determining |
| 9 | + which bytecode variables are live at which points during execution. It will |
| 10 | + also be useful for making our conservative GC scan more precise. Currently it |
| 11 | + doesn't properly account for liveness while the DFG is running, so it will be |
| 12 | + off by default behing a runtime Options flag. |
| 13 | + |
| 14 | + * JavaScriptCore.xcodeproj/project.pbxproj: |
| 15 | + * bytecode/BytecodeBasicBlock.cpp: Added. |
| 16 | + (JSC::isBranch): Used to determine the end of basic blocks. |
| 17 | + (JSC::isUnconditionalBranch): Used to determine when a branch at the end of a |
| 18 | + basic block can't possibly fall through to the next basic block in program order. |
| 19 | + (JSC::isTerminal): Also used to detect the end of a block. |
| 20 | + (JSC::isThrow): |
| 21 | + (JSC::isJumpTarget): Used to correctly separate basic blocks. Any jump destination |
| 22 | + must be the head of its own basic block. |
| 23 | + (JSC::linkBlocks): Links two blocks together in a bi-direcitonal fashion. |
| 24 | + (JSC::computeBytecodeBasicBlocks): Creates a set of basic blocks given a particular |
| 25 | + CodeBlock and links them together. |
| 26 | + * bytecode/BytecodeBasicBlock.h: Added. |
| 27 | + (JSC::BytecodeBasicBlock::isEntryBlock): Entry blocks are a special basic blocks |
| 28 | + that indicate the beginning of the function. |
| 29 | + (JSC::BytecodeBasicBlock::isExitBlock): Exit blocks are a special basic block that |
| 30 | + all blocks that exit the function have as a successor. Entry and exit blocks allows |
| 31 | + the various code paths to be more regular. |
| 32 | + (JSC::BytecodeBasicBlock::leaderBytecodeOffset): The leader bytecode offset is the |
| 33 | + bytecode offset of the first instruction in the block. |
| 34 | + (JSC::BytecodeBasicBlock::totalBytecodeLength): The total length of all the bytecodes |
| 35 | + in this block. |
| 36 | + (JSC::BytecodeBasicBlock::bytecodeOffsets): The bytecode offsets in this particular |
| 37 | + basic block. This Vector allows us to iterate over the bytecodes in reverse order |
| 38 | + which wouldn't be possible normally since they are of variable size. |
| 39 | + (JSC::BytecodeBasicBlock::addPredecessor): Links a block to a specified predecessor. |
| 40 | + Only creates one direction of the link. |
| 41 | + (JSC::BytecodeBasicBlock::addSuccessor): Same as addPredecessor, but for successors. |
| 42 | + (JSC::BytecodeBasicBlock::predecessors): Getter for predecessors. |
| 43 | + (JSC::BytecodeBasicBlock::successors): Getter for successors. |
| 44 | + (JSC::BytecodeBasicBlock::in): Getter for the liveness info at the head of the block. |
| 45 | + (JSC::BytecodeBasicBlock::out): Getter for the liveness info at the tail of the block. |
| 46 | + (JSC::BytecodeBasicBlock::BytecodeBasicBlock): |
| 47 | + (JSC::BytecodeBasicBlock::addBytecodeLength): When creating basic blocks we call |
| 48 | + this function when we want to add the next bytecode in program order to this block. |
| 49 | + * bytecode/BytecodeLivenessAnalysis.cpp: Added. |
| 50 | + (JSC::BytecodeLivenessAnalysis::BytecodeLivenessAnalysis): |
| 51 | + (JSC::numberOfCapturedVariables): Convenience wrapper. Returns the |
| 52 | + number of captured variables for a particular CodeBlock, or 0 if |
| 53 | + the CodeBlock has no SymbolTable. |
| 54 | + (JSC::captureStart): Ditto, but for captureStart(). |
| 55 | + (JSC::captureEnd): Ditto, but for captureEnd(). |
| 56 | + (JSC::isValidRegisterForLiveness): Returns true if the liveness analysis should |
| 57 | + track the liveness of a particular operand. We ignore constants, arguments, and |
| 58 | + captured variables. We ignore arguments because they're live for the duration of |
| 59 | + a function call. We ignore captured variables because we also treat them as live |
| 60 | + for the duration of the function. This could probably be improved to be more precise, |
| 61 | + but it didn't seem worth it for now. |
| 62 | + (JSC::setForOperand): Convenience wrapper that sets the bit in the provided bit |
| 63 | + vector for the provided operand. It handles skipping over captured variables. |
| 64 | + (JSC::computeUsesForBytecodeOffset): Computes which operands are used by a particular bytecode. |
| 65 | + (JSC::computeDefsForBytecodeOffset): Computes which operands are defined by a particular |
| 66 | + bytecode. Typically this is just the left-most operand. |
| 67 | + (JSC::findBasicBlockWithLeaderOffset): |
| 68 | + (JSC::findBasicBlockForBytecodeOffset): Scans over basic blocks to find the block |
| 69 | + which contains a particular bytecode offset. |
| 70 | + (JSC::computeLocalLivenessForBytecodeOffset): Computes block-local liveness from the |
| 71 | + bottom of the block until a specified bytecode offset is reached. |
| 72 | + (JSC::computeLocalLivenessForBlock): Computes liveness for the entire block and |
| 73 | + stores the resulting liveness at the head. |
| 74 | + (JSC::BytecodeLivenessAnalysis::runLivenessFixpoint): Runs backward flow liveness |
| 75 | + analysis to fixpoint. |
| 76 | + (JSC::BytecodeLivenessAnalysis::getLivenessInfoForNonCapturedVarsAtBytecodeOffset): |
| 77 | + Slow path to get liveness info for non-captured, non-argument variable. |
| 78 | + (JSC::BytecodeLivenessAnalysis::operandIsLiveAtBytecodeOffset): |
| 79 | + (JSC::BytecodeLivenessAnalysis::getLivenessInfoAtBytecodeOffset): Returns the liveness |
| 80 | + info for both captured and non-captured vars at a particular bytecode offset. |
| 81 | + (JSC::BytecodeLivenessAnalysis::dumpResults): Dumps the output of the liveness analysis. |
| 82 | + Controlled by new flag in Options.h/.cpp. |
| 83 | + (JSC::BytecodeLivenessAnalysis::compute): Creates bytecode basic blocks and runs |
| 84 | + full liveness analysis. |
| 85 | + * bytecode/BytecodeLivenessAnalysis.h: Added. |
| 86 | + (JSC::BytecodeLivenessAnalysis::hasBeenComputed): |
| 87 | + (JSC::BytecodeLivenessAnalysis::computeIfNecessary): |
| 88 | + * bytecode/CodeBlock.cpp: |
| 89 | + (JSC::CodeBlock::CodeBlock): |
| 90 | + * bytecode/CodeBlock.h: |
| 91 | + (JSC::CodeBlock::livenessAnalysis): |
| 92 | + * bytecode/PreciseJumpTargets.cpp: Refactored to be able to get the jump targets for |
| 93 | + a particular bytecode offset for use during bytecode basic block construction. |
| 94 | + (JSC::getJumpTargetsForBytecodeOffset): |
| 95 | + (JSC::computePreciseJumpTargets): |
| 96 | + (JSC::findJumpTargetsForBytecodeOffset): |
| 97 | + * bytecode/PreciseJumpTargets.h: |
| 98 | + * runtime/Options.cpp: |
| 99 | + (JSC::Options::initialize): |
| 100 | + * runtime/Options.h: |
| 101 | + |
1 | 102 | 2013-11-11 Andy Estes <aestes@apple.com> |
2 | 103 |
|
3 | 104 | [iOS] Define JSC_OBJC_API_ENABLED |
|
0 commit comments