< prev index next >

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

Print this page




  72         }
  73     }
  74 
  75     @Override
  76     protected boolean needsCallee() {
  77         final boolean needsCallee = code.getFirst().needsCallee();
  78         assert allNeedCallee(needsCallee);
  79         return needsCallee;
  80     }
  81 
  82     private boolean allNeedCallee(final boolean needCallee) {
  83         for (final CompiledFunction inv : code) {
  84             if(inv.needsCallee() != needCallee) {
  85                 return false;
  86             }
  87         }
  88         return true;
  89     }
  90 
  91     @Override
  92     CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) {
  93         assert isValidCallSite(callSiteType) : callSiteType;
  94 
  95         CompiledFunction best = null;
  96         for (final CompiledFunction candidate: code) {





  97             if (!forbidden.contains(candidate) && candidate.betterThanFinal(best, callSiteType)) {
  98                 best = candidate;
  99             }
 100         }
 101 
 102         return best;
 103     }
 104 
 105     @Override
 106     MethodType getGenericType() {
 107         // We need to ask the code for its generic type. We can't just rely on this function data's arity, as it's not
 108         // actually correct for lots of built-ins. E.g. ECMAScript 5.1 section 15.5.3.2 prescribes that
 109         // Script.fromCharCode([char0[, char1[, ...]]]) has a declared arity of 1 even though it's a variable arity
 110         // method.
 111         int max = 0;
 112         for(final CompiledFunction fn: code) {
 113             final MethodType t = fn.type();
 114             if(ScriptFunctionData.isVarArg(t)) {
 115                 // 2 for (callee, this, args[])
 116                 return MethodType.genericMethodType(2, true);




  72         }
  73     }
  74 
  75     @Override
  76     protected boolean needsCallee() {
  77         final boolean needsCallee = code.getFirst().needsCallee();
  78         assert allNeedCallee(needsCallee);
  79         return needsCallee;
  80     }
  81 
  82     private boolean allNeedCallee(final boolean needCallee) {
  83         for (final CompiledFunction inv : code) {
  84             if(inv.needsCallee() != needCallee) {
  85                 return false;
  86             }
  87         }
  88         return true;
  89     }
  90 
  91     @Override
  92     CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) {
  93         assert isValidCallSite(callSiteType) : callSiteType;
  94 
  95         CompiledFunction best = null;
  96         for (final CompiledFunction candidate: code) {
  97             if (!linkLogicOkay && candidate.hasLinkLogic()) {
  98                 // Skip! Version with no link logic is desired, but this one has link logic!
  99                 continue;
 100             }
 101 
 102             if (!forbidden.contains(candidate) && candidate.betterThanFinal(best, callSiteType)) {
 103                 best = candidate;
 104             }
 105         }
 106 
 107         return best;
 108     }
 109 
 110     @Override
 111     MethodType getGenericType() {
 112         // We need to ask the code for its generic type. We can't just rely on this function data's arity, as it's not
 113         // actually correct for lots of built-ins. E.g. ECMAScript 5.1 section 15.5.3.2 prescribes that
 114         // Script.fromCharCode([char0[, char1[, ...]]]) has a declared arity of 1 even though it's a variable arity
 115         // method.
 116         int max = 0;
 117         for(final CompiledFunction fn: code) {
 118             final MethodType t = fn.type();
 119             if(ScriptFunctionData.isVarArg(t)) {
 120                 // 2 for (callee, this, args[])
 121                 return MethodType.genericMethodType(2, true);


< prev index next >