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

Commits on Nov 11, 2014

  1. Copy the full SHA
    4120568 View commit details
  2. Copy the full SHA
    064e93d View commit details
  3. Copy the full SHA
    1ea2a18 View commit details
  4. Copy the full SHA
    38158d2 View commit details
  5. [Truffle] Sort HashNodes.

    eregon committed Nov 11, 2014
    Copy the full SHA
    b5ef0c9 View commit details
  6. Copy the full SHA
    ad8ea8b View commit details
  7. [Truffle] Copy over the singleton class in Kernel#clone.

    * Fixes the last failing specs of singleton_class/metaclass.
    eregon committed Nov 11, 2014
    Copy the full SHA
    256829d View commit details
98 changes: 60 additions & 38 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.CoreSourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
@@ -1298,44 +1299,6 @@ public Object deleteAtIntegerFixnum(RubyArray array, int index) {

}

@CoreMethod(names = {"dup", "clone"})
public abstract static class DupNode extends ArrayCoreMethodNode {

public DupNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public DupNode(DupNode prev) {
super(prev);
}

@Specialization(guards = "isNull")
public Object dupNull(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass());
}

@Specialization(guards = "isIntegerFixnum")
public Object dupIntegerFixnum(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOf((int[]) array.getStore(), array.getSize()), array.getSize());
}

@Specialization(guards = "isLongFixnum")
public Object dupLongFixnum(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOf((long[]) array.getStore(), array.getSize()), array.getSize());
}

@Specialization(guards = "isFloat")
public Object dupFloat(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOf((double[]) array.getStore(), array.getSize()), array.getSize());
}

@Specialization(guards = "isObject")
public Object dupObject(RubyArray array) {
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), Arrays.copyOf((Object[]) array.getStore(), array.getSize()), array.getSize());
}

}

@CoreMethod(names = "each", needsBlock = true)
@ImportGuards(ArrayGuards.class)
public abstract static class EachNode extends YieldingCoreMethodNode {
@@ -1851,6 +1814,65 @@ public RubyArray initialize(RubyArray array, int size, Object defaultValue) {

}

@CoreMethod(names = "initialize_copy", visibility = Visibility.PRIVATE, required = 1)
public abstract static class InitializeCopyNode extends ArrayCoreMethodNode {
// TODO(cs): what about allocationSite ?

public InitializeCopyNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public InitializeCopyNode(InitializeCopyNode prev) {
super(prev);
}

@Specialization(guards = "isOtherNull")
public RubyArray initializeCopyNull(RubyArray self, RubyArray from) {
if (self == from) {
return self;
}
self.setStore(null, 0);
return self;
}

@Specialization(guards = "isOtherIntegerFixnum")
public RubyArray initializeCopyIntegerFixnum(RubyArray self, RubyArray from) {
if (self == from) {
return self;
}
self.setStore(Arrays.copyOf((int[]) from.getStore(), from.getSize()), from.getSize());
return self;
}

@Specialization(guards = "isOtherLongFixnum")
public RubyArray initializeCopyLongFixnum(RubyArray self, RubyArray from) {
if (self == from) {
return self;
}
self.setStore(Arrays.copyOf((long[]) from.getStore(), from.getSize()), from.getSize());
return self;
}

@Specialization(guards = "isOtherFloat")
public RubyArray initializeCopyFloat(RubyArray self, RubyArray from) {
if (self == from) {
return self;
}
self.setStore(Arrays.copyOf((double[]) from.getStore(), from.getSize()), from.getSize());
return self;
}

@Specialization(guards = "isOtherObject")
public RubyArray initializeCopyObject(RubyArray self, RubyArray from) {
if (self == from) {
return self;
}
self.setStore(Arrays.copyOf((Object[]) from.getStore(), from.getSize()), from.getSize());
return self;
}

}

@CoreMethod(names = {"inject", "reduce"}, needsBlock = true, optional = 1)
@ImportGuards(ArrayGuards.class)
public abstract static class InjectNode extends YieldingCoreMethodNode {
Loading