Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
more vtables
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dan Sugalski  
View profile  
 More options Nov 1 2004, 3:17 pm
Newsgroups: perl.perl6.internals
From: d...@sidhe.org (Dan Sugalski)
Date: Mon, 1 Nov 2004 15:17:58 -0500
Local: Mon, Nov 1 2004 3:17 pm
Subject: Re: more vtables
At 9:03 PM +0100 11/1/04, Leopold Toetsch wrote:

>We need more vtables.

>* INTVAL hash()

>To properly support Python, we need:
>- a hash PMC that isn't restricted to STRING* keys - low level hash
>code has AFAIK already all the necessary stuff, or mostly. I don't
>know, how much Python specific it really is, but Perl5's "hashing
>objects as strings" isn't really what we want AFAIK.
>Anyway, every hashable PMC should have such a vtable slot to produce
>a unique and reproducable hash value according to the - well value -
>of that PMC. UT python SL.

Works for me. We probably need to make sure that everything's in
place for keys to tag the individual key elements properly too.

>* void finalize()

>We should separate finalize() from the destroy() vtable.
>Currently only closing PIOs and shutting down timer PMCs is
>concerned. but these are good examples of already existing code to
>investigate some of the implications, which are no fun - thanks Dan
>for the blog.

Any reason that the destroy entry's insufficient? That's what I'd
intended it to do, at least.

I can see thinking about changing the scheme we use to destroy
things, certainly (like, say, putting the pmcs that need destruction
in a queue, tagging them as having been queued, run the queue and
trigger the destroy method, tag them as having been destroyed, then
if they come up as dead in the next round of DOD assume they're
garbage), but I'm not sure we need to split finalization and
destruction. Not that I mind, certainly, if there's something I'm
missing. :)
--
                                Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
d...@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Ruby  
View profile  
 More options Nov 1 2004, 4:04 pm
Newsgroups: perl.perl6.internals
From: ru...@intertwingly.net (Sam Ruby)
Date: Mon, 01 Nov 2004 16:04:15 -0500
Local: Mon, Nov 1 2004 4:04 pm
Subject: Re: more vtables

Leopold Toetsch wrote:
> We need more vtables.

> * INTVAL hash()

> To properly support Python, we need:
> - a hash PMC that isn't restricted to STRING* keys - low level hash code
> has AFAIK already all the necessary stuff, or mostly. I don't know, how
> much Python specific it really is, but Perl5's "hashing objects as
> strings" isn't really what we want AFAIK.
> Anyway, every hashable PMC should have such a vtable slot to produce a
> unique and reproducable hash value according to the - well value - of
> that PMC. UT python SL.

I've been looking into Python's dict code (see links below), and it
actually is pretty sweet.  Everything is stored in a single flat array
that doubles in size whenever it reaches 2/3 full.

Notable features of Python dicts:

Only things that are immutable are expected to have hash functions.
Tuple, for example, does have a __hash__ function; list does not.  Nor
does dict.  Unless Parrot has an equivalent notion, it will have to
clone the key.

There also is interesting semantics with respect to values (or more
precisely, the semantics of an assignment statement).  At the moment
pirate is consistent with Python on the following, but pie-thon is not:

   a=1
   d={"a":a}
   a=2
   print d

   a=[1]
   d={"a":a}
   a[0]=2
   print d

The "correct" result is:

   {'a': 1}
   {'a': [2]}

With pie-thon, the results are:

   {'a': 2}
   {'a': [2]}

- Sam Ruby

http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/...
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options Nov 2 2004, 3:41 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Tue, 2 Nov 2004 09:41:42 +0100
Local: Tues, Nov 2 2004 3:41 am
Subject: Re: more vtables

Dan Sugalski <d...@sidhe.org> wrote:
> At 9:03 PM +0100 11/1/04, Leopold Toetsch wrote:
>>We need more vtables.

>>* INTVAL hash()

>>To properly support Python, we need:
>>- a hash PMC that isn't restricted to STRING* keys
> Works for me. We probably need to make sure that everything's in
> place for keys to tag the individual key elements properly too.

