void computePreciseJumpTargetsInternal(Block* codeBlock, Instruction* instructionsBegin, unsigned instructionCount, Vector<unsigned, vectorSize>& out) { ASSERT(out.isEmpty()); // The code block has a superset of the jump targets. So if it claims to have none, we are done. if (Mode == ComputePreciseJumpTargetsMode::FollowCodeBlockClaim && !codeBlock->numberOfJumpTargets()) return; for (unsigned i = codeBlock->numberOfExceptionHandlers(); i--;) { out.append(codeBlock->exceptionHandler(i).target); out.append(codeBlock->exceptionHandler(i).start); out.append(codeBlock->exceptionHandler(i).end); } for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) { OpcodeID opcodeID = Interpreter::getOpcodeID(instructionsBegin[bytecodeOffset]); getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out); bytecodeOffset += opcodeLengths[opcodeID]; } std::sort(out.begin(), out.end()); // We will have duplicates, and we must remove them. unsigned toIndex = 0; unsigned fromIndex = 0; unsigned lastValue = UINT_MAX; while (fromIndex < out.size()) { unsigned value = out[fromIndex++]; if (value == lastValue) continue; out[toIndex++] = value; lastValue = value; } out.shrinkCapacity(toIndex); }
void computePreciseJumpTargets(CodeBlock* codeBlock, Vector<unsigned, 32>& out) { ASSERT(out.isEmpty()); // We will derive a superset of the jump targets that the code block thinks it has. // So, if the code block claims there are none, then we are done. if (!codeBlock->numberOfJumpTargets()) return; for (unsigned i = codeBlock->numberOfExceptionHandlers(); i--;) out.append(codeBlock->exceptionHandler(i).target); Interpreter* interpreter = codeBlock->vm()->interpreter; Instruction* instructionsBegin = codeBlock->instructions().begin(); unsigned instructionCount = codeBlock->instructions().size(); for (unsigned bytecodeOffset = 0; bytecodeOffset < instructionCount;) { OpcodeID opcodeID = interpreter->getOpcodeID(instructionsBegin[bytecodeOffset].u.opcode); getJumpTargetsForBytecodeOffset(codeBlock, interpreter, instructionsBegin, bytecodeOffset, out); bytecodeOffset += opcodeLengths[opcodeID]; } std::sort(out.begin(), out.end()); // We will have duplicates, and we must remove them. unsigned toIndex = 0; unsigned fromIndex = 0; unsigned lastValue = UINT_MAX; while (fromIndex < out.size()) { unsigned value = out[fromIndex++]; if (value == lastValue) continue; out[toIndex++] = value; lastValue = value; } out.resize(toIndex); }
void findJumpTargetsForBytecodeOffset(UnlinkedCodeBlock* codeBlock, UnlinkedInstruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out) { getJumpTargetsForBytecodeOffset(codeBlock, codeBlock->vm()->interpreter, instructionsBegin, bytecodeOffset, out); }
void findJumpTargetsForBytecodeOffset(CodeBlock* codeBlock, unsigned bytecodeOffset, Vector<unsigned, 1>& out) { Interpreter* interpreter = codeBlock->vm()->interpreter; Instruction* instructionsBegin = codeBlock->instructions().begin(); getJumpTargetsForBytecodeOffset(codeBlock, interpreter, instructionsBegin, bytecodeOffset, out); }
void findJumpTargetsForBytecodeOffset(CodeBlock* codeBlock, Instruction* instructionsBegin, unsigned bytecodeOffset, Vector<unsigned, 1>& out) { getJumpTargetsForBytecodeOffset(codeBlock, instructionsBegin, bytecodeOffset, out); }