Subj : Re: Rhino: Obtaining a list of script functions To : Attila Szegedi From : Igor Bukanov Date : Fri Oct 15 2004 10:22 pm Attila Szegedi wrote: > Actually, I have since found a way to enumerate DebuggableScript > objects through Debugger.handleCompilationDone() (I'm talking about 1.6 > codebase here). > > My problem is that the object behind the DebuggableScript is not the > InterpretedFunction object, but rather its InterpretedData. > > I have a script execution engine that serializes lots of script > execution contexts when they are inactive for a period of time - this > is used in conjunction with continuation support in 1.6 - then later > loads them and continues execution. The ability to stub the > InterpretedFunction instances > in serialization would allow me to eliminate redundancy at runtime - if > I have 2000 deserialized states executing the same script, each > InterpetedFunction is deserialized and duplicated in memory 2000 times. > > Now granted, stubbing InterpetedData (which is the only thing I can > enumerate through debugger.handleCompilationDone()) does help eliminate > some of the redundancy - all the deserialized states can use single > instance/function, but if I could enumerate (and therfore stub) > InterpretedFunction > instances, that'd be the real deal. Script instances do not hold any InterpretedFunction objects representing JS functions since they are created during Script.exec. Similarly the nested functions are not wrapped into InterpretedFunction until the parent function is executed. In addition function objects in JS are not read only and if you would ignore modifications of InterpretedFunction during serialize/desirialize then you would break JS code like ContructorName.prototype = ... Also note that Rhino CVS contains Context.getDebuggableView that allows to get DebuggableScript from Script without implementing Debugger interface. Regards, Igor .