diff options
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/GlobalConstants.java')
-rw-r--r-- | src/jdk/nashorn/internal/runtime/GlobalConstants.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/jdk/nashorn/internal/runtime/GlobalConstants.java b/src/jdk/nashorn/internal/runtime/GlobalConstants.java index df947cdb..3a104812 100644 --- a/src/jdk/nashorn/internal/runtime/GlobalConstants.java +++ b/src/jdk/nashorn/internal/runtime/GlobalConstants.java @@ -309,7 +309,7 @@ public final class GlobalConstants implements Loggable { * * @param find property lookup * @param inv normal guarded invocation for this setter, as computed by the ScriptObject linker - * @param desc callsite descriptr + * @param desc callsite descriptor * @param request link request * * @return null if failed to set up constant linkage @@ -376,8 +376,12 @@ public final class GlobalConstants implements Loggable { * @return resulting getter, or null if failed to create constant */ synchronized GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) { - // Also return null if property may have side effects - if ((GLOBAL_ONLY && !find.getOwner().isGlobal()) || find.getProperty() instanceof UserAccessorProperty) { + // Only use constant getter for fast scope access, because the receiver may change between invocations + // for slow-scope and non-scope callsites. + // Also return null for user accessor properties as they may have side effects. + if (!NashornCallSiteDescriptor.isFastScope(desc) + || (GLOBAL_ONLY && !find.getOwner().isGlobal()) + || find.getProperty() instanceof UserAccessorProperty) { return null; } |