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

Commits on Dec 5, 2015

  1. [Truffle] Array storage must be Object[] not DynamicObject[].

    * Avoid copying when only reading from the Encoding list.
    eregon committed Dec 5, 2015
    Copy the full SHA
    0104c31 View commit details
  2. [Truffle] Check the class of Object[] storage strictly.

    * Avoids covariance problems and makes sure no type check is required on cast.
    eregon committed Dec 5, 2015
    Copy the full SHA
    3b3d19e View commit details
Original file line number Diff line number Diff line change
@@ -80,8 +80,8 @@ public static DynamicObject newEncoding(DynamicObject encodingClass, Encoding en
return createRubyEncoding(encodingClass, encoding, new ByteList(name, p, end), dummy);
}

public static DynamicObject[] cloneEncodingList() {
final DynamicObject[] clone = new DynamicObject[encodingList.length];
public static Object[] cloneEncodingList() {
final Object[] clone = new Object[encodingList.length];

System.arraycopy(encodingList, 0, clone, 0, encodingList.length);

@@ -383,7 +383,7 @@ public ListNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject list() {
CompilerDirectives.transferToInterpreter();

final DynamicObject[] encodings = cloneEncodingList();
final Object[] encodings = cloneEncodingList();

return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), encodings, encodings.length);
}
@@ -441,7 +441,7 @@ public EncodingMapNode(RubyContext context, SourceSection sourceSection) {
public Object encodingMap(VirtualFrame frame) {
Object ret = newLookupTableNode.call(frame, getContext().getCoreLibrary().getLookupTableClass(), "new", null);

final DynamicObject[] encodings = cloneEncodingList();
final DynamicObject[] encodings = encodingList;
for (int i = 0; i < encodings.length; i++) {
final Object upcased = upcaseNode.call(frame, createString(Layouts.ENCODING.getName(encodings[i])), "upcase", null);
final Object key = toSymNode.call(frame, upcased, "to_sym", null);
Original file line number Diff line number Diff line change
@@ -530,7 +530,7 @@ public ListNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public DynamicObject list() {
final DynamicObject[] threads = getContext().getThreadManager().getThreads();
final Object[] threads = getContext().getThreadManager().getThreadList();
return Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), threads, threads.length);
}
}
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.core.array;

import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.runtime.layouts.Layouts;

@@ -39,7 +40,8 @@ public static boolean isDoubleArray(DynamicObject array) {

public static boolean isObjectArray(DynamicObject array) {
assert RubyGuards.isRubyArray(array);
return Layouts.ARRAY.getStore(array) instanceof Object[];
final Object store = Layouts.ARRAY.getStore(array);
return store != null && store.getClass() == Object[].class;
}

// Higher level properties
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.core.hash;

import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.runtime.hash.Entry;
import org.jruby.truffle.runtime.layouts.Layouts;
@@ -26,7 +27,8 @@ public static boolean isNullHash(DynamicObject hash) {
public static boolean isPackedHash(DynamicObject hash) {
assert RubyGuards.isRubyHash(hash);
// Can't do instanceof Object[] due to covariance
return !(isNullHash(hash) || isBucketHash(hash));
final Object store = Layouts.HASH.getStore(hash);
return store != null && store.getClass() == Object[].class;
}

public static boolean isBucketHash(DynamicObject hash) {
Original file line number Diff line number Diff line change
@@ -220,8 +220,8 @@ public void shutdown() {
}

@TruffleBoundary
public DynamicObject[] getThreads() {
return runningRubyThreads.toArray(new DynamicObject[runningRubyThreads.size()]);
public Object[] getThreadList() {
return runningRubyThreads.toArray(new Object[runningRubyThreads.size()]);
}

@TruffleBoundary