Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a9cc1b7ed3e1
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ecb7abd2a0f3
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Oct 5, 2015

  1. Copy the full SHA
    eef0e41 View commit details
  2. Copy the full SHA
    d223041 View commit details
  3. Copy the full SHA
    7103905 View commit details
  4. [Truffle] Check the length of the Hash while iterating.

    * It could change if mutated while iterating.
    * Rubinius #each_item expects this check at least in #select!.
    eregon committed Oct 5, 2015
    Copy the full SHA
    ecb7abd View commit details
3 changes: 1 addition & 2 deletions test/truffle/pe/core/binding_pe.rb
Original file line number Diff line number Diff line change
@@ -13,8 +13,7 @@
example "x = 14; binding.local_variable_get(:x) * 2", 28

# Proc#binding
tagged_example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)", 14
example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x) * 2", 28
example "x = 14; p = Proc.new { }; p.binding.local_variable_get(:x)", 14

# set + get
tagged_example "b = binding; b.local_variable_set(:x, 14); b.local_variable_get(:x)", 14
Original file line number Diff line number Diff line change
@@ -894,7 +894,7 @@ public String block() throws InterruptedException {

// Set the local variable $_ in the caller

final Frame caller = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_WRITE, false);
final Frame caller = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_WRITE, true);

final FrameSlot slot = caller.getFrameDescriptor().findFrameSlot("$_");

@@ -1244,8 +1244,7 @@ public LocalVariablesNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public DynamicObject localVariables() {
Frame frame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, false);

final Frame frame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, true);
return BindingNodes.LocalVariablesNode.listLocalVariables(getContext(), frame);
}

Original file line number Diff line number Diff line change
@@ -635,11 +635,12 @@ public Object classEval(VirtualFrame frame, DynamicObject module, DynamicObject
return classEvalSource(module, code, toStr(frame, file).toString());
}

@TruffleBoundary
private Object classEvalSource(DynamicObject module, DynamicObject code, String file) {
assert RubyGuards.isRubyString(code);

final MaterializedFrame callerFrame = RubyCallStack.getCallerFrame(getContext())
.getFrame(FrameInstance.FrameAccess.MATERIALIZE, false).materialize();
.getFrame(FrameInstance.FrameAccess.MATERIALIZE, true).materialize();
Encoding encoding = StringOperations.getByteList(code).getEncoding();

CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ public static Object matchCommon(DynamicObject regexp, DynamicObject source, boo
final ByteList bytes = StringOperations.getByteList(source);
final RubyContext context = Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(regexp)).getContext();

final Frame frame = RubyCallStack.getCallerFrame(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(regexp)).getContext()).getFrame(FrameInstance.FrameAccess.READ_WRITE, false);
final Frame frame = RubyCallStack.getCallerFrame(Layouts.MODULE.getFields(Layouts.BASIC_OBJECT.getLogicalClass(regexp)).getContext()).getFrame(FrameInstance.FrameAccess.READ_WRITE, true);

final int match = matcher.search(startPos, range, Option.DEFAULT);

Original file line number Diff line number Diff line change
@@ -499,7 +499,6 @@ public DynamicObject eachPackedArray(VirtualFrame frame, DynamicObject hash, Dyn
assert HashOperations.verifyStore(getContext(), hash);

final Object[] store = (Object[]) Layouts.HASH.getStore(hash);
final int size = Layouts.HASH.getSize(hash);

int count = 0;

@@ -509,7 +508,7 @@ public DynamicObject eachPackedArray(VirtualFrame frame, DynamicObject hash, Dyn
count++;
}

if (n < size) {
if (n < Layouts.HASH.getSize(hash)) {
yield(frame, block, Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), new Object[]{PackedArrayStrategy.getKey(store, n), PackedArrayStrategy.getValue(store, n)}, 2));
}
}
Original file line number Diff line number Diff line change
@@ -10,9 +10,11 @@

package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
@@ -26,9 +28,11 @@ public RubiniusLastStringReadNode(RubyContext context, SourceSection sourceSecti

@Override
public Object execute(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();

// 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 = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, false).materialize();
final MaterializedFrame callerFrame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, true).materialize();

final FrameSlot slot = callerFrame.getFrameDescriptor().findFrameSlot("$_");
try {
Original file line number Diff line number Diff line change
@@ -54,15 +54,15 @@ public void run(DynamicObject thread, Node currentNode) {
final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();

if (currentFrame != null) {
stack.addAll(getObjectsInFrame(currentFrame.getFrame(FrameInstance.FrameAccess.READ_ONLY, false)));
stack.addAll(getObjectsInFrame(currentFrame.getFrame(FrameInstance.FrameAccess.READ_ONLY, true)));
}

Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {

@Override
public Object visitFrame(FrameInstance frameInstance) {
stack.addAll(getObjectsInFrame(frameInstance
.getFrame(FrameInstance.FrameAccess.READ_ONLY, false)));
.getFrame(FrameInstance.FrameAccess.READ_ONLY, true)));

return null;
}