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

Commits on Apr 17, 2015

  1. Copy the full SHA
    20f4611 View commit details

Commits on Apr 22, 2015

  1. Merge pull request #2845 from eregon/truffle-on-demand-freeze-node

    [Truffle] On demand freeze node
    eregon committed Apr 22, 2015
    Copy the full SHA
    a8830c8 View commit details
Original file line number Diff line number Diff line change
@@ -23,10 +23,12 @@
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.object.Shape;

import org.jruby.truffle.nodes.objects.FreezeNode;
import org.jruby.truffle.nodes.objects.FreezeNodeFactory;
import org.jruby.truffle.nodes.objects.IsFrozenNode;
import org.jruby.truffle.nodes.objects.IsFrozenNodeFactory;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBignum;
import org.jruby.truffle.runtime.core.RubyNilClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.InternalMethod;
@@ -134,47 +136,20 @@ private static void printMethodASTBacktrace(Node currentNode) {
printASTForBacktrace(currentNode.getRootNode(), activeNodes, 0);
}

public static Object verySlowFreeze(Object o) {
if ((o instanceof Boolean) ||
(o instanceof Integer) ||
(o instanceof Long) ||
(o instanceof Double) ||
(o instanceof RubyNilClass) ||
(o instanceof RubySymbol) ||
(o instanceof RubyBignum)) {
return o;
}

final RubyBasicObject object = (RubyBasicObject) o;

object.getOperations().setInstanceVariable(object, RubyBasicObject.FROZEN_IDENTIFIER, true);

return o;
public static Object verySlowFreeze(RubyContext context, final Object object) {
final FreezeNode freezeNode = FreezeNodeFactory.create(context, null, null);
new Node() {
@Child FreezeNode child = freezeNode;
}.adoptChildren();
return freezeNode.executeFreeze(object);
}

public static boolean verySlowIsFrozen(Object o) {
if ((o instanceof Boolean) ||
(o instanceof Integer) ||
(o instanceof Long) ||
(o instanceof Double) ||
(o instanceof RubyNilClass) ||
(o instanceof RubySymbol) ||
(o instanceof RubyBignum)) {
return true;
}

final RubyBasicObject object = (RubyBasicObject) o;

final Shape layout = object.getDynamicObject().getShape();
final Property property = layout.getProperty(RubyBasicObject.FROZEN_IDENTIFIER);

if (property == null) {
return false;
}

final Location storageLocation = property.getLocation();

return (boolean) storageLocation.get(object.getDynamicObject(), layout);
public static boolean verySlowIsFrozen(RubyContext context, Object object) {
final IsFrozenNode isFrozenNode = IsFrozenNodeFactory.create(context, null, null);
new Node() {
@Child IsFrozenNode child = isFrozenNode;
}.adoptChildren();
return isFrozenNode.executeIsFrozen(object);
}

public static boolean verySlowIsTainted(Object o) {
Original file line number Diff line number Diff line change
@@ -84,12 +84,12 @@ public boolean hasClassAsSingleton() {

@Deprecated
public void freeze() {
DebugOperations.verySlowFreeze(this);
DebugOperations.verySlowFreeze(getContext(), this);
}

@Deprecated
public void checkFrozen(Node currentNode) {
if (DebugOperations.verySlowIsFrozen(this)) {
if (DebugOperations.verySlowIsFrozen(getContext(), this)) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(getLogicalClass().getName(), currentNode));
}
@@ -120,8 +120,8 @@ public RubyClass getSingletonClass(Node currentNode) {
metaClass = RubyClass.createSingletonClassOfObject(getContext(), logicalClass, attached,
String.format("#<Class:#<%s:0x%x>>", logicalClass.getName(), verySlowGetObjectID()));

if (DebugOperations.verySlowIsFrozen(this)) {
DebugOperations.verySlowFreeze(metaClass);
if (DebugOperations.verySlowIsFrozen(getContext(), this)) {
DebugOperations.verySlowFreeze(getContext(), metaClass);
}

return metaClass;