23 |
* - update counts when selecting a SWITCH alternative |
* - update counts when selecting a SWITCH alternative |
24 |
* - contracting RECORD(R.1,R.2) => R (only if the type is easily available) |
* - contracting RECORD(R.1,R.2) => R (only if the type is easily available) |
25 |
* - dropping of dead arguments |
* - dropping of dead arguments |
|
* - elimination of constant arguments |
|
26 |
*) |
*) |
27 |
|
|
28 |
(* things that lcontract.sml does that fcontract doesn't do (yet): |
(* things that lcontract.sml does that fcontract doesn't do (yet): |
44 |
|
|
45 |
(* things that could also be added: |
(* things that could also be added: |
46 |
* - elimination of dead vars in let |
* - elimination of dead vars in let |
47 |
|
* - elimination of constant arguments |
48 |
*) |
*) |
49 |
|
|
50 |
(* things that would require some type info: |
(* things that would require some type info: |
196 |
|
|
197 |
(* fun sayexn e = app say (map (fn s => s^" <- ") (SMLofNJ.exnHistory e)) *) |
(* fun sayexn e = app say (map (fn s => s^" <- ") (SMLofNJ.exnHistory e)) *) |
198 |
|
|
|
fun ASSERT (true,_) = () |
|
|
| ASSERT (FALSE,msg) = bug ("assertion "^msg^" failed") |
|
|
|
|
199 |
val cplv = LambdaVar.dupLvar |
val cplv = LambdaVar.dupLvar |
200 |
|
|
201 |
datatype sval |
datatype sval |
381 |
fun inline ifs (f,vs) = |
fun inline ifs (f,vs) = |
382 |
case ((val2sval m f) handle x => raise x) |
case ((val2sval m f) handle x => raise x) |
383 |
of Fun(g,body,args,{inline,...},od) => |
of Fun(g,body,args,{inline,...},od) => |
384 |
(ASSERT(used g, "used "^(C.LVarString g)); |
(if d <> od then (NONE, ifs) |
|
if d <> od then (NONE, ifs) |
|
385 |
else if ((C.usenb(C.get g))handle x => raise x) = 1 andalso not(S.member ifs g) then |
else if ((C.usenb(C.get g))handle x => raise x) = 1 andalso not(S.member ifs g) then |
386 |
|
|
387 |
(* simple inlining: we should copy the body and then |
(* simple inlining: we should copy the body and then |
391 |
* see comments at the begining of this file and in cfun *) |
* see comments at the begining of this file and in cfun *) |
392 |
(click_simpleinline(); |
(click_simpleinline(); |
393 |
ignore(C.unuse true (C.get g)); |
ignore(C.unuse true (C.get g)); |
|
ASSERT(not (used g), "killed"); |
|
394 |
(SOME(F.LET(map #1 args, F.RET vs, body), od), ifs)) |
(SOME(F.LET(map #1 args, F.RET vs, body), od), ifs)) |
395 |
|
|
396 |
(* aggressive inlining (but hopefully safe). We allow |
(* aggressive inlining (but hopefully safe). We allow |