Example #1
0
void BlockCache::MarkModified(BlockCacheBlock* block)
{
	ScopedLock lock(&bcache_mutex);
	UnlinkBlock(block);
	LinkBlock(block);
	block->information |= BCACHE_MODIFIED;
}
void JitBlockCache::FinalizeBlock(int block_num, bool block_link) {
    JitBlock &b = blocks_[block_num];

    b.originalFirstOpcode = Memory::Read_Opcode_JIT(b.originalAddress);
    MIPSOpcode opcode = GetEmuHackOpForBlock(block_num);
    Memory::Write_Opcode_JIT(b.originalAddress, opcode);

    AddBlockMap(block_num);

    u32 latestExit = 0;
    if (block_link) {
        for (int i = 0; i < MAX_JIT_BLOCK_EXITS; i++) {
            if (b.exitAddress[i] != INVALID_EXIT) {
                links_to_.insert(std::make_pair(b.exitAddress[i], block_num));
                latestExit = std::max(latestExit, b.exitAddress[i]);
            }
        }

        LinkBlock(block_num);
        LinkBlockExits(block_num);
    }

    if (Memory::IsScratchpadAddress(b.originalAddress)) {
        ExpandRange(blockMemRanges_[JITBLOCK_RANGE_SCRATCH], b.originalAddress, latestExit);
    }
    const u32 halfUserMemory = (PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase()) / 2;
    if (b.originalAddress < PSP_GetUserMemoryBase() + halfUserMemory) {
        ExpandRange(blockMemRanges_[JITBLOCK_RANGE_RAMBOTTOM], b.originalAddress, latestExit);
    }
    if (latestExit > PSP_GetUserMemoryBase() + halfUserMemory) {
        ExpandRange(blockMemRanges_[JITBLOCK_RANGE_RAMTOP], b.originalAddress, latestExit);
    }

#if defined USE_OPROFILE && USE_OPROFILE
    char buf[100];
    sprintf(buf, "EmuCode%x", b.originalAddress);
    const u8* blockStart = blocks_[block_num].checkedEntry;
    op_write_native_code(agent, buf, (uint64_t)blockStart, blockStart, b.normalEntry + b.codeSize - b.checkedEntry);
#endif

#ifdef USE_VTUNE
    sprintf(b.blockName, "EmuCode_0x%08x", b.originalAddress);

    iJIT_Method_Load jmethod = {0};
    jmethod.method_id = iJIT_GetNewMethodID();
    jmethod.class_file_name = "";
    jmethod.source_file_name = __FILE__;
    jmethod.method_load_address = (void*)blocks_[block_num].checkedEntry;
    jmethod.method_size = b.normalEntry + b.codeSize - b.checkedEntry;
    jmethod.line_number_size = 0;
    jmethod.method_name = b.blockName;
    iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod);
#endif
}
Example #3
0
BlockCacheBlock* BlockCache::AcquireBlock()
{
	ScopedLock lock(&bcache_mutex);
	if ( !unused_block && !AddArea() )
		return NULL;
	BlockCacheBlock* ret = unused_block;
	assert(ret);
	unused_block_count--;
	unused_block = unused_block->next_block;
	ret->prev_block = ret->next_block = NULL;
	if ( unused_block )
		unused_block->prev_block = NULL;
	ret->information |= BCACHE_USED;
	LinkBlock(ret);
	blocks_used++;
	return ret;
}
Example #4
0
void BlockCache::MarkUsed(BlockCacheBlock* block)
{
	ScopedLock lock(&bcache_mutex);
	UnlinkBlock(block);
	LinkBlock(block);
}