Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/call/InlinedUnboxedDispatchNode.java @ 13529:856c2c294f84
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 07 Jan 2014 18:53:04 +0100 |
parents | 0fbee3eb71f0 |
children |
comparison
equal
deleted
inserted
replaced
13528:5a0c694ef735 | 13529:856c2c294f84 |
---|---|
1 /* | |
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This | |
3 * code is released under a tri EPL/GPL/LGPL license. You can use it, | |
4 * redistribute it and/or modify it under the terms of the: | |
5 * | |
6 * Eclipse Public License version 1.0 | |
7 * GNU General Public License version 2 | |
8 * GNU Lesser General Public License version 2.1 | |
9 */ | |
10 package com.oracle.truffle.ruby.nodes.call; | |
11 | |
12 import com.oracle.truffle.api.*; | |
13 import com.oracle.truffle.api.frame.*; | |
14 import com.oracle.truffle.api.nodes.*; | |
15 import com.oracle.truffle.ruby.nodes.*; | |
16 import com.oracle.truffle.ruby.runtime.*; | |
17 import com.oracle.truffle.ruby.runtime.core.*; | |
18 | |
19 public class InlinedUnboxedDispatchNode extends UnboxedDispatchNode { | |
20 | |
21 private final Class expectedClass; | |
22 private final Assumption unmodifiedAssumption; | |
23 | |
24 private final InlinableMethodImplementation method; | |
25 private final RubyRootNode rootNode; | |
26 | |
27 @Child protected UnboxedDispatchNode next; | |
28 | |
29 public InlinedUnboxedDispatchNode(RubyContext context, SourceSection sourceSection, Class expectedClass, Assumption unmodifiedAssumption, InlinableMethodImplementation method, | |
30 UnboxedDispatchNode next) { | |
31 super(context, sourceSection); | |
32 | |
33 assert expectedClass != null; | |
34 assert method != null; | |
35 | |
36 this.expectedClass = expectedClass; | |
37 this.unmodifiedAssumption = unmodifiedAssumption; | |
38 this.method = method; | |
39 this.rootNode = method.getCloneOfPristineRootNode(); | |
40 this.next = adoptChild(next); | |
41 } | |
42 | |
43 @Override | |
44 public Object dispatch(VirtualFrame frame, Object receiverObject, RubyProc blockObject, Object[] argumentsObjects) { | |
45 // Check the class is what we expect | |
46 | |
47 if (receiverObject.getClass() != expectedClass) { | |
48 return next.dispatch(frame, receiverObject, blockObject, argumentsObjects); | |
49 } | |
50 | |
51 // Check the class has not been modified | |
52 | |
53 try { | |
54 unmodifiedAssumption.check(); | |
55 } catch (InvalidAssumptionException e) { | |
56 return respecialize("class modified", frame, receiverObject, blockObject, argumentsObjects); | |
57 } | |
58 | |
59 // Call the method | |
60 | |
61 final RubyArguments arguments = new RubyArguments(method.getDeclarationFrame(), receiverObject, blockObject, argumentsObjects); | |
62 final VirtualFrame inlinedFrame = Truffle.getRuntime().createVirtualFrame(frame.pack(), arguments, method.getFrameDescriptor()); | |
63 return rootNode.execute(inlinedFrame); | |
64 } | |
65 | |
66 @Override | |
67 public void setNext(UnboxedDispatchNode next) { | |
68 this.next = adoptChild(next); | |
69 } | |
70 | |
71 } |