Author: eliot Date: 2012-07-30 17:24:58 -0700 (Mon, 30 Jul 2012) New Revision: 2579
Modified: branches/Cog/cygwinbuild/HowToBuild branches/Cog/macbuild/HowToBuild branches/Cog/nsbuild/cygwinbuild/HowToBuild branches/Cog/nscogbuild/cygwinbuild/HowToBuild branches/Cog/platforms/Cross/vm/sqVirtualMachine.c branches/Cog/platforms/Mac OS/vm/sqMacMain.c branches/Cog/platforms/Mac OS/vm/sqMacUIEventsUniversal.c branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c branches/Cog/platforms/unix/vm/sqUnixMain.c branches/Cog/platforms/win32/vm/sqWin32Intel.c branches/Cog/platforms/win32/vm/sqWin32Window.c branches/Cog/stackbuild/cygwinbuild/HowToBuild branches/Cog/unixbuild/HowToBuild Log: Add a -timephases command-line switch to print start load and run times. Fix the bochs build instructions in HowToBuilds.
Modified: branches/Cog/cygwinbuild/HowToBuild =================================================================== --- branches/Cog/cygwinbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/cygwinbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -69,7 +69,7 @@ Then build the libraries winbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/winbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem and build the plugin either via make (for the entire VM) or just $ cd ROOT/cygwinbuild $ make build/vm/BochsIA32Plugin.dll
Modified: branches/Cog/macbuild/HowToBuild =================================================================== --- branches/Cog/macbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/macbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -31,7 +31,7 @@ Then build the libraries macbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/macbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem Then build the plugin: $ cd ROOT/macbuild/BochsIA32Plugin $ xcodebuild
Modified: branches/Cog/nsbuild/cygwinbuild/HowToBuild =================================================================== --- branches/Cog/nsbuild/cygwinbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/nsbuild/cygwinbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -69,7 +69,7 @@ Then build the libraries winbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/winbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem and build the plugin either via make (for the entire VM) or just $ cd ROOT/nsbuild/cygwinbuild $ make build/vm/BochsIA32Plugin.dll
Modified: branches/Cog/nscogbuild/cygwinbuild/HowToBuild =================================================================== --- branches/Cog/nscogbuild/cygwinbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/nscogbuild/cygwinbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -70,7 +70,7 @@ Then build the libraries winbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/winbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem and build the plugin either via make (for the entire VM) or just $ cd ROOT/nscogbuild/cygwinbuild $ make build/vm/BochsIA32Plugin.dll
Modified: branches/Cog/platforms/Cross/vm/sqVirtualMachine.c =================================================================== --- branches/Cog/platforms/Cross/vm/sqVirtualMachine.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/Cross/vm/sqVirtualMachine.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -560,3 +560,42 @@ } *stdout = stdoutStack[stdoutStackIdx--]; } + +void +printPhaseTime(int phase) +{ + static int printTimes; + static usqLong lastusecs; + usqLong nowusecs, usecs; + + if (phase == 1) { + time_t nowt; + struct tm nowtm; + printTimes = 1; + nowt = time(0); + nowtm = *localtime(&nowt); + printf("started at %s", asctime(&nowtm)); + lastusecs = ioUTCMicrosecondsNow(); + return; + } + + if (!printTimes) return; + + nowusecs = ioUTCMicrosecondsNow(); + usecs = nowusecs - lastusecs; + lastusecs = nowusecs; +#define m 1000000ULL +#define k 1000ULL +#define ul(v) (unsigned long)(v) + if (phase == 2) + printf("loaded in %lu.%03lus\n", ul(usecs/m), ul((usecs % m + k/2)/k)); + if (phase == 3) { + printTimes = 0; /* avoid repeated printing if error during exit */ + if (usecs >= 1ULL<<32) + printf("ran for a long time\n"); + else + printf("ran for %lu.%03lus\n", ul(usecs/m), ul((usecs % m + k/2)/k)); + } +#undef m +#undef k +}
Modified: branches/Cog/platforms/Mac OS/vm/sqMacMain.c =================================================================== --- branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -526,6 +526,8 @@ sqInt ioExitWithErrorCode(int ec) { + extern void printPhaseTime(int); + printPhaseTime(3); UnloadScrap(); ioShutdownAllModules(); if (!gSqueakHeadless || gSqueakBrowserWasHeadlessButMadeFullScreen)
Modified: branches/Cog/platforms/Mac OS/vm/sqMacUIEventsUniversal.c =================================================================== --- branches/Cog/platforms/Mac OS/vm/sqMacUIEventsUniversal.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/Mac OS/vm/sqMacUIEventsUniversal.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -1493,7 +1493,9 @@ { // Run our event loop until quitNow is set. #pragma unused(inHandlerCallRef,inEvent,inUserData) + extern void printPhaseTime(int); SetUpCarbonEvent(); + printPhaseTime(2); interpret(); //Note the application under carbon event mgr starts running here return 0; }
Modified: branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c =================================================================== --- branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/Mac OS/vm/sqMacUnixCommandLineInterface.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -164,6 +164,10 @@ extern int blockOnError; blockOnError = true; return 1; } + else if (!strcmp(argv[0], "-timephases")) { + extern void printPhaseTime(int); + printPhaseTime(1); + return 1; } #if (STACKVM || NewspeakVM) && !COGVM else if (!strcmp(argv[0], "-sendtrace")) { extern sqInt sendTrace; sendTrace = 1; return 1; } #endif @@ -272,6 +276,7 @@ printf("\nCommon <option>s:\n"); printf(" -help print this help message, then exit\n"); printf(" -memory <size>[mk] use fixed heap size (added to image size)\n"); + printf(" -timephases print start load and run times\n"); #if STACKVM || NewspeakVM printf(" -breaksel selector set breakpoint on send of selector\n"); #endif
Modified: branches/Cog/platforms/unix/vm/sqUnixMain.c =================================================================== --- branches/Cog/platforms/unix/vm/sqUnixMain.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/unix/vm/sqUnixMain.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -143,6 +143,7 @@ struct SqSound *snd= 0;
extern void dumpPrimTraceLog(void); +extern void printPhaseTime(int); char *getVersionInfo(int verbose);
@@ -1304,6 +1305,9 @@ else if (!strcmp(argv[0], "-notimer")) { useItimer = 0; return 1; } else if (!strcmp(argv[0], "-nohandlers")) { installHandlers= 0; return 1; } else if (!strcmp(argv[0], "-blockonerror")) { blockOnError = 1; return 1; } + else if (!strcmp(argv[0], "-timephases")) { + printPhaseTime(1); + return 1; } #if !STACKVM && !COGVM else if (!strncmp(argv[0],"-jit", 4)) { useJit = jitArgs(argv[0]+4); return 1; } else if (!strcmp(argv[0], "-nojit")) { useJit = 0; return 1; } @@ -1417,6 +1421,7 @@ printf(" -help print this help message, then exit\n"); printf(" -memory <size>[mk] use fixed heap size (added to image size)\n"); printf(" -mmap <size>[mk] limit dynamic heap size (default: %dm)\n", DefaultMmapSize); + printf(" -timephases print start load and run times\n"); #if STACKVM || NewspeakVM printf(" -breaksel selector set breakpoint on send of selector\n"); #endif @@ -1825,8 +1830,10 @@ #endif
/* run Squeak */ - if (runInterpreter) + if (runInterpreter) { + printPhaseTime(2); interpret(); + }
/* we need these, even if not referenced from main executable */ (void)sq2uxPath; @@ -1841,6 +1848,7 @@ sqInt ioExitWithErrorCode(int ec) { + printPhaseTime(3); dpy->winExit(); exit(ec); return ec;
Modified: branches/Cog/platforms/win32/vm/sqWin32Intel.c =================================================================== --- branches/Cog/platforms/win32/vm/sqWin32Intel.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/win32/vm/sqWin32Intel.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -44,6 +44,7 @@ int getCurrentBytecode(void);
extern TCHAR squeakIniName[]; +extern void printPhaseTime(int);
/* Import from sqWin32Alloc.c */ LONG CALLBACK sqExceptionFilter(LPEXCEPTION_POINTERS exp); @@ -1016,6 +1017,7 @@ sqInt ioExitWithErrorCode(int ec) { + printPhaseTime(3); inCleanExit = 1; exit(ec); return ec; @@ -1467,6 +1469,7 @@
/* run Squeak */ ioInitSecurity(); + printPhaseTime(2); interpret(); #if !NO_FIRST_LEVEL_EXCEPTION_HANDLER # ifdef _MSC_VER @@ -1588,10 +1591,15 @@ /* flags */ if (!strcmp(argv[0], "-help")) { printUsage(1); - return 1; } + return 1; + } else if (!strcmp(argv[0], "-version")) { versionInfo(); return 1; } else if (!strcmp(argv[0], "-headless")) { fHeadlessImage = true; return 1; } else if (!strcmp(argv[0], "-headfull")) { fHeadlessImage = false; return 1;} + else if (!strcmp(argv[0], "-timephases")) { + printPhaseTime(1); + return 1; + } #ifdef VISTA_SECURITY /* IE7/Vista protected mode support */ /* started with low rights, use alternate untrustedUserDirectory */ else if (!strcmp(argv[0], "-lowRights")) { fLowRights = true; return 1; }
Modified: branches/Cog/platforms/win32/vm/sqWin32Window.c =================================================================== --- branches/Cog/platforms/win32/vm/sqWin32Window.c 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/platforms/win32/vm/sqWin32Window.c 2012-07-31 00:24:58 UTC (rev 2579) @@ -3191,6 +3191,7 @@ TEXT("vmOptions:") /* TEXT("\n\t-service: ServiceName \t(install Squeak as NT service)") */ TEXT("\n\t-headless \t\t(force Squeak to run headless)") + TEXT("\n\t-timephases (print start load and run times)") TEXT("\n\t-log: LogFile \t\t(use LogFile for VM messages)") TEXT("\n\t-memory: megaByte \t(set memory to megaByte MB)") #if STACKVM || NewspeakVM @@ -3199,7 +3200,7 @@ #if STACKVM TEXT("\n\t-leakcheck: n \t(leak check on GC (1=full,2=incr,3=both))") TEXT("\n\t-eden: bytes \t(set eden memory size to bytes)") - TEXT("\n\t-stackpages: n \t(use n stack pages)") + TEXT("\n\t-stackpages: n \t(use n stack pages)") TEXT("\n\t-numextsems: n \t(allow up to n external semaphores)") TEXT("\n\t-noheartbeat \t(no heartbeat for debug)") #endif /* STACKVM */
Modified: branches/Cog/stackbuild/cygwinbuild/HowToBuild =================================================================== --- branches/Cog/stackbuild/cygwinbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/stackbuild/cygwinbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -70,7 +70,7 @@ Then build the libraries winbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/winbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem and build the plugin either via make (for the entire VM) or just $ cd ROOT/stackbuild/cygwinbuild $ make build/vm/BochsIA32Plugin.dll
Modified: branches/Cog/unixbuild/HowToBuild =================================================================== --- branches/Cog/unixbuild/HowToBuild 2012-07-31 00:07:39 UTC (rev 2578) +++ branches/Cog/unixbuild/HowToBuild 2012-07-31 00:24:58 UTC (rev 2579) @@ -66,7 +66,7 @@ Then build libraries linuxbochs/{cpu/libcpu.a,disasm/libdisasm.a,fpu/libfpu.a} $ cd ROOT/processors/IA32/linuxbochs $ ./conf.COG - $ ./makeem + $ ../bochs/makeem and build the plugin via $ cd ROOT/unixbuild/bld/BochsIA32Plugin $ make
vm-dev@lists.squeakfoundation.org