private static CallSite getCallSiteFor(CallType callType, MethAddr methAddr) { assert callType != null: "Calltype should never be null"; String name = methAddr.getName(); switch (callType) { case NORMAL: return MethodIndex.getCallSite(name); case FUNCTIONAL: return MethodIndex.getFunctionalCallSite(name); case VARIABLE: return MethodIndex.getVariableCallSite(name); case SUPER: return MethodIndex.getSuperCallSite(); case UNKNOWN: } return null; // fallthrough for unknown }
public OpElementAsgnNode(ISourcePosition position, Node receiverNode, String operatorName, Node argsNode, Node valueNode) { super(position); assert receiverNode != null : "receiverNode is not null"; assert valueNode != null : "valueNode is not null"; this.receiverNode = receiverNode; this.argsNode = argsNode; if (argsNode instanceof ArrayNode) { ((ArrayNode)argsNode).setLightweight(true); } this.valueNode = valueNode; callAdapter = MethodIndex.getCallSite(operatorName); elementAdapter = MethodIndex.getFunctionalCallSite("[]"); elementAsgnAdapter = MethodIndex.getFunctionalCallSite("[]="); }
private CallSite jcreateSite() { // most of the time we won't need to instantiate CallSite callSite = jcreateSite; if (callSite == null) { callSite = jcreateSite = MethodIndex.getFunctionalCallSite("__jcreate!"); } return callSite; }
public Node setIterNode(Node iterNode) { this.iterNode = iterNode; // refresh call adapter, since it matters if this is iter-based or not callAdapter = MethodIndex.getCallSite(callAdapter.methodName); return this; }
public static CallSite[] setSuperCallSite(CallSite[] callSites, int index) { callSites[index] = MethodIndex.getSuperCallSite(); return callSites; }
public static IRubyObject fixnumOperator(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, long value) throws Throwable { String operator = site.name(); String opMethod = MethodIndex.getFastFixnumOpsMethod(operator); String name = "fixnum_" + opMethod; MethodType type = methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class);
Node argument = callNode.getArgsNode().childNodes().get(0); if (argument instanceof FixnumNode) { if (MethodIndex.hasFastFixnumOps(name)) { context.getInvocationCompiler().invokeBinaryFixnumRHS(name, receiverCallback, ((FixnumNode)argument).getValue()); if (!expr) context.consumeCurrentValue(); if (MethodIndex.hasFastFloatOps(name)) { context.getInvocationCompiler().invokeBinaryFloatRHS(name, receiverCallback, ((FloatNode)argument).getValue()); if (!expr) context.consumeCurrentValue();
public static CallSite getCallSite(String name) { // fast and safe respond_to? call site logic if (name.equals("respond_to?")) return new RespondToCallSite(); CallSite callSite = null; // only use fast ops if we're not tracing if (RubyInstanceConfig.FASTOPS_COMPILE_ENABLED && !(RubyInstanceConfig.FULL_TRACE_ENABLED)) { callSite = getFastFixnumOpsCallSite(name); } return callSite != null ? callSite : new NormalCachingCallSite(name); }
public static CallSite[] setVariableCallSite(CallSite[] callSites, int index, String name) { callSites[index] = MethodIndex.getVariableCallSite(name); return callSites; }
@Override public void invokeOtherOneFloat(String file, int line, CallBase call, double flote) { String id = call.getId(); if (!MethodIndex.hasFastFloatOps(id)) { pushFloat(flote); if (call.getCallType() == CallType.NORMAL) { invokeOther(file, line, null, call, 1); } else { invokeSelf(file, line, null, call, 1); } return; } String signature = sig(IRubyObject.class, params(ThreadContext.class, IRubyObject.class, IRubyObject.class)); adapter.invokedynamic( "floatOperator:" + JavaNameMangler.mangleMethodName(id), signature, Bootstrap.getFloatOperatorHandle(), flote, call.getCallType().ordinal(), "", 0); }
@Override public void invokeOtherOneFixnum(String file, int line, CallBase call, long fixnum) { String id = call.getId(); if (!MethodIndex.hasFastFixnumOps(id)) { pushFixnum(fixnum); if (call.getCallType() == CallType.NORMAL) { invokeOther(file, line, null, call, 1); } else { invokeSelf(file, line, null, call, 1); } return; } String signature = sig(IRubyObject.class, params(ThreadContext.class, IRubyObject.class, IRubyObject.class)); adapter.invokedynamic( "fixnumOperator:" + JavaNameMangler.mangleMethodName(id), signature, Bootstrap.getFixnumOperatorHandle(), fixnum, call.getCallType().ordinal(), "", 0); }
public static IRubyObject floatOperator(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, double value) throws Throwable { String operator = site.name(); String opMethod = MethodIndex.getFastFloatOpsMethod(operator); String name = "float_" + opMethod; MethodType type = methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class);
private static void processFrameFields(int bits, String methodNames, String usage, Map<String, Set<FrameField>> methodFrameAccesses) { Set<FrameField> writes = FrameField.unpack(bits); boolean needsFrame = FrameField.needsFrame(bits); boolean needsScope = FrameField.needsScope(bits); if (DEBUG) LOG.debug("Adding method fields for {}: {} for {}", usage, writes, methodNames); if (writes.size() > 0) { List<String> names = StringSupport.split(methodNames, ';'); addAwareness(needsFrame, needsScope, names); addFieldAccesses(methodFrameAccesses, names, writes); } }
private CallSite jcreateSite() { // most of the time we won't need to instantiate CallSite callSite = jcreateSite; if (callSite == null) { callSite = jcreateSite = MethodIndex.getFunctionalCallSite("__jcreate!"); } return callSite; }
public OpElementAsgnNode(ISourcePosition position, Node receiverNode, String operatorName, Node argsNode, Node valueNode) { super(position); assert receiverNode != null : "receiverNode is not null"; assert valueNode != null : "valueNode is not null"; this.receiverNode = receiverNode; this.argsNode = argsNode; if (argsNode instanceof ArrayNode) { ((ArrayNode)argsNode).setLightweight(true); } this.valueNode = valueNode; callAdapter = MethodIndex.getCallSite(operatorName); elementAdapter = MethodIndex.getFunctionalCallSite("[]"); elementAsgnAdapter = MethodIndex.getFunctionalCallSite("[]="); }
public Node setIterNode(Node iterNode) { this.iterNode = iterNode; // refresh call adapter, since it matters if this is iter-based or not callAdapter = MethodIndex.getCallSite(callAdapter.methodName); return this; }
public static CallSite[] setSuperCallSite(CallSite[] callSites, int index) { callSites[index] = MethodIndex.getSuperCallSite(); return callSites; }
public static IRubyObject fixnumOperator(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, long value) throws Throwable { String operator = site.name(); String opMethod = MethodIndex.getFastFixnumOpsMethod(operator); String name = "fixnum_" + opMethod; MethodType type = methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class);
Node argument = callNode.getArgsNode().childNodes().get(0); if (argument instanceof FixnumNode) { if (MethodIndex.hasFastFixnumOps(name)) { context.getInvocationCompiler().invokeBinaryFixnumRHS(name, receiverCallback, ((FixnumNode)argument).getValue()); if (!expr) context.consumeCurrentValue(); if (MethodIndex.hasFastFloatOps(name)) { context.getInvocationCompiler().invokeBinaryFloatRHS(name, receiverCallback, ((FloatNode)argument).getValue()); if (!expr) context.consumeCurrentValue();
public static CallSite getProfilingCallSite(String name, IRScope scope, long callsiteId) { // fast and safe respond_to? call site logic if (name.equals("respond_to?")) return new RespondToCallSite(); CallSite callSite = null; // only use fast ops if we're not tracing if (RubyInstanceConfig.FASTOPS_COMPILE_ENABLED && !(RubyInstanceConfig.FULL_TRACE_ENABLED)) { callSite = getFastFixnumOpsCallSite(name); } return callSite != null ? callSite : new ProfilingCachingCallSite(name, scope, callsiteId); }