comparison src/alloc.c @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 859a2309aef8
children 1917ad0d78d7
comparison
equal deleted inserted replaced
25:383a494979f8 26:441bb1e64a06
214 pure_lossage += size; 214 pure_lossage += size;
215 return (0); 215 return (0);
216 } 216 }
217 else if (pureptr + size > PURESIZE) 217 else if (pureptr + size > PURESIZE)
218 { 218 {
219 message ("\nERROR: Pure Lisp storage exhausted!\n"); 219 /* This can cause recursive bad behavior, we'll yell at the end */
220 /* when we're done. */
221 /* message ("\nERROR: Pure Lisp storage exhausted!\n"); */
220 pure_lossage = size; 222 pure_lossage = size;
221 return (0); 223 return (0);
222 } 224 }
223 else 225 else
224 return (1); 226 return (1);
2545 { 2547 {
2546 if (COMPILED_FUNCTIONP (obj)) 2548 if (COMPILED_FUNCTIONP (obj))
2547 { 2549 {
2548 struct Lisp_Compiled_Function *o = XCOMPILED_FUNCTION (obj); 2550 struct Lisp_Compiled_Function *o = XCOMPILED_FUNCTION (obj);
2549 Lisp_Object new = make_compiled_function (1); 2551 Lisp_Object new = make_compiled_function (1);
2550 struct Lisp_Compiled_Function *n = XCOMPILED_FUNCTION (obj); 2552 /* How on earth could this code have worked before? -sb */
2553 struct Lisp_Compiled_Function *n = XCOMPILED_FUNCTION (new);
2551 n->flags = o->flags; 2554 n->flags = o->flags;
2552 n->bytecodes = Fpurecopy (o->bytecodes); 2555 n->bytecodes = Fpurecopy (o->bytecodes);
2553 n->constants = Fpurecopy (o->constants); 2556 n->constants = Fpurecopy (o->constants);
2554 n->arglist = Fpurecopy (o->arglist); 2557 n->arglist = Fpurecopy (o->arglist);
2555 n->doc_and_interactive = Fpurecopy (o->doc_and_interactive); 2558 n->doc_and_interactive = Fpurecopy (o->doc_and_interactive);
2559 n->maxdepth = o->maxdepth;
2556 return (new); 2560 return (new);
2557 } 2561 }
2558 #ifdef LISP_FLOAT_TYPE 2562 #ifdef LISP_FLOAT_TYPE
2559 else if (FLOATP (obj)) 2563 else if (FLOATP (obj))
2560 return make_pure_float (float_data (XFLOAT (obj))); 2564 return make_pure_float (float_data (XFLOAT (obj)));
2566 return (obj); 2570 return (obj);
2567 } 2571 }
2568 2572
2569 2573
2570 2574
2575 static void
2576 PURESIZE_h(long int puresize)
2577 {
2578 int fd;
2579 char *PURESIZE_h_file = "PURESIZE.h";
2580 char *WARNING = "/* This file is generated by XEmacs, DO NOT MODIFY!!! */\n";
2581 char define_PURESIZE[256];
2582
2583 if ((fd = open(PURESIZE_h_file, O_WRONLY|O_CREAT)) < 0) {
2584 report_file_error("Can't write PURESIZE",
2585 Fcons(build_ext_string(PURESIZE_h_file, FORMAT_FILENAME),
2586 Qnil));
2587 }
2588
2589 write(fd, WARNING, strlen(WARNING));
2590 sprintf(define_PURESIZE, "# define PURESIZE %ld\n", puresize);
2591 write(fd, define_PURESIZE, strlen(define_PURESIZE));
2592 close(fd);
2593 }
2594
2571 void 2595 void
2572 report_pure_usage (int report_impurities, 2596 report_pure_usage (int report_impurities,
2573 int die_if_pure_storage_exceeded) 2597 int die_if_pure_storage_exceeded)
2574 { 2598 {
2599 int rc = 0;
2600
2575 if (pure_lossage) 2601 if (pure_lossage)
2576 { 2602 {
2577 CONST long report_round = 5000; 2603 CONST long report_round = 5000;
2578 2604
2579 message ("\n****\tPure Lisp storage exhausted!\n" 2605 message ("\n****\tPure Lisp storage exhausted!\n"
2580 "\tCheck whether you are loading .el files when .elc files were intended.\n"
2581 "\tOtherwise, increase PURESIZE in puresize.h and relink.\n\n"
2582 "\tPURESIZE is presently %ld.\n"
2583 "\tAn additional %ld bytes will guarantee enough pure space;\n" 2606 "\tAn additional %ld bytes will guarantee enough pure space;\n"
2584 "\ta smaller increment may work (due to structure-sharing).\n" 2607 "\ta smaller increment may work (due to structure-sharing).\n"
2585 "****", 2608 "****",
2586 (long) PURESIZE,
2587 (((pure_lossage + report_round - 1) 2609 (((pure_lossage + report_round - 1)
2588 / report_round) * report_round)); 2610 / report_round) * report_round));
2611 if (die_if_pure_storage_exceeded) {
2612 PURESIZE_h(PURESIZE + pure_lossage);
2613 rc = -1;
2614 }
2589 } 2615 }
2590 else 2616 else
2591 { 2617 {
2592 int lost = (PURESIZE - pureptr) / 1024; 2618 int lost = (PURESIZE - pureptr) / 1024;
2593 char buf[200]; 2619 char buf[200];
2594 2620
2595 sprintf (buf, "Purespace usage: %ld of %ld (%d%%", 2621 sprintf (buf, "Purespace usage: %ld of %ld (%d%%",
2596 pureptr, (long) PURESIZE, 2622 pureptr, (long) PURESIZE,
2597 (int) (pureptr / (PURESIZE / 100.0) + 0.5)); 2623 (int) (pureptr / (PURESIZE / 100.0) + 0.5));
2598 if (lost > 2) 2624 if (lost > 2) {
2599 sprintf (buf + strlen (buf), " -- %dk wasted", lost); 2625 sprintf (buf + strlen (buf), " -- %dk wasted", lost);
2626 if (die_if_pure_storage_exceeded) {
2627 PURESIZE_h(pureptr + 16);
2628 rc = -1;
2629 }
2630 }
2631
2600 strcat (buf, ")."); 2632 strcat (buf, ").");
2601 message ("%s", buf); 2633 message ("%s", buf);
2602 } 2634 }
2603 2635
2604 #ifdef PURESTAT 2636 #ifdef PURESTAT
2677 UNGCPRO; 2709 UNGCPRO;
2678 garbage_collect_1 (); /* GC garbage_collect's garbage */ 2710 garbage_collect_1 (); /* GC garbage_collect's garbage */
2679 } 2711 }
2680 clear_message (); 2712 clear_message ();
2681 2713
2682 if (pure_lossage && die_if_pure_storage_exceeded) 2714 if (rc < 0) {
2715 fatal ("Pure size adjusted, will restart `make'");
2716 } else if (pure_lossage && die_if_pure_storage_exceeded) {
2683 fatal ("Pure storage exhausted"); 2717 fatal ("Pure storage exhausted");
2718 }
2719 (void)sys_unlink("SATISFIED");
2684 } 2720 }
2685 2721
2686 2722
2687 /**********************************************************************/ 2723 /**********************************************************************/
2688 /* staticpro */ 2724 /* staticpro */
4112 { 4148 {
4113 Lisp_Object pl = Qnil; 4149 Lisp_Object pl = Qnil;
4114 Lisp_Object ret[6]; 4150 Lisp_Object ret[6];
4115 int i; 4151 int i;
4116 4152
4153 if (purify_flag && pure_lossage)
4154 {
4155 return Qnil;
4156 }
4157
4117 garbage_collect_1 (); 4158 garbage_collect_1 ();
4118 4159
4119 for (i = 0; i < last_lrecord_type_index_assigned; i++) 4160 for (i = 0; i < last_lrecord_type_index_assigned; i++)
4120 { 4161 {
4121 if (lcrecord_stats[i].bytes_in_use != 0 4162 if (lcrecord_stats[i].bytes_in_use != 0