jpcsp源码解读11:近期笔记

最近阅读代码主要牵涉到两个问题,一个是动态二进制翻译,一个是进程管理。

两个问题都很棘手,代码量大,复杂度高。今天主要备份一下关键笔记。

/
启动运行流程:
用户点击 运行 按钮
RunButtonActionPerformed
RunEmu
emulator.RunEmu()
mainThread.start()
start就是调用该线程的run方法
Emulator.run()
如果使能动态二进制翻译
RuntimeContext.run()
-->getExecutable(processor.cpu.pc)
-->Compiler.getInstance().compile(address)
-->compile(address, getResetCount())
-->executable = analyse(context, address, false, instanceIndex)
-->context.analysedAddresses.add(pc)
  codeBlock.addInstruction(pc, opcode, insn, isBranchTarget, isBranching, branchingTo)
  executable = codeBlock.getExecutable(context)
-->compile(context)
-->prepare(context, context.getMethodMaxInstructions())
  compile(context, mv, codeInstructions)
  compile(context, mv, sequenceCodeInstruction.getCodeSequence().getInstructions())
否则,不使能动态二进制翻译,就单步执行
processor.step()
/


进程调度与进程切换:
ThreadManForUser.java(Initialise创建了第一个进程)
hleRescheduleCurrentThread
contextSwitch                   *************************关键函数,关于callback此处还有疑问**********************
internalContextSwitch
这个函数调用过程完成了操作系统层面的进程调度和上下文切换,在系统层的进程管理器中记录了新的运行态进程,并且根据该进程的描


述符更新了processor
internalContextSwitch最后调用了RuntimeContext.update
RuntimeContext.update
则是更新运行时上下文,将运行上下文切换到新进程。函数调用过程:
RuntimeContext.update
switchThread
switchRealThread
{
thread = new RuntimeThread(threadInfo)
thread.start()
-->thread.run()
-->RuntimeContext.runThread(this)
-->getExecutable(processor.cpu.pc)
-->executable = Compiler.getInstance().compile(address)


如果目标进程尚未创建运行时上下文,就在此时创建(也就是动态编译出可执行程序)
}

restoreContext中也调用了update操作,似乎与前述内容有重复


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值