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: 2990190e9500
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7562bf98f3db
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Jan 22, 2015

  1. Copy the full SHA
    320fc89 View commit details
  2. Copy the full SHA
    129ec64 View commit details
  3. Copy the full SHA
    07238ca View commit details
  4. 1
    Copy the full SHA
    7562bf9 View commit details
37 changes: 35 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -2970,6 +2970,31 @@ public RubyArray pushIntegerFixnumSingleIntegerFixnum(RubyArray array, Object...
return array;
}

@Specialization(guards = { "isIntegerFixnum", "!isSingleIntegerFixnum", "!isSingleLongFixnum" })
public RubyArray pushIntegerFixnum(RubyArray array, Object... values) {
final int oldSize = array.getSize();
final int newSize = oldSize + values.length;

int[] oldStore = (int[]) array.getStore();
final Object[] store;

if (oldStore.length < newSize) {
extendBranch.enter();
store = ArrayUtils.box(oldStore, ArrayUtils.capacity(oldStore.length, newSize) - oldStore.length);
} else {
store = ArrayUtils.box(oldStore);
}

array.setStore(store, oldSize);

for (int n = 0; n < values.length; n++) {
store[oldSize + n] = values[n];
}

array.setSize(newSize);
return array;
}

@Specialization(guards = {"isLongFixnum", "isSingleIntegerFixnum"})
public RubyArray pushLongFixnumSingleIntegerFixnum(RubyArray array, Object... values) {
final int oldSize = array.getSize();
@@ -3074,13 +3099,21 @@ public RubyArray pushIntegerFixnumIntegerFixnum(RubyArray array, int value) {
return array;
}

@Specialization(guards = "isIntegerFixnum")
@Specialization(guards = { "isIntegerFixnum", "!isInteger(arguments[1])" })
public RubyArray pushIntegerFixnumObject(RubyArray array, Object value) {
final int oldSize = array.getSize();
final int newSize = oldSize + 1;

final int[] oldStore = (int[]) array.getStore();
final Object[] newStore = ArrayUtils.box(oldStore, newSize);
final Object[] newStore;

if (oldStore.length < newSize) {
extendBranch.enter();
newStore = ArrayUtils.box(oldStore, ArrayUtils.capacity(oldStore.length, newSize) - oldStore.length);
} else {
newStore = ArrayUtils.box(oldStore);
}

newStore[oldSize] = value;
array.setStore(newStore, newSize);
return array;
Original file line number Diff line number Diff line change
@@ -1006,17 +1006,19 @@ public InstanceVariableGetNode(InstanceVariableGetNode prev) {
}

@Specialization
public Object isInstanceVariableGet(RubyBasicObject object, RubyString name) {
notDesignedForCompilation();

return object.getInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
public Object instanceVariableGet(RubyBasicObject object, RubyString name) {
return instanceVariableGet(object, name.toString());
}

@Specialization
public Object isInstanceVariableGet(RubyBasicObject object, RubySymbol name) {
public Object instanceVariableGet(RubyBasicObject object, RubySymbol name) {
return instanceVariableGet(object, name.toString());
}

private Object instanceVariableGet(RubyBasicObject object, String name) {
notDesignedForCompilation();

return object.getInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name.toString(), this));
return object.getInstanceVariable(RubyContext.checkInstanceVariableName(getContext(), name, this));
}

}
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ public ToSNode(ToSNode prev) {
public RubyString toS(RubySymbol symbol) {
notDesignedForCompilation();

return getContext().makeString(symbol.getJRubySymbol().to_s().asString().decodeString());
return getContext().makeString(symbol.getSymbolBytes().dup());
}

}
@@ -203,7 +203,7 @@ public InspectNode(InspectNode prev) {
}

@Specialization
public RubyString toS(RubySymbol symbol) {
public RubyString inspect(RubySymbol symbol) {
notDesignedForCompilation();

return getContext().makeString(symbol.getJRubySymbol().inspect(getContext().getRuntime().getCurrentContext()).asString().decodeString());
Original file line number Diff line number Diff line change
@@ -58,6 +58,10 @@ public RubyProc toProc(SourceSection sourceSection, final RubyNode currentNode)
callTarget, callTarget, null, null, null, getContext().getCoreLibrary().getNilObject(), null);
}

public ByteList getSymbolBytes() {
return symbolBytes;
}

public org.jruby.RubySymbol getJRubySymbol() {
RubyNode.notDesignedForCompilation();