Hi, I'm still working on this with Tobias. Our current understanding of what happens is as follows: When invocation or evaluation is requested on a NashornScriptEngine, it will: 1. Fetch its current context (protected AbstractScriptEngine member field) scope: ScriptContext.ENGINE_SCOPE 2. Set this context as the global nashorn context in the current thread (internal.runtime.Context.setGlobal() -> ThreadLocal<ScriptObject> currentGlobal) 3. Do the evaluation 4. Reset the global nashorn context in the current thread (most likely to null, since ThreadLocal<ScriptObject> currentGlobal gets initialized to nothing but an empty ThreadLocal<>())
Is this rougly correct? If yes, question is, why does the context that is explicitly engine-scoped become the global scope during execution? (On a sidenote, we tried to do some things with using GLOBAL_SCOPE bindings with Nashorn in the past and it didn't work. Seems like you aren't using/supporting this at all?) ps: Here's the profiler output missing in Tobias' Mail: evernote dotcom/shard/s4/sh/1eaec11d-9732-43c3-b33d-c7e4d6e07d5f/264ff0ba4e4721525a411b5cbcb9fe6a Best regards, Benjamin
