13514
|
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.yield;
|
|
11
|
|
12 import com.oracle.truffle.api.*;
|
|
13 import com.oracle.truffle.api.frame.*;
|
|
14 import com.oracle.truffle.ruby.nodes.*;
|
|
15 import com.oracle.truffle.ruby.nodes.call.*;
|
|
16 import com.oracle.truffle.ruby.runtime.*;
|
|
17 import com.oracle.truffle.ruby.runtime.core.*;
|
|
18 import com.oracle.truffle.ruby.runtime.methods.*;
|
|
19
|
|
20 /**
|
|
21 * An uninitialized node in the yield dispatch chain.
|
|
22 */
|
|
23 public class UninitializedYieldDispatchNode extends YieldDispatchNode {
|
|
24
|
|
25 public UninitializedYieldDispatchNode(RubyContext context, SourceSection sourceSection) {
|
|
26 super(context, sourceSection);
|
|
27 }
|
|
28
|
|
29 @Override
|
|
30 public Object dispatch(VirtualFrame frame, RubyProc block, Object[] argumentsObjects) {
|
|
31 CompilerDirectives.transferToInterpreter();
|
|
32
|
|
33 final MethodImplementation implementation = block.getMethod().getImplementation();
|
|
34
|
|
35 if (implementation instanceof InlinableMethodImplementation && InlineHeuristic.shouldInlineYield((InlinableMethodImplementation) implementation)) {
|
|
36 final InlinedYieldDispatchNode dispatch = new InlinedYieldDispatchNode(getContext(), getSourceSection(), (InlinableMethodImplementation) implementation);
|
|
37 replace(dispatch);
|
|
38 return dispatch.dispatch(frame, block, argumentsObjects);
|
|
39 } else {
|
|
40 final GeneralYieldDispatchNode dispatch = new GeneralYieldDispatchNode(getContext(), getSourceSection());
|
|
41 replace(dispatch);
|
|
42 return dispatch.dispatch(frame, block, argumentsObjects);
|
|
43 }
|
|
44 }
|
|
45
|
|
46 }
|