Skip to content

Commit

Permalink
[Truffle] Array allocation sites weren't really being used.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 12, 2015
1 parent 43b68cd commit 2e8f5e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 77 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,40 +131,24 @@ private RubyArray makeGeneric(VirtualFrame frame,

public static class IntegerFixnumArrayLiteralNode extends ArrayLiteralNode {

private final ArrayAllocationSite arrayAllocationSite = new ArrayAllocationSite();

public IntegerFixnumArrayLiteralNode(RubyContext context, SourceSection sourceSection, RubyNode[] values) {
super(context, sourceSection, values);
}

@ExplodeLoop
@Override
public RubyArray executeRubyArray(VirtualFrame frame) {
if (arrayAllocationSite.hasConvertedIntToLong()) {
final long[] executedValues = new long[values.length];

for (int n = 0; n < values.length; n++) {
try {
executedValues[n] = values[n].executeLong(frame);
} catch (UnexpectedResultException e) {
return makeGeneric(frame, executedValues, n);
}
}
final int[] executedValues = new int[values.length];

return new RubyArray(getContext().getCoreLibrary().getArrayClass(), arrayAllocationSite, executedValues, values.length);
} else {
final int[] executedValues = new int[values.length];

for (int n = 0; n < values.length; n++) {
try {
executedValues[n] = values[n].executeInteger(frame);
} catch (UnexpectedResultException e) {
return makeGeneric(frame, executedValues, n);
}
for (int n = 0; n < values.length; n++) {
try {
executedValues[n] = values[n].executeInteger(frame);
} catch (UnexpectedResultException e) {
return makeGeneric(frame, executedValues, n);
}

return new RubyArray(getContext().getCoreLibrary().getArrayClass(), arrayAllocationSite, executedValues, values.length);
}

return new RubyArray(getContext().getCoreLibrary().getArrayClass(), executedValues, values.length);
}

private RubyArray makeGeneric(VirtualFrame frame,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public RubyArray mulIntegerFixnum(RubyArray array, int count) {
System.arraycopy(store, 0, newStore, storeLength * n, storeLength);
}

return new RubyArray(array.getLogicalClass(), array.getAllocationSite(), newStore, newStoreLength);
return new RubyArray(array.getLogicalClass(), newStore, newStoreLength);
}

@Specialization(guards = "isLongFixnum(array)")
Expand All @@ -228,7 +228,7 @@ public RubyArray mulLongFixnum(RubyArray array, int count) {
System.arraycopy(store, 0, newStore, storeLength * n, storeLength);
}

return new RubyArray(array.getLogicalClass(), array.getAllocationSite(), newStore, newStoreLength);
return new RubyArray(array.getLogicalClass(), newStore, newStoreLength);
}

@Specialization(guards = "isFloat(array)")
Expand All @@ -246,7 +246,7 @@ public RubyArray mulFloat(RubyArray array, int count) {
System.arraycopy(store, 0, newStore, storeLength * n, storeLength);
}

return new RubyArray(array.getLogicalClass(), array.getAllocationSite(), newStore, newStoreLength);
return new RubyArray(array.getLogicalClass(), newStore, newStoreLength);
}

@Specialization(guards = "isObject(array)")
Expand All @@ -264,7 +264,7 @@ public RubyArray mulObject(RubyArray array, int count) {
System.arraycopy(store, 0, newStore, storeLength * n, storeLength);
}

return new RubyArray(array.getLogicalClass(), array.getAllocationSite(), newStore, newStoreLength);
return new RubyArray(array.getLogicalClass(), newStore, newStoreLength);
}

@Specialization(guards = "isRubyString(string)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.interop.ForeignAccessFactory;
import com.oracle.truffle.api.nodes.Node;
import org.jruby.truffle.nodes.core.array.ArrayAllocationSite;
import org.jruby.truffle.nodes.objects.Allocator;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager;
Expand All @@ -33,7 +32,6 @@ public final class RubyArray extends RubyBasicObject {
private static final boolean RANDOMIZE_STORAGE_ARRAY = Options.TRUFFLE_RANDOMIZE_STORAGE_ARRAY.load();
private static final Random random = new Random(Options.TRUFFLE_RANDOMIZE_SEED.load());

private final ArrayAllocationSite allocationSite;
private Object store;
private int size;

Expand All @@ -42,12 +40,7 @@ public RubyArray(RubyClass arrayClass) {
}

public RubyArray(RubyClass arrayClass, Object store, int size) {
this(arrayClass, null, store, size);
}

public RubyArray(RubyClass arrayClass, ArrayAllocationSite allocationSite, Object store, int size) {
super(arrayClass);
this.allocationSite = allocationSite;
setStore(store, size);
}

Expand Down Expand Up @@ -302,10 +295,6 @@ private boolean verifyStore(Object store, int size) {
return true;
}

public ArrayAllocationSite getAllocationSite() {
return allocationSite;
}

@Override
public void visitObjectGraphChildren(ObjectSpaceManager.ObjectGraphVisitor visitor) {
for (Object object : slowToArray()) {
Expand Down

0 comments on commit 2e8f5e6

Please sign in to comment.