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: 02847f0ef618
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c085e5747c36
Choose a head ref
  • 6 commits
  • 9 files changed
  • 1 contributor

Commits on Apr 23, 2015

  1. Copy the full SHA
    f7661d7 View commit details
  2. Copy the full SHA
    0399ce5 View commit details
  3. [Truffle] Typo.

    chrisseaton committed Apr 23, 2015
    Copy the full SHA
    1cbc92c View commit details
  4. Copy the full SHA
    fab18bb View commit details
  5. Copy the full SHA
    6326931 View commit details
  6. Copy the full SHA
    c085e57 View commit details
18 changes: 13 additions & 5 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@

import org.jcodings.Encoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jcodings.specific.UTF16BEEncoding;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.common.IRubyWarnings.ID;
@@ -60,19 +60,28 @@
import org.jruby.runtime.marshal.UnmarshalStream;
import org.jruby.util.ByteList;
import org.jruby.util.Pack;
import org.jruby.util.PerlHash;
import org.jruby.util.Qsort;
import org.jruby.util.RecursiveComparator;
import org.jruby.util.SipHashInline;
import org.jruby.util.TypeConverter;

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;

import static org.jruby.RubyEnumerator.enumeratorize;
import static org.jruby.RubyEnumerator.enumeratorizeWithSize;
import static org.jruby.runtime.Helpers.invokedynamic;
import static org.jruby.runtime.Helpers.memchr;
import static org.jruby.runtime.Visibility.PRIVATE;
import static org.jruby.runtime.invokedynamic.MethodNames.HASH;
import static org.jruby.runtime.invokedynamic.MethodNames.OP_CMP;
@@ -1781,7 +1790,7 @@ public IRubyObject call() {
len += ((RubyString) tmp).getByteList().length();
}

return joinStrings(sepString, begin + realLength,
return joinStrings(sepString, begin + realLength,
(RubyString) RubyString.newStringLight(runtime, len).infectBy(this));
}

