aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-03-31 21:25:27 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-03-31 21:25:27 +0000
commitd534e83da02988507374d63648d48dcb52930dac (patch)
tree22abefa2e3324d9a1089811a81cf4bafbc593359
parent86be9fa5494be9417f90f16f87eca6ab2a28631d (diff)
downloadmailfromd-d534e83da02988507374d63648d48dcb52930dac.tar.gz
mailfromd-d534e83da02988507374d63648d48dcb52930dac.tar.bz2
(dataseg_layout): Make sure all global variables are subject to final_gc
git-svn-id: file:///svnroot/mailfromd/trunk@1332 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r--ChangeLog30
-rw-r--r--src/gram.y36
2 files changed, 56 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index be99f994..965d65e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
+2007-04-01 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ * src/gram.y (dataseg_layout): Make sure all global variables are
+ subject to final_gc
+
2007-03-31 Sergey Poznyakoff <gray@gnu.org.ua>
+ Switch to flat address space model. Data space (and stack) contain
+ only references to objects within the data space (virtual
+ addresses), no actual pointers are passed.
+
+ * src/snarf.m4 (MF_ALLOC_HEAP, MF_COPY_STRING): Take two arguments
+ (MF_BEGIN_TEMP_SPACE): Use env_data_ref
+ (MF_VAR_SET_STRING): New macro
+ * src/bi_poll.m4, src/bi_string.m4, src/bi_dns.m4, src/bi_spf.m4,
+ src/bi_sa.m4, src/bi_vars.m4, src/bi_db.m4: Use new heap
+ allocation macros.
+ * src/drivers.c (code_memref, code_type_string): Use opcode_push
+ (code_type_variable): Remove opcode_svalidate. This time for good
+ * src/mailfromd.h (env_throw_0): Change signature
+ * src/prog.c (struct eval_environ.stack): Remove. Use plain
+ addressing model. All references updated.
+ (env_reference,env_var_ref): Remove
+ (heap_reserve_words, heap_reserve): Return offset into the data
+ space instead of the pointer. All uses updated.
+ (env_data_ref): New function
+ * src/opcodes (MEMEXT,MEM,SVALIDATE): Remove
+ * src/prog.h (env_data_ref): New function
+ (heap_reserve_words): New function
+ (heap_reserve): Return size_t
+ * TODO: Update
+
* src/snarf.m4, src/prog.c, src/prog.h: Use different argument
accessors for different argument types.
diff --git a/src/gram.y b/src/gram.y
index 93dd4b9c..b6fc4527 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -3397,8 +3397,23 @@ _ds_variable_fun(void *sym, void *data)
struct variable *var = sym;
size_t *offset = data;
- if (!(var->flags & VAR_VOLATILE) && (var->flags & VAR_REFERENCED))
- var->off = (*offset)++;
+ if (!(var->flags & VAR_VOLATILE) && (var->flags & VAR_REFERENCED))
+ var->off = variable_count++;
+ if ((var->flags & (VAR_VOLATILE | VAR_REFERENCED))
+ && var->type == dtype_string)
+ dataseg_reloc_count++;
+ return 0;
+}
+
+static int
+_ds_reloc_fun(void *sym, void *data)
+{
+ struct variable *var = sym;
+ size_t *pi = data;
+
+ if (var->flags & (VAR_VOLATILE | VAR_REFERENCED)
+ && var->type == dtype_string)
+ dataseg_reloc[(*pi)++] = var->off;
return 0;
}
@@ -3430,16 +3445,15 @@ dataseg_layout()
size_t i;
struct switch_stmt *sw;
- /* Count used variables */
- symbol_enumerate(SYM_VARIABLE, _ds_variable_fun, &variable_count);
-
- /* Count number of relocations and mark literals used to initialize
- variables as referenced */
+ /* Count used variables and estimate the number of relocations
+ needed */
dataseg_reloc_count = 0;
+ symbol_enumerate(SYM_VARIABLE, _ds_variable_fun, NULL);
+
+ /* Mark literals used to initialize variables as referenced */
for (dv = declvar; dv; dv = dv->next) {
if ((dv->var->flags & (VAR_VOLATILE | VAR_REFERENCED))
&& dv->var->type == dtype_string) {
- dataseg_reloc_count++;
dv->val.v.literal->flags |= VAR_REFERENCED;
}
}
@@ -3458,15 +3472,17 @@ dataseg_layout()
dataseg = xcalloc(datasize, sizeof(STKVAL));
dataseg_reloc = xcalloc(dataseg_reloc_count, sizeof *dataseg_reloc);
- /* Initialize variables */
+ /* Fill relocation table */
i = 0;
+ symbol_enumerate(SYM_VARIABLE, _ds_reloc_fun, &i);
+
+ /* Initialize variables */
for (dv = declvar; dv; dv = dv->next) {
if (dv->var->flags & (VAR_VOLATILE | VAR_REFERENCED)) {
switch (dv->var->type) {
case dtype_string:
dataseg[dv->var->off] =
(STKVAL) dv->val.v.literal->off;
- dataseg_reloc[i++] = dv->var->off;
break;
case dtype_number:

Return to:

Send suggestions and report system problems to the System administrator.