Subj : Re: Pairs of 32-bit pointers To : Sterling Bates From : Brendan Eich Date : Sat Dec 13 2003 12:15 pm Sterling Bates wrote: > "Brendan Eich" wrote in message > news:3FDB68D2.1020807@meer.net... > >>It wastes two words where one will do, compared to tagged jsvals as we >>have today, so it's not something that we can accept. Space utilization >>matters. This would double the size of obj->slots vectors, double the >>size of stack frames, and double the size of atom keys, e.g. > > Actually you wouldn't necessary have to double the size of the vectors. > Just use jsval * instead of jsval as the obj->slots value. Then point to > variable[1], bumping back a memory slot if you need to access variable[0]. Now you have tripled the amount of memory. Look: Today: obj->slots points to an array of jsvals, one per value. Your last post: obj->slots points to an array of twice as many jsvals, one for type, one for value, etc. Two jsvals per slot where today we have one. Your current post: obj->slots points to an array of jsval pointers, each element points to the 2nd element of a jsval[2] array. Three jsvals per slot where today we have one. > Additionally, you could use arbitrary bits on variable[0] to trim code in > other places. For instance: > > 1. One bit could represent a rooted GC thing. As I understand gc-ing, this > would eliminate the need for a gcroots hash on the runtime. User confusion > around GCing might improve too :) No. The GC has to find roots from a well-known member of the runtime. It can't inspect its heap. If you are thinking of lock-bits, we have those too, but they're not for rooting. > 2. Both JSVAL_* (bits 1-3) and JSTYPE_* (bits 4-7) values can be stored > there, reducing JS_TypeOfValue(...) to a macro. That could speed up > function calls. Nonsense. There is no JS_TypeOfValue execution on any critical path, and the JSTYPE_ fiction is used only for the typeof operator. > 3. JSString and jsdouble wouldn't need to be special cases, potentially > speeding up code where pointer indirection and private slot work might slow > things down. (I know that's a nitpick...) In JS, string and number are distinct types, so they need to be handled specially when stored and fetched. > Anyway, this all makes sense with my limited understanding :) Sorry, I think you need to study C itself, as well as the engine a bit more. Counting and estimating space required for basic data structures is an important skill. /be .