/// <summary> /// 预备存档,保存时必须先调用此方法 /// </summary> /// <returns>不要保存到稳定储存器上的内容的打包</returns> public PreviewSaveDataStoringPackage PreviewSave() { // 处理主调用堆栈上的栈帧 PreviewSaveDataStoringPackage savePak = new PreviewSaveDataStoringPackage { saveTraceBackStack = new Stack <StackMachineFrame>() }; // 弹空所有的函数调用和等待,只保存稳定性场景 while (this.CallStack.ESP != this.CallStack.SAVEP) { savePak.saveTraceBackStack.Push(this.CallStack.Consume()); } // 缓存指令指针,这里必须直接设null而不能用mircoStep避免IR寄存器被修改 savePak.CacheIP = this.CallStack.ESP.IP; this.CallStack.ESP.IP = null; // 处理并行句柄引用 savePak.ParallelHandlerStore = this.ParallelHandler; this.ParallelHandler = null; // 处理并行器向量的引用 savePak.ParallelExecutorStore = this.ParallelExecutorStack; this.ParallelExecutorStack = null; // 返回封装包 return(savePak); }
/// <summary> /// 完成存档,保存后必须调用此方法 /// </summary> /// <param name="savePack">调用PreviewSave时的返回值</param> public void FinishedSave(PreviewSaveDataStoringPackage savePack) { // 恢复指令指针 this.CallStack.ESP.MircoStep(savePack.CacheIP); // 恢复主调用堆栈上的栈帧 while (savePack.saveTraceBackStack.Count > 0) { this.CallStack.Submit(savePack.saveTraceBackStack.Pop()); } // 恢复并行句柄引用 this.ParallelHandler = savePack.ParallelHandlerStore; // 恢复并行器向量的引用 this.ParallelExecutorStack = savePack.ParallelExecutorStore; }