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

Commits on May 6, 2016

  1. Copy the full SHA
    4975b66 View commit details
  2. [Truffle] Have a static slow path helper to check if frozen.

    * Since it's fairly simple and much more reasonable.
    eregon committed May 6, 2016
    Copy the full SHA
    9ed3224 View commit details
Original file line number Diff line number Diff line change
@@ -158,22 +158,11 @@ public void initCopy(DynamicObject from) {

// TODO (eregon, 12 May 2015): ideally all callers would be nodes and check themselves.
public void checkFrozen(RubyContext context, Node currentNode) {
if (context.getCoreLibrary() != null && verySlowIsFrozen(context, rubyModuleObject)) {
CompilerDirectives.transferToInterpreter();
if (context.getCoreLibrary() != null && IsFrozenNode.isFrozen(rubyModuleObject)) {
throw new RaiseException(context.getCoreExceptions().frozenError(rubyModuleObject, currentNode));
}
}

// TODO CS 20-Aug-15 this needs to go
public static boolean verySlowIsFrozen(RubyContext context, Object object) {
final IsFrozenNode node = IsFrozenNodeGen.create(context, null, null);
new Node() {
@Child RubyNode child = node;
}.adoptChildren();

return node.executeIsFrozen(object);
}

public void insertAfter(DynamicObject module) {
parentModule = new IncludedModule(module, parentModule);
}
@@ -279,7 +268,7 @@ public void setConstant(RubyContext context, Node currentNode, String name, Obje
}

if (RubyGuards.isRubyModule(value)) {
Layouts.MODULE.getFields(((DynamicObject) value)).getAdoptedByLexicalParent(context, rubyModuleObject, name, currentNode);
Layouts.MODULE.getFields((DynamicObject) value).getAdoptedByLexicalParent(context, rubyModuleObject, name, currentNode);
} else {
setConstantInternal(context, currentNode, name, value, false);
}
Original file line number Diff line number Diff line change
@@ -50,9 +50,9 @@ protected Object getConstant(DynamicObject module, String name, RubyConstant con

@Specialization(guards = { "constant != null", "constant.isAutoload()" })
protected Object autoloadConstant(VirtualFrame frame, DynamicObject module, String name, RubyConstant constant,
@Cached("createRequireNode()") RequireNode requireNode,
@Cached("deepCopyReadConstantNode()") RestartableReadConstantNode readConstantNode,
@Cached("create()")IndirectCallNode callNode) {
@Cached("createRequireNode()") RequireNode requireNode,
@Cached("deepCopyReadConstantNode()") RestartableReadConstantNode readConstantNode,
@Cached("create()") IndirectCallNode callNode) {

final DynamicObject path = (DynamicObject) constant.getValue();

Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public Object execute(VirtualFrame frame) {
final Object value = valueNode.execute(frame);
final Object moduleObject = moduleNode.execute(frame);

if (moduleProfile.profile(!(RubyGuards.isRubyModule(moduleObject)))) {
if (!moduleProfile.profile(RubyGuards.isRubyModule(moduleObject))) {
throw new RaiseException(coreExceptions().typeErrorIsNotAClassModule(moduleObject, this));
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
package org.jruby.truffle.language.objects;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
@@ -67,4 +68,11 @@ protected boolean isFrozen(
protected ReadObjectFieldNode createReadFrozenNode() {
return ReadObjectFieldNodeGen.create(Layouts.FROZEN_IDENTIFIER, false);
}

@TruffleBoundary
public static boolean isFrozen(Object object) {
return !(object instanceof DynamicObject) ||
((DynamicObject) object).containsKey(Layouts.FROZEN_IDENTIFIER);
}

}