void AlignedStream::Reset() { if (!_stream) { return; } FinalizeBlock(); }
void AlignedStream::Close() { if (!_stream) { return; } FinalizeBlock(); ProxyStream::Close(); }
// construct an invalid block (but with a valid header) const std::shared_ptr<const CBlock> BadBlock(const uint256& prev_hash) { auto pblock = Block(prev_hash); CMutableTransaction coinbase_spend; coinbase_spend.vin.push_back(CTxIn(COutPoint(pblock->vtx[0]->GetHash(), 0), CScript(), 0)); coinbase_spend.vout.push_back(pblock->vtx[0]->vout[0]); CTransactionRef tx = MakeTransactionRef(coinbase_spend); pblock->vtx.push_back(tx); auto ret = FinalizeBlock(pblock); return ret; }
void CachedInterpreter::Jit(u32 address) { if (m_code.size() >= CODE_SIZE / sizeof(Instruction) - 0x1000 || IsFull() || SConfig::GetInstance().bJITNoBlockCache) { ClearCache(); } u32 nextPC = analyzer.Analyze(PC, &code_block, &code_buffer, code_buffer.GetSize()); if (code_block.m_memory_exception) { // Address of instruction could not be translated NPC = nextPC; PowerPC::ppcState.Exceptions |= EXCEPTION_ISI; PowerPC::CheckExceptions(); WARN_LOG(POWERPC, "ISI exception at 0x%08x", nextPC); return; } int block_num = AllocateBlock(PC); JitBlock *b = GetBlock(block_num); js.blockStart = PC; js.firstFPInstructionFound = false; js.fifoBytesThisBlock = 0; js.downcountAmount = 0; js.curBlock = b; PPCAnalyst::CodeOp *ops = code_buffer.codebuffer; b->checkedEntry = GetCodePtr(); b->normalEntry = GetCodePtr(); b->runCount = 0; for (u32 i = 0; i < code_block.m_num_instructions; i++) { js.downcountAmount += ops[i].opinfo->numCycles; u32 function = HLE::GetFunctionIndex(ops[i].address); if (function != 0) { int type = HLE::GetFunctionTypeByIndex(function); if (type == HLE::HLE_HOOK_START || type == HLE::HLE_HOOK_REPLACE) { int flags = HLE::GetFunctionFlagsByIndex(function); if (HLE::IsEnabled(flags)) { m_code.emplace_back(WritePC, ops[i].address); m_code.emplace_back(Interpreter::HLEFunction, ops[i].inst); if (type == HLE::HLE_HOOK_REPLACE) { m_code.emplace_back(EndBlock, js.downcountAmount); m_code.emplace_back(); break; } } } } if (!ops[i].skip) { if ((ops[i].opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound) { m_code.emplace_back(CheckFPU, ops[i].address); js.firstFPInstructionFound = true; } if (ops[i].opinfo->flags & FL_ENDBLOCK) m_code.emplace_back(WritePC, ops[i].address); m_code.emplace_back(GetInterpreterOp(ops[i].inst), ops[i].inst); if (ops[i].opinfo->flags & FL_ENDBLOCK) m_code.emplace_back(EndBlock, js.downcountAmount); } } if (code_block.m_broken) { m_code.emplace_back(WritePC, nextPC); m_code.emplace_back(EndBlock, js.downcountAmount); } m_code.emplace_back(); b->codeSize = (u32)(GetCodePtr() - b->checkedEntry); b->originalSize = code_block.m_num_instructions; FinalizeBlock(block_num, jo.enableBlocklink, b->checkedEntry); }
// construct a valid block const std::shared_ptr<const CBlock> GoodBlock(const uint256& prev_hash) { return FinalizeBlock(Block(prev_hash)); }