Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/compiler/FLINT/opt/fcontract.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/FLINT/opt/fcontract.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 159, Mon Oct 12 02:45:03 1998 UTC revision 162, Tue Oct 27 22:16:21 1998 UTC
# Line 21  Line 21 
21   * - several things not mentioned   * - several things not mentioned
22   * - elimination of Con(Decon x)   * - elimination of Con(Decon x)
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)
25   *)   *)
26    
27  (* things that lcontract.sml does that fcontract doesn't do (yet):  (* things that lcontract.sml does that fcontract doesn't do (yet):
# Line 43  Line 44 
44    
45  (* things that could also be added:  (* things that could also be added:
46   * - elimination of dead vars in let (subsumes what lcontract does)   * - elimination of dead vars in let (subsumes what lcontract does)
  * - elimination of Record(a.1, a.2, ...)  
47   *)   *)
48    
49  (* things that would require some type info:  (* things that would require some type info:
50   * - dropping foo in LET vs = RAISE v IN foo   * - dropping foo in LET vs = RAISE v IN foo
  * - contracting RECORD(R.1,R.2) => R  
51   *)   *)
52    
53  (* eta-reduction is tricky:  (* eta-reduction is tricky:
# Line 533  Line 532 
532    
533        | F.SWITCH (v,ac,arms,def) =>        | F.SWITCH (v,ac,arms,def) =>
534          (case ((val2sval m v) handle x => raise x)          (case ((val2sval m v) handle x => raise x)
535            of sv as (Var{1=lvc,...} | Select{1=lvc,...} | Record{1=lvc,...}            of sv as (Var{1=lvc,...} | Select{1=lvc,...} | Decon{1=lvc, ...}
536                      | Decon{1=lvc, ...}) =>                      | (* will probably never happen *) Record{1=lvc,...}) =>
537               let fun carm (F.DATAcon(dc,tycs,lv),le) =               let fun carm (F.DATAcon(dc,tycs,lv),le) =
538                        let val ndc = cdcon dc                        let val ndc = cdcon dc
                           (* here I should try to extract the type of lv *)  
539                            val nm = addbind(m, lv, Decon(lv, F.VAR lvc, ndc, tycs))                            val nm = addbind(m, lv, Decon(lv, F.VAR lvc, ndc, tycs))
540                            (* we can rebind lv to a more precise value *)                            (* we can rebind lv to a more precise value
541                               * !!BEWARE!!  This rebinding is misleading:
542                               * - it gives the impression that `lvc' is built from
543                               *   `lv' although the reverse is true:  if `lvc' is
544                               *   undertaken, `lv's count should *not* be updated!
545                               *   Luckily, `lvc' will not become dead while rebound
546                               *   to Con(lv) because it's used by the SWITCH.
547                               *   All in all, it works fine, but it's not as
548                               *   straightforward as it seems.
549                               * - it seems to be a good idea, but it can hide
550                               *   other opt-opportunities since it hides the
551                               *   previous binding. *)
552                            val nm = addbind(nm, lvc, Con(lvc, F.VAR lv, ndc, tycs))                            val nm = addbind(nm, lvc, Con(lvc, F.VAR lv, ndc, tycs))
553                        in (F.DATAcon(ndc, tycs, lv), loop nm le)                        in (F.DATAcon(ndc, tycs, lv), loop nm le)
554                        end                        end

Legend:
Removed from v.159  
changed lines
  Added in v.162

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0