Skip to content

Commit

Permalink
Fix broken isValue check in CreateActorPrim (fixes #101)
Browse files Browse the repository at this point in the history
Add proper exception and remove todo.

Note, this change stops using the DSL for the IsValue node, because it was generating wrong code, and passing a `null` to isValue.execute*.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Jan 30, 2017
1 parent 075a3ce commit 5654323
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

- Added breakpoints for channel operations in [PR #99](https://github.com/smarr/SOMns/pull/81).

- Fixed isolation issue for actors. The test that an actor is only created
from a value was broken ([issue #101](https://github.com/smarr/SOMns/issues/101), [PR #102](https://github.com/smarr/SOMns/pull/102))

## 0.1.0 - 2016-12-15

This is the first tagged version. For previous changes, please refer to the
Expand Down
25 changes: 16 additions & 9 deletions src/som/primitives/actors/CreateActorPrim.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
package som.primitives.actors;

import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

import som.interpreter.actors.Actor;
import som.interpreter.actors.SFarReference;
import som.interpreter.nodes.nary.BinaryComplexOperation;
import som.primitives.ObjectPrims.IsValue;
import som.primitives.ObjectPrimsFactory.IsValueFactory;
import som.primitives.ObjectPrimsFactory.IsValueFactory.IsValueNodeGen;
import som.primitives.Primitive;
import som.primitives.actors.PromisePrims.IsActorModule;
import som.vm.VmSettings;
import som.vm.constants.KernelObj;
import tools.concurrency.ActorExecutionTrace;


@GenerateNodeFactory
@Primitive(primitive = "actors:createFromValue:", selector = "createActorFromValue:",
specializer = IsActorModule.class, extraChild = IsValueFactory.class)
@NodeChild(value = "isValue", type = IsValue.class, executeWith = "receiver")
specializer = IsActorModule.class)
public abstract class CreateActorPrim extends BinaryComplexOperation {
protected CreateActorPrim(final boolean eagWrap, final SourceSection source) { super(eagWrap, source); }
@Child protected IsValue isValue;

@Specialization(guards = "isValue")
public final SFarReference createActor(final Object nil, final Object value, final boolean isValue) {
protected CreateActorPrim(final boolean eagWrap, final SourceSection source) {
super(eagWrap, source);
isValue = IsValueNodeGen.createSubNode();
}

@Specialization(guards = "isValue.executeEvaluated(argument)")
public final SFarReference createActor(final Object receiver, final Object argument) {
Actor actor = Actor.createActor();
SFarReference ref = new SFarReference(actor, value);
SFarReference ref = new SFarReference(actor, argument);

if (VmSettings.ACTOR_TRACING) {
ActorExecutionTrace.actorCreation(ref);
}
return ref;
}

// TODO: add a proper error or something if it isn't a value...
@Specialization(guards = "!isValue.executeEvaluated(argument)")
public final Object throwNotAValueException(final Object receiver, final Object argument) {
return KernelObj.signalException("signalNotAValueWith:", argument);
}
}

0 comments on commit 5654323

Please # to comment.