changeset 921:ae0110465421

Don't replace <sc> in blob returns; optimize more 'option' pattern matches; detect more opportunities for 'let' inlining
author Adam Chlipala <adamc@hcoop.net>
date Wed, 09 Sep 2009 08:00:45 -0400
parents 7accd4546cf9
children d6a71f19a3d8
files src/c/urweb.c src/mono_reduce.sml
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/urweb.c	Tue Sep 08 20:12:17 2009 -0400
+++ b/src/c/urweb.c	Wed Sep 09 08:00:45 2009 -0400
@@ -346,6 +346,7 @@
   void *get_header_data;
 
   buf outHeaders, page, heap, script;
+  int returning_blob;
   input *inputs, *subinputs, *cur_container;
   size_t n_subinputs, used_subinputs;
 
@@ -386,6 +387,7 @@
 
   buf_init(&ctx->outHeaders, 0);
   buf_init(&ctx->page, 0);
+  ctx->returning_blob = 0;
   buf_init(&ctx->heap, 0);
   buf_init(&ctx->script, 1);
   ctx->script.start[0] = 0;
@@ -458,6 +460,7 @@
   buf_reset(&ctx->script);
   ctx->script.start[0] = 0;
   buf_reset(&ctx->page);
+  ctx->returning_blob = 0;
   buf_reset(&ctx->heap);
   ctx->regions = NULL;
   ctx->cleanup_front = ctx->cleanup;
@@ -2549,7 +2552,7 @@
     ctx->transactionals[i].free(ctx->transactionals[i].data);
 
   // Splice script data into appropriate part of page
-  if (ctx->script_header[0] == 0)
+  if (ctx->returning_blob || ctx->script_header[0] == 0)
     ;
   else if (buf_used(&ctx->script) == 0) {
     size_t len = strlen(ctx->script_header);
@@ -2776,6 +2779,7 @@
   cleanup *cl;
   int len;
 
+  ctx->returning_blob = 1;
   buf_reset(&ctx->outHeaders);
   buf_reset(&ctx->page);
 
--- a/src/mono_reduce.sml	Tue Sep 08 20:12:17 2009 -0400
+++ b/src/mono_reduce.sml	Wed Sep 09 08:00:45 2009 -0400
@@ -237,7 +237,9 @@
         end
 
       | (PNone _, ENone _) => Yes env
+      | (PNone _, ESome _) => No
       | (PSome (_, p), ESome (_, e)) => match (env, p, e)
+      | (PSome _, ENone _) => No
 
       | _ => Maybe
 
@@ -543,7 +545,7 @@
                                     val effs_b = summarize 0 b
 
                                     (*val () = Print.prefaces "Try"
-                                                            [("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan)),
+                                                            [(*("e", MonoPrint.p_exp env (e, ErrorMsg.dummySpan)),*)
                                                              ("e'", MonoPrint.p_exp env e'),
                                                              ("e'_eff", p_events effs_e'),
                                                              ("b", p_events effs_b)]*)
@@ -574,8 +576,12 @@
                                                     ("b", MonoPrint.p_exp (E.pushERel env x t NONE) b),
                                                     ("effs_e'", Print.p_list p_event effs_e'),
                                                     ("effs_b", Print.p_list p_event effs_b)];*)
-                                    if List.null effs_e' orelse (List.all (fn eff => eff <> Unsure) effs_e'
-                                                                 andalso verifyCompatible effs_b) then
+                                    if List.null effs_e'
+                                       orelse (List.all (fn eff => eff <> Unsure) effs_e'
+                                               andalso verifyCompatible effs_b)
+                                       orelse (case effs_b of
+                                                   UseRel :: effs => List.all verifyUnused effs
+                                                 | _ => false) then
                                         trySub ()
                                     else
                                         e