There is one entry in the hash structure:

  Hash_key_type key_type;

That should suffice. I don't think, we should mix STRING and PMC keys in
one hash - or only with care: a STRING "foo" and a String PMC "foo" hash
to the same hash value. An Integer PMC C<1> and a STRING key "1" are
different.

>>* void finalize()

>>We should separate finalize() from the destroy() vtable.
> Any reason that the destroy entry's insufficient? That's what I'd
> intended it to do, at least.

These two have different usage patterns.

destroy() is needed commonly to free memory. finalize() is currently
needed to close file handles and clear active timer PMCs.

> I can see thinking about changing the scheme we use to destroy
> things, certainly (like, say, putting the pmcs that need destruction
> in a queue, tagging them as having been queued, run the queue and
> trigger the destroy method, tag them as having been destroyed, then
> if they come up as dead in the next round of DOD assume they're
> garbage), but I'm not sure we need to split finalization and
> destruction.

When we have objects with finalizers, we have to run the finalizers in
order from most derived down the parent chain. So as you state, we've to
defer destruction, store these objects with finalizers somewhere, sort
them, run user code to finalize objects and so on.

Doing that all in the destroy vtable is tedious especially, when user
code is involved too. The finalize vtable is overridable, the destroy
isn't. A split makes this functionality much cleaner.

leo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Clites  
View profile  
 More options Nov 2 2004, 11:42 am
Newsgroups: perl.perl6.internals
From: jcli...@mac.com (Jeff Clites)
Date: Tue, 2 Nov 2004 08:42:26 -0800
Local: Tues, Nov 2 2004 11:42 am
Subject: Re: more vtables
On Nov 2, 2004, at 12:41 AM, Leopold Toetsch wrote:

> When we have objects with finalizers, we have to run the finalizers in
> order from most derived down the parent chain.

Maybe, but not necessarily. The case of loops means that we cannot
always do this cleanly (no "top" of the chain), and the fact that
finalizers may modify the topology of the object graph also makes this
a bit ill-defined. There are several possible approaches, ranging from
very conservative to very aggresive. Two real-world approaches already
used are: make no guarantees about finalization order--only guarantee
that a finalizer will be called at some point after an object becomes
unreferenced, with no guarantees about ordering, and no guarantees that
it will not be called if the object has already be re-rooted (Java);
or, do graph-ordered finalization, and never call the finalizers of
objects which are in loops (the Boehm collector does something along
these lines, I believe).

> So as you state, we've to
> defer destruction, store these objects with finalizers somewhere, sort
> them, run user code to finalize objects and so on.

Other objects are impacted as well--any object reachable from a
finalizable object must wait for reclamation until finalizers have
fired.

> Doing that all in the destroy vtable is tedious especially, when user
> code is involved too. The finalize vtable is overridable, the destroy
> isn't. A split makes this functionality much cleaner.

I think what's bothering me about this is that I think part of the idea
is to move closing of filehandles and such into destroy()--right? That
sounds good--don't get rid of this resource until it's certain nothing
will try to use it (eg, things which want to log a message during their
finalization would use a filehandle). But I don't think this really
solves it. For one thing, there will be similar-in-functionality code
coming up in HLL's (doing some orderly shutdown of connections, which
involves more than just closing the filehandle), and this will have to
happen in a finalizer (since that's the only HLL option), which will
feel "too early" in some cases. And even in a destroy(), you might want
to do some I/O, and whether this will work will depend on whether the
filehandles have been closed yet, and the same ordering concerns
re-emerge.

So I think the split would help, in a sense, but only be a partial
solution to an unsolvable problem, and therefore maybe is not very
elegant. So I'm a bit on the fence.

(And in my parlance, just to be clear: "finalizers" are called after an
object becomes un-referenced, and could re-root an object;
"destructors" are called when the object is actually having its memory
re-claimed--when it is going away for sure. No user code can be called
from a destructor in the Parrot case, because of the possibility of
re-rooting, and because of other constraints which may exist at
destroy-time.)

JEff


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google