[MLton] PowerPC .deb built
Wesley W. Terpstra
wesley@terpstra.ca
Tue, 17 May 2005 11:24:26 +0200
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Sat, May 14, 2005 at 03:12:50PM +0200, Wesley W. Terpstra wrote:
> However, hppa is giving me some problems...
It turns out that the remaining problems I had were a kernel bug.
For hppa+profiling, one needs kernel >= 2.6.3.
I've attached my final version of the patch.
It changes things to use char pointers as I explained.
As I understand it, the reason for the odd pointer locations is that on
hppa, a function pointer is actually a pointer to a description about the
function which is then used to actually call the function.
I've also attached the results of profiling for the 4 platforms I tested.
These results come after a full-rebuild of MLton.
For future reference, the .debs are located at <http://terpstra.ca/mlton>
PS. The include directory is read-only for some reason:
W: mlton: non-standard-dir-perm usr/lib/mlton/include/ 0777 != 0755
W: mlton: non-standard-file-perm usr/lib/mlton/include/assert.h 0444 != 0644
...
--
Wesley W. Terpstra <wesley@terpstra.ca>
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="profile.patch"
Index: debian/control
===================================================================
RCS file: /cvsroot/mlton/mlton/debian/control,v
retrieving revision 1.16
diff -u -r1.16 control
--- debian/control 13 May 2005 05:02:27 -0000 1.16
+++ debian/control 16 May 2005 20:24:59 -0000
@@ -6,7 +6,7 @@
Standards-Version: 3.6.1
Package: mlton
-Architecture: i386, powerpc, hppa, sparc
+Architecture: i386 powerpc hppa sparc
Depends: ${shlibs:Depends}, gcc, libgmp3-dev (>= 4.0.1)
Description: Optimizing compiler for Standard ML
MLton (www.mlton.org) is a whole-program
Index: include/main.h
===================================================================
RCS file: /cvsroot/mlton/mlton/include/main.h,v
retrieving revision 1.12
diff -u -r1.12 main.h
--- include/main.h 10 Dec 2004 03:42:08 -0000 1.12
+++ include/main.h 16 May 2005 20:24:59 -0000
@@ -7,7 +7,7 @@
* the code that declares the label is dead and hence eliminate the declaration.
*/
#define DeclareProfileLabel(l) \
- void l() __attribute__ ((weak))
+ extern char l __attribute__ ((weak))
#define BeginIntInfs static struct GC_intInfInit intInfInits[] = {
#define IntInf(g, n) { g, n },
Index: mlton/codegen/c-codegen/c-codegen.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/c-codegen/c-codegen.fun,v
retrieving revision 1.102
diff -u -r1.102 c-codegen.fun
--- mlton/codegen/c-codegen/c-codegen.fun 22 Apr 2005 18:13:46 -0000 1.102
+++ mlton/codegen/c-codegen/c-codegen.fun 16 May 2005 20:25:00 -0000
@@ -393,7 +393,7 @@
; (declareArray
("struct GC_sourceLabel", "sourceLabels", labels,
fn (_, {label, sourceSeqsIndex}) =>
- concat ["{(pointer)", ProfileLabel.toString label, ", ",
+ concat ["{(pointer)&", ProfileLabel.toString label, ", ",
C.int sourceSeqsIndex, "}"]))
; declareArray ("string", "sourceNames", names, C.string o #2)
; declareArray ("struct GC_source", "sources", sources,
Index: runtime/basis/Int/Word.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/basis/Int/Word.c,v
retrieving revision 1.8
diff -u -r1.8 Word.c
--- runtime/basis/Int/Word.c 13 May 2005 05:02:28 -0000 1.8
+++ runtime/basis/Int/Word.c 16 May 2005 20:25:01 -0000
@@ -28,7 +28,7 @@
#define DEBUG FALSE
#endif
-#if ! (defined (__i386__) || defined (__parisc__) || defined (__ppc__) || defined (__powerpc__) || defined (__sparc__))
+#if ! (defined (__i386__) || defined (__hppa__) || defined (__ppc__) || defined (__powerpc__) || defined (__sparc__))
#error check that C {/,%} correctly implement {quot,rem} from the basis library
#endif
Index: runtime/platform/getText.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/getText.c,v
retrieving revision 1.1
diff -u -r1.1 getText.c
--- runtime/platform/getText.c 28 Sep 2004 18:56:40 -0000 1.1
+++ runtime/platform/getText.c 16 May 2005 20:25:02 -0000
@@ -1,6 +1,6 @@
/* To get the beginning and end of the text segment. */
-extern void _start(void);
-extern void etext(void);
+extern char _start;
+extern char etext;
void *getTextStart () {
return &_start;
Index: runtime/platform/linux.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/platform/linux.c,v
retrieving revision 1.9
diff -u -r1.9 linux.c
--- runtime/platform/linux.c 13 May 2005 05:02:29 -0000 1.9
+++ runtime/platform/linux.c 16 May 2005 20:25:02 -0000
@@ -13,57 +13,41 @@
#define EIP 14
#endif
-/* The locations of the EIP equivalent register found in kaffe */
-#if (defined (__alpha__))
-static void catcher (int sig, siginfo_t *sip, struct sigcontext* scp) {
- GC_handleSigProf ((pointer) scp->sc_pc);
-}
-#elif (defined (__x86_64__))
+/* potentially correct for other archs:
+ * alpha: ucp->m_context.sc_pc
+ * arm: ucp->m_context.ctx.arm_pc
+ * ia64: ucp->m_context.sc_ip & ~0x3UL
+ * mips: ucp->m_context.sc_pc
+ * s390: ucp->m_context.sregs->regs.psw.addr
+ */
+static void catcher (int sig, siginfo_t* sip, void* mystery) {
+#if (defined (__x86_64__))
#define REG_INDEX(NAME) (offsetof(struct sigcontext, NAME) / sizeof(greg_t))
#ifndef REG_RIP
#define REG_RIP REG_INDEX(rip) /* seems to be 16 */
#endif
-static void catcher (int sig, siginfo_t *sip, ucontext_t* ucp) {
+ ucontext_t* ucp = (ucontext_t*)mystery;
GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[REG_RIP]);
-}
-#elif (defined (__arm__))
-static void catcher (int sig, int arm1, int arm2, int arm3, struct sigcontext ctx) {
- GC_handleSigProf ((pointer) ctx.arm_pc);
-}
#elif (defined (__hppa__))
-static void catcher (int sig, siginfo_t *sip, ucontext_t* ucp) {
- GC_handleSigProf ((pointer) ucp->uc_mcontext.sc_iaoq[0]);
-}
-#elif (defined (__ia64__))
-static void catcher (int sig, siginfo_t *sip, struct sigcontext* scp) {
- GC_handleSigProf ((pointer) scp->sc_ip & ~0x3ULL);
-}
-#elif (defined (__m68k__))
-#error Eek - how to get EIP without assembler on m68k?
-#elif (defined (__mips__))
-static void catcher (int sig, int dummy, struct sigcontext* scp) {
- GC_handleSigProf ((pointer) scp->sc_pc);
-}
+ ucontext_t* ucp = (ucontext_t*)mystery;
+ GC_handleSigProf ((pointer) (ucp->uc_mcontext.sc_iaoq[0] & ~0x3UL));
#elif (defined (__ppc__)) || (defined (__powerpc__))
-static void catcher (int sig, struct sigcontext* scp) {
- GC_handleSigProf ((pointer) scp->regs->nip);
-}
-#elif (defined (__s390__))
-static void catcher (int sig, struct sigcontext sc) {
- GC_handleSigProf ((pointer) sc.sregs->regs.psw.addr);
-}
+ ucontext_t* ucp = (ucontext_t*)mystery;
+ GC_handleSigProf ((pointer) ucp->uc_mcontext.regs->nip);
#elif (defined (__sparc__))
-static void catcher (int sig, struct sigcontext* scp) {
+ struct sigcontext* scp = (struct sigcontext*)mystery;
+#if __WORDSIZE == 64
+ GC_handleSigProf ((pointer) scp->sigc_regs.tpc);
+#else
GC_handleSigProf ((pointer) scp->si_regs.pc);
-//64bit GC_handleSigProf ((pointer) scp->sigc_regs.tpc);
-}
+#endif
#elif (defined (__i386__))
-static void catcher (int sig, struct sigcontext* scp, ucontext_t* ucp) {
+ ucontext_t* ucp = (ucontext_t*)mystery;
GC_handleSigProf ((pointer) ucp->uc_mcontext.gregs[EIP]);
-}
#else
#error Profiling handler is missing for this architecture
#endif
+}
void setSigProfHandler (struct sigaction *sa) {
sa->sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="i386-profile.log"
terpstra@carrot:~/mlton/doc/examples/profiling$ make
mlton -profile time tak.sml
./tak
mlprof tak mlmon.out
3.89 seconds of CPU time (0.00 seconds GC)
function cur
------------- -----
Tak.tak1.tak2 73.8%
Tak.tak1 26.2%
mlprof -raw true tak mlmon.out
3.89 seconds of CPU time (0.00 seconds GC)
function cur raw
------------- ----- -------
Tak.tak1.tak2 73.8% (2.87s)
Tak.tak1 26.2% (1.02s)
mlprof -show-line true tak mlmon.out
3.89 seconds of CPU time (0.00 seconds GC)
function cur
------------------------- -----
Tak.tak1.tak2 tak.sml: 5 73.8%
Tak.tak1 tak.sml: 3 26.2%
mlton -profile alloc list-rev.sml
./list-rev
mlprof -show-line true list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur
---------------------------------------------- -----
append list-rev.sml: 1 97.4%
<gc> 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2%
List.tabulate.loop <basis>/list/list.sml: 106 0.2%
rev list-rev.sml: 6 0.2%
<main> 0.0%
mlton -profile count tak.sml
./tak
mlprof -raw true -show-line true tak mlmon.out
305,555,001 ticks
function cur raw
------------------------- ----- -------------
Tak.tak1.tak2 tak.sml: 5 78.1% (238,530,000)
Tak.tak1 tak.sml: 3 21.9% (67,025,000)
f tak.sml: 23 0.0% (1)
uncalled tak.sml: 29 0.0% (0)
mlton -profile alloc -profile-stack true list-rev.sml
./list-rev
mlprof -call-graph list-rev.dot -show-line true \
list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur stack GC
---------------------------------------------- ----- ----- ----
append list-rev.sml: 1 97.4% 97.4% 1.4%
<gc> 2.0% 0.0% 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2% 0.2% 0.0%
List.tabulate.loop <basis>/list/list.sml: 106 0.2% 0.2% 0.0%
rev list-rev.sml: 6 0.2% 97.4% 2.0%
<main> 0.0% 98.0% 2.0%
dot -Tps list-rev.dot >list-rev.ps || true
/bin/sh: line 1: dot: command not found
mlton -profile time fib-tak.sml
./fib-tak
mlprof fib-tak mlmon.fib.out
3.19 seconds of CPU time (0.00 seconds GC)
function cur
--------- -----
fib 97.8%
<unknown> 2.2%
mlprof fib-tak mlmon.tak.out
0.41 seconds of CPU time (0.00 seconds GC)
function cur
-------- ------
tak 100.0%
mlprof fib-tak mlmon.fib.out mlmon.tak.out mlmon.out
3.60 seconds of CPU time (0.00 seconds GC)
function cur
--------- -----
fib 86.7%
tak 11.4%
<unknown> 1.9%
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="powerpc-profile.log"
maria@apple:~/mlton/cvs/doc/examples/profiling$ make
mlton -profile time tak.sml
./tak
mlprof tak mlmon.out
10.04 seconds of CPU time (0.00 seconds GC)
function cur
--------------- -----
Tak.tak1.tak2 54.9%
Tak.tak1 21.6%
<unknown> 16.3%
Exit.exit 4.3%
<main> 2.3%
Sequence.concat 0.6%
mlprof -raw true tak mlmon.out
10.04 seconds of CPU time (0.00 seconds GC)
function cur raw
--------------- ----- -------
Tak.tak1.tak2 54.9% (5.51s)
Tak.tak1 21.6% (2.17s)
<unknown> 16.3% (1.64s)
Exit.exit 4.3% (0.43s)
<main> 2.3% (0.23s)
Sequence.concat 0.6% (0.06s)
mlprof -show-line true tak mlmon.out
10.04 seconds of CPU time (0.00 seconds GC)
function cur
------------------------------------------------------------- -----
Tak.tak1.tak2 tak.sml: 5 54.9%
Tak.tak1 tak.sml: 3 21.6%
<unknown> 16.3%
Exit.exit <basis>/mlton/exit.sml: 12 4.3%
<main> 2.3%
Sequence.concat <basis>/arrays-and-vectors/sequence.fun: 454 0.6%
mlton -profile alloc list-rev.sml
./list-rev
mlprof -show-line true list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur
---------------------------------------------- -----
append list-rev.sml: 1 97.4%
<gc> 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2%
List.tabulate.loop <basis>/list/list.sml: 106 0.2%
rev list-rev.sml: 6 0.2%
<main> 0.0%
mlton -profile count tak.sml
./tak
mlprof -raw true -show-line true tak mlmon.out
305,555,001 ticks
function cur raw
------------------------- ----- -------------
Tak.tak1.tak2 tak.sml: 5 78.1% (238,530,000)
Tak.tak1 tak.sml: 3 21.9% (67,025,000)
f tak.sml: 23 0.0% (1)
uncalled tak.sml: 29 0.0% (0)
mlton -profile alloc -profile-stack true list-rev.sml
./list-rev
mlprof -call-graph list-rev.dot -show-line true \
list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur stack GC
---------------------------------------------- ----- ----- ----
append list-rev.sml: 1 97.4% 97.4% 1.4%
<gc> 2.0% 0.0% 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2% 0.2% 0.0%
List.tabulate.loop <basis>/list/list.sml: 106 0.2% 0.2% 0.0%
rev list-rev.sml: 6 0.2% 97.4% 2.0%
<main> 0.0% 98.0% 2.0%
dot -Tps list-rev.dot >list-rev.ps || true
/bin/sh: line 1: dot: command not found
mlton -profile time fib-tak.sml
./fib-tak
mlprof fib-tak mlmon.fib.out
9.37 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
fib 53.5%
<unknown> 30.1%
Sequence.Slice.sequence 6.7%
Exit.exit 6.0%
<main> 3.7%
mlprof fib-tak mlmon.tak.out
1.16 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
tak 81.9%
<unknown> 13.8%
Sequence.Slice.sequence 2.6%
<main> 0.9%
fib 0.9%
mlprof fib-tak mlmon.fib.out mlmon.tak.out mlmon.out
10.53 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
fib 47.7%
<unknown> 28.3%
tak 9.0%
Sequence.Slice.sequence 6.3%
Exit.exit 5.3%
<main> 3.4%
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="hppa-profile.log"
terpstra@gsyprf11:~/mlton/doc/examples/profiling$ make
mlton -profile time tak.sml
./tak
mlprof tak mlmon.out
13.56 seconds of CPU time (0.00 seconds GC)
function cur
--------------- -----
Tak.tak1.tak2 58.6%
Tak.tak1 22.9%
<unknown> 15.3%
Exit.exit 1.5%
<main> 1.0%
Sequence.concat 0.7%
mlprof -raw true tak mlmon.out
13.56 seconds of CPU time (0.00 seconds GC)
function cur raw
--------------- ----- -------
Tak.tak1.tak2 58.6% (7.95s)
Tak.tak1 22.9% (3.10s)
<unknown> 15.3% (2.07s)
Exit.exit 1.5% (0.21s)
<main> 1.0% (0.13s)
Sequence.concat 0.7% (0.10s)
mlprof -show-line true tak mlmon.out
13.56 seconds of CPU time (0.00 seconds GC)
function cur
------------------------------------------------------------- -----
Tak.tak1.tak2 tak.sml: 5 58.6%
Tak.tak1 tak.sml: 3 22.9%
<unknown> 15.3%
Exit.exit <basis>/mlton/exit.sml: 12 1.5%
<main> 1.0%
Sequence.concat <basis>/arrays-and-vectors/sequence.fun: 454 0.7%
mlton -profile alloc list-rev.sml
./list-rev
mlprof -show-line true list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur
---------------------------------------------- -----
append list-rev.sml: 1 97.4%
<gc> 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2%
List.tabulate.loop <basis>/list/list.sml: 106 0.2%
rev list-rev.sml: 6 0.2%
<main> 0.0%
mlton -profile count tak.sml
./tak
mlprof -raw true -show-line true tak mlmon.out
305,555,001 ticks
function cur raw
------------------------- ----- -------------
Tak.tak1.tak2 tak.sml: 5 78.1% (238,530,000)
Tak.tak1 tak.sml: 3 21.9% (67,025,000)
f tak.sml: 23 0.0% (1)
uncalled tak.sml: 29 0.0% (0)
mlton -profile alloc -profile-stack true list-rev.sml
./list-rev
mlprof -call-graph list-rev.dot -show-line true \
list-rev mlmon.out
6,030,240 bytes allocated (122,680 bytes by GC)
function cur stack GC
---------------------------------------------- ----- ----- ----
append list-rev.sml: 1 97.4% 97.4% 1.4%
<gc> 2.0% 0.0% 2.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2% 0.2% 0.0%
List.tabulate.loop <basis>/list/list.sml: 106 0.2% 0.2% 0.0%
rev list-rev.sml: 6 0.2% 97.4% 2.0%
<main> 0.0% 98.0% 2.0%
dot -Tps list-rev.dot >list-rev.ps || true
/bin/sh: line 1: dot: command not found
mlton -profile time fib-tak.sml
./fib-tak
mlprof fib-tak mlmon.fib.out
12.30 seconds of CPU time (0.00 seconds GC)
function cur
--------- -----
fib 74.5%
<unknown> 16.2%
<main> 6.3%
Exit.exit 3.0%
mlprof fib-tak mlmon.tak.out
1.42 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
tak 78.9%
<unknown> 13.4%
<main> 4.2%
Sequence.Slice.sequence 2.8%
wrap.anon 0.7%
mlprof fib-tak mlmon.fib.out mlmon.tak.out mlmon.out
13.73 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
fib 66.7%
<unknown> 15.9%
tak 8.2%
<main> 6.1%
Exit.exit 2.7%
Sequence.Slice.sequence 0.3%
MLtonProfile.Data.write 0.1%
wrap.anon 0.1%
--J/dobhs11T7y2rNN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sparc-profile.log"
terpstra@vore:~/mlton/doc/examples/profiling$ make
mlton -profile time tak.sml
./tak
mlprof tak mlmon.out
56.36 seconds of CPU time (0.00 seconds GC)
function cur
--------------- -----
Tak.tak1.tak2 59.7%
Tak.tak1 23.5%
<unknown> 11.0%
Exit.exit 4.4%
Sequence.concat 0.8%
<main> 0.6%
mlprof -raw true tak mlmon.out
56.36 seconds of CPU time (0.00 seconds GC)
function cur raw
--------------- ----- --------
Tak.tak1.tak2 59.7% (33.62s)
Tak.tak1 23.5% (13.27s)
<unknown> 11.0% (6.19s)
Exit.exit 4.4% (2.50s)
Sequence.concat 0.8% (0.46s)
<main> 0.6% (0.32s)
mlprof -show-line true tak mlmon.out
56.36 seconds of CPU time (0.00 seconds GC)
function cur
------------------------------------------------------------- -----
Tak.tak1.tak2 tak.sml: 5 59.7%
Tak.tak1 tak.sml: 3 23.5%
<unknown> 11.0%
Exit.exit <basis>/mlton/exit.sml: 12 4.4%
Sequence.concat <basis>/arrays-and-vectors/sequence.fun: 454 0.8%
<main> 0.6%
mlton -profile alloc list-rev.sml
./list-rev
mlprof -show-line true list-rev mlmon.out
8,040,288 bytes allocated (82,712 bytes by GC)
function cur
---------------------------------------------- -----
append list-rev.sml: 1 98.4%
<gc> 1.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2%
List.tabulate.loop <basis>/list/list.sml: 106 0.2%
rev list-rev.sml: 6 0.2%
<main> 0.0%
mlton -profile count tak.sml
./tak
mlprof -raw true -show-line true tak mlmon.out
305,555,001 ticks
function cur raw
------------------------- ----- -------------
Tak.tak1.tak2 tak.sml: 5 78.1% (238,530,000)
Tak.tak1 tak.sml: 3 21.9% (67,025,000)
f tak.sml: 23 0.0% (1)
uncalled tak.sml: 29 0.0% (0)
mlton -profile alloc -profile-stack true list-rev.sml
./list-rev
mlprof -call-graph list-rev.dot -show-line true \
list-rev mlmon.out
8,040,288 bytes allocated (82,712 bytes by GC)
function cur stack GC
---------------------------------------------- ----- ----- ----
append list-rev.sml: 1 98.4% 98.4% 0.5%
<gc> 1.0% 0.0% 1.0%
List.foldl.loop <basis>/list/list.sml: 39 0.2% 0.2% 0.0%
List.tabulate.loop <basis>/list/list.sml: 106 0.2% 0.2% 0.0%
rev list-rev.sml: 6 0.2% 98.4% 1.0%
<main> 0.0% 99.0% 1.0%
dot -Tps list-rev.dot >list-rev.ps || true
/bin/sh: dot: command not found
mlton -profile time fib-tak.sml
./fib-tak
mlprof fib-tak mlmon.fib.out
56.38 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
fib 71.1%
<unknown> 14.6%
Exit.exit 7.8%
<main> 3.4%
Sequence.Slice.sequence 2.4%
wrap.anon 0.6%
mlprof fib-tak mlmon.tak.out
6.59 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
tak 83.0%
<unknown> 9.4%
fib 3.3%
Sequence.Slice.sequence 2.7%
<main> 1.5%
mlprof fib-tak mlmon.fib.out mlmon.tak.out mlmon.out
62.98 seconds of CPU time (0.00 seconds GC)
function cur
----------------------- -----
fib 64.0%
<unknown> 14.1%
tak 8.7%
Exit.exit 6.9%
<main> 3.2%
Sequence.Slice.sequence 2.5%
wrap.anon 0.6%
MLtonProfile.Data.write 0.0%
--J/dobhs11T7y2rNN--