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

Commits on Feb 19, 2016

  1. Copy the full SHA
    dd24724 View commit details
  2. Copy the full SHA
    ad81f50 View commit details
6 changes: 6 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -1033,6 +1034,11 @@ public DynamicObject noBlockToYieldTo(Node currentNode) {
return localJumpError("no block given (yield)", currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorCantCreateInstanceOfSingletonClass(Node currentNode) {
return typeError("can't create instance of singleton class", currentNode, null);
}

public DynamicObject typeError(String message, Node currentNode) {
return typeError(message, currentNode, null);
}
Original file line number Diff line number Diff line change
@@ -39,13 +39,13 @@ public ArrayDupNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isNullArray(from)")
public DynamicObject dupNull(DynamicObject from) {
return allocateNode.allocate(getContext().getCoreLibrary().getArrayClass(), null, 0);
return allocateNode.allocateArray(getContext().getCoreLibrary().getArrayClass(), null, 0);
}

@Specialization(guards = "isIntArray(from)")
public DynamicObject dupIntegerFixnum(DynamicObject from) {
final int[] store = (int[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocate(
return allocateNode.allocateArray(
getContext().getCoreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
@@ -54,7 +54,7 @@ public DynamicObject dupIntegerFixnum(DynamicObject from) {
@Specialization(guards = "isLongArray(from)")
public DynamicObject dupLongFixnum(DynamicObject from) {
final long[] store = (long[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocate(
return allocateNode.allocateArray(
getContext().getCoreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
@@ -63,7 +63,7 @@ public DynamicObject dupLongFixnum(DynamicObject from) {
@Specialization(guards = "isDoubleArray(from)")
public DynamicObject dupFloat(DynamicObject from) {
final double[] store = (double[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocate(
return allocateNode.allocateArray(
getContext().getCoreLibrary().getArrayClass(),
store.clone(),
Layouts.ARRAY.getSize(from));
@@ -72,7 +72,7 @@ public DynamicObject dupFloat(DynamicObject from) {
@Specialization(guards = "isObjectArray(from)")
public DynamicObject dupObject(DynamicObject from) {
final Object[] store = (Object[]) Layouts.ARRAY.getStore(from);
return allocateNode.allocate(
return allocateNode.allocateArray(
getContext().getCoreLibrary().getArrayClass(),
ArrayUtils.copy(store),
Layouts.ARRAY.getSize(from));
Original file line number Diff line number Diff line change
@@ -37,27 +37,49 @@
})
public abstract class AllocateObjectNode extends RubyNode {

private final boolean useCallerFrame;
private final boolean useCallerFrameForTracing;

public AllocateObjectNode(RubyContext context, SourceSection sourceSection) {
this(context, sourceSection, true);
}

public AllocateObjectNode(RubyContext context, SourceSection sourceSection, boolean useCallerFrame) {
public AllocateObjectNode(RubyContext context, SourceSection sourceSection, boolean useCallerFrameForTracing) {
super(context, sourceSection);
this.useCallerFrame = useCallerFrame;
this.useCallerFrameForTracing = useCallerFrameForTracing;
}

public DynamicObject allocate(DynamicObject classToAllocate, Object... values) {
return executeAllocateX(classToAllocate, values);
return executeAllocate(classToAllocate, values);
}

public DynamicObject allocateHash(DynamicObject classToAllocate, Object store, int size, Entry firstInSequence, Entry lastInSequence, DynamicObject defaultBlock, Object defaultValue,
public DynamicObject allocateArray(
DynamicObject classToAllocate,
Object store,
int size) {
return allocate(classToAllocate, store, size);
}

public DynamicObject allocateHash(
DynamicObject classToAllocate,
Object store,
int size,
Entry firstInSequence,
Entry lastInSequence,
DynamicObject defaultBlock,
Object defaultValue,
boolean compareByIdentity) {
return allocate(classToAllocate, store, size, firstInSequence, lastInSequence, defaultBlock, defaultValue, compareByIdentity);
return allocate(
classToAllocate,
store,
size,
firstInSequence,
lastInSequence,
defaultBlock,
defaultValue,
compareByIdentity);
}

public abstract DynamicObject executeAllocateX(DynamicObject classToAllocate, Object[] values);
protected abstract DynamicObject executeAllocate(DynamicObject classToAllocate, Object[] values);

@Specialization(guards = {
"cachedClassToAllocate == classToAllocate",
@@ -91,7 +113,7 @@ public DynamicObject allocateTracing(DynamicObject classToAllocate, Object[] val
final FrameInstance allocatingFrameInstance;
final Node allocatingNode;

if (useCallerFrame) {
if (useCallerFrameForTracing) {
allocatingFrameInstance = getContext().getCallStack().getCallerFrameIgnoringSend();
allocatingNode = getContext().getCallStack().getTopMostUserCallNode();
} else {
@@ -121,8 +143,7 @@ private DynamicObject string(String value) {

@Specialization(guards = "isSingleton(classToAllocate)")
public DynamicObject allocateSingleton(DynamicObject classToAllocate, Object[] values) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().typeError("can't create instance of singleton class", this));
throw new RaiseException(getContext().getCoreLibrary().typeErrorCantCreateInstanceOfSingletonClass(this));
}

protected Assumption getTracingAssumption() {