Mercurial > urweb
comparison src/mono_reduce.sml @ 1360:02fc16faecf3
[De]serialization of times in JavaScript; proper integer division in JavaScript; Basis.crypt; Top.mkRead'; more aggressive Mono-level inlining, for values of function-y types
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 23 Dec 2010 17:46:40 -0500 |
parents | e665527fce1c |
children | 802c179dac1f |
comparison
equal
deleted
inserted
replaced
1359:e525ad571e15 | 1360:02fc16faecf3 |
---|---|
90 | EFfiApp (m, x, _) => Settings.isEffectful (m, x) orelse Settings.isBenignEffectful (m, x) | 90 | EFfiApp (m, x, _) => Settings.isEffectful (m, x) orelse Settings.isBenignEffectful (m, x) |
91 | EApp ((EFfi _, _), _) => false | 91 | EApp ((EFfi _, _), _) => false |
92 | EApp _ => true | 92 | EApp _ => true |
93 | 93 |
94 | EUnop (_, e) => impure e | 94 | EUnop (_, e) => impure e |
95 | EBinop (_, e1, e2) => impure e1 orelse impure e2 | 95 | EBinop (_, _, e1, e2) => impure e1 orelse impure e2 |
96 | 96 |
97 | ERecord xes => List.exists (fn (_, e, _) => impure e) xes | 97 | ERecord xes => List.exists (fn (_, e, _) => impure e) xes |
98 | EField (e, _) => impure e | 98 | EField (e, _) => impure e |
99 | 99 |
100 | ECase (e, pes, _) => impure e orelse List.exists (fn (_, e) => impure e) pes | 100 | ECase (e, pes, _) => impure e orelse List.exists (fn (_, e) => impure e) pes |
363 IM.empty file | 363 IM.empty file |
364 | 364 |
365 val size = U.Exp.fold {typ = fn (_, n) => n, | 365 val size = U.Exp.fold {typ = fn (_, n) => n, |
366 exp = fn (_, n) => n + 1} 0 | 366 exp = fn (_, n) => n + 1} 0 |
367 | 367 |
368 fun mayInline (n, e) = | 368 val functionInside' = U.Typ.exists (fn c => case c of |
369 TFun _ => true | |
370 | _ => false) | |
371 | |
372 fun functionInside t = | |
373 case #1 t of | |
374 TFun (t1, t2) => functionInside' t1 orelse functionInside t2 | |
375 | _ => functionInside' t | |
376 | |
377 fun mayInline (n, e, t) = | |
369 case IM.find (uses, n) of | 378 case IM.find (uses, n) of |
370 NONE => false | 379 NONE => false |
371 | SOME count => count <= 1 | 380 | SOME count => count <= 1 |
372 orelse size e <= Settings.getMonoInline () | 381 orelse size e <= Settings.getMonoInline () |
382 orelse functionInside t | |
373 | 383 |
374 fun summarize d (e, _) = | 384 fun summarize d (e, _) = |
375 let | 385 let |
376 val s = | 386 val s = |
377 case e of | 387 case e of |
424 end | 434 end |
425 | 435 |
426 | EAbs _ => [] | 436 | EAbs _ => [] |
427 | 437 |
428 | EUnop (_, e) => summarize d e | 438 | EUnop (_, e) => summarize d e |
429 | EBinop (_, e1, e2) => summarize d e1 @ summarize d e2 | 439 | EBinop (_, _, e1, e2) => summarize d e1 @ summarize d e2 |
430 | 440 |
431 | ERecord xets => List.concat (map (summarize d o #2) xets) | 441 | ERecord xets => List.concat (map (summarize d o #2) xets) |
432 | EField (e, _) => summarize d e | 442 | EField (e, _) => summarize d e |
433 | 443 |
434 | ECase (e, pes, _) => | 444 | ECase (e, pes, _) => |
699 | U.Decl.RelE (x, t) => E.pushERel env x t NONE | 709 | U.Decl.RelE (x, t) => E.pushERel env x t NONE |
700 | U.Decl.NamedE (x, n, t, eo, s) => | 710 | U.Decl.NamedE (x, n, t, eo, s) => |
701 let | 711 let |
702 val eo = case eo of | 712 val eo = case eo of |
703 NONE => NONE | 713 NONE => NONE |
704 | SOME e => if mayInline (n, e) then | 714 | SOME e => if mayInline (n, e, t) then |
705 SOME e | 715 SOME e |
706 else | 716 else |
707 NONE | 717 NONE |
708 in | 718 in |
709 E.pushENamed env x n t (Option.map (reduceExp env) eo) s | 719 E.pushENamed env x n t (Option.map (reduceExp env) eo) s |