Subj : Re: Persistent storage of compiled scripts To : netscape.public.mozilla.jseng From : Thorsten R Date : Thu Jul 22 2004 10:03 am > That's right, too -- JS by definition looks up most names at run-time. > Only unambiguous local variable and argument names are resolved to stack > frame slots at compile-time. Whilst this is fine for serializing compiled scripts, it is also a bit disappointing. Execution speed would be *much* higher, if pointers were stored within scripts. Of course this conflicts with garbage collection, so I think I understand the reason (do I?). A curious question: how fast is the search for object names, i.e. is it a linear search or are the objects arranged in a tree structure or something like that? For JS 2.0: Instead of pointers, isn't there a way possible to store indices to tables in compiled scripts, where the tables contain the true pointers to objects? This method would make the lookup much faster and GC would be possible too (an object itself could also contain its indice into the table, so if the object is moved in memory it could update its pointer in the table). The table could be arranged as a tree, where each node contains a chunk of the table (say 4096 entries) and has a header what range of indices is covered. If each entry within the node is freed, the whole node could be removed from the tree, so no uncontrolled memory growth. In addition a linked list would be required, which stores ranges of unused indices - for fast assignment of an indice to a newly allocated object. However, this way serialization of compiled scripts would require to put back the object names into the script... Regards Thorsten .