comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java @ 13807:533b21375e58

SL: migration to Truffle CallNode.
author Christian Humer <christian.humer@gmail.com>
date Tue, 28 Jan 2014 13:37:07 +0100
parents 7c418666c6c9
children 5dfc531a5af1
comparison
equal deleted inserted replaced
13806:0a20f43a4a78 13807:533b21375e58
25 import com.oracle.truffle.api.*; 25 import com.oracle.truffle.api.*;
26 import com.oracle.truffle.api.frame.*; 26 import com.oracle.truffle.api.frame.*;
27 import com.oracle.truffle.api.nodes.*; 27 import com.oracle.truffle.api.nodes.*;
28 import com.oracle.truffle.sl.runtime.*; 28 import com.oracle.truffle.sl.runtime.*;
29 29
30 abstract class SLDirectDispatchNode extends SLAbstractDispatchNode { 30 final class SLDirectDispatchNode extends SLAbstractDispatchNode {
31 31
32 protected final SLFunction cachedFunction; 32 protected final SLFunction cachedFunction;
33 protected final RootCallTarget cachedCallTarget; 33 protected final RootCallTarget cachedCallTarget;
34 protected final Assumption cachedCallTargetStable; 34 protected final Assumption cachedCallTargetStable;
35 35
36 @Child protected CallNode callNode;
36 @Child protected SLAbstractDispatchNode nextNode; 37 @Child protected SLAbstractDispatchNode nextNode;
37 38
38 protected SLDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) { 39 protected SLDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) {
39 this.cachedFunction = cachedFunction; 40 this.cachedFunction = cachedFunction;
40 this.cachedCallTarget = cachedFunction.getCallTarget(); 41 this.cachedCallTarget = cachedFunction.getCallTarget();
41 this.cachedCallTargetStable = cachedFunction.getCallTargetStable(); 42 this.cachedCallTargetStable = cachedFunction.getCallTargetStable();
43 this.callNode = CallNode.create(cachedCallTarget);
42 this.nextNode = adoptChild(next); 44 this.nextNode = adoptChild(next);
43 } 45 }
44 46
45 @Override 47 @Override
46 protected final Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments) { 48 protected Object executeCall(VirtualFrame frame, SLFunction function, SLArguments arguments) {
47 if (this.cachedFunction == function) { 49 if (this.cachedFunction == function) {
48 try { 50 try {
49 cachedCallTargetStable.check(); 51 cachedCallTargetStable.check();
50 return executeCurrent(frame, arguments); 52 return callNode.call(frame.pack(), arguments);
51 } catch (InvalidAssumptionException ex) { 53 } catch (InvalidAssumptionException ex) {
52 /* 54 /*
53 * Remove ourselfs from the polymorphic inline cache, so that we fail the check only 55 * Remove ourselfs from the polymorphic inline cache, so that we fail the check only
54 * once. 56 * once.
55 */ 57 */
59 */ 61 */
60 } 62 }
61 } 63 }
62 return nextNode.executeCall(frame, function, arguments); 64 return nextNode.executeCall(frame, function, arguments);
63 } 65 }
64
65 protected abstract Object executeCurrent(VirtualFrame frame, SLArguments arguments);
66 } 66 }