private BuildResult DoCompilation(string arguments) { string l; ProcessStartInfo si = new ProcessStartInfo(ncc, arguments); si.RedirectStandardOutput = true; si.RedirectStandardError = true; si.UseShellExecute = false; VProcess p = new VProcess(); p.StartInfo = si; p.Start(); p.OutWatch(); while ((!p.HasExited) && p.HasNoOut()) // while ((!p.HasExited) && (p.StandardOutput.Peek() == -1)) // this could eliminate VProcess outgrowth { System.Threading.Thread.Sleep(100); } CompilerResultsParser cr = new CompilerResultsParser(); while ((l = p.StandardOutput.ReadLine()) != null) { cr.Parse(l); } if ((l = p.StandardError.ReadLine()) != null) { cr.Parse("error: " + ncc + " execution problem"); } return(cr.GetResult()); }
public static void ExecTest() { int count = 11; using (VProcess proc = new VProcess()) { uint stackPtr = 0x500000 + 0x10000 / 2; if (VConsts.Addressing == AddressingMode.Paging) { proc.Memory.AllocateMemory(0x8000000, 0x100000); proc.Memory.AllocateMemory(0x500000, 0x10000); } else { proc.Memory.AllocateContiguousMemory(0x500000, 0x8000000 + 0x100000 - 0x500000); } VCpuState state = new VCpuState(proc); uint ret = 0xffffffff; Stopwatch sw = new Stopwatch(); //sw.Start(); for (int i = 0; i < count; i++) { if (i == 1) { sw.Start(); } state.Esp = stackPtr; state.Esp -= 4; proc.Memory.Write(state.Esp, (uint)VCode.CallRetAddress._MagicReturn); VCode.Iam_The_IntelCPU_HaHaHa(state, (uint)VCode.FunctionTable.test_target1); if (state.ExceptionString != null) { throw new ApplicationException($"Error: {state.ExceptionString} at 0x{state.ExceptionAddress:x}."); } else { uint r = state.Eax; if (ret == 0xffffffff) { ret = r; Console.WriteLine($"ret = {state.Eax}"); } else if (ret == r) { } else { throw new ApplicationException("Error: Invalid result: " + r); } } } sw.Stop(); long result = sw.Elapsed.Ticks * 100 / (count - 1); Console.WriteLine($"time = {result:#,0}"); } }
private BuildResult DoCompilation(string arguments) { string l; ProcessStartInfo si = new ProcessStartInfo(ncc, arguments); si.RedirectStandardOutput = true; si.RedirectStandardError = true; si.UseShellExecute = false; VProcess p = new VProcess(); p.StartInfo = si; p.Start(); p.OutWatch(); while ((!p.HasExited) && p.HasNoOut()) // while ((!p.HasExited) && (p.StandardOutput.Peek() == -1)) // this could eliminate VProcess outgrowth { System.Threading.Thread.Sleep (100); } CompilerResultsParser cr = new CompilerResultsParser(); while ((l = p.StandardOutput.ReadLine()) != null) { cr.Parse(l); } if ((l = p.StandardError.ReadLine()) != null) { cr.Parse("error: " + ncc + " execution problem"); } return cr.GetResult(); }