@@ -4088,7 +4097,6 @@ public static IRubyObject try_convert(ThreadContext context, IRubyObject self, I
@JRubyMethod(name = "pack", required = 1)
public RubyString pack(ThreadContext context, IRubyObject obj) {
RubyString iFmt = obj.convertToString();

try {
return Pack.pack(context, context.runtime, this, iFmt);
} catch (ArrayIndexOutOfBoundsException aioob) {
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ def mvn(*args)
sh 'mvn', *args
end

def mspec(env, command, *args)
def mspec(command, *args)
env_vars = {}
mspec_env env_vars, command, *args
end
Original file line number Diff line number Diff line change
@@ -103,7 +103,9 @@ private RubyException translate(UnsupportedSpecializationException exception) {
for (Object value : exception.getSuppliedValues()) {
builder.append(" ");

if (value instanceof RubyBasicObject) {
if (value == null) {
builder.append("null");
} else if (value instanceof RubyBasicObject) {
builder.append(((RubyBasicObject) value).getLogicalClass().getName());
builder.append("(");
builder.append(value.getClass().getName());
@@ -134,11 +136,7 @@ private RubyException translate(UnsupportedSpecializationException exception) {
}
}
} else {
if (value == null) {
builder.append("null");
} else {
builder.append(value.getClass().getName());
}
builder.append(value.getClass().getName());
}

if (value instanceof Number || value instanceof Boolean) {
20 changes: 10 additions & 10 deletions truffle/src/main/java/org/jruby/truffle/pack/nodes/PackNode.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.pack.runtime.PackFrame;
import org.jruby.truffle.pack.runtime.PackFrameDescriptor;
import org.jruby.truffle.pack.runtime.exceptions.TooFewArgumentsException;
import org.jruby.util.ByteList;

@@ -42,18 +42,18 @@ public abstract class PackNode extends Node {
*/
public int getSourceLength(VirtualFrame frame) {
try {
return frame.getInt(PackFrame.INSTANCE.getSourceLengthSlot());
return frame.getInt(PackFrameDescriptor.SOURCE_LENGTH_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
}

/**
* Set the current position we are reading from in the source array.
* Get the current position we are reading from in the source array.
*/
protected int getSourcePosition(VirtualFrame frame) {
try {
return frame.getInt(PackFrame.INSTANCE.getSourcePositionSlot());
return frame.getInt(PackFrameDescriptor.SOURCE_POSITION_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
@@ -63,7 +63,7 @@ protected int getSourcePosition(VirtualFrame frame) {
* Set the current position we will read from next in the source array.
*/
protected void setSourcePosition(VirtualFrame frame, int position) {
frame.setInt(PackFrame.INSTANCE.getSourcePositionSlot(), position);
frame.setInt(PackFrameDescriptor.SOURCE_POSITION_SLOT, position);
}

/**
@@ -88,7 +88,7 @@ protected int advanceSourcePosition(VirtualFrame frame) {
*/
protected byte[] getOutput(VirtualFrame frame) {
try {
return (byte[]) frame.getObject(PackFrame.INSTANCE.getOutputSlot());
return (byte[]) frame.getObject(PackFrameDescriptor.OUTPUT_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
@@ -101,15 +101,15 @@ protected byte[] getOutput(VirtualFrame frame) {
*/
protected void setOutput(VirtualFrame frame, byte[] output) {
CompilerAsserts.neverPartOfCompilation();
frame.setObject(PackFrame.INSTANCE.getOutputSlot(), output);
frame.setObject(PackFrameDescriptor.OUTPUT_SLOT, output);
}

/**
* Get the current position we are writing to the in the output array.
*/
protected int getOutputPosition(VirtualFrame frame) {
try {
return frame.getInt(PackFrame.INSTANCE.getOutputPositionSlot());
return frame.getInt(PackFrameDescriptor.OUTPUT_POSITION_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
@@ -119,14 +119,14 @@ protected int getOutputPosition(VirtualFrame frame) {
* Set the current position we are writing to in the output array.
*/
protected void setOutputPosition(VirtualFrame frame, int position) {
frame.setInt(PackFrame.INSTANCE.getOutputPositionSlot(), position);
frame.setInt(PackFrameDescriptor.OUTPUT_POSITION_SLOT, position);
}

/**
* Set the output to be tainted.
*/
protected void setTainted(VirtualFrame frame) {
frame.setBoolean(PackFrame.INSTANCE.getTaintSlot(), true);
frame.setBoolean(PackFrameDescriptor.TAINT_SLOT, true);
}

/**
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.source.NullSourceSection;
import org.jruby.truffle.pack.runtime.PackEncoding;
import org.jruby.truffle.pack.runtime.PackFrame;
import org.jruby.truffle.pack.runtime.PackFrameDescriptor;
import org.jruby.truffle.pack.runtime.PackResult;
import org.jruby.truffle.runtime.util.ArrayUtils;

@@ -32,27 +32,27 @@ public class PackRootNode extends RootNode {
@CompilerDirectives.CompilationFinal private int expectedLength = ArrayUtils.capacity(0, 0);

public PackRootNode(String description, PackEncoding encoding, PackNode child) {
super(new NullSourceSection("pack", description), PackFrame.INSTANCE.getFrameDescriptor());
super(new NullSourceSection("pack", description), PackFrameDescriptor.FRAME_DESCRIPTOR);
this.description = description;
this.encoding = encoding;
this.child = child;
}

@Override
public Object execute(VirtualFrame frame) {
frame.setObject(PackFrame.INSTANCE.getSourceSlot(), frame.getArguments()[0]);
frame.setInt(PackFrame.INSTANCE.getSourceLengthSlot(), (int) frame.getArguments()[1]);
frame.setInt(PackFrame.INSTANCE.getSourcePositionSlot(), 0);
frame.setObject(PackFrame.INSTANCE.getOutputSlot(), new byte[expectedLength]);
frame.setInt(PackFrame.INSTANCE.getOutputPositionSlot(), 0);
frame.setBoolean(PackFrame.INSTANCE.getTaintSlot(), false);
frame.setObject(PackFrameDescriptor.SOURCE_SLOT, frame.getArguments()[0]);
frame.setInt(PackFrameDescriptor.SOURCE_LENGTH_SLOT, (int) frame.getArguments()[1]);
frame.setInt(PackFrameDescriptor.SOURCE_POSITION_SLOT, 0);
frame.setObject(PackFrameDescriptor.OUTPUT_SLOT, new byte[expectedLength]);
frame.setInt(PackFrameDescriptor.OUTPUT_POSITION_SLOT, 0);
frame.setBoolean(PackFrameDescriptor.TAINT_SLOT, false);

child.execute(frame);

final int outputLength;

try {
outputLength = frame.getInt(PackFrame.INSTANCE.getOutputPositionSlot());
outputLength = frame.getInt(PackFrameDescriptor.OUTPUT_POSITION_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
@@ -65,15 +65,15 @@ public Object execute(VirtualFrame frame) {
final byte[] output;

try {
output = (byte[]) frame.getObject(PackFrame.INSTANCE.getOutputSlot());
output = (byte[]) frame.getObject(PackFrameDescriptor.OUTPUT_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}

final boolean taint;

try {
taint = frame.getBoolean(PackFrame.INSTANCE.getTaintSlot());
taint = frame.getBoolean(PackFrameDescriptor.TAINT_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import com.oracle.truffle.api.frame.FrameSlotTypeException;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import org.jruby.truffle.pack.runtime.PackFrame;
import org.jruby.truffle.pack.runtime.PackFrameDescriptor;

/**
* Reads the source array from the frame - written as a node so that we can
@@ -24,7 +24,7 @@ public class SourceNode extends Node {

public Object execute(VirtualFrame frame) {
try {
return frame.getObject(PackFrame.INSTANCE.getSourceSlot());
return frame.getObject(PackFrameDescriptor.SOURCE_SLOT);
} catch (FrameSlotTypeException e) {
throw new IllegalStateException(e);
}
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@
import org.jruby.truffle.pack.runtime.exceptions.OutsideOfStringException;

/**
* Moves the output position to a particular location - similar to seek
* absolute in a file stream.
* Moves the output position to the previous byte - similar to seek
* absolute -1 in a file stream.
* <pre>
* [0xabcd, 0x1234].pack('NN') # => "\x00\x00\xAB\xCD\x00\x00\x124"
* [0xabcd, 0x1234].pack('NXN') # => "\x00\x00\xAB\x00\x00\x124"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.pack.runtime;

import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotKind;

public class PackFrameDescriptor {

public static FrameDescriptor FRAME_DESCRIPTOR = new FrameDescriptor();
public static FrameSlot SOURCE_SLOT = FRAME_DESCRIPTOR.addFrameSlot("source", FrameSlotKind.Object);
public static FrameSlot SOURCE_LENGTH_SLOT = FRAME_DESCRIPTOR.addFrameSlot("source-length", FrameSlotKind.Int);
public static FrameSlot SOURCE_POSITION_SLOT = FRAME_DESCRIPTOR.addFrameSlot("source-position", FrameSlotKind.Int);
public static FrameSlot OUTPUT_SLOT = FRAME_DESCRIPTOR.addFrameSlot("output", FrameSlotKind.Object);
public static FrameSlot OUTPUT_POSITION_SLOT = FRAME_DESCRIPTOR.addFrameSlot("output-position", FrameSlotKind.Int);
public static FrameSlot TAINT_SLOT = FRAME_DESCRIPTOR.addFrameSlot("taint", FrameSlotKind.Boolean);

}