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

WIP: Try moving boundary away from adapter invocation #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@ private static int convertIID(Object argument) {
return iid;
}

@TruffleBoundary
private static boolean checkArguments(int count, Object[] arguments, String funcName) throws ArityException {
if (arguments.length == count) {
return true;
}
return checkArgumentsSlow(count, arguments, funcName);
}

@TruffleBoundary
private static boolean checkArgumentsSlow(int count, Object[] arguments, String funcName) throws ArityException {
if (arguments.length < count) {
Logger.error("call to " + funcName + " expects " + count + " argument(s)");
if (!GlobalConfiguration.IGNORE_JALANGI_EXCEPTION) {
Expand All @@ -149,15 +156,35 @@ private Object getConfig() {
return obj;
}

@ExportMessage
@TruffleBoundary
final Object invokeMember(String identifier, Object[] arguments) throws ArityException, UnsupportedTypeException {
ApiMember api;
ApiMember lookupApiMethod(String identifier) {
try {
api = ApiMember.valueOf(identifier.toUpperCase());
return ApiMember.valueOf(identifier.toUpperCase());
} catch (IllegalArgumentException e) {
Logger.warning("Unsupported NodeProf-Jalangi operation " + identifier);
return 0;
}
return null;
}

@ExportMessage
final Object invokeMember(String identifier, Object[] arguments) throws ArityException, UnsupportedTypeException {
ApiMember api;
switch (identifier) {
case "iidToLocation":
api = ApiMember.IIDTOLOCATION;
break;
case "iidToCode":
api = ApiMember.IIDTOCODE;
break;
case "nativeLog":
api = ApiMember.NATIVELOG;
break;
default:
api = lookupApiMethod(identifier);
if (api == null) {
return null;
}
break;
}
switch (api) {
case IIDTOLOCATION: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright 2018 Dynamic Analysis Group, Università della Svizzera Italiana (USI)
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@ public static int getIIDForSourceSection(SourceSection sourceSection) {
return newIId;
}

@TruffleBoundary
@TruffleBoundary(allowInlining = true)
public static String getLocationForIID(int iid) {
if (iidToLocationCache.containsKey(iid)) {
return iidToLocationCache.get(iid);
Expand All @@ -79,7 +79,7 @@ public static String getLocationForIID(int iid) {
}
}

@TruffleBoundary
@TruffleBoundary(allowInlining = true)
public static String getCodeForIID(int iid) {
if (idToSource.containsKey(iid)) {
return idToSource.get(iid).getCharacters().toString();
Expand Down