Skip to content

Commit

Permalink
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
@@ -11,9 +11,7 @@
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotTypeException;
import com.oracle.truffle.api.frame.MaterializedFrame;
@@ -22,7 +20,6 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.ThreadLocalObject;
import org.jruby.util.Memo;

public class RubiniusLastStringReadNode extends RubyNode {

@@ -32,23 +29,9 @@ public RubiniusLastStringReadNode(RubyContext context, SourceSection sourceSecti

@Override
public Object execute(VirtualFrame frame) {
final Memo<Integer> frameCount = new Memo<>(0);

// Rubinius expects $_ to be thread-local, rather than frame-local. If we see it in a method call, we need
// to look to the caller's frame to get the correct value, otherwise it will be nil.
final MaterializedFrame callerFrame = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<MaterializedFrame>() {

@Override
public MaterializedFrame visitFrame(FrameInstance frameInstance) {
if (frameCount.get() == 0) {
return frameInstance.getFrame(FrameInstance.FrameAccess.READ_WRITE, false).materialize();
} else {
frameCount.set(frameCount.get() + 1);
return null;
}
}

});
final MaterializedFrame callerFrame = Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_ONLY, false).materialize();

final FrameSlot slot = callerFrame.getFrameDescriptor().findFrameSlot("$_");
try {

0 comments on commit b0995c6

Please sign in to comment.