Skip to content

Commit

Permalink
Get rid of some warnings - Add @shared to some @cached parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Jul 4, 2023
1 parent a341b2b commit 15244d2
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.enso.interpreter.epb.node;

import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.ReportPolymorphism;
Expand Down Expand Up @@ -79,7 +80,7 @@ boolean doWrappedBoolean(
Object b,
GuardedTruffleContext origin,
GuardedTruffleContext target,
@CachedLibrary(limit = "5") InteropLibrary bools) {
@Shared("interop") @CachedLibrary(limit = "5") InteropLibrary bools) {
try {
return bools.asBoolean(b);
} catch (UnsupportedMessageException e) {
Expand All @@ -92,7 +93,7 @@ long doWrappedLong(
Object l,
GuardedTruffleContext origin,
GuardedTruffleContext target,
@CachedLibrary(limit = "5") InteropLibrary numbers) {
@Shared("interop") @CachedLibrary(limit = "5") InteropLibrary numbers) {
try {
return numbers.asLong(l);
} catch (UnsupportedMessageException e) {
Expand All @@ -106,7 +107,7 @@ long doWrappedLong(
Object d,
GuardedTruffleContext origin,
GuardedTruffleContext target,
@CachedLibrary(limit = "5") InteropLibrary numbers) {
@Shared("interop") @CachedLibrary(limit = "5") InteropLibrary numbers) {
try {
return numbers.asDouble(d);
} catch (UnsupportedMessageException e) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Exclusive;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.Specialization;
Expand Down Expand Up @@ -103,7 +104,7 @@ Object invokeFunction(
InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode,
InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode,
BaseNode.TailStatus isTail,
@Cached IndirectInvokeFunctionNode invokeFunctionNode) {
@Exclusive @Cached IndirectInvokeFunctionNode invokeFunctionNode) {
return invokeFunctionNode.execute(
function,
callerFrame,
Expand All @@ -125,7 +126,7 @@ Object invokeConstructor(
InvokeCallableNode.DefaultsExecutionMode defaultsExecutionMode,
InvokeCallableNode.ArgumentsExecutionMode argumentsExecutionMode,
BaseNode.TailStatus isTail,
@Cached IndirectInvokeFunctionNode invokeFunctionNode) {
@Exclusive @Cached IndirectInvokeFunctionNode invokeFunctionNode) {
return invokeFunction(
constructor.getConstructorFunction(),
callerFrame,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.dsl.Cached.Exclusive;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.IndirectCallNode;
Expand Down Expand Up @@ -58,7 +59,7 @@ Object doCached(
State state,
BaseNode.TailStatus isTail,
@Cached("create(function.getCallTarget())") DirectCallNode callNode,
@Cached LoopingCallOptimiserNode loopingCallOptimiserNode) {
@Exclusive @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) {
CompilerAsserts.partialEvaluationConstant(isTail);
if (isTail != BaseNode.TailStatus.NOT_TAIL) {
return callNode.call(Function.ArgumentsHelper.buildArguments(function, state));
Expand All @@ -79,7 +80,7 @@ Object doUncached(
State state,
BaseNode.TailStatus isTail,
@Cached IndirectCallNode callNode,
@Cached LoopingCallOptimiserNode loopingCallOptimiserNode) {
@Exclusive @Cached LoopingCallOptimiserNode loopingCallOptimiserNode) {
if (isTail != BaseNode.TailStatus.NOT_TAIL) {
return callNode.call(
function.getCallTarget(), Function.ArgumentsHelper.buildArguments(function, state));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.enso.interpreter.node.expression.builtin.error;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
Expand Down Expand Up @@ -38,7 +39,7 @@ EnsoContext getContext() {
Object doCaughtPanic(
VirtualFrame frame,
Atom payload,
@CachedLibrary(limit = "5") InteropLibrary interopLibrary,
@Shared("interop") @CachedLibrary(limit = "5") InteropLibrary interopLibrary,
@CachedLibrary(limit = "5") StructsLibrary structs,
@Cached BranchProfile typeErrorProfile) {
// Note [Original Exception Type]
Expand All @@ -63,7 +64,8 @@ Object doCaughtPanic(

@Specialization(guards = "interopLibrary.isException(payload)")
Object doOtherException(
Object payload, @CachedLibrary(limit = "5") InteropLibrary interopLibrary) {
Object payload,
@Shared("interop") @CachedLibrary(limit = "5") InteropLibrary interopLibrary) {
try {
throw interopLibrary.throwException(payload);
} catch (UnsupportedMessageException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.enso.interpreter.node.expression.builtin.meta;

import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.Specialization;
Expand Down Expand Up @@ -50,7 +51,9 @@ boolean isSameType(Type typeLeft, Type typeRight) {
*/
@Specialization(guards = {"interop.isMetaObject(metaLeft)", "interop.isMetaObject(metaRight)"})
boolean isSameMetaObjects(
Object metaLeft, Object metaRight, @CachedLibrary(limit = "2") InteropLibrary interop) {
Object metaLeft,
Object metaRight,
@Shared("interop") @CachedLibrary(limit = "2") InteropLibrary interop) {
try {
Object metaLeftName = interop.getMetaQualifiedName(metaLeft);
Object metaRightName = interop.getMetaQualifiedName(metaRight);
Expand All @@ -62,7 +65,9 @@ boolean isSameMetaObjects(

@Fallback
boolean isIdenticalObjects(
Object left, Object right, @CachedLibrary(limit = "2") InteropLibrary interop) {
Object left,
Object right,
@Shared("interop") @CachedLibrary(limit = "2") InteropLibrary interop) {
if (left == right) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.enso.interpreter.node.expression.builtin.meta;

import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.InteropLibrary;
Expand Down Expand Up @@ -30,7 +31,7 @@ public static IsValueOfTypeNode build() {
boolean doTyped(
Object expectedType,
Object payload,
@CachedLibrary(limit = "3") TypesLibrary types,
@Shared("types") @CachedLibrary(limit = "3") TypesLibrary types,
@Cached Typed typed) {
return typed.execute(expectedType, payload);
}
Expand All @@ -39,7 +40,7 @@ boolean doTyped(
boolean doPolyglot(
Object expectedType,
Object payload,
@CachedLibrary(limit = "3") TypesLibrary types,
@Shared("types") @CachedLibrary(limit = "3") TypesLibrary types,
@Cached Untyped untyped) {
return untyped.execute(expectedType, payload);
}
Expand Down Expand Up @@ -120,7 +121,9 @@ private boolean checkParentTypes(Type actual, Type expected) {

@Specialization(guards = {"!isArrayType(expectedType)", "!isAnyType(expectedType)"})
boolean doType(
Type expectedType, Object payload, @CachedLibrary(limit = "3") TypesLibrary types) {
Type expectedType,
Object payload,
@Shared("types") @CachedLibrary(limit = "3") TypesLibrary types) {
return typeAndCheck(payload, expectedType, typeOfNode, isSameObject, profile);
}

Expand All @@ -133,7 +136,7 @@ public boolean doArrayViaType(
Object expectedType,
Object payload,
@CachedLibrary(limit = "3") InteropLibrary interop,
@CachedLibrary(limit = "3") TypesLibrary types) {
@Shared("types") @CachedLibrary(limit = "3") TypesLibrary types) {
return EnsoContext.get(this).getBuiltins().array() == types.getType(payload);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.Specialization;
Expand Down Expand Up @@ -126,7 +127,9 @@ Type doPolyglotString(Interop type, Object value) {

@Specialization(guards = {"type.isNumber()"})
Type doPolyglotNumber(
Interop type, Object value, @CachedLibrary(limit = "3") InteropLibrary interop) {
Interop type,
Object value,
@Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) {
Builtins builtins = EnsoContext.get(this).getBuiltins();
if (interop.fitsInInt(value)) {
return builtins.number().getInteger();
Expand Down Expand Up @@ -170,7 +173,9 @@ Type doDuration(Interop type, Object value) {

@Specialization(guards = {"type.isMetaObject()"})
Object doMetaObject(
Interop type, Object value, @CachedLibrary(limit = "3") InteropLibrary interop) {
Interop type,
Object value,
@Shared("interop") @CachedLibrary(limit = "3") InteropLibrary interop) {
try {
return interop.getMetaObject(value);
} catch (UnsupportedMessageException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ Type getMetaObject(@CachedLibrary("this") InteropLibrary thisLib) {

@ExportMessage
@TruffleBoundary
Object toDisplayString(
boolean allowSideEffects) {
Object toDisplayString(boolean allowSideEffects) {
return toString(true);
}

Expand Down

0 comments on commit 15244d2

Please sign in to comment.