diff options
Diffstat (limited to 'src/jdk/nashorn/internal/codegen/SharedScopeCall.java')
-rw-r--r-- | src/jdk/nashorn/internal/codegen/SharedScopeCall.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/jdk/nashorn/internal/codegen/SharedScopeCall.java b/src/jdk/nashorn/internal/codegen/SharedScopeCall.java index da29ac05..078324cc 100644 --- a/src/jdk/nashorn/internal/codegen/SharedScopeCall.java +++ b/src/jdk/nashorn/internal/codegen/SharedScopeCall.java @@ -25,6 +25,8 @@ package jdk.nashorn.internal.codegen; +import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC; + import java.util.Arrays; import java.util.EnumSet; import jdk.nashorn.internal.codegen.types.Type; @@ -81,6 +83,7 @@ class SharedScopeCall { this.valueType = valueType; this.returnType = returnType; this.paramTypes = paramTypes; + assert (flags & CALLSITE_OPTIMISTIC) == 0; this.flags = flags; // If paramTypes is not null this is a call, otherwise it's just a get. this.isCall = paramTypes != null; @@ -150,7 +153,10 @@ class SharedScopeCall { method._goto(parentLoopStart); method.label(parentLoopDone); - method.dynamicGet(valueType, symbol.getName(), flags, isCall); + assert !isCall || valueType.isObject(); // Callables are always objects + // If flags are optimistic, but we're doing a call, remove optimistic flags from the getter, as they obviously + // only apply to the call. + method.dynamicGet(valueType, symbol.getName(), isCall ? CodeGenerator.nonOptimisticFlags(flags) : flags, isCall, false); // If this is a get we're done, otherwise call the value as function. if (isCall) { @@ -159,11 +165,10 @@ class SharedScopeCall { method.loadUndefined(Type.OBJECT); int slot = 2; for (final Type type : paramTypes) { - method.load(type, slot++); - if (type == Type.NUMBER || type == Type.LONG) { - slot++; - } + method.load(type, slot); + slot += type.getSlots(); } + // Shared scope calls disabled in optimistic world. TODO is this right? method.dynamicCall(returnType, 2 + paramTypes.length, flags); } @@ -179,17 +184,16 @@ class SharedScopeCall { final Type[] params = new Type[paramTypes.length + 2]; params[0] = Type.typeFor(ScriptObject.class); params[1] = Type.INT; - int i = 2; - for (Type type : paramTypes) { - if (type.isObject()) { - type = Type.OBJECT; - } - params[i++] = type; - } + System.arraycopy(paramTypes, 0, params, 2, paramTypes.length); staticSignature = Type.getMethodDescriptor(returnType, params); } } return staticSignature; } + @Override + public String toString() { + return methodName + " " + staticSignature; + } + } |