From: David Carlton <carlton@math.stanford.edu>
To: Daniel Jacobowitz <drow@mvista.com>
Cc: gdb <gdb@sources.redhat.com>
Subject: Re: struct environment
Date: Wed, 11 Sep 2002 12:27:00 -0000 [thread overview]
Message-ID: <ro1ofb472et.fsf@jackfruit.Stanford.EDU> (raw)
In-Reply-To: <20020911183628.GA30630@nevyn.them.org>
On Wed, 11 Sep 2002 14:36:28 -0400, Daniel Jacobowitz <drow@mvista.com> said:
> On Wed, Sep 11, 2002 at 11:33:08AM -0700, David Carlton wrote:
>> But I think I was making too much of the memory-management
>> difficulties: I'll do iterators correctly (so you can have as many
>> of them active as you want), and just write an ALL_ENV_SYMBOLS
>> macro that allocates them on the stack using alloca().
> Or you could just require an iterator to be declared in the function
> which uses ALL_BLOCK_SYMBOLS.... why bring alloca into it? The
> pointer you allocate into would need to be a local variable so the
> iterator might as well just be a local variable. Sure, it makes
> them a tiny bit less opaque. But make them opaque -in practice-.
I know, I'm too in love with opacity right now. Chalk it up to the
bad influence of C++, or something. (What, I can't just store my
pointer in a std::auto_ptr and have its contents deleted automatically
when it goes out of scope?)
Having said that, there's a bit more reason for these types to be
opaque than normal. There will be multiple implementations of
environments: currently fixed-size hash, fixed-size linear, and
expandable linear (for use by jv-lang.c and mdebugread.c, sigh), plus
two temporary implementions using struct block that will only exist
until all the block code is switched over to using environments. And
once I tackle global symbols, there will be at least one new permanent
environment implementation and one new temporary environment
implementation to handle that, too. Also, there is literally no
information that is common to all the different implementations, so it
simply doesn't make sense to have publically-accessible macros to get
at parts of the environment, for example. So it would be nice if,
say, adding new implementations was all localized to environment.c
plus adding one creation function prototype to symtab.h, rather than
polluting symtab.h with lots of data that only environment.c will use.
But, on the other hand, alloca() should still be avoided if possible.
And it's not like the solution using alloca() is all that clean: in an
opaque implementation, I can't alloca(sizeof struct env_iterator), so
I would have to provide a function call env_sizeof_iterator() to
return that information. And I suspect that, once we move on to the
global environment, we'll want to add a 'parent environment' member to
environments that will be there for all implementations, so it might
make sense to make environments slightly less opaque. It's even
possible that, for performance reasons, some of the functions will
have to be turned into macros eventually.
I'll think about it some more. It might well be the case that all
iterators would just need a struct environment *, a struct symbol **,
and an integer: so they all have the same data, but use it in
different ways depending on how the struct environment is
implemented. If that's the case, it would be perverse to use
alloca(): I can certainly break opaqueness to that extent.
David Carlton
carlton@math.stanford.edu
next prev parent reply other threads:[~2002-09-11 19:27 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-05 13:50 David Carlton
2002-09-06 8:06 ` Daniel Jacobowitz
2002-09-06 10:20 ` David Carlton
2002-09-06 10:57 ` Daniel Jacobowitz
2002-09-06 11:56 ` David Carlton
2002-09-06 12:34 ` Daniel Berlin
2002-09-06 12:41 ` Daniel Jacobowitz
2002-09-06 12:55 ` Daniel Berlin
2002-09-11 11:33 ` David Carlton
2002-09-11 11:36 ` Daniel Jacobowitz
2002-09-11 12:27 ` David Carlton [this message]
2002-09-06 14:43 ` David Carlton
2002-09-06 14:46 ` Daniel Jacobowitz
2002-09-06 14:57 ` mdebugread.c (was Re: struct environment) David Carlton
2002-09-06 15:35 ` Daniel Jacobowitz
2002-09-10 17:25 ` struct environment David Carlton
2002-09-10 17:31 ` Daniel Jacobowitz
2002-09-11 10:29 ` David Carlton
2002-09-11 10:55 ` Daniel Jacobowitz
2002-09-11 12:33 ` Daniel Berlin
2002-09-10 17:36 ` David Carlton
2002-09-16 22:03 ` Andrew Cagney
2002-09-06 15:00 ` David Carlton
2002-09-06 16:37 ` Tom Tromey
2002-09-06 17:19 ` David Carlton
2002-09-07 10:26 ` Per Bothner
2002-09-07 10:32 ` Daniel Jacobowitz
2002-09-09 11:18 ` David Carlton
2002-09-12 12:26 ` Andrew Cagney
2002-09-13 9:44 ` David Carlton
2002-09-17 0:48 ` Andrew Cagney
2002-09-17 6:41 ` Daniel Jacobowitz
2002-09-17 8:59 ` Andrew Cagney
2002-09-17 9:07 ` Daniel Jacobowitz
2002-09-17 10:54 ` Andrew Cagney
2002-09-17 11:02 ` Daniel Jacobowitz
2002-09-17 12:37 ` Andrew Cagney
2002-09-17 12:41 ` Daniel Jacobowitz
2002-09-18 8:13 ` Andrew Cagney
2002-09-17 12:52 ` Daniel Berlin
2002-09-17 13:34 ` Daniel Jacobowitz
2002-09-17 21:51 ` Daniel Berlin
2002-09-18 7:26 ` Daniel Jacobowitz
2002-09-18 9:08 ` David Carlton
2002-09-17 12:18 ` David Carlton
2002-09-17 10:29 ` David Carlton
2002-09-17 12:50 ` Daniel Berlin
2002-09-17 13:24 ` David Carlton
2002-09-18 22:26 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ro1ofb472et.fsf@jackfruit.Stanford.EDU \
--to=carlton@math.stanford.edu \
--cc=drow@mvista.com \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox