< prev index next >
src/jdk/nashorn/internal/codegen/ApplySpecialization.java
Print this page
rev 1494 : 8134731: Function.prototype.apply interacts incorrectly with arguments
Reviewed-by: attila, hannesw
@@ -281,21 +281,17 @@
final TypeMap ptm = compiler.getTypeMap();
if (ptm.needsCallee()) {
start++;
}
- start++; //we always uses this
+ start++; // we always use this
- final List<IdentNode> params = functionNode.getParameters();
+ assert functionNode.getNumOfParams() == 0 : "apply2call on function with named paramaters!";
final List<IdentNode> newParams = new ArrayList<>();
- final long to = Math.max(params.size(), actualCallSiteType.parameterCount() - start);
+ final long to = actualCallSiteType.parameterCount() - start;
for (int i = 0; i < to; i++) {
- if (i >= params.size()) {
newParams.add(new IdentNode(functionNode.getToken(), functionNode.getFinish(), EXPLODED_ARGUMENT_PREFIX.symbolName() + (i)));
- } else {
- newParams.add(params.get(i));
- }
}
callSiteTypes.push(actualCallSiteType);
explodedArguments.push(newParams);
}
@@ -314,10 +310,14 @@
if (!compiler.isOnDemandCompilation()) {
return false;
}
+ if (functionNode.getNumOfParams() != 0) {
+ return false;
+ }
+
if (functionNode.hasEval()) {
return false;
}
if (!hasApplies(functionNode)) {
< prev index next >