Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor Truffle DSL/interop usage fixes #20

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
minor Truffle DSL/interop usage fixes
  • Loading branch information
lukasstadler committed Mar 3, 2020
commit 4d2e5f4acae9dfa80d83b7416bc88978b8069dc1
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ boolean isMemberInvocable(String memberName) {
@ExportMessage
Object invokeMember(String memberName,
Object[] arguments,
@CachedLibrary(limit = "1") InteropLibrary interopRead,
@CachedLibrary("this") InteropLibrary interopRead,
@CachedLibrary(limit = "1") InteropLibrary interopExecute)
throws UnsupportedTypeException, ArityException, UnsupportedMessageException, UnknownIdentifierException {
return interopExecute.execute(interopRead.readMember(this, memberName), arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ boolean isMemberInvocable(String memberName) {
@ExportMessage
Object invokeMember(String memberName,
Object[] arguments,
@CachedLibrary(limit = "1") InteropLibrary interopRead,
@CachedLibrary("this") InteropLibrary interopRead,
@CachedLibrary(limit = "1") InteropLibrary interopExecute)
throws UnsupportedTypeException, ArityException, UnsupportedMessageException, UnknownIdentifierException {
return interopExecute.execute(interopRead.readMember(this, memberName), arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.ExportLibrary;
import com.oracle.truffle.api.library.ExportMessage;

Expand Down Expand Up @@ -101,18 +100,6 @@ public String toString() {

// Implementation of Truffle API

@ExportMessage
@SuppressWarnings("static-method")
boolean hasMembers() {
return false;
}

@ExportMessage
@SuppressWarnings("static-method")
Object getMembers(@SuppressWarnings("unused") boolean includeInternal) {
return null;
}

@ExportMessage
@SuppressWarnings("static-method")
boolean hasArrayElements() {
Expand All @@ -129,18 +116,6 @@ boolean isArrayElementReadable(long index) {
return index >= 0 && index < devices.length;
}

@SuppressWarnings("static-method")
@ExportMessage
boolean isArrayElementModifiable(@SuppressWarnings("unused") long index) {
return false;
}

@SuppressWarnings("static-method")
@ExportMessage
boolean isArrayElementInsertable(@SuppressWarnings("unused") long index) {
return false;
}

@ExportMessage
Object readArrayElement(long index) throws InvalidArrayIndexException {
if ((index < 0) || (index >= devices.length)) {
Expand All @@ -149,11 +124,4 @@ Object readArrayElement(long index) throws InvalidArrayIndexException {
}
return devices[(int) index];
}

@SuppressWarnings("static-method")
@ExportMessage
void writeArrayElement(@SuppressWarnings("unused") long index, @SuppressWarnings("unused") Object value) throws UnsupportedMessageException {
CompilerDirectives.transferToInterpreter();
throw UnsupportedMessageException.create();
}
muellren marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import java.util.Optional;

import com.nvidia.grcuda.gpu.CUDARuntime.CUDADeviceAttribute;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.TruffleObject;
Expand Down Expand Up @@ -72,15 +72,16 @@ Object getMembers(boolean includeInternal) {
}

@ExportMessage
@TruffleBoundary
@SuppressWarnings("static-method")
boolean isMemberReadable(String member) {
return PROPERTY_SET.contains(member);
}

@ExportMessage
@TruffleBoundary
Object readMember(String member) throws UnknownIdentifierException {
if (!isMemberReadable(member)) {
CompilerDirectives.transferToInterpreter();
throw UnknownIdentifierException.create(member);
}
Object value = properties.get(member);
Expand Down Expand Up @@ -146,14 +147,15 @@ public long getArraySize() {
}

@ExportMessage
@TruffleBoundary
public boolean isArrayElementReadable(long index) {
return index >= 0 && index < propertyMap.size();
}

@ExportMessage
@TruffleBoundary
public Object readArrayElement(long index) throws InvalidArrayIndexException {
if ((index < 0) || (index >= propertyMap.size())) {
CompilerDirectives.transferToInterpreter();
throw InvalidArrayIndexException.create(index);
}
return names[(int) index];
Expand Down