Mercurial > people > rkennke > jdk9-shenandoah-final > nashorn
changeset 213:812e9cc70320
8012919: findMegaMorphicSetMethod should not cast result type
Reviewed-by: attila, sundar
Contributed-by: james.laskey@oracle.com
author | jlaskey |
---|---|
date | Mon, 22 Apr 2013 10:37:58 -0300 |
parents | ead94bc57939 |
children | cfda59f3d827 |
files | src/jdk/nashorn/internal/runtime/ScriptObject.java src/jdk/nashorn/internal/runtime/WithObject.java |
diffstat | 2 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Mon Apr 22 18:09:04 2013 +0530 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Mon Apr 22 10:37:58 2013 -0300 @@ -1892,7 +1892,7 @@ private static GuardedInvocation findMegaMorphicSetMethod(final CallSiteDescriptor desc, final String name) { final MethodType type = desc.getMethodType().insertParameterTypes(1, Object.class); - final GuardedInvocation inv = findSetIndexMethod(type, NashornCallSiteDescriptor.isStrict(desc)).asType(type); + final GuardedInvocation inv = findSetIndexMethod(type, NashornCallSiteDescriptor.isStrict(desc)); return inv.replaceMethods(MH.insertArguments(inv.getInvocation(), 1, name), inv.getGuard()); }
--- a/src/jdk/nashorn/internal/runtime/WithObject.java Mon Apr 22 18:09:04 2013 +0530 +++ b/src/jdk/nashorn/internal/runtime/WithObject.java Mon Apr 22 10:37:58 2013 -0300 @@ -232,11 +232,18 @@ return (Scope) proto; } + private static GuardedInvocation fixReceiverType(final GuardedInvocation link, final MethodHandle filter) { + // The receiver may be an Object or a ScriptObject. + final MethodType invType = link.getInvocation().type(); + final MethodType newInvType = invType.changeParameterType(0, filter.type().returnType()); + return link.asType(newInvType); + } + private static GuardedInvocation fixExpressionCallSite(final NashornCallSiteDescriptor desc, final GuardedInvocation link) { // If it's not a getMethod, just add an expression filter that converts WithObject in "this" position to its // expression. if(!"getMethod".equals(desc.getFirstOperator())) { - return link.filterArguments(0, WITHEXPRESSIONFILTER); + return fixReceiverType(link, WITHEXPRESSIONFILTER).filterArguments(0, WITHEXPRESSIONFILTER); } final MethodHandle linkInvocation = link.getInvocation(); @@ -252,10 +259,7 @@ } private static GuardedInvocation fixScopeCallSite(final GuardedInvocation link) { - // The receiver may be an object or a ScriptObject. - final MethodType invType = link.getInvocation().type(); - final MethodType newInvType = invType.changeParameterType(0, WITHSCOPEFILTER.type().returnType()); - final GuardedInvocation newLink = link.asType(newInvType); + final GuardedInvocation newLink = fixReceiverType(link, WITHSCOPEFILTER); return link.replaceMethods(filter(newLink.getInvocation(), WITHSCOPEFILTER), filterGuard(newLink, WITHSCOPEFILTER)); }