[MLton-devel] cvs commit: -profile-split <regexp>
Stephen Weeks
MLton@mlton.org
Tue, 25 Feb 2003 12:44:33 -0800
sweeks 03/02/25 12:44:32
Modified: doc/user-guide man-page.tex profiling.tex
man mlton.1
mlton/atoms source-info.fun source-info.sig
mlton/backend profile.fun
mlton/codegen/c-codegen c-codegen.fun
mlton/control control.sig control.sml
mlton/main main.sml
Log:
Replace -profile-combine {false|true} with -profile-split <regexp>.
So, the default is now that duplicates will not be split (except for
those from defunctorization) and that you can selectively split
functions that you want to by using -profile-split.
Revision Changes Path
1.29 +35 -20 mlton/doc/user-guide/man-page.tex
Index: man-page.tex
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/man-page.tex,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- man-page.tex 12 Feb 2003 03:08:06 -0000 1.28
+++ man-page.tex 25 Feb 2003 20:44:19 -0000 1.29
@@ -37,7 +37,16 @@
\begin{description}
-\option{-basis \{2002|2002-strict|1997|none\}}
+\newcommand{\choices}{{\it \{}}
+\newcommand{\choice}{{\it |}}
+\newcommand{\choicesEnd}{{\it \}}}
+\newcommand{\choiceTwo}[2]{\choices #1\choice #2\choicesEnd}
+\newcommand{\choiceThree}[3]{\choices #1\choice #2\choice #3\choicesEnd}
+\newcommand{\choiceFour}[4]{\choices #1\choice #2\choice #3\choice #4\choicesEnd}
+\newcommand{\falseTrue}{\choiceTwo{false}{true}}
+\newcommand{\trueFalse}{\choiceTwo{true}{false}}
+
+\option{-basis \choices 2002\choice 2002-strict\choice 1997\choice none\choicesEnd}
Selects a Basis Library to be used by the input program. {\tt 2002}
and {\tt 2002-strict} implement the 2002 Basis Library
specification; {\tt 2002-strict} removes all extensions described in
@@ -45,7 +54,7 @@
Library specification; see \secref{basis1997} for more information.
{\tt none} removes all Basis Library functionality.
-\option{-detect-overflow \{true|false\}}
+\option{-detect-overflow \trueFalse}
This flag controls whether or not overflow checking is performed on integer
arithmetic, in particular on {\tt Int.\{+,-,*,\~{},div,quot\}}.
@@ -58,19 +67,19 @@
%If you compile {\tt -DMLton\_debug=1}, then the value of the variable
%{\tt MLton.debug} will be true. The default is false.
-\option{-exn-history \{false|true\}}
+\option{-exn-history \falseTrue}
Enable {\tt Exn.history}. See \secref{exn} for details. This has a
performance impact, both in memory usage of exceptions and in runtime,
because of additional work that must be performed at each exception
construction, raise, and handle.
-\option{-host \{self|...\}}
+\option{-host \choiceTwo{self}{\ldots}}
Generate an executable that runs on the specified host. The default is {\tt
self}, which means to compile for the machine that {\mlton} is running on. To
use any other host, you must first install a cross-compiler. See
\secref{cross-compiling}.
-\option{-ieee-fp \{false|true\}}
+\option{-ieee-fp \falseTrue}
Control whether or not the native code generator is pedantic about following
the IEEE floating point standard. By default, it is not, because of the
performance cost. This has no effect with {\tt -native false}.
@@ -80,14 +89,14 @@
%constants (see \secref{compile-time-constant}). The file will be included with
%{\tt \#include <file.h>}.
-\option{-inline \mbox{\rm n}}
+\option{-inline {\it n}}
Set the inlining threshold used in the optimizer. The default is 320.
%\option{-I\mbox{\rm dir}}
%Specify an additional directory to be searched for include files (included with
%{\tt -i}).
-\option{-keep \{g|o|sml|...\}}
+\option{-keep \choiceThree{g}{o}{sml}}
Save the intermediate file(s) corresponding to the given arg. If
no {\tt -keep} argument is given, then only the final file(s) is saved.\\
\begin{tabular}{ll}
@@ -96,55 +105,61 @@
{\tt sml} & SML file\\
\end{tabular}
-\option{-lib-search \mbox{\rm dir}}
+\option{-lib-search {\it dir}}
Specify an additional directory to be searched for libraries when
linking.
-\option{-link \mbox{\rm lib}}
+\option{-link {\it lib}}
Specify an additional library to link with.
-\option{-may-load-world \{true|false\}}
+\option{-may-load-world \trueFalse}
Controls whether or not the generated executable supports the {\tt
@MLton load-world} runtime system option.
-\option{-native \{true|false\}}
+\option{-native \trueFalse}
Controls whether or not to use native code generation, as opposed to
generating C and using {\tt gcc}. With native code generation,
{\mlton} typically compiles more quickly and generates better code.
-\option{-output \mbox{\rm file}}
+\option{-output {\it file}}
Specify the name of the final output file. The default name is the
input file name with its suffix removed and an appropriate suffix
added.
-\option{-profile \{no|alloc|time\}}
+\option{-profile \choiceThree{no}{alloc}{time}}
Produce an executable that will gather allocation or time profiling
information. When such an executable is run, it will produce an {\tt
mlmon.out} file. See \secref{profiling} for details.
-\option{-profile-stack \{false|true\}}
+\option{-profile-split {\it regexp}}
+Attribute time or allocation costs separately to duplicates of
+functions whose name and source position matches {\it regexp}.
+Multiple {\tt -profile-split} args can be used and will be or-ed
+together.
+
+\option{-profile-stack \falseTrue}
If true, the profiler will count the time spent (or bytes allocated)
while a function is on the stack.
-\option{-safe \{true|false\}}
+\option{-safe \trueFalse}
This switch determines the value of the SML variable {\tt MLton.safe}, which
controls whether the basis library performs array, string, and vector bounds
checks, division for zero checks, and other checks. Compiling {\tt -safe false}
changes the behavior of some programs, does not conform to the basis library
specification, and may cause programs to seg fault.
-\option{-show-basis \{false|true\}}
+\option{-show-basis \falseTrue}
If true, the compiler shows the basis library and exits.
-\option{-show-basis-used \{false|true\}}
+\option{-show-basis-used \falseTrue}
If true, then the compiler prints out the types, values, signatures, structures,
and functors from the basis library that the input program uses, and then exits.
-\option{-static \{false|true\}}
+\option{-static \falseTrue}
If true, then produce a statically linked executable. This option only
affects the linker.
-\option{-stop \{f|g|o|sml\}}
+\option{-stop \choiceFour{f}{g}{o}{sml}}
Secify pass to stop at.\\
\begin{tabular}{ll}
{\tt f} & list of files on stdout (only makes sense when input is {\tt foo.cm})\\
@@ -155,7 +170,7 @@
If you compile {\tt -stop g} or {\tt -stop o}, you can resume compilation by
running {\tt mlton} on the generated {\tt .c} and {\tt .S} or {\tt .o} files.
-\option{-verbose \{0|1|2|3\}}
+\option{-verbose \choiceFour{0}{1}{2}{3}}
How verbose to be about what passes are running. The default is 0.\\
\begin{tabular}{ll}
{\tt 0} & silent\\
1.23 +6 -6 mlton/doc/user-guide/profiling.tex
Index: profiling.tex
===================================================================
RCS file: /cvsroot/mlton/mlton/doc/user-guide/profiling.tex,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- profiling.tex 11 Feb 2003 04:47:54 -0000 1.22
+++ profiling.tex 25 Feb 2003 20:44:19 -0000 1.23
@@ -262,12 +262,12 @@
\subsection{Profiling details}
{\mlton}'s optimizer may duplicate source functions for any of a
-number of reasons. By default, each of these duplicates is treated as
-a different function for the purposes of profiling. It you would like
-all of the copies of a function to be treated as one, you can compile
-the program with {\tt -profile-combine true}. Even with this, copies
-of a function that arise from functor duplication are still kept
-separate.
+number of reasons (functor duplication, monomorphisation,
+polyvariance, inlining). By default, duplicates arising from functor
+duplication are treated as different functions, while duplicates
+arising from other optimizations are treated as the same function.
+If you would like all the copies of a function to be treated
+as different, you can use {\tt -profile-split}.
Conceptually, both allocation and time profiling work in the same way.
The compiler produces information that maps machine code positions to
1.27 +5 -3 mlton/man/mlton.1
Index: mlton.1
===================================================================
RCS file: /cvsroot/mlton/mlton/man/mlton.1,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- mlton.1 12 Feb 2003 03:08:06 -0000 1.26
+++ mlton.1 25 Feb 2003 20:44:20 -0000 1.27
@@ -137,9 +137,11 @@
extract information from this file.
.TP
-\fB-profile-combine \fI{\fBfalse\fP|\fBtrue\fP}\fR
-When \fBtrue\fP, combine all copies of each function together for
-profiling data and for the call graph.
+\fB-profile-split \fIregexp\fP
+Attribute time or allocation costs separately to duplicates of
+functions whose name and source position matches \fIregexp\fP.
+Multiple \fB-profile-split\fP args can be used and will be or-ed
+together.
.TP
\fB-profile-stack \fI{\fBfalse\fP|\fBtrue\fP}\fR
1.7 +4 -2 mlton/mlton/atoms/source-info.fun
Index: source-info.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/atoms/source-info.fun,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- source-info.fun 11 Feb 2003 18:05:47 -0000 1.6
+++ source-info.fun 25 Feb 2003 20:44:20 -0000 1.7
@@ -78,12 +78,14 @@
new (Function {name = name,
pos = Pos.fromRegion region})
-fun toString si =
+fun toString' (si, sep) =
case info si of
Anonymous p => Pos.toString p
| C s => concat ["<", s, ">"]
- | Function {name, pos} => concat [name, "\t", Pos.toString pos]
+ | Function {name, pos} => concat [name, sep, Pos.toString pos]
+fun toString si = toString' (si, " ")
+
val layout = Layout.str o toString
val equals: t * t -> bool =
1.5 +1 -0 mlton/mlton/atoms/source-info.sig
Index: source-info.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/atoms/source-info.sig,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- source-info.sig 28 Jan 2003 05:23:07 -0000 1.4
+++ source-info.sig 25 Feb 2003 20:44:22 -0000 1.5
@@ -25,5 +25,6 @@
val plist: t -> PropertyList.t
val polyEqual: t
val toString: t -> string
+ val toString': t * string -> string
val unknown: t
end
1.26 +7 -5 mlton/mlton/backend/profile.fun
Index: profile.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/backend/profile.fun,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- profile.fun 11 Feb 2003 04:37:35 -0000 1.25
+++ profile.fun 25 Feb 2003 20:44:22 -0000 1.26
@@ -111,12 +111,14 @@
in
infoNode
end
+ val {get = share, ...} =
+ Property.get (SourceInfo.plist, Property.initFun new)
+ val rc = Regexp.compileNFA (!Control.profileSplit)
in
- val sourceInfoNode =
- if !Control.profileCombine
- then
- #get (Property.get (SourceInfo.plist, Property.initFun new))
- else new
+ fun sourceInfoNode (si: SourceInfo.t) =
+ if Regexp.Compiled.matchesAll (rc, SourceInfo.toString si)
+ then new si
+ else share si
end
fun firstEnter (ps: Push.t list): InfoNode.t option =
List.peekMap (ps, fn p =>
1.46 +2 -1 mlton/mlton/codegen/c-codegen/c-codegen.fun
Index: c-codegen.fun
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/codegen/c-codegen/c-codegen.fun,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- c-codegen.fun 28 Jan 2003 06:47:08 -0000 1.45
+++ c-codegen.fun 25 Feb 2003 20:44:23 -0000 1.46
@@ -261,7 +261,8 @@
concat ["{(pointer)", ProfileLabel.toString label,
", ", C.int sourceSeqsIndex, "}"])
; declareArray ("string", "sources", sources,
- C.string o SourceInfo.toString o #2)
+ fn (_, si) =>
+ C.string (SourceInfo.toString' (si, "\t")))
; Vector.foreachi (sourceSeqs, fn (i, v) =>
(print (concat ["static int sourceSeq",
Int.toString i,
1.69 +1 -1 mlton/mlton/control/control.sig
Index: control.sig
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sig,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- control.sig 11 Feb 2003 04:37:35 -0000 1.68
+++ control.sig 25 Feb 2003 20:44:26 -0000 1.69
@@ -198,7 +198,7 @@
val profileBasis: bool ref
- val profileCombine: bool ref
+ val profileSplit: Regexp.t ref
datatype profileIL = ProfileSSA | ProfileSource
val profileIL: profileIL ref
1.85 +3 -3 mlton/mlton/control/control.sml
Index: control.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sml,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- control.sml 11 Feb 2003 04:37:35 -0000 1.84
+++ control.sml 25 Feb 2003 20:44:28 -0000 1.85
@@ -370,9 +370,9 @@
default = false,
toString = Bool.toString}
-val profileCombine = control {name = "profile combine",
- default = false,
- toString = Bool.toString}
+val profileSplit = control {name = "profile split",
+ default = Regexp.none,
+ toString = Regexp.toString}
datatype profileIL = datatype ProfileIL.t
1.125 +8 -4 mlton/mlton/main/main.sml
Index: main.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/main/main.sml,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- main.sml 12 Feb 2003 03:08:06 -0000 1.124
+++ main.sml 25 Feb 2003 20:44:29 -0000 1.125
@@ -172,7 +172,7 @@
(* (Normal, "I", "dir", "search dir for include files",
* push includeDirs),
*)
- (Normal, "keep", " {dot|g|o|sml|ssa}", "save intermediate files",
+ (Normal, "keep", " {g|o|sml}", "save intermediate files",
SpaceString (fn s =>
case s of
"dot" => keepDot := true
@@ -274,15 +274,19 @@
(Expert, "profile-basis", " {false|true}",
"profile the basis implementation",
boolRef profileBasis),
- (Normal, "profile-combine", " {false|true}",
- "combine all occurrences of a function",
- boolRef profileCombine),
(Expert, "profile-il", " {source}", "where to insert profile exps",
SpaceString
(fn s =>
case s of
"source" => profileIL := ProfileSource
| _ => usage (concat ["invalid -profile-il arg: ", s]))),
+ (Normal, "profile-split", " <regexp>",
+ "split occurrences of function",
+ SpaceString
+ (fn s =>
+ case Regexp.fromString s of
+ NONE => usage (concat ["invalid -profile-split regexp: ", s])
+ | SOME (r, _) => profileSplit := Regexp.or [r, !profileSplit])),
(Normal, "profile-stack", " {false|true}",
"profile the stack",
boolRef profileStack),
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel