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
|
$NetBSD: patch-ah,v 1.9 2005/02/05 00:26:18 adrianp Exp $
--- asmrun/power-bsd.S.orig 2005-02-05 00:20:14.000000000 +0000
+++ asmrun/power-bsd.S 2005-02-05 00:22:01.000000000 +0000
@@ -13,6 +13,35 @@
/* $Id: patch-ah,v 1.9 2005/02/05 00:26:18 adrianp Exp $ */
+#if defined(PROFILING)
+#define PROFILE_CAML \
+ stwu 1, -32(1) \
+ 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 +59,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 +212,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 +241,7 @@
.globl caml_raise_exception
.type caml_raise_exception, @function
caml_raise_exception:
+ PROFILE_C
/* Reload Caml global registers */
Loadglobal(1, caml_exception_pointer, 11)
Loadglobal(31, caml_young_ptr, 11)
@@ -230,6 +262,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 caml_callback */
@@ -380,6 +413,7 @@
.globl caml_callback_exn
.type caml_callback_exn, @function
caml_callback_exn:
+ PROFILE_C
/* Initial shuffling of arguments */
mr 0, 3 /* Closure */
mr 3, 4 /* Argument */
@@ -390,6 +424,7 @@
.globl caml_callback2_exn
.type caml_callback2_exn, @function
caml_callback2_exn:
+ PROFILE_C
mr 0, 3 /* Closure */
mr 3, 4 /* First argument */
mr 4, 5 /* Second argument */
@@ -400,6 +435,7 @@
.globl caml_callback3_exn
.type caml_callback3_exn, @function
caml_callback3_exn:
+ PROFILE_C
mr 0, 3 /* Closure */
mr 3, 4 /* First argument */
mr 4, 5 /* Second argument */
|