We (eclipse dltk project) already have something for this patched in our js
code:
public Object get(String name, Scriptable start)
{
Context currentContext = Context.getCurrentContext();
if (currentContext != null)
{
Debugger debugger = currentContext.getDebugger();
if (debugger instanceof IDeguggerWithWatchPoints)
{
IDeguggerWithWatchPoints wp = (IDeguggerWithWatchPoints)
debugger;
wp.access(name, this);
}
}
This is for access and modification (what you want) in the IdScriptable
class
I would hope that something like this would also make it in a release of
rhino so that the debugger can have watchpoint support
johan
On Wed, Nov 12, 2008 at 3:56 PM, David Parks <[EMAIL PROTECTED]> wrote:
> I have a question that I think I know the answer to, but before I commit
> myself I want to validate that I am correct.
>
> The question: (the important part)
> ==============
> I have set up an implementation of an embedded debugger. I want to know if
> I
> can be notified any time a new attribute is added to my instance scope
> (specifically, that's the scope that the script is running under, and any
> child ScriptableObject(s) under it).
>
>
> Why I need this: (extra detail)
> =================
> I need to calculate the relative memory a script consumes (I don't need
> absolute memory used, just a number I can compute relative to what other
> scripts are running so that I can keep untrusted scripts from
> over-allocating memory).
>
>
> My current approach: (fyi)
> ====================
> Is to recursively iterate over all ScriptableObject(s) from the instance
> scope down using Scriptable.getIds() after every X lines of code execute.
> It's pretty easy to computer a numeric value for each possible attribute
> (null, Undefined, Number, String, Object+it's recursive attributes).
> However
> I run into a problem with multiple references (e.g. var y = new
> Array("Green", "Blue"); var z = y[0]; both reference the same string
> object). So if I use my approach I count the string "Green" twice which
> isn't a fair representation of the actual memory utilization.
>
> My best solution to this, if I can't just get notified of a new attribute
> creation, is to add a flag to ScriptableObject, then my recursive algorithm
> above can flip it on each memCount operation to ensure it doesn't double
> count objects with multiple references. However this requires me to change
> the Rhino base classes which is inelegant. Not to mention the fact that a
> full scan each X steps is inefficient. Thus my search for a better
> solution.
>
>
> Thanks!
> David
>
> p.s. Norris: thanks for the previous response, I just didn't understand the
> delete operator well enough, it now makes sense how to deal with the case.
>
>
>
>
> _______________________________________________
> dev-tech-js-engine-rhino mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino