1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
$NetBSD: patch-aj,v 1.1 2003/07/10 07:44:02 jtb Exp $
--- asmrun/power-bsd.S.orig
+++ asmrun/power-bsd.S
@@ -13,6 +13,36 @@
/* $Id: patch-aj,v 1.1 2003/07/10 07:44:02 jtb Exp $ */
+#if defined(PROFILING)
+#define PROFILE_CAML \
+ stwu 1, -32(1) \
+ stw 1, 0(3) \
+ mflr 0 \
+ stw 0, 4(1) \
+ stw 2, 8(1) \
+ stw 3, 12(1) \
+ stw 4, 16(1) \
+ stw 5, 20(1) \
+ stw 6, 24(1) \
+ stw 7, 28(1) \
+ bl _mcount \
+ lwz 2, 8(1) \
+ lwz 3, 12(1) \
+ lwz 4, 16(1) \
+ lwz 5, 20(1) \
+ lwz 6, 24(1) \
+ lwz 7, 28(1) \
+ addic 1, 1, 32
+
+#define PROFILE_C \
+ mflr 0 \
+ stw 0, 4(1) \
+ bl _mcount
+#else
+#define PROFILE_CAML
+#define PROFILE_C
+#endif
+
#define Addrglobal(reg,glob) \
addis reg, 0, glob@ha; \
addi reg, reg, glob@l
@@ -30,6 +60,7 @@
.globl caml_call_gc
.type caml_call_gc, @function
caml_call_gc:
+ PROFILE_CAML
/* Set up stack frame */
stwu 1, -0x1A0(1)
/* 0x1A0 = 4*32 (int regs) + 8*32 (float regs) + 32 (space for C call) */
@@ -182,6 +213,7 @@
.globl caml_c_call
.type caml_c_call, @function
caml_c_call:
+ PROFILE_CAML
/* Save return address */
mflr 25
/* Get ready to call C function (address in 11) */
@@ -210,6 +242,7 @@
.globl raise_caml_exception
.type raise_caml_exception, @function
raise_caml_exception:
+ PROFILE_C
/* Reload Caml global registers */
Loadglobal(1, caml_exception_pointer, 11)
Loadglobal(31, young_ptr, 11)
@@ -230,6 +263,7 @@
.globl caml_start_program
.type caml_start_program, @function
caml_start_program:
+ PROFILE_C
Addrglobal(12, caml_program)
/* Code shared between caml_start_program and callback */
@@ -380,6 +414,7 @@
.globl callback_exn
.type callback_exn, @function
callback_exn:
+ PROFILE_C
/* Initial shuffling of arguments */
mr 0, 3 /* Closure */
mr 3, 4 /* Argument */
@@ -390,6 +425,7 @@
.globl callback2_exn
.type callback2_exn, @function
callback2_exn:
+ PROFILE_C
mr 0, 3 /* Closure */
mr 3, 4 /* First argument */
mr 4, 5 /* Second argument */
@@ -400,6 +436,7 @@
.globl callback3_exn
.type callback3_exn, @function
callback3_exn:
+ PROFILE_C
mr 0, 3 /* Closure */
mr 3, 4 /* First argument */
mr 4, 5 /* Second argument */
@@ -418,4 +455,3 @@
.long .L105 + 4 /* return address into callback */
.short -1 /* negative size count => use callback link */
.short 0 /* no roots here */
-
|