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: 9579fbe6c442
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7905705eee06
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 23, 2015

  1. Copy the full SHA
    b398b5a View commit details
  2. Copy the full SHA
    fda90f5 View commit details
  3. Copy the full SHA
    7905705 View commit details
Original file line number Diff line number Diff line change
@@ -151,7 +151,9 @@ public DynamicObject appendOneGeneralizeDouble(DynamicObject array, Object value
public void appendOneGeneralizeGeneric(DynamicObject array, ArrayMirror storeMirror, Object value) {
final int oldSize = Layouts.ARRAY.getSize(array);
final int newSize = oldSize + 1;
Object[] newStore = storeMirror.getBoxedCopy(ArrayUtils.capacity(storeMirror.getLength(), newSize));
final int oldCapacity = storeMirror.getLength();
final int newCapacity = newSize > oldCapacity ? ArrayUtils.capacity(storeMirror.getLength(), newSize) : oldCapacity;
Object[] newStore = storeMirror.getBoxedCopy(newCapacity);
newStore[oldSize] = value;
Layouts.ARRAY.setStore(array, newStore);
Layouts.ARRAY.setSize(array, newSize);
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import org.jruby.truffle.runtime.Options;

import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Cached;
@@ -79,14 +80,18 @@ public void writeNewField(DynamicObject object, Object value,
}
}

@TruffleBoundary
@Specialization(guards = "object.updateShape()")
@Specialization(guards = "updateShape(object)")
public void updateShape(DynamicObject object, Object value) {
execute(object, value);
}

protected boolean updateShape(DynamicObject object) {
CompilerDirectives.transferToInterpreter();
return object.updateShape();
}

@TruffleBoundary
@Specialization
@Specialization(contains = { "writeExistingField", "writeNewField", "updateShape" })
public void writeUncached(DynamicObject object, Object value) {
object.updateShape();
final Shape shape = object.getShape();
Original file line number Diff line number Diff line change
@@ -356,14 +356,18 @@ public static long[] longCopyOf(int[] ints, int newLength) {
return longs;
}

private static final int INITIAL_CAPACITY = 16;

public static int capacity(int current, int needed) {
if (needed < 16) {
return 16;
assert current < needed;

if (needed < INITIAL_CAPACITY) {
return INITIAL_CAPACITY;
} else {
int capacity = current;

if (capacity == 0) {
capacity = 16;
capacity = INITIAL_CAPACITY;
}

while (capacity < needed) {