diff -r -u mozilla/js/rhino/src/org/mozilla/javascript/optimizer/ Codegen.java mozilla-patched/js/rhino/src/org/mozilla/javascript/ optimizer/Codegen.java --- mozilla/js/rhino/src/org/mozilla/javascript/optimizer/Codegen.java 2008-03-25 07:32:27.000000000 -0700 +++ mozilla-patched/js/rhino/src/org/mozilla/javascript/optimizer/ Codegen.java 2008-04-30 15:53:21.000000000 -0700 @@ -1541,8 +1541,17 @@ } } } - - if (fnCurrent != null && !inDirectCallFunction + + // This is site of a Jetstream specific modification that is not Mozilla. + // The the reason for the change is that Jetstream requires static scoping + // for functions that do not require activation. This is because Jetstream + // uses a class derived from ScriptableObject as a kind of package. The + // code that is supposed to be in the package is executed against the object + // (which is parented to the global scope) and when it is done the Package + // object contains all of the functions and other variables defined in the + // package source file as properties. Direct call was causing these functions + // to lose their static scoping. + if (fnCurrent != null && (!compilerEnv.isUseDynamicScope() || fnCurrent.fnode.getIgnoreDynamicScope())) {
FWIW, it seems that the dynamic scoping check is completely vestigial. If I'm not mistaken (and I easily could be) dynamic scoping is handled entirely inside of ScriptRuntime now so it's probably safe to get rid of that check as well.I think it should be safe to always load the proper static scope, even if a direct call is being made and I can't imagine that the performance cost is atrocious. That being said, I don't have a good benchmark to prove it. It should be noted that without the above patch, Rhino behaves very differently with respect to certain kinds of scoping between the compiler and interpreter (the code in the previous post shows how to reproduce this if anyone is interested). I'm already maintaining a patch-set for my project so it isn't a big deal, but some change should probably be made to improve the consistency between the interpreter and optimizer. Cheers, Ben _______________________________________________ dev-tech-js-engine-rhino mailing list dev-tech-js-engine-rhino@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino