src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java

Print this page




1984     protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
1985         final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
1986 
1987         String name;
1988         name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
1989         if (NashornCallSiteDescriptor.isApplyToCall(desc)) {
1990             if (Global.isBuiltinFunctionPrototypeApply()) {
1991                 name = "call";
1992             }
1993         }
1994 
1995         if (request.isCallSiteUnstable() || hasWithScope()) {
1996             return findMegaMorphicGetMethod(desc, name, "getMethod".equals(operator));
1997         }
1998 
1999         final FindProperty find = findProperty(name, true);
2000         MethodHandle mh;
2001 
2002         if (find == null) {
2003             switch (operator) {

2004             case "getProp":
2005                 return noSuchProperty(desc, request);
2006             case "getMethod":
2007                 return noSuchMethod(desc, request);
2008             case "getElem":
2009                 return createEmptyGetter(desc, explicitInstanceOfCheck, name);
2010             default:
2011                 throw new AssertionError(operator); // never invoked with any other operation
2012             }
2013         }
2014 
2015         final GlobalConstants globalConstants = getGlobalConstants();
2016         if (globalConstants != null) {
2017             final GuardedInvocation cinv = globalConstants.findGetMethod(find, this, desc);
2018             if (cinv != null) {
2019                 return cinv;
2020             }
2021         }
2022 
2023         final Class<?> returnType = desc.getMethodType().returnType();
2024         final Property property   = find.getProperty();
2025 
2026         final int programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ?
2027                 NashornCallSiteDescriptor.getProgramPoint(desc) :
2028                 UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
2029 




1984     protected GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
1985         final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);
1986 
1987         String name;
1988         name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
1989         if (NashornCallSiteDescriptor.isApplyToCall(desc)) {
1990             if (Global.isBuiltinFunctionPrototypeApply()) {
1991                 name = "call";
1992             }
1993         }
1994 
1995         if (request.isCallSiteUnstable() || hasWithScope()) {
1996             return findMegaMorphicGetMethod(desc, name, "getMethod".equals(operator));
1997         }
1998 
1999         final FindProperty find = findProperty(name, true);
2000         MethodHandle mh;
2001 
2002         if (find == null) {
2003             switch (operator) {
2004             case "getElem": // getElem only gets here if element name is constant, so treat it like a property access
2005             case "getProp":
2006                 return noSuchProperty(desc, request);
2007             case "getMethod":
2008                 return noSuchMethod(desc, request);


2009             default:
2010                 throw new AssertionError(operator); // never invoked with any other operation
2011             }
2012         }
2013 
2014         final GlobalConstants globalConstants = getGlobalConstants();
2015         if (globalConstants != null) {
2016             final GuardedInvocation cinv = globalConstants.findGetMethod(find, this, desc);
2017             if (cinv != null) {
2018                 return cinv;
2019             }
2020         }
2021 
2022         final Class<?> returnType = desc.getMethodType().returnType();
2023         final Property property   = find.getProperty();
2024 
2025         final int programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ?
2026                 NashornCallSiteDescriptor.getProgramPoint(desc) :
2027                 UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
2028