diff --git a/README.md b/README.md index c69d73bd2396e106a6c1615cce97bdfe013e2fc5..b529ffcc769e4ecf81cf26bfa0e649c2b821343d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Aparapi [](http://www.apache.org/licenses/LICENSE-2.0.html) -[](http://www.javadoc.io/doc/com.syncleus.aparapi/aparapi) +[](http://www.javadoc.io/doc/com.aparapi/aparapi) [](https://gitter.im/Syncleus/aparapi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) A framework for executing native Java code on the GPU. @@ -27,7 +27,7 @@ To include Aparapi in your project of choice include the following Maven depende ```xml <dependency> - <groupId>com.syncleus.aparapi</groupId> + <groupId>com.aparapi</groupId> <artifactId>aparapi</artifactId> <version>1.0.0</version> </dependency> diff --git a/pom.xml b/pom.xml index e835e026d6e0be2a5bc9df35faaccc4a5d71b67d..2c8d44a3821f7b72465372be0818fd813a337ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ <organization> <name>Syncleus</name> - <url>http://www.syncleus.com</url> + <url>http://syncleus.com</url> </organization> <scm> @@ -55,7 +55,7 @@ <email>Jeffrey.Freeman@Syncleus.com</email> <url>http://JeffreyFreeman.me</url> <organization>Syncleus</organization> - <organizationUrl>http://www.syncleus.com</organizationUrl> + <organizationUrl>http://syncleus.com</organizationUrl> <roles> <role>Chief Technology Officer</role> <role>Project Owner</role> diff --git a/src/main/java/com/syncleus/aparapi/Config.java b/src/main/java/com/aparapi/Config.java similarity index 93% rename from src/main/java/com/syncleus/aparapi/Config.java rename to src/main/java/com/aparapi/Config.java index 186d61a4fdf89b0502e4198a3ea8f0713c9b4a45..4d7af85c1e01361952b448178010b421954687e1 100644 --- a/src/main/java/com/syncleus/aparapi/Config.java +++ b/src/main/java/com/aparapi/Config.java @@ -50,11 +50,11 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi; +package com.aparapi; -import com.syncleus.aparapi.internal.instruction.*; -import com.syncleus.aparapi.internal.jni.*; -import com.syncleus.aparapi.internal.tool.*; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.jni.ConfigJNI; +import com.aparapi.internal.tool.InstructionViewer; import java.util.logging.*; @@ -67,7 +67,7 @@ import java.util.logging.*; * @author gfrost * */ -public class Config extends ConfigJNI{ +public class Config extends ConfigJNI { // Logging setup private static final String logPropName = propPkgName + ".logLevel"; @@ -78,7 +78,7 @@ public class Config extends ConfigJNI{ * Allows the user to request to use a jvmti agent to * access JNI code rather than loading explicitly. * - * Usage -agentpath=/full/path/to/agent.dll -Dcom.syncleus.aparapi.useAgent=true + * Usage -agentpath=/full/path/to/agent.dll -Dcom.aparapi.useAgent=true */ public static final boolean useAgent = Boolean.getBoolean(propPkgName + ".useAgent"); @@ -91,16 +91,16 @@ public class Config extends ConfigJNI{ /** * Allows the user to request a specific Kernel.EXECUTION_MODE enum value for all Kernels. * - * Usage -Dcom.syncleus.aparapi.executionMode={SEQ|JTP|CPU|GPU|ACC} + * Usage -Dcom.aparapi.executionMode={SEQ|JTP|CPU|GPU|ACC} * - * @see com.syncleus.aparapi.Kernel.EXECUTION_MODE + * @see Kernel.EXECUTION_MODE */ public static final String executionMode = System.getProperty(propPkgName + ".executionMode"); /** * Allows the user to request that the execution mode of each kernel invocation be reported to stdout. * - * Usage -Dcom.syncleus.aparapi.enableExecutionModeReporting={true|false} + * Usage -Dcom.aparapi.enableExecutionModeReporting={true|false} * */ public static final boolean enableExecutionModeReporting = Boolean.getBoolean(propPkgName + ".enableExecutionModeReporting"); @@ -108,7 +108,7 @@ public class Config extends ConfigJNI{ /** * Allows the user to request that generated OpenCL code is dumped to standard out. * - * Usage -Dcom.syncleus.aparapi.enableShowGeneratedOpenCL={true|false} + * Usage -Dcom.aparapi.enableShowGeneratedOpenCL={true|false} * */ public static final boolean enableShowGeneratedOpenCL = Boolean.getBoolean(propPkgName + ".enableShowGeneratedOpenCL"); @@ -116,7 +116,7 @@ public class Config extends ConfigJNI{ /** * Upon exiting the JVM, dumps kernel profiling info to standard out. * - * Usage -Dcom.syncleus.aparapi.dumpProfilesOnExit={true|false} + * Usage -Dcom.aparapi.dumpProfilesOnExit={true|false} * */ public static final boolean dumpProfilesOnExit = Boolean.getBoolean(propPkgName + ".dumpProfilesOnExit"); @@ -124,7 +124,7 @@ public class Config extends ConfigJNI{ /** * Dumps profiling info (for a single execution) after every Kernel execution. * - * Usage -Dcom.syncleus.aparapi.dumpProfileOnExecution={true|false} + * Usage -Dcom.aparapi.dumpProfileOnExecution={true|false} * */ public static final boolean dumpProfileOnExecution = Boolean.getBoolean(propPkgName + ".dumpProfileOnExecution"); @@ -228,7 +228,7 @@ public class Config extends ConfigJNI{ System.out.println(propPkgName + ".enableExecutionModeReporting{true|false}=" + enableExecutionModeReporting); System.out.println(propPkgName + ".enableInstructionDecodeViewer{true|false}=" + enableInstructionDecodeViewer); System.out.println(propPkgName - + ".instructionListenerClassName{<class name which extends com.syncleus.aparapi.Config.InstructionListener>}=" + + ".instructionListenerClassName{<class name which extends Config.InstructionListener>}=" + instructionListenerClassName); } } diff --git a/src/main/java/com/syncleus/aparapi/Kernel.java b/src/main/java/com/aparapi/Kernel.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/Kernel.java rename to src/main/java/com/aparapi/Kernel.java index 1d87e1c85bc29a29f688944e44d11248fac8e6cd..6deaa7aa1a059259cff6849f559e1de59660e15c 100644 --- a/src/main/java/com/syncleus/aparapi/Kernel.java +++ b/src/main/java/com/aparapi/Kernel.java @@ -50,20 +50,25 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi; - -import com.syncleus.aparapi.annotation.Experimental; -import com.syncleus.aparapi.device.*; -import com.syncleus.aparapi.exception.DeprecatedException; -import com.syncleus.aparapi.internal.kernel.*; -import com.syncleus.aparapi.internal.model.CacheEnabler; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.MethodReferenceEntry; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.NameAndTypeEntry; -import com.syncleus.aparapi.internal.model.ValueCache; -import com.syncleus.aparapi.internal.model.ValueCache.ThrowingValueComputer; -import com.syncleus.aparapi.internal.model.ValueCache.ValueComputer; -import com.syncleus.aparapi.internal.opencl.OpenCLLoader; -import com.syncleus.aparapi.internal.util.*; +package com.aparapi; + +import com.aparapi.device.Device; +import com.aparapi.device.JavaDevice; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.exception.DeprecatedException; +import com.aparapi.internal.kernel.KernelArg; +import com.aparapi.internal.kernel.KernelManager; +import com.aparapi.internal.kernel.KernelProfile; +import com.aparapi.internal.kernel.KernelRunner; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.annotation.Experimental; +import com.aparapi.internal.util.Reflection; +import com.aparapi.internal.util.UnsafeWrapper; +import com.aparapi.internal.model.CacheEnabler; +import com.aparapi.internal.model.ValueCache; +import com.aparapi.internal.model.ValueCache.ThrowingValueComputer; +import com.aparapi.internal.model.ValueCache.ValueComputer; +import com.aparapi.internal.opencl.OpenCLLoader; import java.lang.annotation.Annotation; import java.lang.annotation.ElementType; @@ -323,8 +328,8 @@ public abstract class Kernel implements Cloneable { } /** - * @deprecated It is no longer recommended that {@code EXECUTION_MODE}s are used, as a more sophisticated {@link com.syncleus.aparapi.device.Device} - * preference mechanism is in place, see {@link com.syncleus.aparapi.internal.kernel.KernelManager}. Though {@link #setExecutionMode(EXECUTION_MODE)} + * @deprecated It is no longer recommended that {@code EXECUTION_MODE}s are used, as a more sophisticated {@link Device} + * preference mechanism is in place, see {@link KernelManager}. Though {@link #setExecutionMode(EXECUTION_MODE)} * is still honored, the default EXECUTION_MODE is now {@link EXECUTION_MODE#AUTO}, which indicates that the KernelManager * will determine execution behaviours. * @@ -358,10 +363,10 @@ public abstract class Kernel implements Cloneable { * kernel.execute(values.length); * </pre></blockquote> * <p> - * Alternatively, the property <code>com.syncleus.aparapi.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> + * Alternatively, the property <code>com.aparapi.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> * when an application is launched. * <p><blockquote><pre> - * java -classpath ....;aparapi.jar -Dcom.syncleus.aparapi.executionMode=GPU MyApplication + * java -classpath ....;aparapi.jar -Dcom.aparapi.executionMode=GPU MyApplication * </pre></blockquote><p> * Generally setting the execution mode is not recommended (it is best to let Aparapi decide automatically) but the option * provides a way to compare a kernel's performance under multiple execution modes. @@ -2264,7 +2269,7 @@ public abstract class Kernel implements Cloneable { return mapping; } - public static String getMappedMethodName(MethodReferenceEntry _methodReferenceEntry) { + public static String getMappedMethodName(ClassModel.ConstantPool.MethodReferenceEntry _methodReferenceEntry) { if (CacheEnabler.areCachesEnabled()) return getProperty(mappedMethodNamesCache, _methodReferenceEntry, null); String mappedName = null; @@ -2304,7 +2309,7 @@ public abstract class Kernel implements Cloneable { return (mappedName); } - public static boolean isMappedMethod(MethodReferenceEntry methodReferenceEntry) { + public static boolean isMappedMethod(ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { if (CacheEnabler.areCachesEnabled()) return getBoolean(mappedMethodFlags, methodReferenceEntry); boolean isMapped = false; @@ -2320,7 +2325,7 @@ public abstract class Kernel implements Cloneable { return (isMapped); } - public static boolean isOpenCLDelegateMethod(MethodReferenceEntry methodReferenceEntry) { + public static boolean isOpenCLDelegateMethod(ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { if (CacheEnabler.areCachesEnabled()) return getBoolean(openCLDelegateMethodFlags, methodReferenceEntry); boolean isMapped = false; @@ -2336,7 +2341,7 @@ public abstract class Kernel implements Cloneable { return (isMapped); } - public static boolean usesAtomic32(MethodReferenceEntry methodReferenceEntry) { + public static boolean usesAtomic32(ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { if (CacheEnabler.areCachesEnabled()) return getProperty(atomic32Cache, methodReferenceEntry, false); for (final Method kernelMethod : Kernel.class.getDeclaredMethods()) { @@ -2351,7 +2356,7 @@ public abstract class Kernel implements Cloneable { } // For alpha release atomic64 is not supported - public static boolean usesAtomic64(MethodReferenceEntry methodReferenceEntry) { + public static boolean usesAtomic64(ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { // if (CacheEnabler.areCachesEnabled()) // return getProperty(atomic64Cache, methodReferenceEntry, false); //for (java.lang.reflect.Method kernelMethod : Kernel.class.getDeclaredMethods()) { @@ -2894,7 +2899,7 @@ public abstract class Kernel implements Cloneable { }); private static boolean getBoolean(ValueCache<Class<?>, Map<String, Boolean>, RuntimeException> methodNamesCache, - MethodReferenceEntry methodReferenceEntry) { + ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { return getProperty(methodNamesCache, methodReferenceEntry, false); } @@ -2930,7 +2935,7 @@ public abstract class Kernel implements Cloneable { } private static <V, T extends Throwable> V getProperty(ValueCache<Class<?>, Map<String, V>, T> cache, - MethodReferenceEntry methodReferenceEntry, V defaultValue) throws T { + ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry, V defaultValue) throws T { Map<String, V> map = cache.computeIfAbsent(methodReferenceEntry.getOwnerClassModel().getClassWeAreModelling()); String key = toSignature(methodReferenceEntry); if (map.containsKey(key)) @@ -2938,8 +2943,8 @@ public abstract class Kernel implements Cloneable { return defaultValue; } - private static String toSignature(MethodReferenceEntry methodReferenceEntry) { - NameAndTypeEntry nameAndTypeEntry = methodReferenceEntry.getNameAndTypeEntry(); + private static String toSignature(ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry) { + ClassModel.ConstantPool.NameAndTypeEntry nameAndTypeEntry = methodReferenceEntry.getNameAndTypeEntry(); return nameAndTypeEntry.getNameUTF8Entry().getUTF8() + nameAndTypeEntry.getDescriptorUTF8Entry().getUTF8(); } diff --git a/src/main/java/com/syncleus/aparapi/ProfileInfo.java b/src/main/java/com/aparapi/ProfileInfo.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/ProfileInfo.java rename to src/main/java/com/aparapi/ProfileInfo.java index fdb7ec8d0a5c96780904b724b144affed2c1e85c..00aadbffa38a2107e0e90b69743075035bba5704 100644 --- a/src/main/java/com/syncleus/aparapi/ProfileInfo.java +++ b/src/main/java/com/aparapi/ProfileInfo.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi; +package com.aparapi; public class ProfileInfo{ diff --git a/src/main/java/com/syncleus/aparapi/Range.java b/src/main/java/com/aparapi/Range.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/Range.java rename to src/main/java/com/aparapi/Range.java index f451fad4c94cec00bef9a257e7bda22cada69c1f..21aab03bf77976b2af53b15b07676f7c3408a93d 100644 --- a/src/main/java/com/syncleus/aparapi/Range.java +++ b/src/main/java/com/aparapi/Range.java @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi; +package com.aparapi; -import com.syncleus.aparapi.device.*; -import com.syncleus.aparapi.internal.jni.*; +import com.aparapi.device.Device; +import com.aparapi.device.JavaDevice; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.jni.RangeJNI; import java.util.*; @@ -62,7 +64,7 @@ import java.util.*; * Range.create3D(width, height, depth, groupWidth, groupHeight, groupDepth); * </pre></blockquote> */ -public class Range extends RangeJNI{ +public class Range extends RangeJNI { public static final int THREADS_PER_CORE = 16; diff --git a/src/main/java/com/syncleus/aparapi/annotation/Experimental.java b/src/main/java/com/aparapi/annotation/Experimental.java similarity index 92% rename from src/main/java/com/syncleus/aparapi/annotation/Experimental.java rename to src/main/java/com/aparapi/annotation/Experimental.java index 4cfd4ad7b53a3e8518dcc242842c5b7fac92ecb3..932b5d20438506dafc84a64b92c5101387e44391 100644 --- a/src/main/java/com/syncleus/aparapi/annotation/Experimental.java +++ b/src/main/java/com/aparapi/annotation/Experimental.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.annotation; +package com.aparapi.annotation; /** * Used to tag experimental features (methods/fields) diff --git a/src/main/java/com/syncleus/aparapi/opencl/package-info.java b/src/main/java/com/aparapi/annotation/package-info.java similarity index 92% rename from src/main/java/com/syncleus/aparapi/opencl/package-info.java rename to src/main/java/com/aparapi/annotation/package-info.java index a1b476c2934690bc520e12433168ad1e1e028b46..835f6363d740fe2907f03b2e5e3d38bc31cf58ac 100644 --- a/src/main/java/com/syncleus/aparapi/opencl/package-info.java +++ b/src/main/java/com/aparapi/annotation/package-info.java @@ -16,4 +16,4 @@ /** * */ -package com.syncleus.aparapi.opencl; \ No newline at end of file +package com.aparapi.annotation; \ No newline at end of file diff --git a/src/main/java/com/syncleus/aparapi/device/Device.java b/src/main/java/com/aparapi/device/Device.java similarity index 88% rename from src/main/java/com/syncleus/aparapi/device/Device.java rename to src/main/java/com/aparapi/device/Device.java index 8a8eccb1e7ec00af3b3f8579967f44bc1a41cebe..658e9ccdfb9352ba4c3dc5e54ac66d56a4c0e219 100644 --- a/src/main/java/com/syncleus/aparapi/device/Device.java +++ b/src/main/java/com/aparapi/device/Device.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.device; +package com.aparapi.device; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.kernel.*; +import com.aparapi.Range; +import com.aparapi.internal.kernel.KernelManager; +import com.aparapi.*; public abstract class Device{ @@ -38,7 +39,7 @@ public abstract class Device{ }; /** @deprecated use {@link KernelManager#bestDevice()} - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @Deprecated public static Device best() { @@ -46,7 +47,7 @@ public abstract class Device{ } /** - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @SuppressWarnings("deprecation") @Deprecated @@ -55,7 +56,7 @@ public abstract class Device{ } /** - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @Deprecated public static Device first(final Device.TYPE _type) { @@ -63,7 +64,7 @@ public abstract class Device{ } /** - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @SuppressWarnings("deprecation") @Deprecated @@ -72,7 +73,7 @@ public abstract class Device{ } /** - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @SuppressWarnings("deprecation") @Deprecated @@ -81,7 +82,7 @@ public abstract class Device{ } /** - * @see com.syncleus.aparapi.device + * @see com.aparapi.device */ @Deprecated public static Device bestACC() { diff --git a/src/main/java/com/syncleus/aparapi/device/JavaDevice.java b/src/main/java/com/aparapi/device/JavaDevice.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/device/JavaDevice.java rename to src/main/java/com/aparapi/device/JavaDevice.java index 08e08ac67830d20df205806d546f0227ecd97757..eaeb8abed896a24633f43022324bc6d35e7a62bc 100644 --- a/src/main/java/com/syncleus/aparapi/device/JavaDevice.java +++ b/src/main/java/com/aparapi/device/JavaDevice.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.device; +package com.aparapi.device; public class JavaDevice extends Device { diff --git a/src/main/java/com/syncleus/aparapi/device/OpenCLDevice.java b/src/main/java/com/aparapi/device/OpenCLDevice.java similarity index 90% rename from src/main/java/com/syncleus/aparapi/device/OpenCLDevice.java rename to src/main/java/com/aparapi/device/OpenCLDevice.java index 37ddf8b0bf6d677ced8f3d7a74fc9e5c50a3cb62..f031b5df898150ed364bb224886f3d3d51c597b8 100644 --- a/src/main/java/com/syncleus/aparapi/device/OpenCLDevice.java +++ b/src/main/java/com/aparapi/device/OpenCLDevice.java @@ -13,13 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.device; +package com.aparapi.device; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.opencl.*; -import com.syncleus.aparapi.opencl.*; -import com.syncleus.aparapi.opencl.OpenCL.*; -import com.syncleus.aparapi.opencl.OpenCL.Kernel; +import com.aparapi.Range; +import com.aparapi.internal.opencl.OpenCLArgDescriptor; +import com.aparapi.internal.opencl.OpenCLKernel; +import com.aparapi.internal.opencl.OpenCLPlatform; +import com.aparapi.internal.opencl.OpenCLProgram; +import com.aparapi.opencl.OpenCL; +import com.aparapi.*; import java.io.*; import java.lang.annotation.*; @@ -212,23 +214,23 @@ public class OpenCLDevice extends Device{ long bits = 0L; String name = null; for (final Annotation pa : parameterAnnotations[arg]) { - if (pa instanceof GlobalReadOnly) { - name = ((GlobalReadOnly) pa).value(); + if (pa instanceof OpenCL.GlobalReadOnly) { + name = ((OpenCL.GlobalReadOnly) pa).value(); bits |= OpenCLArgDescriptor.ARG_GLOBAL_BIT | OpenCLArgDescriptor.ARG_READONLY_BIT; - } else if (pa instanceof GlobalWriteOnly) { - name = ((GlobalWriteOnly) pa).value(); + } else if (pa instanceof OpenCL.GlobalWriteOnly) { + name = ((OpenCL.GlobalWriteOnly) pa).value(); bits |= OpenCLArgDescriptor.ARG_GLOBAL_BIT | OpenCLArgDescriptor.ARG_WRITEONLY_BIT; - } else if (pa instanceof GlobalReadWrite) { - name = ((GlobalReadWrite) pa).value(); + } else if (pa instanceof OpenCL.GlobalReadWrite) { + name = ((OpenCL.GlobalReadWrite) pa).value(); bits |= OpenCLArgDescriptor.ARG_GLOBAL_BIT | OpenCLArgDescriptor.ARG_READWRITE_BIT; - } else if (pa instanceof Local) { - name = ((Local) pa).value(); + } else if (pa instanceof OpenCL.Local) { + name = ((OpenCL.Local) pa).value(); bits |= OpenCLArgDescriptor.ARG_LOCAL_BIT; - } else if (pa instanceof Constant) { - name = ((Constant) pa).value(); + } else if (pa instanceof OpenCL.Constant) { + name = ((OpenCL.Constant) pa).value(); bits |= OpenCLArgDescriptor.ARG_CONST_BIT | OpenCLArgDescriptor.ARG_READONLY_BIT; - } else if (pa instanceof Arg) { - name = ((Arg) pa).value(); + } else if (pa instanceof OpenCL.Arg) { + name = ((OpenCL.Arg) pa).value(); bits |= OpenCLArgDescriptor.ARG_ISARG_BIT; } @@ -328,12 +330,12 @@ public class OpenCLDevice extends Device{ final StringBuilder sourceBuilder = new StringBuilder(); boolean interfaceIsAnnotated = false; for (final Annotation a : _interface.getAnnotations()) { - if (a instanceof Source) { - final Source source = (Source) a; + if (a instanceof OpenCL.Source) { + final OpenCL.Source source = (OpenCL.Source) a; sourceBuilder.append(source.value()).append("\n"); interfaceIsAnnotated = true; - } else if (a instanceof Resource) { - final Resource sourceResource = (Resource) a; + } else if (a instanceof OpenCL.Resource) { + final OpenCL.Resource sourceResource = (OpenCL.Resource) a; final InputStream stream = _interface.getClassLoader().getResourceAsStream(sourceResource.value()); sourceBuilder.append(streamToString(stream)); interfaceIsAnnotated = true; @@ -355,7 +357,7 @@ public class OpenCLDevice extends Device{ for (final Annotation a : m.getAnnotations()) { // System.out.println(" annotation "+a); // System.out.println(" annotation type " + a.annotationType()); - if (a instanceof Kernel) { + if (a instanceof OpenCL.Kernel) { sourceBuilder.append("__kernel void " + m.getName() + "("); final List<OpenCLArgDescriptor> args = getArgs(m); @@ -370,7 +372,7 @@ public class OpenCLDevice extends Device{ } sourceBuilder.append(")"); - final Kernel kernel = (Kernel) a; + final OpenCL.Kernel kernel = (OpenCL.Kernel) a; sourceBuilder.append(kernel.value()); kernelNameToArgsMap.put(m.getName(), args); diff --git a/src/main/java/com/syncleus/aparapi/device/package-info.java b/src/main/java/com/aparapi/device/package-info.java similarity index 64% rename from src/main/java/com/syncleus/aparapi/device/package-info.java rename to src/main/java/com/aparapi/device/package-info.java index c1bd31261a3ebcafded8919c2b1c6f4031a2c521..2785230f0b000b2a1d47bde00b821d37b3dc338b 100644 --- a/src/main/java/com/syncleus/aparapi/device/package-info.java +++ b/src/main/java/com/aparapi/device/package-info.java @@ -16,19 +16,22 @@ /** * Contains classes representing OpenCL-capable devices, and "virtual" (java) devices which execute kernels using java. * - * <p>Various methods of {@link com.syncleus.aparapi.device.Device} which selected devices of a particular type have been deprecated, - * as now the preferred mechanism for device selection is to rely on the {@link com.syncleus.aparapi.internal.kernel.KernelManager} to + * <p>Various methods of {@link com.aparapi.device.Device} which selected devices of a particular type have been deprecated, + * as now the preferred mechanism for device selection is to rely on the {@link com.aparapi.internal.kernel.KernelManager} to * select an appropriate device. Where a particular device is required to be used for a certain kernel, for such purposes as * debugging or unit testing, this can be achieved by using - * {@link com.syncleus.aparapi.internal.kernel.KernelManager#setKernelManager(com.syncleus.aparapi.internal.kernel.KernelManager)} prior to - * invoking any Kernel executions, by overriding {@link com.syncleus.aparapi.Kernel#isAllowDevice(com.syncleus.aparapi.device.Device)} + * {@link com.aparapi.internal.kernel.KernelManager#setKernelManager(KernelManager)} prior to + * invoking any Kernel executions, by overriding {@link com.aparapi.Kernel#isAllowDevice(Device)} * to veto/approve devices from the available devices for a given Kernel class, or (not recommended) by using - * {@link com.syncleus.aparapi.internal.kernel.KernelManager#setPreferredDevices(com.syncleus.aparapi.Kernel, java.util.LinkedHashSet)} to specify + * {@link com.aparapi.internal.kernel.KernelManager#setPreferredDevices(Kernel, java.util.LinkedHashSet)} to specify * a particular device list for a given Kernel class. * - * <p>In order to determine the Device which will be used to execute a particular Kernel, use {@link com.syncleus.aparapi.Kernel#getTargetDevice()}. + * <p>In order to determine the Device which will be used to execute a particular Kernel, use {@link com.aparapi.Kernel#getTargetDevice()}. * This can also be used immediately after execution to see on which device the kernel actually got executed (in case the execution failed * and fell back to another device). * */ -package com.syncleus.aparapi.device; \ No newline at end of file +package com.aparapi.device; + +import com.aparapi.Kernel; +import com.aparapi.internal.kernel.KernelManager; \ No newline at end of file diff --git a/src/main/java/com/syncleus/aparapi/exception/DeprecatedException.java b/src/main/java/com/aparapi/exception/DeprecatedException.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/exception/DeprecatedException.java rename to src/main/java/com/aparapi/exception/DeprecatedException.java index 62db0f0a73171dd0e92ea0391e4469648853e56c..628e5377088b07beb901414516e6f32a6ceb5f4f 100644 --- a/src/main/java/com/syncleus/aparapi/exception/DeprecatedException.java +++ b/src/main/java/com/aparapi/exception/DeprecatedException.java @@ -50,9 +50,9 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.exception; +package com.aparapi.exception; -import com.syncleus.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.AparapiException; @SuppressWarnings("serial") public class DeprecatedException extends AparapiException{ diff --git a/src/main/java/com/syncleus/aparapi/exception/package-info.java b/src/main/java/com/aparapi/exception/package-info.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/exception/package-info.java rename to src/main/java/com/aparapi/exception/package-info.java index c96396e15f60f3fd97be709a00e5684ad0cb8fb5..0f2873dfa3426accafd6ddee073516f7b6f5d4af 100644 --- a/src/main/java/com/syncleus/aparapi/exception/package-info.java +++ b/src/main/java/com/aparapi/exception/package-info.java @@ -16,4 +16,4 @@ /** * */ -package com.syncleus.aparapi.exception; \ No newline at end of file +package com.aparapi.exception; \ No newline at end of file diff --git a/src/main/java/com/syncleus/aparapi/internal/annotation/DocMe.java b/src/main/java/com/aparapi/internal/annotation/DocMe.java similarity index 90% rename from src/main/java/com/syncleus/aparapi/internal/annotation/DocMe.java rename to src/main/java/com/aparapi/internal/annotation/DocMe.java index 2363c4db3c623d3e27ff3a9b148abe8b04f5116b..054b79ae716f9299329ca8d2c1fd52cc4b7633b0 100644 --- a/src/main/java/com/syncleus/aparapi/internal/annotation/DocMe.java +++ b/src/main/java/com/aparapi/internal/annotation/DocMe.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.annotation; +package com.aparapi.internal.annotation; /** * Use this annotation to tag stuff that needs Java Doc added diff --git a/src/main/java/com/syncleus/aparapi/internal/annotation/RemoveMe.java b/src/main/java/com/aparapi/internal/annotation/RemoveMe.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/annotation/RemoveMe.java rename to src/main/java/com/aparapi/internal/annotation/RemoveMe.java index 451dac7b0c71a3b177e1b636dc14390bf043ad05..584693fee02b390e3f4616fe36287b80714a363b 100644 --- a/src/main/java/com/syncleus/aparapi/internal/annotation/RemoveMe.java +++ b/src/main/java/com/aparapi/internal/annotation/RemoveMe.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.annotation; +package com.aparapi.internal.annotation; /** * Use this annotation to tag fields that we think need to be removed (method/field/var) diff --git a/src/main/java/com/syncleus/aparapi/internal/annotation/Unused.java b/src/main/java/com/aparapi/internal/annotation/Unused.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/annotation/Unused.java rename to src/main/java/com/aparapi/internal/annotation/Unused.java index 00db9d7a9747333c8263ec7ae0e9492a8939700b..fed55e49415f8edd0b2648342a4fca4afb7bec8d 100644 --- a/src/main/java/com/syncleus/aparapi/internal/annotation/Unused.java +++ b/src/main/java/com/aparapi/internal/annotation/Unused.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.annotation; +package com.aparapi.internal.annotation; /** * Used to tag unused features (methods/fields) diff --git a/src/main/java/com/syncleus/aparapi/internal/annotation/UsedByJNICode.java b/src/main/java/com/aparapi/internal/annotation/UsedByJNICode.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/annotation/UsedByJNICode.java rename to src/main/java/com/aparapi/internal/annotation/UsedByJNICode.java index 745726318e0bc05bf83ea891651600034223a009..829d2e5c6bf2c84f1010328edef8874473c60336 100644 --- a/src/main/java/com/syncleus/aparapi/internal/annotation/UsedByJNICode.java +++ b/src/main/java/com/aparapi/internal/annotation/UsedByJNICode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.annotation; +package com.aparapi.internal.annotation; /** * Be careful changing the name/type of this field as it is referenced from JNI code. diff --git a/src/main/java/com/syncleus/aparapi/internal/exception/AparapiException.java b/src/main/java/com/aparapi/internal/exception/AparapiException.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/exception/AparapiException.java rename to src/main/java/com/aparapi/internal/exception/AparapiException.java index 9e77d87368dd89c1b90289d69e688f1e53630f9c..f0cafb0b7a88d04bfcd8bf8cbc0e9d76a224ea2c 100644 --- a/src/main/java/com/syncleus/aparapi/internal/exception/AparapiException.java +++ b/src/main/java/com/aparapi/internal/exception/AparapiException.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.exception; +package com.aparapi.internal.exception; /** * We use <code>AparapiException</code> class and subclasses to wrap other @@ -59,8 +59,8 @@ package com.syncleus.aparapi.internal.exception; * The class parser for example will throw a specific <code>ClassParseException</code> if any Aparapi unfriendly * constructs are found. This allows us to <strong>fail fast</strong> during classfile parsing. * - * @see com.syncleus.aparapi.internal.exception.ClassParseException - * @see com.syncleus.aparapi.internal.exception.CodeGenException + * @see ClassParseException + * @see CodeGenException * * @author gfrost * diff --git a/src/main/java/com/syncleus/aparapi/internal/exception/ClassParseException.java b/src/main/java/com/aparapi/internal/exception/ClassParseException.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/exception/ClassParseException.java rename to src/main/java/com/aparapi/internal/exception/ClassParseException.java index 9114a3bf4070990db9cd4eb3afb901bdee11fcc2..25d0e48fbf5ff02f190c7bd2fe9fb97432a3c6a6 100644 --- a/src/main/java/com/syncleus/aparapi/internal/exception/ClassParseException.java +++ b/src/main/java/com/aparapi/internal/exception/ClassParseException.java @@ -50,15 +50,15 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.exception; +package com.aparapi.internal.exception; -import com.syncleus.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.Instruction; /** * We throw <code>ClassParseException</code>s (derived from <code>AparapiException</code>) if we encounter any Aparapi unfriendly * constructs. This allows us to <strong>fail fast</strong>. * - * @see com.syncleus.aparapi.internal.exception.AparapiException + * @see AparapiException * * @author gfrost * diff --git a/src/main/java/com/syncleus/aparapi/internal/exception/CodeGenException.java b/src/main/java/com/aparapi/internal/exception/CodeGenException.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/internal/exception/CodeGenException.java rename to src/main/java/com/aparapi/internal/exception/CodeGenException.java index f529d1335153fa61766d0ffed6ac2e2c62ef17b5..e32cd0701ade6d96d8bd00fe83b24f9a24455b62 100644 --- a/src/main/java/com/syncleus/aparapi/internal/exception/CodeGenException.java +++ b/src/main/java/com/aparapi/internal/exception/CodeGenException.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.exception; +package com.aparapi.internal.exception; @SuppressWarnings("serial") public class CodeGenException extends AparapiException{ diff --git a/src/main/java/com/syncleus/aparapi/internal/exception/RangeException.java b/src/main/java/com/aparapi/internal/exception/RangeException.java similarity index 97% rename from src/main/java/com/syncleus/aparapi/internal/exception/RangeException.java rename to src/main/java/com/aparapi/internal/exception/RangeException.java index 30633a02afd2fb9c9abff6e336a73900965c03b1..12c4fdbb1e752265801c2e8d53ee7b4c44d19a59 100644 --- a/src/main/java/com/syncleus/aparapi/internal/exception/RangeException.java +++ b/src/main/java/com/aparapi/internal/exception/RangeException.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.exception; +package com.aparapi.internal.exception; @SuppressWarnings("serial") public class RangeException extends AparapiException{ diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/BranchSet.java b/src/main/java/com/aparapi/internal/instruction/BranchSet.java similarity index 89% rename from src/main/java/com/syncleus/aparapi/internal/instruction/BranchSet.java rename to src/main/java/com/aparapi/internal/instruction/BranchSet.java index 46816933820b1d3ab67f5192d29ea857d99d0f5b..a88649d9151367b50883020c42f5a9ba52a8d476 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/BranchSet.java +++ b/src/main/java/com/aparapi/internal/instruction/BranchSet.java @@ -50,16 +50,13 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; +package com.aparapi.internal.instruction; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Branch; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ConditionalBranch; - /** * Deals with the issue of recognizing that a sequence of bytecode branch instructions actually represent a single if/while with a logical expression. * @@ -172,15 +169,15 @@ public class BranchSet { * */ public static class SimpleLogicalExpressionNode extends LogicalExpressionNode { - private final ConditionalBranch branch; + private final InstructionSet.ConditionalBranch branch; private boolean invert; - public SimpleLogicalExpressionNode(ConditionalBranch _branch) { + public SimpleLogicalExpressionNode(InstructionSet.ConditionalBranch _branch) { this(_branch, false); } - private SimpleLogicalExpressionNode(ConditionalBranch _branch, boolean _invert) { + private SimpleLogicalExpressionNode(InstructionSet.ConditionalBranch _branch, boolean _invert) { branch = _branch; invert = _invert; } @@ -209,7 +206,7 @@ public class BranchSet { return (invert); } - public ConditionalBranch getBranch() { + public InstructionSet.ConditionalBranch getBranch() { return branch; } @@ -300,15 +297,15 @@ public class BranchSet { } - private final List<ConditionalBranch> set = new ArrayList<ConditionalBranch>(); + private final List<InstructionSet.ConditionalBranch> set = new ArrayList<InstructionSet.ConditionalBranch>(); private final Instruction fallThrough; private final Instruction target; - private final Branch last; + private final InstructionSet.Branch last; - private Branch first; + private InstructionSet.Branch first; private LogicalExpressionNode logicalExpressionNode = null; @@ -319,11 +316,11 @@ public class BranchSet { * * @param _branch */ - public BranchSet(Branch _branch) { + public BranchSet(InstructionSet.Branch _branch) { target = _branch.getTarget(); last = _branch; - final Set<Branch> expandedSet = new LinkedHashSet<Branch>(); + final Set<InstructionSet.Branch> expandedSet = new LinkedHashSet<InstructionSet.Branch>(); final Instruction fallThroughRoot = last.getNextExpr(); fallThrough = fallThroughRoot == null ? last.getNextPC() : fallThroughRoot.getStartInstruction(); first = last; @@ -338,14 +335,14 @@ public class BranchSet { } } for (Instruction i = first; i != fallThroughRoot; i = i.getNextExpr()) { - set.add((ConditionalBranch) i.asBranch()); - ((ConditionalBranch) i.asBranch()).setBranchSet(this); + set.add((InstructionSet.ConditionalBranch) i.asBranch()); + ((InstructionSet.ConditionalBranch) i.asBranch()).setBranchSet(this); } // ConditionalBranch16 branches[] = set.toArray(new ConditionalBranch16[0]); LogicalExpressionNode end = null; - for (final ConditionalBranch cb : set) { + for (final InstructionSet.ConditionalBranch cb : set) { final SimpleLogicalExpressionNode sn = new SimpleLogicalExpressionNode(cb); if (logicalExpressionNode == null) { logicalExpressionNode = sn; @@ -391,21 +388,21 @@ public class BranchSet { } } - public List<ConditionalBranch> getBranches() { + public List<InstructionSet.ConditionalBranch> getBranches() { return (set); } - public Branch getFirst() { + public InstructionSet.Branch getFirst() { return (first); } - public Branch getLast() { + public InstructionSet.Branch getLast() { return (last); } public void unhook() { - for (final Branch b : set) { + for (final InstructionSet.Branch b : set) { b.unhook(); } } diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/ExpressionList.java b/src/main/java/com/aparapi/internal/instruction/ExpressionList.java similarity index 85% rename from src/main/java/com/syncleus/aparapi/internal/instruction/ExpressionList.java rename to src/main/java/com/aparapi/internal/instruction/ExpressionList.java index 2366e62c72589e9be651f578d731e2255731109e..d22c438073bd4cd7a60c21c701b0c868d2462794 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/ExpressionList.java +++ b/src/main/java/com/aparapi/internal/instruction/ExpressionList.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; +package com.aparapi.internal.instruction; import java.util.ArrayList; import java.util.LinkedList; @@ -58,20 +58,11 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import com.syncleus.aparapi.Config; -import com.syncleus.aparapi.internal.exception.ClassParseException; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AssignToLocalVariable; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Branch; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ByteCode; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CompositeArbitraryScopeInstruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CompositeInstruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ConditionalBranch; -import com.syncleus.aparapi.internal.instruction.InstructionSet.FakeGoto; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Return; -import com.syncleus.aparapi.internal.instruction.InstructionSet.UnconditionalBranch; -import com.syncleus.aparapi.internal.model.MethodModel; -import com.syncleus.aparapi.internal.model.ClassModel.LocalVariableTableEntry; -import com.syncleus.aparapi.internal.model.ClassModel.LocalVariableInfo; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.Config; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.internal.model.ClassModel.LocalVariableInfo; /** * Essentially a glorified linked list of Instructions plus some additional state to allow us to transform sequences. @@ -152,7 +143,7 @@ public class ExpressionList{ public boolean doesNotContainCompositeOrBranch(Instruction _start, Instruction _exclusiveEnd) { boolean ok = true; for (Instruction i = _start; (i != null) && (i != _exclusiveEnd); i = i.getNextExpr()) { - if (!(i instanceof CompositeInstruction) && (i.isBranch())) { + if (!(i instanceof InstructionSet.CompositeInstruction) && (i.isBranch())) { ok = false; break; } @@ -471,7 +462,7 @@ public class ExpressionList{ * <---------- * </pre> **/ - final BranchSet branchSet = ((ConditionalBranch) tail.asBranch()).getOrCreateBranchSet(); + final BranchSet branchSet = ((InstructionSet.ConditionalBranch) tail.asBranch()).getOrCreateBranchSet(); Instruction loopTop = branchSet.getTarget().getRootExpr(); final Instruction beginingOfBranch = branchSet.getFirst(); @@ -480,14 +471,14 @@ public class ExpressionList{ if (startOfBeginningOfBranch == loopTop) { loopTop = loopTop.getPrevExpr(); - if (loopTop instanceof AssignToLocalVariable) { - final LocalVariableInfo localVariableInfo = ((AssignToLocalVariable) loopTop).getLocalVariableInfo(); + if (loopTop instanceof InstructionSet.AssignToLocalVariable) { + final ClassModel.LocalVariableInfo localVariableInfo = ((InstructionSet.AssignToLocalVariable) loopTop).getLocalVariableInfo(); if ((localVariableInfo.getStart() == loopTop.getNextExpr().getStartPC()) && (localVariableInfo.getEnd() == _instruction.getThisPC())) { loopTop = loopTop.getPrevExpr(); // back up over the initialization } } - addAsComposites(ByteCode.COMPOSITE_EMPTY_LOOP, loopTop, branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_EMPTY_LOOP, loopTop, branchSet); handled = true; } else { @@ -499,14 +490,14 @@ public class ExpressionList{ loopTop = loopTop.getPrevExpr(); // looptop == the unconditional? loopTop = loopTop.getPrevExpr(); - if (loopTop instanceof AssignToLocalVariable) { - final LocalVariableInfo localVariableInfo = ((AssignToLocalVariable) loopTop).getLocalVariableInfo(); + if (loopTop instanceof InstructionSet.AssignToLocalVariable) { + final ClassModel.LocalVariableInfo localVariableInfo = ((InstructionSet.AssignToLocalVariable) loopTop).getLocalVariableInfo(); if ((localVariableInfo.getStart() == loopTop.getNextExpr().getStartPC()) && (localVariableInfo.getEnd() == _instruction.getThisPC())) { loopTop = loopTop.getPrevExpr(); // back up over the initialization } } - addAsComposites(ByteCode.COMPOSITE_FOR_ECLIPSE, loopTop, branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_FOR_ECLIPSE, loopTop, branchSet); handled = true; } } @@ -520,7 +511,7 @@ public class ExpressionList{ .getPrevExpr())) { loopTop = loopTop.getPrevExpr(); branchSet.unhook(); - addAsComposites(ByteCode.COMPOSITE_DO_WHILE, loopTop, branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_DO_WHILE, loopTop, branchSet); handled = true; } } else { @@ -555,9 +546,9 @@ public class ExpressionList{ * *</pre> */ - final ConditionalBranch lastForwardConditional = _instruction.getForwardConditionalBranches().getLast(); + final InstructionSet.ConditionalBranch lastForwardConditional = _instruction.getForwardConditionalBranches().getLast(); final BranchSet branchSet = lastForwardConditional.getOrCreateBranchSet(); - final Branch reverseGoto = tail.asBranch(); + final InstructionSet.Branch reverseGoto = tail.asBranch(); final Instruction loopBackTarget = reverseGoto.getTarget(); if (loopBackTarget.getReverseUnconditionalBranches().size() > 1) { throw new ClassParseException(ClassParseException.TYPE.CONFUSINGBRANCHESPOSSIBLYCONTINUE); @@ -574,7 +565,7 @@ public class ExpressionList{ * *</pre> */ - final Branch lastForwardUnconditional = _instruction.getForwardUnconditionalBranches().getLast(); + final InstructionSet.Branch lastForwardUnconditional = _instruction.getForwardUnconditionalBranches().getLast(); if ((lastForwardUnconditional != null) && lastForwardUnconditional.isAfter(lastForwardConditional)) { throw new ClassParseException(ClassParseException.TYPE.CONFUSINGBRANCHESPOSSIBLYBREAK); } @@ -607,7 +598,7 @@ public class ExpressionList{ final Instruction loopbackTargetRoot = loopBackTarget.getRootExpr(); if (loopbackTargetRoot.isBranch() && loopbackTargetRoot.asBranch().isConditional()) { - final ConditionalBranch topOfRealLoop = (ConditionalBranch) loopbackTargetRoot.asBranch(); + final InstructionSet.ConditionalBranch topOfRealLoop = (InstructionSet.ConditionalBranch) loopbackTargetRoot.asBranch(); BranchSet extentBranchSet = topOfRealLoop.getBranchSet(); if (topOfRealLoop.getBranchSet() == null) { extentBranchSet = topOfRealLoop.findEndOfConditionalBranchSet(_instruction.getNextPC()) @@ -617,8 +608,8 @@ public class ExpressionList{ if (doesNotContainCompositeOrBranch(extentBranchSet.getLast().getNextExpr(), reverseGoto)) { Instruction loopTop = topOfRealLoop.getPrevExpr(); - if (loopTop instanceof AssignToLocalVariable) { - final LocalVariableInfo localVariableInfo = ((AssignToLocalVariable) loopTop).getLocalVariableInfo(); + if (loopTop instanceof InstructionSet.AssignToLocalVariable) { + final ClassModel.LocalVariableInfo localVariableInfo = ((InstructionSet.AssignToLocalVariable) loopTop).getLocalVariableInfo(); if ((localVariableInfo.getStart() == loopTop.getNextExpr().getStartPC()) && (localVariableInfo.getEnd() == _instruction.getThisPC())) { loopTop = loopTop.getPrevExpr(); // back up over the initialization @@ -626,8 +617,8 @@ public class ExpressionList{ } extentBranchSet.unhook(); - addAsComposites(ByteCode.COMPOSITE_FOR_SUN, loopTop, extentBranchSet); - final UnconditionalBranch fakeGoto = new FakeGoto(methodModel, extentBranchSet.getLast().getTarget()); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_FOR_SUN, loopTop, extentBranchSet); + final InstructionSet.UnconditionalBranch fakeGoto = new InstructionSet.FakeGoto(methodModel, extentBranchSet.getLast().getTarget()); add(fakeGoto); extentBranchSet.getLast().getTarget().addBranchTarget(fakeGoto); @@ -651,8 +642,8 @@ public class ExpressionList{ } } - if (loopTop instanceof AssignToLocalVariable) { - final LocalVariableInfo localVariableInfo = ((AssignToLocalVariable) loopTop).getLocalVariableInfo(); + if (loopTop instanceof InstructionSet.AssignToLocalVariable) { + final ClassModel.LocalVariableInfo localVariableInfo = ((InstructionSet.AssignToLocalVariable) loopTop).getLocalVariableInfo(); if ((localVariableInfo.getStart() == loopTop.getNextExpr().getStartPC()) && (localVariableInfo.getEnd() == _instruction.getThisPC())) { loopTop = loopTop.getPrevExpr(); // back up over the initialization @@ -663,10 +654,10 @@ public class ExpressionList{ // If there is an inner scope, it is likely that the loop counter var // is modified using an inner scope variable so use while rather than for - if (reverseGoto.getPrevExpr() instanceof CompositeArbitraryScopeInstruction) { - addAsComposites(ByteCode.COMPOSITE_WHILE, loopTop, branchSet); + if (reverseGoto.getPrevExpr() instanceof InstructionSet.CompositeArbitraryScopeInstruction) { + addAsComposites(InstructionSet.ByteCode.COMPOSITE_WHILE, loopTop, branchSet); } else { - addAsComposites(ByteCode.COMPOSITE_FOR_SUN, loopTop, branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_FOR_SUN, loopTop, branchSet); } handled = true; } @@ -683,31 +674,31 @@ public class ExpressionList{ * *</pre> */ - final ConditionalBranch lastForwardConditional = _instruction.getForwardConditionalBranches().getLast(); + final InstructionSet.ConditionalBranch lastForwardConditional = _instruction.getForwardConditionalBranches().getLast(); final BranchSet branchSet = lastForwardConditional.getOrCreateBranchSet(); if (doesNotContainContinueOrBreak(branchSet.getLast().getNextExpr(), _instruction)) { branchSet.unhook(); - addAsComposites(ByteCode.COMPOSITE_IF, branchSet.getFirst().getPrevExpr(), branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_IF, branchSet.getFirst().getPrevExpr(), branchSet); handled = true; } } if (!handled && !tail.isForwardBranch() && _instruction.isForwardUnconditionalBranchTarget()) { - final LinkedList<Branch> forwardUnconditionalBranches = _instruction.getForwardUnconditionalBranches(); + final LinkedList<InstructionSet.Branch> forwardUnconditionalBranches = _instruction.getForwardUnconditionalBranches(); - final Branch lastForwardUnconditional = forwardUnconditionalBranches.getLast(); + final InstructionSet.Branch lastForwardUnconditional = forwardUnconditionalBranches.getLast(); final Instruction afterGoto = lastForwardUnconditional.getNextExpr(); if (afterGoto.getStartInstruction().isForwardConditionalBranchTarget()) { - final LinkedList<ConditionalBranch> forwardConditionalBranches = afterGoto.getStartInstruction() + final LinkedList<InstructionSet.ConditionalBranch> forwardConditionalBranches = afterGoto.getStartInstruction() .getForwardConditionalBranches(); - final ConditionalBranch lastForwardConditional = forwardConditionalBranches.getLast(); + final InstructionSet.ConditionalBranch lastForwardConditional = forwardConditionalBranches.getLast(); final BranchSet branchSet = lastForwardConditional.getOrCreateBranchSet(); if (doesNotContainCompositeOrBranch(branchSet.getLast().getNextExpr(), lastForwardUnconditional)) { if (doesNotContainContinueOrBreak(afterGoto.getNextExpr(), _instruction)) { branchSet.unhook(); lastForwardUnconditional.unhook(); - addAsComposites(ByteCode.COMPOSITE_IF_ELSE, branchSet.getFirst().getPrevExpr(), branchSet); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_IF_ELSE, branchSet.getFirst().getPrevExpr(), branchSet); handled = true; } } else { @@ -730,8 +721,8 @@ public class ExpressionList{ // as a possible end for (int i = forwardUnconditionalBranches.size(); i > 1; i--) { - final Branch thisGoto = forwardUnconditionalBranches.get(i - 1); - final Branch elseGoto = forwardUnconditionalBranches.get(i - 2); + final InstructionSet.Branch thisGoto = forwardUnconditionalBranches.get(i - 1); + final InstructionSet.Branch elseGoto = forwardUnconditionalBranches.get(i - 2); final Instruction afterElseGoto = elseGoto.getNextExpr(); if (afterElseGoto.getStartInstruction().isConditionalBranchTarget()) { final BranchSet elseBranchSet = afterElseGoto.getStartInstruction() @@ -748,8 +739,8 @@ public class ExpressionList{ } - final CompositeInstruction composite = CompositeInstruction.create( - ByteCode.COMPOSITE_IF_ELSE, methodModel, elseBranchSet.getFirst(), thisGoto, + final InstructionSet.CompositeInstruction composite = InstructionSet.CompositeInstruction.create( + InstructionSet.ByteCode.COMPOSITE_IF_ELSE, methodModel, elseBranchSet.getFirst(), thisGoto, elseBranchSet); replaceInclusive(elseBranchSet.getFirst(), thisGoto.getPrevExpr(), composite); @@ -772,8 +763,8 @@ public class ExpressionList{ && _instruction.isForwardUnconditionalBranchTarget()) { // here we have multiple composites ending at the same point - final Branch lastForwardUnconditional = _instruction.getForwardUnconditionalBranches().getLast(); - final ConditionalBranch lastForwardConditional = _instruction.getStartInstruction() + final InstructionSet.Branch lastForwardUnconditional = _instruction.getForwardUnconditionalBranches().getLast(); + final InstructionSet.ConditionalBranch lastForwardConditional = _instruction.getStartInstruction() .getForwardConditionalBranches().getLast(); // we will clip the tail and see if recursing helps @@ -796,11 +787,11 @@ public class ExpressionList{ } else { // might be end of arbitrary scope - final LocalVariableTableEntry<LocalVariableInfo> localVariableTable = methodModel.getMethod() + final ClassModel.LocalVariableTableEntry<LocalVariableInfo> localVariableTable = methodModel.getMethod() .getLocalVariableTableEntry(); int startPc = Short.MAX_VALUE; - for (final LocalVariableInfo localVariableInfo : localVariableTable) { + for (final ClassModel.LocalVariableInfo localVariableInfo : localVariableTable) { if (localVariableInfo.getEnd() == _instruction.getThisPC()) { logger.fine(localVariableInfo.getVariableName() + " scope " + localVariableInfo.getStart() + " ," + localVariableInfo.getEnd()); @@ -816,7 +807,7 @@ public class ExpressionList{ final Instruction startInstruction = i.getRootExpr().getPrevExpr(); logger.fine("Start = " + startInstruction); - addAsComposites(ByteCode.COMPOSITE_ARBITRARY_SCOPE, startInstruction.getPrevExpr(), null); + addAsComposites(InstructionSet.ByteCode.COMPOSITE_ARBITRARY_SCOPE, startInstruction.getPrevExpr(), null); handled = true; break; } @@ -839,10 +830,10 @@ public class ExpressionList{ return (handled); } - private void addAsComposites(ByteCode _byteCode, Instruction _start, BranchSet _branchSet) { + private void addAsComposites(InstructionSet.ByteCode _byteCode, Instruction _start, BranchSet _branchSet) { final Instruction childTail = tail; final Instruction childHead = createList(_start); - final CompositeInstruction composite = CompositeInstruction.create(_byteCode, methodModel, childHead, childTail, _branchSet); + final InstructionSet.CompositeInstruction composite = InstructionSet.CompositeInstruction.create(_byteCode, methodModel, childHead, childTail, _branchSet); add(composite); } @@ -874,7 +865,7 @@ public class ExpressionList{ final Instruction[] array = list.toArray(new Instruction[0]); boolean lastWasCursor = false; - final List<Branch> branches = new ArrayList<Branch>(); + final List<InstructionSet.Branch> branches = new ArrayList<InstructionSet.Branch>(); for (final Instruction i : list) { sb.append(String.format(" %3d", i.getStartPC())); } @@ -914,9 +905,9 @@ public class ExpressionList{ } else { sb.append("<<"); } - } else if (i instanceof CompositeInstruction) { + } else if (i instanceof InstructionSet.CompositeInstruction) { sb.append(" C"); - } else if (i instanceof Return) { + } else if (i instanceof InstructionSet.Return) { sb.append(" R"); // } else if (i instanceof AssignToLocalVariable) { @@ -932,7 +923,7 @@ public class ExpressionList{ sb.append(" "); } - for (final Branch b : branches) { + for (final InstructionSet.Branch b : branches) { sb.append("\n "); if (b.isForward()) { for (int i = 0; i < array.length; i++) { diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/Instruction.java b/src/main/java/com/aparapi/internal/instruction/Instruction.java similarity index 84% rename from src/main/java/com/syncleus/aparapi/internal/instruction/Instruction.java rename to src/main/java/com/aparapi/internal/instruction/Instruction.java index a04148a84442ff44a92456d1ab2af0810cae40f2..c786a28f85acb20ac78233f3649ae16b37049a5b 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/Instruction.java +++ b/src/main/java/com/aparapi/internal/instruction/Instruction.java @@ -50,16 +50,12 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; +package com.aparapi.internal.instruction; import java.util.LinkedList; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Branch; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ByteCode; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CompositeInstruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ConditionalBranch; -import com.syncleus.aparapi.internal.model.MethodModel; -import com.syncleus.aparapi.internal.reader.ByteReader; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.internal.reader.ByteReader; /** * Initially represents a single Java bytecode instruction. @@ -76,7 +72,7 @@ public abstract class Instruction{ protected MethodModel method; - private final ByteCode byteCode; + private final InstructionSet.ByteCode byteCode; private int length; @@ -94,13 +90,13 @@ public abstract class Instruction{ private Instruction parentExpr = null; - private LinkedList<ConditionalBranch> forwardConditionalBranchTargets; + private LinkedList<InstructionSet.ConditionalBranch> forwardConditionalBranchTargets; - private LinkedList<ConditionalBranch> reverseConditionalBranchTargets; + private LinkedList<InstructionSet.ConditionalBranch> reverseConditionalBranchTargets; - private LinkedList<Branch> forwardUnconditionalBranchTargets; + private LinkedList<InstructionSet.Branch> forwardUnconditionalBranchTargets; - private LinkedList<Branch> reverseUnconditionalBranchTargets; + private LinkedList<InstructionSet.Branch> reverseUnconditionalBranchTargets; private Instruction firstChild = null; @@ -160,7 +156,7 @@ public abstract class Instruction{ length = _length; } - public final ByteCode getByteCode() { + public final InstructionSet.ByteCode getByteCode() { return (byteCode); } @@ -172,13 +168,13 @@ public abstract class Instruction{ return (getFirstChild() == null ? pc : getFirstChild().getStartPC()); } - protected Instruction(MethodModel _method, ByteCode _byteCode, int _pc) { + protected Instruction(MethodModel _method, InstructionSet.ByteCode _byteCode, int _pc) { method = _method; pc = _pc; byteCode = _byteCode; } - protected Instruction(MethodModel _method, ByteCode _byteCode, ByteReader _byteReader, boolean _wide) { + protected Instruction(MethodModel _method, InstructionSet.ByteCode _byteCode, ByteReader _byteReader, boolean _wide) { this(_method, _byteCode, _wide ? _byteReader.getOffset() - 2 : _byteReader.getOffset() - 1); } @@ -200,7 +196,7 @@ public abstract class Instruction{ } public boolean isBranch() { - return (this instanceof Branch); + return (this instanceof InstructionSet.Branch); } public int compareTo(Instruction _other) { @@ -296,51 +292,51 @@ public abstract class Instruction{ } public boolean producesStack() { - return ((this instanceof CompositeInstruction) || (getStackProduceCount() > 0)); + return ((this instanceof InstructionSet.CompositeInstruction) || (getStackProduceCount() > 0)); } public Instruction getReal() { return (this); } - public Branch asBranch() { - return ((Branch) this); + public InstructionSet.Branch asBranch() { + return ((InstructionSet.Branch) this); } public boolean consumesStack() { return (getStackConsumeCount() > 0); } - public void addBranchTarget(Branch _branch) { + public void addBranchTarget(InstructionSet.Branch _branch) { if (_branch.isReverse()) { if (_branch.isConditional()) { if (reverseConditionalBranchTargets == null) { - reverseConditionalBranchTargets = new LinkedList<ConditionalBranch>(); + reverseConditionalBranchTargets = new LinkedList<InstructionSet.ConditionalBranch>(); } - reverseConditionalBranchTargets.add((ConditionalBranch) _branch); + reverseConditionalBranchTargets.add((InstructionSet.ConditionalBranch) _branch); } else { if (reverseUnconditionalBranchTargets == null) { - reverseUnconditionalBranchTargets = new LinkedList<Branch>(); + reverseUnconditionalBranchTargets = new LinkedList<InstructionSet.Branch>(); } reverseUnconditionalBranchTargets.add(_branch); } } else { if (_branch.isConditional()) { if (forwardConditionalBranchTargets == null) { - forwardConditionalBranchTargets = new LinkedList<ConditionalBranch>(); + forwardConditionalBranchTargets = new LinkedList<InstructionSet.ConditionalBranch>(); } - forwardConditionalBranchTargets.add((ConditionalBranch) _branch); + forwardConditionalBranchTargets.add((InstructionSet.ConditionalBranch) _branch); } else { if (forwardUnconditionalBranchTargets == null) { - forwardUnconditionalBranchTargets = new LinkedList<Branch>(); + forwardUnconditionalBranchTargets = new LinkedList<InstructionSet.Branch>(); } forwardUnconditionalBranchTargets.add(_branch); } } } - public void removeBranchTarget(Branch _branch) { + public void removeBranchTarget(InstructionSet.Branch _branch) { if (_branch.isReverse()) { if (_branch.isConditional()) { if (reverseConditionalBranchTargets != null) { @@ -376,19 +372,19 @@ public abstract class Instruction{ } } - public LinkedList<Branch> getForwardUnconditionalBranches() { + public LinkedList<InstructionSet.Branch> getForwardUnconditionalBranches() { return (forwardUnconditionalBranchTargets); } - public LinkedList<ConditionalBranch> getForwardConditionalBranches() { + public LinkedList<InstructionSet.ConditionalBranch> getForwardConditionalBranches() { return (forwardConditionalBranchTargets); } - public LinkedList<Branch> getReverseUnconditionalBranches() { + public LinkedList<InstructionSet.Branch> getReverseUnconditionalBranches() { return (reverseUnconditionalBranchTargets); } - public LinkedList<ConditionalBranch> getReverseConditionalBranches() { + public LinkedList<InstructionSet.ConditionalBranch> getReverseConditionalBranches() { return (reverseConditionalBranchTargets); } diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionPattern.java b/src/main/java/com/aparapi/internal/instruction/InstructionPattern.java similarity index 77% rename from src/main/java/com/syncleus/aparapi/internal/instruction/InstructionPattern.java rename to src/main/java/com/aparapi/internal/instruction/InstructionPattern.java index 646476231421f9e24fcfc25cf3d73d3f312e1ec3..517d1a1205531f9f5557481ae0d489597e5b2891 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionPattern.java +++ b/src/main/java/com/aparapi/internal/instruction/InstructionPattern.java @@ -50,21 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; - -import com.syncleus.aparapi.internal.instruction.InstructionSet.AccessArrayElement; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AccessInstanceField; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AccessLocalVariable; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AssignToArrayElement; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AssignToInstanceField; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AssignToLocalVariable; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CastOperator; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Constant; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_IADD; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_ICONST_1; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_IINC; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_ISUB; -import com.syncleus.aparapi.internal.instruction.InstructionSet.MethodCall; +package com.aparapi.internal.instruction; public class InstructionPattern{ @@ -151,25 +137,25 @@ public class InstructionPattern{ public static final InstructionMatcher assignToLocalVariable = new InstructionMatcher("Assign to local variable"){ @Override public InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof AssignToLocalVariable)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.AssignToLocalVariable)); } }; public static final InstructionMatcher constant = new InstructionMatcher("Constant "){ @Override public InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof Constant<?>)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.Constant<?>)); } }; public static final InstructionMatcher assignToArrayElement = new InstructionMatcher("Assign to array element"){ @Override public InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof AssignToArrayElement)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.AssignToArrayElement)); } }; public static final InstructionMatcher methodCall = new InstructionMatcher("Method Call"){ @Override public InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof MethodCall)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.MethodCall)); } }; @@ -188,22 +174,22 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof AssignToLocalVariable) { - final AssignToLocalVariable assign = (AssignToLocalVariable) _instruction; + if (_instruction instanceof InstructionSet.AssignToLocalVariable) { + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) _instruction; Instruction child = ((Instruction) assign).getFirstChild(); - if (child instanceof CastOperator) { + if (child instanceof InstructionSet.CastOperator) { child = child.getFirstChild(); } - if (child instanceof I_IADD) { - final I_IADD add = (I_IADD) child; + if (child instanceof InstructionSet.I_IADD) { + final InstructionSet.I_IADD add = (InstructionSet.I_IADD) child; final Instruction lhs = add.getLhs(); final Instruction rhs = add.getRhs(); - if (lhs instanceof AccessLocalVariable) { - final AccessLocalVariable access = (AccessLocalVariable) lhs; + if (lhs instanceof InstructionSet.AccessLocalVariable) { + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) lhs; if (access.getLocalVariableTableIndex() == assign.getLocalVariableTableIndex()) { - if (rhs instanceof I_ICONST_1) { + if (rhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -230,22 +216,22 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof AssignToLocalVariable) { - final AssignToLocalVariable assign = (AssignToLocalVariable) _instruction; + if (_instruction instanceof InstructionSet.AssignToLocalVariable) { + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) _instruction; Instruction child = ((Instruction) assign).getFirstChild(); - if (child instanceof CastOperator) { + if (child instanceof InstructionSet.CastOperator) { child = child.getFirstChild(); } - if (child instanceof I_ISUB) { - final I_ISUB add = (I_ISUB) child; + if (child instanceof InstructionSet.I_ISUB) { + final InstructionSet.I_ISUB add = (InstructionSet.I_ISUB) child; final Instruction lhs = add.getLhs(); final Instruction rhs = add.getRhs(); - if (lhs instanceof AccessLocalVariable) { - final AccessLocalVariable access = (AccessLocalVariable) lhs; + if (lhs instanceof InstructionSet.AccessLocalVariable) { + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) lhs; if (access.getLocalVariableTableIndex() == assign.getLocalVariableTableIndex()) { - if (rhs instanceof I_ICONST_1) { + if (rhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -271,17 +257,17 @@ public class InstructionPattern{ */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof CastOperator) { - final CastOperator topCastOperator = (CastOperator) _instruction; + if (_instruction instanceof InstructionSet.CastOperator) { + final InstructionSet.CastOperator topCastOperator = (InstructionSet.CastOperator) _instruction; _instruction = topCastOperator.getFirstChild().getReal(); } - if (_instruction instanceof I_IADD) { - final I_IADD add = (I_IADD) _instruction; + if (_instruction instanceof InstructionSet.I_IADD) { + final InstructionSet.I_IADD add = (InstructionSet.I_IADD) _instruction; final Instruction addLhs = add.getLhs().getReal(); final Instruction addRhs = add.getRhs().getReal(); - if (addLhs instanceof AccessInstanceField) { - if (addRhs instanceof I_ICONST_1) { + if (addLhs instanceof InstructionSet.AccessInstanceField) { + if (addRhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -305,17 +291,17 @@ public class InstructionPattern{ */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof CastOperator) { - final CastOperator topCastOperator = (CastOperator) _instruction; + if (_instruction instanceof InstructionSet.CastOperator) { + final InstructionSet.CastOperator topCastOperator = (InstructionSet.CastOperator) _instruction; _instruction = topCastOperator.getFirstChild().getReal(); } - if (_instruction instanceof I_ISUB) { - final I_ISUB add = (I_ISUB) _instruction; + if (_instruction instanceof InstructionSet.I_ISUB) { + final InstructionSet.I_ISUB add = (InstructionSet.I_ISUB) _instruction; final Instruction addLhs = add.getLhs().getReal(); final Instruction addRhs = add.getRhs().getReal(); - if (addLhs instanceof AccessInstanceField) { - if (addRhs instanceof I_ICONST_1) { + if (addLhs instanceof InstructionSet.AccessInstanceField) { + if (addRhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -336,11 +322,11 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof AccessArrayElement) { - final AccessArrayElement accessArrayElement = (AccessArrayElement) _instruction; + if (_instruction instanceof InstructionSet.AccessArrayElement) { + final InstructionSet.AccessArrayElement accessArrayElement = (InstructionSet.AccessArrayElement) _instruction; final Instruction addLhs = accessArrayElement.getArrayRef().getReal(); // Instruction addRhs = accessArrayElement.getArrayIndex().getReal(); - if (addLhs instanceof AccessInstanceField) { + if (addLhs instanceof InstructionSet.AccessInstanceField) { return (InstructionMatch.TRUE); @@ -361,13 +347,13 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof I_IADD) { - final I_IADD accessArrayElement = (I_IADD) _instruction; + if (_instruction instanceof InstructionSet.I_IADD) { + final InstructionSet.I_IADD accessArrayElement = (InstructionSet.I_IADD) _instruction; if (accessArrayElement.getLhs() != null) { final Instruction addLhs = accessArrayElement.getLhs().getReal(); if (fieldArrayElementAccess.matches(addLhs).ok) { final Instruction addRhs = accessArrayElement.getRhs().getReal(); - if (addRhs instanceof I_ICONST_1) { + if (addRhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -388,12 +374,12 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof I_ISUB) { - final I_ISUB accessArrayElement = (I_ISUB) _instruction; + if (_instruction instanceof InstructionSet.I_ISUB) { + final InstructionSet.I_ISUB accessArrayElement = (InstructionSet.I_ISUB) _instruction; final Instruction addLhs = accessArrayElement.getLhs().getReal(); if (fieldArrayElementAccess.matches(addLhs).ok) { final Instruction addRhs = accessArrayElement.getRhs().getReal(); - if (addRhs instanceof I_ICONST_1) { + if (addRhs instanceof InstructionSet.I_ICONST_1) { return (InstructionMatch.TRUE); } } @@ -415,14 +401,14 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof AssignToArrayElement) { - final AssignToArrayElement accessArrayElement = (AssignToArrayElement) _instruction; + if (_instruction instanceof InstructionSet.AssignToArrayElement) { + final InstructionSet.AssignToArrayElement accessArrayElement = (InstructionSet.AssignToArrayElement) _instruction; final Instruction arrayRef = accessArrayElement.getArrayRef().getReal(); // Instruction arrayIndex = accessArrayElement.getArrayIndex().getReal(); final Instruction value = accessArrayElement.getValue().getReal(); // Instruction addRhs = accessArrayElement.getArrayIndex().getReal(); - if (arrayRef instanceof AccessInstanceField) { + if (arrayRef instanceof InstructionSet.AccessInstanceField) { if (fieldArrayElementPlusOne.matches(value).ok) { return (InstructionMatch.TRUE); } @@ -445,13 +431,13 @@ public class InstructionPattern{ * </pre> */ @Override public InstructionMatch matches(Instruction _instruction) { - if (_instruction instanceof AssignToArrayElement) { - final AssignToArrayElement accessArrayElement = (AssignToArrayElement) _instruction; + if (_instruction instanceof InstructionSet.AssignToArrayElement) { + final InstructionSet.AssignToArrayElement accessArrayElement = (InstructionSet.AssignToArrayElement) _instruction; final Instruction arrayRef = accessArrayElement.getArrayRef().getReal(); // Instruction arrayIndex = accessArrayElement.getArrayIndex().getReal(); final Instruction value = accessArrayElement.getValue().getReal(); // Instruction addRhs = accessArrayElement.getArrayIndex().getReal(); - if (arrayRef instanceof AccessInstanceField) { + if (arrayRef instanceof InstructionSet.AccessInstanceField) { if (fieldArrayElementMinusOne.matches(value).ok) { return (InstructionMatch.TRUE); } @@ -464,37 +450,37 @@ public class InstructionPattern{ public static final InstructionMatcher accessLocalVariable = new InstructionMatcher("access to local variable"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof AccessLocalVariable)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.AccessLocalVariable)); } }; public static final InstructionMatcher inc = new InstructionMatcher("inc"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof I_IINC)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.I_IINC)); } }; public static final InstructionMatcher cast = new InstructionMatcher("cast"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof CastOperator)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.CastOperator)); } }; public static final InstructionMatcher accessInstanceField = new InstructionMatcher("access instance field"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof AccessInstanceField)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.AccessInstanceField)); } }; public static final InstructionMatcher assignToInstanceField = new InstructionMatcher("assign to instance field"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof AssignToInstanceField)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.AssignToInstanceField)); } }; public static final InstructionMatcher iadd = new InstructionMatcher("iadd"){ @Override InstructionMatch matches(Instruction _instruction) { - return (InstructionMatch.test(_instruction instanceof I_IADD)); + return (InstructionMatch.test(_instruction instanceof InstructionSet.I_IADD)); } }; } diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionSet.java b/src/main/java/com/aparapi/internal/instruction/InstructionSet.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/instruction/InstructionSet.java rename to src/main/java/com/aparapi/internal/instruction/InstructionSet.java index e9bc0fccc4f0bc95d057f542dd5ef44455a38084..cee82112289995a3236c8e875254d95e2b91ce25 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionSet.java +++ b/src/main/java/com/aparapi/internal/instruction/InstructionSet.java @@ -50,19 +50,14 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; +package com.aparapi.internal.instruction; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import com.syncleus.aparapi.internal.model.MethodModel; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.Entry; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.FieldEntry; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.MethodEntry; -import com.syncleus.aparapi.internal.model.ClassModel.LocalVariableTableEntry; -import com.syncleus.aparapi.internal.model.ClassModel.LocalVariableInfo; -import com.syncleus.aparapi.internal.reader.ByteReader; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.internal.reader.ByteReader; public class InstructionSet{ @@ -1250,7 +1245,7 @@ public class InstructionSet{ return (index); } - @Override public LocalVariableInfo getLocalVariableInfo() { + @Override public ClassModel.LocalVariableInfo getLocalVariableInfo() { return (method.getLocalVariableTableEntry().getVariable(getThisPC() + getLength(), getLocalVariableTableIndex())); } } @@ -1274,7 +1269,7 @@ public class InstructionSet{ } @Override public boolean isDeclaration() { - LocalVariableInfo lvi = method.getLocalVariableTableEntry().getVariable(getThisPC() + getLength(), + ClassModel.LocalVariableInfo lvi = method.getLocalVariableTableEntry().getVariable(getThisPC() + getLength(), getLocalVariableTableIndex()); return (lvi.getStart() == getThisPC() + getLength()); } @@ -1293,7 +1288,7 @@ public class InstructionSet{ return (index); } - @Override public LocalVariableInfo getLocalVariableInfo() { + @Override public ClassModel.LocalVariableInfo getLocalVariableInfo() { return (method.getLocalVariableTableEntry().getVariable(getThisPC() + getLength(), getLocalVariableTableIndex())); } } @@ -1314,8 +1309,8 @@ public class InstructionSet{ } @Override public boolean isDeclaration() { - final LocalVariableTableEntry localVariableTableEntry = method.getLocalVariableTableEntry(); - final LocalVariableInfo localVarInfo = localVariableTableEntry.getVariable(getThisPC() + getLength(), + final ClassModel.LocalVariableTableEntry localVariableTableEntry = method.getLocalVariableTableEntry(); + final ClassModel.LocalVariableInfo localVarInfo = localVariableTableEntry.getVariable(getThisPC() + getLength(), getLocalVariableTableIndex()); return ((localVarInfo != null) && (localVarInfo.getStart() == (getThisPC() + getLength()))); } @@ -2050,7 +2045,7 @@ public class InstructionSet{ return (index); } - @Override public FieldEntry getConstantPoolFieldEntry() { + @Override public ClassModel.ConstantPool.FieldEntry getConstantPoolFieldEntry() { return (method.getConstantPool().getFieldEntry(getConstantPoolFieldIndex())); } @@ -2080,7 +2075,7 @@ public class InstructionSet{ return (index); } - @Override public FieldEntry getConstantPoolFieldEntry() { + @Override public ClassModel.ConstantPool.FieldEntry getConstantPoolFieldEntry() { return (method.getConstantPool().getFieldEntry(getConstantPoolFieldIndex())); } @@ -2473,7 +2468,7 @@ public class InstructionSet{ return ("inc var index 08 bit by byte"); } - public LocalVariableInfo getLocalVariableInfo() { + public ClassModel.LocalVariableInfo getLocalVariableInfo() { return (method.getLocalVariableTableEntry().getVariable(getThisPC(), getLocalVariableTableIndex())); } @@ -2586,7 +2581,7 @@ public class InstructionSet{ return (index); } - @Override public ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry() { + @Override public ClassModel.ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry() { return (method.getConstantPool().getInterfaceMethodEntry(getConstantPoolInterfaceMethodIndex())); } @@ -2637,7 +2632,7 @@ public class InstructionSet{ return (index); } - @Override public ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry() { + @Override public ClassModel.ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry() { return (method.getConstantPool().getInterfaceMethodEntry(getConstantPoolInterfaceMethodIndex())); } @@ -2679,7 +2674,7 @@ public class InstructionSet{ return (index); } - @Override public ConstantPool.MethodEntry getConstantPoolMethodEntry() { + @Override public ClassModel.ConstantPool.MethodEntry getConstantPoolMethodEntry() { return (method.getConstantPool().getMethodEntry(getConstantPoolMethodIndex())); } @@ -2721,7 +2716,7 @@ public class InstructionSet{ return (index); } - @Override public ConstantPool.MethodEntry getConstantPoolMethodEntry() { + @Override public ClassModel.ConstantPool.MethodEntry getConstantPoolMethodEntry() { return (method.getConstantPool().getMethodEntry(getConstantPoolMethodIndex())); } @@ -2759,7 +2754,7 @@ public class InstructionSet{ return (index); } - @Override public ConstantPool.MethodEntry getConstantPoolMethodEntry() { + @Override public ClassModel.ConstantPool.MethodEntry getConstantPoolMethodEntry() { return (method.getConstantPool().getMethodEntry(getConstantPoolMethodIndex())); } @@ -3035,7 +3030,7 @@ public class InstructionSet{ return (index); } - @Override public Entry getConstantPoolEntry() { + @Override public ClassModel.ConstantPool.Entry getConstantPoolEntry() { return (method.getConstantPool().get(getConstantPoolIndex())); } } @@ -3058,7 +3053,7 @@ public class InstructionSet{ } - @Override public Entry getConstantPoolEntry() { + @Override public ClassModel.ConstantPool.Entry getConstantPoolEntry() { return (method.getConstantPool().get(getConstantPoolIndex())); } } @@ -3076,7 +3071,7 @@ public class InstructionSet{ return (index); } - @Override public Entry getConstantPoolEntry() { + @Override public ClassModel.ConstantPool.Entry getConstantPoolEntry() { return (method.getConstantPool().get(getConstantPoolIndex())); } @@ -3396,7 +3391,7 @@ public class InstructionSet{ return (index); } - @Override public FieldEntry getConstantPoolFieldEntry() { + @Override public ClassModel.ConstantPool.FieldEntry getConstantPoolFieldEntry() { return (method.getConstantPool().getFieldEntry(getConstantPoolFieldIndex())); } @@ -3430,7 +3425,7 @@ public class InstructionSet{ return (index); } - @Override public FieldEntry getConstantPoolFieldEntry() { + @Override public ClassModel.ConstantPool.FieldEntry getConstantPoolFieldEntry() { return (method.getConstantPool().getFieldEntry(getConstantPoolFieldIndex())); } @@ -3456,7 +3451,7 @@ public class InstructionSet{ return ("return to pc in local var index 08 bit"); } - @Override public LocalVariableInfo getLocalVariableInfo() { + @Override public ClassModel.LocalVariableInfo getLocalVariableInfo() { return (method.getLocalVariableTableEntry().getVariable(getThisPC() + getLength(), getLocalVariableTableIndex())); } @@ -3685,7 +3680,7 @@ public class InstructionSet{ public interface MethodCall{ int getConstantPoolMethodIndex(); - MethodEntry getConstantPoolMethodEntry(); + ClassModel.ConstantPool.MethodEntry getConstantPoolMethodEntry(); Instruction getArg(int _arg); } @@ -3697,7 +3692,7 @@ public class InstructionSet{ public interface InterfaceConstantPoolMethodIndexAccessor{ public int getConstantPoolInterfaceMethodIndex(); - public ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry(); + public ClassModel.ConstantPool.InterfaceMethodEntry getConstantPoolInterfaceMethodEntry(); public Instruction getInstanceReference(); @@ -3712,7 +3707,7 @@ public class InstructionSet{ public interface FieldReference{ public int getConstantPoolFieldIndex(); - public FieldEntry getConstantPoolFieldEntry(); + public ClassModel.ConstantPool.FieldEntry getConstantPoolFieldEntry(); } public interface AccessField extends FieldReference{ @@ -3734,7 +3729,7 @@ public class InstructionSet{ public interface LocalVariableTableIndexAccessor{ int getLocalVariableTableIndex(); - LocalVariableInfo getLocalVariableInfo(); + ClassModel.LocalVariableInfo getLocalVariableInfo(); } public interface AccessLocalVariable extends LocalVariableTableIndexAccessor{ @@ -3752,7 +3747,7 @@ public class InstructionSet{ @SuppressWarnings("unchecked") public interface ConstantPoolEntryConstant extends Constant{ int getConstantPoolIndex(); - ConstantPool.Entry getConstantPoolEntry(); + ClassModel.ConstantPool.Entry getConstantPoolEntry(); }; public interface HasOperator{ diff --git a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionTransformer.java b/src/main/java/com/aparapi/internal/instruction/InstructionTransformer.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/internal/instruction/InstructionTransformer.java rename to src/main/java/com/aparapi/internal/instruction/InstructionTransformer.java index 3cc3a87cdcdde513b68e6aaf00f98648515c5785..b930c37dc67ed554948e9362810154a8a112fd99 100644 --- a/src/main/java/com/syncleus/aparapi/internal/instruction/InstructionTransformer.java +++ b/src/main/java/com/aparapi/internal/instruction/InstructionTransformer.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.instruction; +package com.aparapi.internal.instruction; public abstract class InstructionTransformer{ diff --git a/src/main/java/com/syncleus/aparapi/internal/jni/ConfigJNI.java b/src/main/java/com/aparapi/internal/jni/ConfigJNI.java similarity index 79% rename from src/main/java/com/syncleus/aparapi/internal/jni/ConfigJNI.java rename to src/main/java/com/aparapi/internal/jni/ConfigJNI.java index 9577ce7c2c489c0380b8ac23df47403200af3661..91f4ab4401f6d25b7df18eb30a2d506d5a5e95cf 100644 --- a/src/main/java/com/syncleus/aparapi/internal/jni/ConfigJNI.java +++ b/src/main/java/com/aparapi/internal/jni/ConfigJNI.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.jni; +package com.aparapi.internal.jni; -import com.syncleus.aparapi.Config; -import com.syncleus.aparapi.internal.annotation.UsedByJNICode; +import com.aparapi.Config; +import com.aparapi.internal.annotation.UsedByJNICode; /** * This class is intended to be used as a 'proxy' or 'facade' object for Java code to interact with JNI @@ -24,14 +24,14 @@ import com.syncleus.aparapi.internal.annotation.UsedByJNICode; public abstract class ConfigJNI{ /** - * Value defaults to com.syncleus.aparapi.config if not overridden by extending classes + * Value defaults to com.aparapi.config if not overridden by extending classes */ protected static final String propPkgName = Config.class.getPackage().getName(); /** * Allows the user to turn on OpenCL profiling for the JNI/OpenCL layer. * - * Usage -Dcom.syncleus.aparapi.enableProfiling={true|false} + * Usage -Dcom.aparapi.enableProfiling={true|false} * */ @UsedByJNICode public static final boolean enableProfiling = Boolean.getBoolean(propPkgName + ".enableProfiling"); @@ -39,7 +39,7 @@ public abstract class ConfigJNI{ /** * Allows the user to turn on OpenCL profiling for the JNI/OpenCL layer, this information will be written to CSV file * - * Usage -Dcom.syncleus.aparapi.enableProfiling={true|false} + * Usage -Dcom.aparapi.enableProfiling={true|false} * */ @UsedByJNICode public static final boolean enableProfilingCSV = Boolean.getBoolean(propPkgName + ".enableProfilingCSV"); @@ -47,7 +47,7 @@ public abstract class ConfigJNI{ /** * Allows the user to request that verbose JNI messages be dumped to stderr. * - * Usage -Dcom.syncleus.aparapi.enableVerboseJNI={true|false} + * Usage -Dcom.aparapi.enableVerboseJNI={true|false} * */ @UsedByJNICode public static final boolean enableVerboseJNI = Boolean.getBoolean(propPkgName + ".enableVerboseJNI"); @@ -57,7 +57,7 @@ public abstract class ConfigJNI{ * * This is really a debugging option to help locate leaking OpenCL resources, this will be dumped to stderr. * - * Usage -Dcom.syncleus.aparapi.enableOpenCLResourceTracking={true|false} + * Usage -Dcom.aparapi.enableOpenCLResourceTracking={true|false} * */ @UsedByJNICode public static final boolean enableVerboseJNIOpenCLResourceTracking = Boolean.getBoolean(propPkgName diff --git a/src/main/java/com/syncleus/aparapi/internal/jni/KernelArgJNI.java b/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/jni/KernelArgJNI.java rename to src/main/java/com/aparapi/internal/jni/KernelArgJNI.java index a576736e0b8f67fbb6871bc3835ad840c15075f6..a8a2c0452ade3ede7a8227f9eda73bb3dbc8d3eb 100644 --- a/src/main/java/com/syncleus/aparapi/internal/jni/KernelArgJNI.java +++ b/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.jni; +package com.aparapi.internal.jni; -import com.syncleus.aparapi.internal.annotation.*; +import com.aparapi.internal.annotation.UsedByJNICode; import java.lang.reflect.*; @@ -47,7 +47,8 @@ public abstract class KernelArgJNI{ * @see KernelRunnerJNI#ARG_EXPLICIT_WRITE * @see KernelRunnerJNI#ARG_OBJ_ARRAY_STRUCT */ - @UsedByJNICode protected int type; + @UsedByJNICode + protected int type; /** * Name of the field diff --git a/src/main/java/com/syncleus/aparapi/internal/jni/KernelRunnerJNI.java b/src/main/java/com/aparapi/internal/jni/KernelRunnerJNI.java similarity index 80% rename from src/main/java/com/syncleus/aparapi/internal/jni/KernelRunnerJNI.java rename to src/main/java/com/aparapi/internal/jni/KernelRunnerJNI.java index 1637632fd2616959013131d27ccf42577c6aa04b..d25423113dbfd51011e0fd2aade0598f292abf89 100644 --- a/src/main/java/com/syncleus/aparapi/internal/jni/KernelRunnerJNI.java +++ b/src/main/java/com/aparapi/internal/jni/KernelRunnerJNI.java @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.jni; +package com.aparapi.internal.jni; -import com.syncleus.aparapi.Kernel; -import com.syncleus.aparapi.ProfileInfo; -import com.syncleus.aparapi.Range; -import com.syncleus.aparapi.annotation.Experimental; -import com.syncleus.aparapi.device.OpenCLDevice; -import com.syncleus.aparapi.internal.annotation.DocMe; -import com.syncleus.aparapi.internal.annotation.UsedByJNICode; +import com.aparapi.Kernel; +import com.aparapi.Range; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.ProfileInfo; +import com.aparapi.annotation.Experimental; +import com.aparapi.internal.annotation.DocMe; +import com.aparapi.internal.annotation.UsedByJNICode; import java.nio.ByteBuffer; import java.util.List; @@ -35,7 +35,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>boolean</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -45,7 +45,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>byte</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -55,7 +55,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>float</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -65,7 +65,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>int</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -75,7 +75,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>double</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -85,7 +85,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>long</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -94,7 +94,7 @@ public abstract class KernelRunnerJNI{ /** * TODO: * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -105,7 +105,7 @@ public abstract class KernelRunnerJNI{ * So <code>ARG_ARRAY|ARG_INT</code> tells us this arg is an array of <code>int</code>. * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -116,7 +116,7 @@ public abstract class KernelRunnerJNI{ * So <code>ARG_PRIMITIVE|ARG_INT</code> tells us this arg is a primitive <code>int</code>. * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -127,7 +127,7 @@ public abstract class KernelRunnerJNI{ * So <code>ARG_ARRAY|ARG_INT|ARG_READ</code> tells us this arg is an array of int's that are read by the kernel. * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -138,7 +138,7 @@ public abstract class KernelRunnerJNI{ * So <code>ARG_ARRAY|ARG_INT|ARG_WRITE</code> tells us this arg is an array of int's that we expect the kernel to mutate. * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -148,8 +148,8 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> resides in local memory in the generated OpenCL code.<br/> * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode - * @see com.syncleus.aparapi.annotation.Experimental + * @see UsedByJNICode + * @see Experimental * * @author gfrost */ @@ -159,8 +159,8 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> resides in global memory in the generated OpenCL code.<br/> * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode - * @see com.syncleus.aparapi.annotation.Experimental + * @see UsedByJNICode + * @see Experimental * * @author gfrost */ @@ -170,8 +170,8 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> resides in constant memory in the generated OpenCL code.<br/> * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode - * @see com.syncleus.aparapi.annotation.Experimental + * @see UsedByJNICode + * @see Experimental * * @author gfrost */ @@ -181,7 +181,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> has it's length reference, in which case a synthetic arg is passed (name mangled) to the OpenCL kernel.<br/> * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -190,7 +190,7 @@ public abstract class KernelRunnerJNI{ /** * TODO: * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -199,7 +199,7 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that the arg has been explicitly marked for reading * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -208,7 +208,7 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that the arg has been explicitly marked for writing * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -217,7 +217,7 @@ public abstract class KernelRunnerJNI{ /** * TODO: * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -228,7 +228,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>char</code> type (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author rlamothe */ @@ -238,7 +238,7 @@ public abstract class KernelRunnerJNI{ * This 'bit' indicates that a particular <code>KernelArg</code> represents a <code>static</code> field (array or primitive). * * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -247,7 +247,7 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that we wish to enable profiling from the JNI code. * - * @see com.syncleus.aparapi.annotations.UsedByJNICode + * @see com.aparapi.annotations.UsedByJNICode * * @author gfrost */ @@ -256,7 +256,7 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that we wish to store profiling information in a CSV file from JNI code. * - * @see com.syncleus.aparapi.annotations.UsedByJNICode + * @see com.aparapi.annotations.UsedByJNICode * * @author gfrost */ @@ -267,7 +267,7 @@ public abstract class KernelRunnerJNI{ * * Be careful changing final constants starting with JNI.<br/> * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author gfrost */ @@ -276,7 +276,7 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that we wish to enable verbose JNI layer messages to stderr.<br/> * - * @see com.syncleus.aparapi.annotations.UsedByJNICode + * @see com.aparapi.annotations.UsedByJNICode * * @author gfrost */ @@ -285,8 +285,8 @@ public abstract class KernelRunnerJNI{ /** * This 'bit' indicates that we wish to enable OpenCL resource tracking by JNI layer to be written to stderr.<br/> * - * @see com.syncleus.aparapi.annotations.UsedByJNICode - * @see com.syncleus.aparapi.annotations.Experimental + * @see com.aparapi.annotations.UsedByJNICode + * @see com.aparapi.annotations.Experimental * * @author gfrost */ @@ -297,7 +297,7 @@ public abstract class KernelRunnerJNI{ * * Be careful changing final constants starting with JNI.<br/> * - * @see com.syncleus.aparapi.internal.annotation.UsedByJNICode + * @see UsedByJNICode * * @author ekasit */ diff --git a/src/main/java/com/syncleus/aparapi/internal/jni/OpenCLJNI.java b/src/main/java/com/aparapi/internal/jni/OpenCLJNI.java similarity index 76% rename from src/main/java/com/syncleus/aparapi/internal/jni/OpenCLJNI.java rename to src/main/java/com/aparapi/internal/jni/OpenCLJNI.java index 02a34f08144e0f55b695b474cc741b270898ff3f..3e8d48ec4c6f2b55f231f28c0fc7823f53c62aae 100644 --- a/src/main/java/com/syncleus/aparapi/internal/jni/OpenCLJNI.java +++ b/src/main/java/com/aparapi/internal/jni/OpenCLJNI.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.jni; +package com.aparapi.internal.jni; -import com.syncleus.aparapi.ProfileInfo; +import com.aparapi.internal.opencl.OpenCLKernel; +import com.aparapi.ProfileInfo; import java.util.List; -import com.syncleus.aparapi.device.OpenCLDevice; -import com.syncleus.aparapi.internal.opencl.OpenCLArgDescriptor; -import com.syncleus.aparapi.internal.opencl.OpenCLKernel; -import com.syncleus.aparapi.internal.opencl.OpenCLMem; -import com.syncleus.aparapi.internal.opencl.OpenCLPlatform; -import com.syncleus.aparapi.internal.opencl.OpenCLProgram; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.opencl.OpenCLArgDescriptor; +import com.aparapi.internal.opencl.OpenCLMem; +import com.aparapi.internal.opencl.OpenCLPlatform; +import com.aparapi.internal.opencl.OpenCLProgram; /** * This class is intended to be used as a 'proxy' or 'facade' object for Java code to interact with JNI diff --git a/src/main/java/com/syncleus/aparapi/internal/jni/RangeJNI.java b/src/main/java/com/aparapi/internal/jni/RangeJNI.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/jni/RangeJNI.java rename to src/main/java/com/aparapi/internal/jni/RangeJNI.java index 03b07aab17dc92cf44588d342fcade707b643902..161f7551ad819800a203e4b713f190f1b48af9fb 100644 --- a/src/main/java/com/syncleus/aparapi/internal/jni/RangeJNI.java +++ b/src/main/java/com/aparapi/internal/jni/RangeJNI.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.jni; +package com.aparapi.internal.jni; -import com.syncleus.aparapi.internal.annotation.UsedByJNICode; +import com.aparapi.internal.annotation.UsedByJNICode; /** * This class is intended to be used as a 'proxy' or 'facade' object for Java code to interact with JNI diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelArg.java b/src/main/java/com/aparapi/internal/kernel/KernelArg.java similarity index 90% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelArg.java rename to src/main/java/com/aparapi/internal/kernel/KernelArg.java index c6746072f70695702ebfb0b77105bbe6822fb878..86b389e37fd913a1e2150bb0666ae98ab2056857 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelArg.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelArg.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; -import com.syncleus.aparapi.internal.jni.*; -import com.syncleus.aparapi.internal.model.*; -import com.syncleus.aparapi.internal.util.*; +import com.aparapi.Kernel; +import com.aparapi.internal.jni.KernelArgJNI; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.util.Reflection; import java.lang.reflect.*; import java.nio.*; @@ -26,12 +27,12 @@ import java.nio.*; * Each field (or captured field in the case of an anonymous inner class) referenced by any bytecode reachable from the users Kernel.run(), will * need to be represented as a <code>KernelArg</code>. * - * @see com.syncleus.aparapi.Kernel#execute(int _globalSize) + * @see Kernel#execute(int _globalSize) * * @author gfrost * */ -public class KernelArg extends KernelArgJNI{ +public class KernelArg extends KernelArgJNI { /** * The byte array for obj conversion passed to opencl diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelDeviceProfile.java b/src/main/java/com/aparapi/internal/kernel/KernelDeviceProfile.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelDeviceProfile.java rename to src/main/java/com/aparapi/internal/kernel/KernelDeviceProfile.java index f02c6c4ba809009fa1ce18227ba9c079fe827702..072b38ba6b0c6fb3fd147452af5c5886969f3e99 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelDeviceProfile.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelDeviceProfile.java @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.device.*; +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.device.Device; +import com.aparapi.*; import java.text.*; import java.util.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelManager.java b/src/main/java/com/aparapi/internal/kernel/KernelManager.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelManager.java rename to src/main/java/com/aparapi/internal/kernel/KernelManager.java index 9fe27f0cf41f5d5b7d6e37c89c9fad1ebc0e165e..34ce62097642f67a30b1164d47996cdfac666325 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelManager.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelManager.java @@ -13,11 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.device.*; -import com.syncleus.aparapi.internal.util.*; +package com.aparapi.internal.kernel; + +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.device.Device; +import com.aparapi.device.JavaDevice; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.util.Reflection; +import com.aparapi.*; import java.lang.reflect.*; import java.util.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelManagers.java b/src/main/java/com/aparapi/internal/kernel/KernelManagers.java similarity index 90% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelManagers.java rename to src/main/java/com/aparapi/internal/kernel/KernelManagers.java index 6d1343e28eb8895b4dab4fbce642d29c15c5719f..d5154e8a72b65c3cf49ee45b28585f9a3fd2d0f4 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelManagers.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelManagers.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; -import com.syncleus.aparapi.device.*; +import com.aparapi.device.Device; import java.util.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelPreferences.java b/src/main/java/com/aparapi/internal/kernel/KernelPreferences.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelPreferences.java rename to src/main/java/com/aparapi/internal/kernel/KernelPreferences.java index a9940f2051f81a52883d3dda5d10d56c12b4379d..66d22b9d14ad38a96708442bfb5e5ef86dd5246f 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelPreferences.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelPreferences.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.device.*; +import com.aparapi.Kernel; +import com.aparapi.device.Device; +import com.aparapi.*; import java.util.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelProfile.java b/src/main/java/com/aparapi/internal/kernel/KernelProfile.java similarity index 93% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelProfile.java rename to src/main/java/com/aparapi/internal/kernel/KernelProfile.java index d0841224589dd3b065ed3f0caa6ec807e9d9ddda..97f3fa27c16db2a29946ea5a939bd814fb6b70aa 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelProfile.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelProfile.java @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.device.*; +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.device.Device; +import com.aparapi.*; import java.util.*; import java.util.logging.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelRunner.java b/src/main/java/com/aparapi/internal/kernel/KernelRunner.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/kernel/KernelRunner.java rename to src/main/java/com/aparapi/internal/kernel/KernelRunner.java index 17b4584f11db7c555f965454cff7601fb4f85020..231acdb2914c2f58058357202474105dcbf05e96 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/KernelRunner.java +++ b/src/main/java/com/aparapi/internal/kernel/KernelRunner.java @@ -50,20 +50,26 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.kernel; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.Kernel.Constant; -import com.syncleus.aparapi.Kernel.*; -import com.syncleus.aparapi.device.*; -import com.syncleus.aparapi.internal.annotation.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.jni.*; -import com.syncleus.aparapi.internal.model.*; -import com.syncleus.aparapi.internal.util.*; -import com.syncleus.aparapi.internal.writer.*; -import com.syncleus.aparapi.opencl.*; +package com.aparapi.internal.kernel; + +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.ProfileInfo; +import com.aparapi.Range; +import com.aparapi.device.Device; +import com.aparapi.device.JavaDevice; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.annotation.UsedByJNICode; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.CodeGenException; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.jni.KernelRunnerJNI; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.util.UnsafeWrapper; +import com.aparapi.internal.writer.KernelWriter; +import com.aparapi.opencl.OpenCL; +import com.aparapi.*; import java.lang.reflect.*; import java.nio.*; @@ -83,19 +89,20 @@ import java.util.logging.*; * time the <code>ExecutionMode</code> is consulted to determine the default requested mode. This will dictate how * the <code>KernelRunner</code> will attempt to execute the <code>Kernel</code> * - * @see com.syncleus.aparapi.Kernel#execute(int _globalSize) + * @see Kernel#execute(int _globalSize) * * @author gfrost * */ -public class KernelRunner extends KernelRunnerJNI{ +public class KernelRunner extends KernelRunnerJNI { public static boolean BINARY_CACHING_DISABLED = false; private static final int MINIMUM_ARRAY_SIZE = 1; /** @see #getCurrentPass() */ - @UsedByJNICode public static final int PASS_ID_PREPARING_EXECUTION = -2; + @UsedByJNICode + public static final int PASS_ID_PREPARING_EXECUTION = -2; /** @see #getCurrentPass() */ @UsedByJNICode public static final int PASS_ID_COMPLETED_EXECUTION = -1; @UsedByJNICode public static final int CANCEL_STATUS_FALSE = 0; @@ -338,7 +345,7 @@ public class KernelRunner extends KernelRunnerJNI{ // @FunctionalInterface private interface ThreadIdSetter{ - void set(KernelState kernelState, int globalGroupId, int threadId); + void set(Kernel.KernelState kernelState, int globalGroupId, int threadId); } /** @@ -383,7 +390,7 @@ public class KernelRunner extends KernelRunnerJNI{ } final Kernel kernelClone = kernel.clone(); - final KernelState kernelState = kernelClone.getKernelState(); + final Kernel.KernelState kernelState = kernelClone.getKernelState(); kernelState.setRange(_settings.range); kernelState.setGroupId(0, 0); @@ -467,7 +474,7 @@ public class KernelRunner extends KernelRunnerJNI{ if (_settings.range.getDims() == 1) { threadIdSetter = new ThreadIdSetter() { @Override - public void set(KernelState kernelState, int globalGroupId, int threadId) { + public void set(Kernel.KernelState kernelState, int globalGroupId, int threadId) { // (kernelState, globalGroupId, threadId) ->{ kernelState.setLocalId(0, (threadId % localSize0)); kernelState.setGlobalId(0, (threadId + (globalGroupId * threads))); @@ -546,7 +553,7 @@ public class KernelRunner extends KernelRunnerJNI{ */ threadIdSetter = new ThreadIdSetter() { @Override - public void set(KernelState kernelState, int globalGroupId, int threadId) { + public void set(Kernel.KernelState kernelState, int globalGroupId, int threadId) { // (kernelState, globalGroupId, threadId) ->{ kernelState.setLocalId(0, (threadId % localSize0)); // threadId % localWidth = (for 33 = 1 % 4 = 1) kernelState.setLocalId(1, (threadId / localSize0)); // threadId / localWidth = (for 33 = 1 / 4 == 0) @@ -565,7 +572,7 @@ public class KernelRunner extends KernelRunnerJNI{ //Same as 2D actually turns out that localId[0] is identical for all three dims so could be hoisted out of conditional code threadIdSetter = new ThreadIdSetter() { @Override - public void set(KernelState kernelState, int globalGroupId, int threadId) { + public void set(Kernel.KernelState kernelState, int globalGroupId, int threadId) { // (kernelState, globalGroupId, threadId) ->{ kernelState.setLocalId(0, (threadId % localSize0)); @@ -634,7 +641,7 @@ public class KernelRunner extends KernelRunnerJNI{ * about other threads. */ final Kernel kernelClone = kernel.clone(); - final KernelState kernelState = kernelClone.getKernelState(); + final Kernel.KernelState kernelState = kernelClone.getKernelState(); kernelState.setRange(_settings.range); kernelState.setPassId(passId); @@ -765,7 +772,7 @@ public class KernelRunner extends KernelRunnerJNI{ final Object object = UnsafeWrapper.getObject(newRef, arrayBaseOffset + (arrayScale * j)); for (int i = 0; i < c.getStructMemberTypes().size(); i++) { - final TypeSpec t = c.getStructMemberTypes().get(i); + final InstructionSet.TypeSpec t = c.getStructMemberTypes().get(i); final long offset = c.getStructMemberOffsets().get(i); if (logger.isLoggable(Level.FINEST)) { @@ -796,7 +803,7 @@ public class KernelRunner extends KernelRunnerJNI{ final boolean x = UnsafeWrapper.getBoolean(object, offset); arg.getObjArrayByteBuffer().put(x == true ? (byte) 1 : (byte) 0); // Booleans converted to 1 byte C chars for opencl - sizeWritten += TypeSpec.B.getSize(); + sizeWritten += InstructionSet.TypeSpec.B.getSize(); break; } case B: { @@ -866,7 +873,7 @@ public class KernelRunner extends KernelRunnerJNI{ int sizeWritten = 0; final Object object = UnsafeWrapper.getObject(arg.getArray(), arrayBaseOffset + (arrayScale * j)); for (int i = 0; i < c.getStructMemberTypes().size(); i++) { - final TypeSpec t = c.getStructMemberTypes().get(i); + final InstructionSet.TypeSpec t = c.getStructMemberTypes().get(i); final long offset = c.getStructMemberOffsets().get(i); switch (t) { case I: { @@ -904,7 +911,7 @@ public class KernelRunner extends KernelRunnerJNI{ } UnsafeWrapper.putBoolean(object, offset, (x == 1 ? true : false)); // Booleans converted to 1 byte C chars for open cl - sizeWritten += TypeSpec.B.getSize(); + sizeWritten += InstructionSet.TypeSpec.B.getSize(); break; } case B: { @@ -1192,7 +1199,7 @@ public class KernelRunner extends KernelRunnerJNI{ throw new IllegalStateException("range can't be null"); } - EXECUTION_MODE requestedExecutionMode = kernel.getExecutionMode(); + Kernel.EXECUTION_MODE requestedExecutionMode = kernel.getExecutionMode(); if (requestedExecutionMode.isOpenCL() && _settings.range.getDevice() != null && !(_settings.range.getDevice() instanceof OpenCLDevice)) { fallBackToNextDevice(_settings, "OpenCL EXECUTION_MODE was requested but Device supplied was not an OpenCLDevice"); @@ -1209,9 +1216,9 @@ public class KernelRunner extends KernelRunnerJNI{ device = JavaDevice.THREAD_POOL; } } else { - if (requestedExecutionMode == EXECUTION_MODE.JTP) { + if (requestedExecutionMode == Kernel.EXECUTION_MODE.JTP) { device = JavaDevice.THREAD_POOL; - } else if (requestedExecutionMode == EXECUTION_MODE.SEQ) { + } else if (requestedExecutionMode == Kernel.EXECUTION_MODE.SEQ) { device = JavaDevice.SEQUENTIAL; } } @@ -1229,14 +1236,14 @@ public class KernelRunner extends KernelRunnerJNI{ int jniFlags = 0; // for legacy reasons use old logic where Kernel.EXECUTION_MODE is not AUTO if (_settings.legacyExecutionMode && !userSpecifiedDevice && requestedExecutionMode.isOpenCL()) { - if (requestedExecutionMode.equals(EXECUTION_MODE.GPU)) { + if (requestedExecutionMode.equals(Kernel.EXECUTION_MODE.GPU)) { // Get the best GPU openCLDevice = (OpenCLDevice) KernelManager.DeprecatedMethods.bestGPU(); jniFlags |= JNI_FLAG_USE_GPU; // this flag might be redundant now. if (openCLDevice == null) { return fallBackToNextDevice(_settings, "GPU request can't be honored, no GPU device"); } - } else if (requestedExecutionMode.equals(EXECUTION_MODE.ACC)) { + } else if (requestedExecutionMode.equals(Kernel.EXECUTION_MODE.ACC)) { // Get the best ACC openCLDevice = (OpenCLDevice) KernelManager.DeprecatedMethods.bestACC(); jniFlags |= JNI_FLAG_USE_ACC; // this flag might be redundant now. @@ -1395,9 +1402,9 @@ public class KernelRunner extends KernelRunnerJNI{ final Class<?> type = field.getType(); if (type.isArray()) { - if (field.getAnnotation(Local.class) != null || args[i].getName().endsWith(Kernel.LOCAL_SUFFIX)) { + if (field.getAnnotation(Kernel.Local.class) != null || args[i].getName().endsWith(Kernel.LOCAL_SUFFIX)) { args[i].setType(args[i].getType() | ARG_LOCAL); - } else if ((field.getAnnotation(Constant.class) != null) + } else if ((field.getAnnotation(Kernel.Constant.class) != null) || args[i].getName().endsWith(Kernel.CONSTANT_SUFFIX)) { args[i].setType(args[i].getType() | ARG_CONSTANT); } else { diff --git a/src/main/java/com/syncleus/aparapi/internal/kernel/ProfilingEvent.java b/src/main/java/com/aparapi/internal/kernel/ProfilingEvent.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/kernel/ProfilingEvent.java rename to src/main/java/com/aparapi/internal/kernel/ProfilingEvent.java index 5ecd6d561734d1f7cf9689626671e34da27da6a1..7a166567e39320da61aba7cb1ef814d37c53b703 100644 --- a/src/main/java/com/syncleus/aparapi/internal/kernel/ProfilingEvent.java +++ b/src/main/java/com/aparapi/internal/kernel/ProfilingEvent.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.kernel; +package com.aparapi.internal.kernel; /** * Created by Barney on 02/09/2015. diff --git a/src/main/java/com/syncleus/aparapi/internal/model/CacheEnabler.java b/src/main/java/com/aparapi/internal/model/CacheEnabler.java similarity index 89% rename from src/main/java/com/syncleus/aparapi/internal/model/CacheEnabler.java rename to src/main/java/com/aparapi/internal/model/CacheEnabler.java index ec5abdc2611a33bdf7638d57ac181b6b09a47013..2ef0808acd45051c24b2b160d0e6f62333602bf7 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/CacheEnabler.java +++ b/src/main/java/com/aparapi/internal/model/CacheEnabler.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; -import com.syncleus.aparapi.Kernel; +import com.aparapi.Kernel; public class CacheEnabler{ private static volatile boolean cachesEnabled = true; diff --git a/src/main/java/com/syncleus/aparapi/internal/model/ClassModel.java b/src/main/java/com/aparapi/internal/model/ClassModel.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/internal/model/ClassModel.java rename to src/main/java/com/aparapi/internal/model/ClassModel.java index 6b4b597700045a2deeea4dd4929444f5d8cdd9d1..1ea548ac63eb83e201dca890d9c0cceb045c2df0 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/ClassModel.java +++ b/src/main/java/com/aparapi/internal/model/ClassModel.java @@ -50,17 +50,18 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.model; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.annotation.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.model.ValueCache.ThrowingValueComputer; -import com.syncleus.aparapi.internal.model.ClassModel.AttributePool.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.*; -import com.syncleus.aparapi.internal.reader.*; -import com.syncleus.aparapi.internal.util.*; +package com.aparapi.internal.model; + +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.internal.annotation.DocMe; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.reader.ByteReader; +import com.aparapi.internal.util.Reflection; +import com.aparapi.*; +import com.aparapi.internal.model.ValueCache.ThrowingValueComputer; import java.io.*; import java.lang.reflect.*; @@ -2300,7 +2301,7 @@ public class ClassModel { for (int i = 0; i < attributeCount; i++) { final int attributeNameIndex = _byteReader.u2(); final int length = _byteReader.u4(); - UTF8Entry utf8Entry = constantPool.getUTF8Entry(attributeNameIndex); + ConstantPool.UTF8Entry utf8Entry = constantPool.getUTF8Entry(attributeNameIndex); if (utf8Entry == null) { throw new IllegalStateException("corrupted state reading attributes for " + name); } @@ -2484,7 +2485,7 @@ public class ClassModel { private final int nameIndex; - private final CodeEntry codeEntry; + private final AttributePool.CodeEntry codeEntry; public ClassModelMethod(ByteReader _byteReader, int _index) { index = _index; @@ -2737,7 +2738,7 @@ public class ClassModel { * * @return The Method or null if we fail to locate a given method. */ - public ClassModelMethod getMethod(MethodEntry _methodEntry, boolean _isSpecial) { + public ClassModelMethod getMethod(ConstantPool.MethodEntry _methodEntry, boolean _isSpecial) { final String entryClassNameInDotForm = _methodEntry.getClassEntry().getNameUTF8Entry().getUTF8().replace('/', '.'); // Shortcut direct calls to supers to allow "foo() { super.foo() }" type stuff to work @@ -2749,7 +2750,7 @@ public class ClassModel { return superClazz.getMethod(_methodEntry, false); } - NameAndTypeEntry nameAndTypeEntry = _methodEntry.getNameAndTypeEntry(); + ConstantPool.NameAndTypeEntry nameAndTypeEntry = _methodEntry.getNameAndTypeEntry(); ClassModelMethod methodOrNull = getMethodOrNull(nameAndTypeEntry.getNameUTF8Entry().getUTF8(), nameAndTypeEntry .getDescriptorUTF8Entry().getUTF8()); if (methodOrNull == null) @@ -2788,15 +2789,15 @@ public class ClassModel { } // These fields use for accessor conversion - private final ArrayList<FieldEntry> structMembers = new ArrayList<FieldEntry>(); + private final ArrayList<ConstantPool.FieldEntry> structMembers = new ArrayList<ConstantPool.FieldEntry>(); private final ArrayList<Long> structMemberOffsets = new ArrayList<Long>(); - private final ArrayList<TypeSpec> structMemberTypes = new ArrayList<TypeSpec>(); + private final ArrayList<InstructionSet.TypeSpec> structMemberTypes = new ArrayList<InstructionSet.TypeSpec>(); private int totalStructSize = 0; - public ArrayList<FieldEntry> getStructMembers() { + public ArrayList<ConstantPool.FieldEntry> getStructMembers() { return structMembers; } @@ -2804,7 +2805,7 @@ public class ClassModel { return structMemberOffsets; } - public ArrayList<TypeSpec> getStructMemberTypes() { + public ArrayList<InstructionSet.TypeSpec> getStructMemberTypes() { return structMemberTypes; } diff --git a/src/main/java/com/syncleus/aparapi/internal/model/Entrypoint.java b/src/main/java/com/aparapi/internal/model/Entrypoint.java similarity index 83% rename from src/main/java/com/syncleus/aparapi/internal/model/Entrypoint.java rename to src/main/java/com/aparapi/internal/model/Entrypoint.java index 2405a64609f5dcb93ba241d9da0aa3620807b6e9..cb8d87f5f8212a96372fcddd590f2cc06690fbd1 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/Entrypoint.java +++ b/src/main/java/com/aparapi/internal/model/Entrypoint.java @@ -50,16 +50,16 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.model.ClassModel.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.MethodReferenceEntry.*; -import com.syncleus.aparapi.internal.util.*; +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.util.UnsafeWrapper; +import com.aparapi.*; import java.lang.reflect.*; import java.util.*; @@ -275,13 +275,13 @@ public class Entrypoint implements Cloneable { return memberClassModel; } - public ClassModelMethod resolveAccessorCandidate(MethodCall _methodCall, MethodEntry _methodEntry) throws AparapiException { + public ClassModel.ClassModelMethod resolveAccessorCandidate(InstructionSet.MethodCall _methodCall, ClassModel.ConstantPool.MethodEntry _methodEntry) throws AparapiException { final String methodsActualClassName = (_methodEntry.getClassEntry().getNameUTF8Entry().getUTF8()).replace('/', '.'); - if (_methodCall instanceof VirtualMethodCall) { - final Instruction callInstance = ((VirtualMethodCall) _methodCall).getInstanceReference(); - if (callInstance instanceof AccessArrayElement) { - final AccessArrayElement arrayAccess = (AccessArrayElement) callInstance; + if (_methodCall instanceof InstructionSet.VirtualMethodCall) { + final Instruction callInstance = ((InstructionSet.VirtualMethodCall) _methodCall).getInstanceReference(); + if (callInstance instanceof InstructionSet.AccessArrayElement) { + final InstructionSet.AccessArrayElement arrayAccess = (InstructionSet.AccessArrayElement) callInstance; final Instruction refAccess = arrayAccess.getArrayRef(); //if (refAccess instanceof I_GETFIELD) { @@ -303,7 +303,7 @@ public class Entrypoint implements Cloneable { * Update accessor structures when there is a direct access to an * obect array element's data members */ - public void updateObjectMemberFieldAccesses(String className, FieldEntry field) throws AparapiException { + public void updateObjectMemberFieldAccesses(String className, ClassModel.ConstantPool.FieldEntry field) throws AparapiException { final String accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); // Quickly bail if it is a ref @@ -343,8 +343,8 @@ public class Entrypoint implements Cloneable { // Look at super's fields for a match if (superCandidate != null) { - final ArrayList<FieldEntry> structMemberSet = superCandidate.getStructMembers(); - for (final FieldEntry f : structMemberSet) { + final ArrayList<ClassModel.ConstantPool.FieldEntry> structMemberSet = superCandidate.getStructMembers(); + for (final ClassModel.ConstantPool.FieldEntry f : structMemberSet) { if (f.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(accessedFieldName) && f.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8() .equals(field.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8())) { @@ -375,8 +375,8 @@ public class Entrypoint implements Cloneable { // if not already there if (add) { boolean found = false; - final ArrayList<FieldEntry> structMemberSet = memberClassModel.getStructMembers(); - for (final FieldEntry f : structMemberSet) { + final ArrayList<ClassModel.ConstantPool.FieldEntry> structMemberSet = memberClassModel.getStructMembers(); + for (final ClassModel.ConstantPool.FieldEntry f : structMemberSet) { if (f.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(accessedFieldName) && f.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8() .equals(field.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8())) { @@ -397,12 +397,12 @@ public class Entrypoint implements Cloneable { /* * Find a suitable call target in the kernel class, supers, object members or static calls */ - ClassModelMethod resolveCalledMethod(MethodCall methodCall, ClassModel classModel) throws AparapiException { - MethodEntry methodEntry = methodCall.getConstantPoolMethodEntry(); + ClassModel.ClassModelMethod resolveCalledMethod(InstructionSet.MethodCall methodCall, ClassModel classModel) throws AparapiException { + ClassModel.ConstantPool.MethodEntry methodEntry = methodCall.getConstantPoolMethodEntry(); int thisClassIndex = classModel.getThisClassConstantPoolIndex();//arf boolean isMapped = (thisClassIndex != methodEntry.getClassIndex()) && Kernel.isMappedMethod(methodEntry); if (logger.isLoggable(Level.FINE)) { - if (methodCall instanceof I_INVOKESPECIAL) { + if (methodCall instanceof InstructionSet.I_INVOKESPECIAL) { logger.fine("Method call to super: " + methodEntry); } else if (thisClassIndex != methodEntry.getClassIndex()) { logger.fine("Method call to ??: " + methodEntry + ", isMappedMethod=" + isMapped); @@ -411,7 +411,7 @@ public class Entrypoint implements Cloneable { } } - ClassModelMethod m = classModel.getMethod(methodEntry, (methodCall instanceof I_INVOKESPECIAL) ? true : false); + ClassModel.ClassModelMethod m = classModel.getMethod(methodEntry, (methodCall instanceof InstructionSet.I_INVOKESPECIAL) ? true : false); // Did not find method in this class or supers. Look for data member object arrays if (m == null && !isMapped) { @@ -423,7 +423,7 @@ public class Entrypoint implements Cloneable { for (ClassModel c : allFieldsClasses.values()) { if (c.getClassWeAreModelling().getName() .equals(methodEntry.getClassEntry().getNameUTF8Entry().getUTF8().replace('/', '.'))) { - m = c.getMethod(methodEntry, (methodCall instanceof I_INVOKESPECIAL) ? true : false); + m = c.getMethod(methodEntry, (methodCall instanceof InstructionSet.I_INVOKESPECIAL) ? true : false); assert m != null; break; } @@ -431,7 +431,7 @@ public class Entrypoint implements Cloneable { } // Look for static call to some other class - if ((m == null) && !isMapped && (methodCall instanceof I_INVOKESTATIC)) { + if ((m == null) && !isMapped && (methodCall instanceof InstructionSet.I_INVOKESTATIC)) { String otherClassName = methodEntry.getClassEntry().getNameUTF8Entry().getUTF8().replace('/', '.'); ClassModel otherClassModel = getOrUpdateAllClassAccesses(otherClassName); @@ -454,7 +454,7 @@ public class Entrypoint implements Cloneable { methodModel = _methodModel; kernelInstance = _k; - final Map<ClassModelMethod, MethodModel> methodMap = new LinkedHashMap<ClassModelMethod, MethodModel>(); + final Map<ClassModel.ClassModelMethod, MethodModel> methodMap = new LinkedHashMap<ClassModel.ClassModelMethod, MethodModel>(); boolean discovered = true; @@ -474,9 +474,9 @@ public class Entrypoint implements Cloneable { } // Collect all methods called directly from kernel's run method - for (final MethodCall methodCall : methodModel.getMethodCalls()) { + for (final InstructionSet.MethodCall methodCall : methodModel.getMethodCalls()) { - ClassModelMethod m = resolveCalledMethod(methodCall, classModel); + ClassModel.ClassModelMethod m = resolveCalledMethod(methodCall, classModel); if ((m != null) && !methodMap.keySet().contains(m) && !noCL(m)) { final MethodModel target = new MethodModel(m, this); methodMap.put(m, target); @@ -490,9 +490,9 @@ public class Entrypoint implements Cloneable { while (discovered) { discovered = false; for (final MethodModel mm : new ArrayList<MethodModel>(methodMap.values())) { - for (final MethodCall methodCall : mm.getMethodCalls()) { + for (final InstructionSet.MethodCall methodCall : mm.getMethodCalls()) { - ClassModelMethod m = resolveCalledMethod(methodCall, classModel); + ClassModel.ClassModelMethod m = resolveCalledMethod(methodCall, classModel); if (m != null && !noCL(m)) { MethodModel target = null; if (methodMap.keySet().contains(m)) { @@ -548,49 +548,49 @@ public class Entrypoint implements Cloneable { for (Instruction instruction = methodModel.getPCHead(); instruction != null; instruction = instruction.getNextPC()) { - if (instruction instanceof AssignToArrayElement) { - final AssignToArrayElement assignment = (AssignToArrayElement) instruction; + if (instruction instanceof InstructionSet.AssignToArrayElement) { + final InstructionSet.AssignToArrayElement assignment = (InstructionSet.AssignToArrayElement) instruction; final Instruction arrayRef = assignment.getArrayRef(); // AccessField here allows instance and static array refs - if (arrayRef instanceof I_GETFIELD) { - final I_GETFIELD getField = (I_GETFIELD) arrayRef; - final FieldEntry field = getField.getConstantPoolFieldEntry(); + if (arrayRef instanceof InstructionSet.I_GETFIELD) { + final InstructionSet.I_GETFIELD getField = (InstructionSet.I_GETFIELD) arrayRef; + final ClassModel.ConstantPool.FieldEntry field = getField.getConstantPoolFieldEntry(); final String assignedArrayFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); arrayFieldAssignments.add(assignedArrayFieldName); referencedFieldNames.add(assignedArrayFieldName); } - } else if (instruction instanceof AccessArrayElement) { - final AccessArrayElement access = (AccessArrayElement) instruction; + } else if (instruction instanceof InstructionSet.AccessArrayElement) { + final InstructionSet.AccessArrayElement access = (InstructionSet.AccessArrayElement) instruction; final Instruction arrayRef = access.getArrayRef(); // AccessField here allows instance and static array refs - if (arrayRef instanceof I_GETFIELD) { - final I_GETFIELD getField = (I_GETFIELD) arrayRef; - final FieldEntry field = getField.getConstantPoolFieldEntry(); + if (arrayRef instanceof InstructionSet.I_GETFIELD) { + final InstructionSet.I_GETFIELD getField = (InstructionSet.I_GETFIELD) arrayRef; + final ClassModel.ConstantPool.FieldEntry field = getField.getConstantPoolFieldEntry(); final String accessedArrayFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); arrayFieldAccesses.add(accessedArrayFieldName); referencedFieldNames.add(accessedArrayFieldName); } - } else if (instruction instanceof I_ARRAYLENGTH) { + } else if (instruction instanceof InstructionSet.I_ARRAYLENGTH) { Instruction child = instruction.getFirstChild(); - while(child instanceof I_AALOAD) { + while(child instanceof InstructionSet.I_AALOAD) { child = child.getFirstChild(); } - if (!(child instanceof AccessField)) { + if (!(child instanceof InstructionSet.AccessField)) { throw new ClassParseException(ClassParseException.TYPE.LOCALARRAYLENGTHACCESS); } - final AccessField childField = (AccessField) child; + final InstructionSet.AccessField childField = (InstructionSet.AccessField) child; final String arrayName = childField.getConstantPoolFieldEntry().getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); arrayFieldArrayLengthUsed.add(arrayName); if (logger.isLoggable(Level.FINE)) { logger.fine("Noted arraylength in " + methodModel.getName() + " on " + arrayName); } - } else if (instruction instanceof AccessField) { - final AccessField access = (AccessField) instruction; - final FieldEntry field = access.getConstantPoolFieldEntry(); + } else if (instruction instanceof InstructionSet.AccessField) { + final InstructionSet.AccessField access = (InstructionSet.AccessField) instruction; + final ClassModel.ConstantPool.FieldEntry field = access.getConstantPoolFieldEntry(); final String accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); fieldAccesses.add(accessedFieldName); referencedFieldNames.add(accessedFieldName); @@ -602,7 +602,7 @@ public class Entrypoint implements Cloneable { // Add the class model for the referenced obj array if (signature.startsWith("[L")) { - // Turn [Lcom/syncleus/javalabs/opencl/demo/DummyOOA; into com.syncleus.javalabs.opencl.demo.DummyOOA for example + // Turn [Lcom/aparapi/javalabs/opencl/demo/DummyOOA; into com.aparapi.javalabs.opencl.demo.DummyOOA for example final String className = (signature.substring(2, signature.length() - 1)).replace('/', '.'); final ClassModel arrayFieldModel = getOrUpdateAllClassAccesses(className); if (arrayFieldModel != null) { @@ -641,9 +641,9 @@ public class Entrypoint implements Cloneable { } } - } else if (instruction instanceof AssignToField) { - final AssignToField assignment = (AssignToField) instruction; - final FieldEntry field = assignment.getConstantPoolFieldEntry(); + } else if (instruction instanceof InstructionSet.AssignToField) { + final InstructionSet.AssignToField assignment = (InstructionSet.AssignToField) instruction; + final ClassModel.ConstantPool.FieldEntry field = assignment.getConstantPoolFieldEntry(); final String assignedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); fieldAssignments.add(assignedFieldName); referencedFieldNames.add(assignedFieldName); @@ -662,27 +662,27 @@ public class Entrypoint implements Cloneable { } } - else if (instruction instanceof I_INVOKEVIRTUAL) { - final I_INVOKEVIRTUAL invokeInstruction = (I_INVOKEVIRTUAL) instruction; + else if (instruction instanceof InstructionSet.I_INVOKEVIRTUAL) { + final InstructionSet.I_INVOKEVIRTUAL invokeInstruction = (InstructionSet.I_INVOKEVIRTUAL) instruction; MethodModel invokedMethod = invokeInstruction.getMethod(); - FieldEntry getterField = getSimpleGetterField(invokedMethod); + ClassModel.ConstantPool.FieldEntry getterField = getSimpleGetterField(invokedMethod); if (getterField != null) { referencedFieldNames.add(getterField.getNameAndTypeEntry().getNameUTF8Entry().getUTF8()); } else { - final MethodEntry methodEntry = invokeInstruction.getConstantPoolMethodEntry(); + final ClassModel.ConstantPool.MethodEntry methodEntry = invokeInstruction.getConstantPoolMethodEntry(); if (Kernel.isMappedMethod(methodEntry)) { //only do this for intrinsics if (Kernel.usesAtomic32(methodEntry)) { setRequiresAtomics32Pragma(true); } - final Arg methodArgs[] = methodEntry.getArgs(); + final ClassModel.ConstantPool.MethodReferenceEntry.Arg methodArgs[] = methodEntry.getArgs(); if ((methodArgs.length > 0) && methodArgs[0].isArray()) { //currently array arg can only take slot 0 final Instruction arrInstruction = invokeInstruction.getArg(0); - if (arrInstruction instanceof AccessField) { - final AccessField access = (AccessField) arrInstruction; - final FieldEntry field = access.getConstantPoolFieldEntry(); + if (arrInstruction instanceof InstructionSet.AccessField) { + final InstructionSet.AccessField access = (InstructionSet.AccessField) arrInstruction; + final ClassModel.ConstantPool.FieldEntry field = access.getConstantPoolFieldEntry(); final String accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); arrayFieldAssignments.add(accessedFieldName); referencedFieldNames.add(accessedFieldName); @@ -705,7 +705,7 @@ public class Entrypoint implements Cloneable { final Field field = getFieldFromClassHierarchy(clazz, referencedFieldName); if (field != null) { referencedFields.add(field); - final ClassModelField ff = classModel.getField(referencedFieldName); + final ClassModel.ClassModelField ff = classModel.getField(referencedFieldName); assert ff != null : "ff should not be null for " + clazz.getName() + "." + referencedFieldName; referencedClassModelFields.add(ff); } @@ -734,8 +734,8 @@ public class Entrypoint implements Cloneable { } // Sort fields of each class biggest->smallest - final Comparator<FieldEntry> fieldSizeComparator = new Comparator<FieldEntry>(){ - @Override public int compare(FieldEntry aa, FieldEntry bb) { + final Comparator<ClassModel.ConstantPool.FieldEntry> fieldSizeComparator = new Comparator<ClassModel.ConstantPool.FieldEntry>(){ + @Override public int compare(ClassModel.ConstantPool.FieldEntry aa, ClassModel.ConstantPool.FieldEntry bb) { final String aType = aa.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8(); final String bType = bb.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8(); @@ -759,7 +759,7 @@ public class Entrypoint implements Cloneable { }; for (final ClassModel c : objectArrayFieldsClasses.values()) { - final ArrayList<FieldEntry> fields = c.getStructMembers(); + final ArrayList<ClassModel.ConstantPool.FieldEntry> fields = c.getStructMembers(); if (fields.size() > 0) { Collections.sort(fields, fieldSizeComparator); @@ -767,7 +767,7 @@ public class Entrypoint implements Cloneable { int totalSize = 0; int alignTo = 0; - for (final FieldEntry f : fields) { + for (final ClassModel.ConstantPool.FieldEntry f : fields) { // Record field offset for use while copying // Get field we will copy out of the kernel member object final Field rfield = getFieldFromClassHierarchy(c.getClassWeAreModelling(), f.getNameAndTypeEntry() @@ -777,8 +777,8 @@ public class Entrypoint implements Cloneable { final String fType = f.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8(); //c.getStructMemberTypes().add(TypeSpec.valueOf(fType.equals("Z") ? "B" : fType)); - c.getStructMemberTypes().add(TypeSpec.valueOf(fType)); - final int fSize = TypeSpec.valueOf(fType.equals("Z") ? "B" : fType).getSize(); + c.getStructMemberTypes().add(InstructionSet.TypeSpec.valueOf(fType)); + final int fSize = InstructionSet.TypeSpec.valueOf(fType.equals("Z") ? "B" : fType).getSize(); if (fSize > alignTo) { alignTo = fSize; } @@ -804,12 +804,12 @@ public class Entrypoint implements Cloneable { } } - private boolean noCL(ClassModelMethod m) { + private boolean noCL(ClassModel.ClassModelMethod m) { boolean found = m.getClassModel().getNoCLMethods().contains(m.getName()); return found; } - private FieldEntry getSimpleGetterField(MethodModel method) { + private ClassModel.ConstantPool.FieldEntry getSimpleGetterField(MethodModel method) { return method.getAccessorVariableFieldEntry(); } @@ -852,10 +852,10 @@ public class Entrypoint implements Cloneable { /* * Return the best call target MethodModel by looking in the class hierarchy * @param _methodEntry MethodEntry for the desired target - * @return the fully qualified name such as "com_amd_javalabs_opencl_demo_PaternityTest$SimpleKernel__actuallyDoIt" + * @return the fully qualified name such as "com_aparapi_javalabs_opencl_demo_PaternityTest$SimpleKernel__actuallyDoIt" */ - public MethodModel getCallTarget(MethodEntry _methodEntry, boolean _isSpecial) { - ClassModelMethod target = getClassModel().getMethod(_methodEntry, _isSpecial); + public MethodModel getCallTarget(ClassModel.ConstantPool.MethodEntry _methodEntry, boolean _isSpecial) { + ClassModel.ClassModelMethod target = getClassModel().getMethod(_methodEntry, _isSpecial); boolean isMapped = Kernel.isMappedMethod(_methodEntry); if (logger.isLoggable(Level.FINE) && (target == null)) { diff --git a/src/main/java/com/syncleus/aparapi/internal/model/EntrypointKey.java b/src/main/java/com/aparapi/internal/model/EntrypointKey.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/model/EntrypointKey.java rename to src/main/java/com/aparapi/internal/model/EntrypointKey.java index d9caaf273390065bed8ad48b3040a1eebf0e3515..3280f44ea7579e50e6187f3a7655c80f59d6d969 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/EntrypointKey.java +++ b/src/main/java/com/aparapi/internal/model/EntrypointKey.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; final class EntrypointKey{ public static EntrypointKey of(String entrypointName, String descriptor) { diff --git a/src/main/java/com/syncleus/aparapi/internal/model/Memoizer.java b/src/main/java/com/aparapi/internal/model/Memoizer.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/model/Memoizer.java rename to src/main/java/com/aparapi/internal/model/Memoizer.java index 043d5ae0e8c76129d06005c0a040b24556776b6b..b72be234f20a855402a713f03036003876ea0cf6 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/Memoizer.java +++ b/src/main/java/com/aparapi/internal/model/Memoizer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; import java.util.*; import java.util.concurrent.atomic.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/model/MethodKey.java b/src/main/java/com/aparapi/internal/model/MethodKey.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/model/MethodKey.java rename to src/main/java/com/aparapi/internal/model/MethodKey.java index 69857b0ed07c7a2de04cb87a6df4e897066d7104..b6afea1fccbb2cbbffff1478626ca593ebbf7426 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/MethodKey.java +++ b/src/main/java/com/aparapi/internal/model/MethodKey.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; final class MethodKey{ static MethodKey of(String name, String signature) { diff --git a/src/main/java/com/syncleus/aparapi/internal/model/MethodModel.java b/src/main/java/com/aparapi/internal/model/MethodModel.java similarity index 79% rename from src/main/java/com/syncleus/aparapi/internal/model/MethodModel.java rename to src/main/java/com/aparapi/internal/model/MethodModel.java index 6f3bafecbe6601651a84a9d0ff705dc8673324b9..fa5e32db471c74244876788ed009533a5035767e 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/MethodModel.java +++ b/src/main/java/com/aparapi/internal/model/MethodModel.java @@ -50,17 +50,15 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.model; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.*; -import com.syncleus.aparapi.internal.instruction.InstructionPattern.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.model.ClassModel.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.MethodReferenceEntry.*; -import com.syncleus.aparapi.internal.reader.*; +package com.aparapi.internal.model; + +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.instruction.*; +import com.aparapi.internal.reader.ByteReader; +import com.aparapi.*; import java.util.*; import java.util.Map.Entry; @@ -72,7 +70,7 @@ public class MethodModel{ private ExpressionList expressionList; - private ClassModelMethod method; + private ClassModel.ClassModelMethod method; /** True is an indication to use the fp64 pragma @@ -93,7 +91,7 @@ public class MethodModel{ // Only setters can use putfield private boolean usesPutfield; - private FieldEntry accessorVariableFieldEntry; + private ClassModel.ConstantPool.FieldEntry accessorVariableFieldEntry; private boolean noCL = false; @@ -117,11 +115,11 @@ public class MethodModel{ return methodIsPrivateMemoryGetter; } - public ClassModelMethod getMethod() { + public ClassModel.ClassModelMethod getMethod() { return method; } - public FieldEntry getAccessorVariableFieldEntry() { + public ClassModel.ConstantPool.FieldEntry getAccessorVariableFieldEntry() { return accessorVariableFieldEntry; } @@ -173,7 +171,7 @@ public class MethodModel{ } } - if ((instruction instanceof I_BASTORE) || (instruction instanceof I_CASTORE /* || instruction instanceof I_SASTORE */)) { + if ((instruction instanceof InstructionSet.I_BASTORE) || (instruction instanceof InstructionSet.I_CASTORE /* || instruction instanceof I_SASTORE */)) { usesByteWrites = true; if (usesByteWrites && logger.isLoggable(Level.FINE)) { logger.fine("Found Byte Addressable Store on =" + instruction + " in " + getName()); @@ -212,56 +210,56 @@ public class MethodModel{ final int pc = codeReader.getOffset(); final Instruction instruction = InstructionSet.ByteCode.create(this, codeReader); - if ((!Config.enablePUTFIELD) && (instruction instanceof I_PUTFIELD)) { + if ((!Config.enablePUTFIELD) && (instruction instanceof InstructionSet.I_PUTFIELD)) { // Special case putfield handling to allow object setter processing // and bail later if necessary //throw new ClassParseException("We don't support putfield instructions"); usesPutfield = true; } - if ((!Config.enableARETURN) && (instruction instanceof I_ARETURN)) { + if ((!Config.enableARETURN) && (instruction instanceof InstructionSet.I_ARETURN)) { throw new ClassParseException(instruction, ClassParseException.TYPE.ARRAY_RETURN); } - if ((!Config.enablePUTSTATIC) && (instruction instanceof I_PUTSTATIC)) { + if ((!Config.enablePUTSTATIC) && (instruction instanceof InstructionSet.I_PUTSTATIC)) { throw new ClassParseException(instruction, ClassParseException.TYPE.PUTFIELD); } - if ((!Config.enableINVOKEINTERFACE) && (instruction instanceof I_INVOKEINTERFACE)) { + if ((!Config.enableINVOKEINTERFACE) && (instruction instanceof InstructionSet.I_INVOKEINTERFACE)) { throw new ClassParseException(instruction, ClassParseException.TYPE.INVOKEINTERFACE); } - if ((!Config.enableGETSTATIC) && (instruction instanceof I_GETSTATIC)) { + if ((!Config.enableGETSTATIC) && (instruction instanceof InstructionSet.I_GETSTATIC)) { throw new ClassParseException(instruction, ClassParseException.TYPE.GETSTATIC); } - if ((!Config.enableATHROW) && (instruction instanceof I_ATHROW)) { + if ((!Config.enableATHROW) && (instruction instanceof InstructionSet.I_ATHROW)) { throw new ClassParseException(instruction, ClassParseException.TYPE.ATHROW); } - if ((!Config.enableMONITOR) && ((instruction instanceof I_MONITORENTER) || (instruction instanceof I_MONITOREXIT))) { + if ((!Config.enableMONITOR) && ((instruction instanceof InstructionSet.I_MONITORENTER) || (instruction instanceof InstructionSet.I_MONITOREXIT))) { throw new ClassParseException(instruction, ClassParseException.TYPE.SYNCHRONIZE); } - if ((!Config.enableNEW) && (instruction instanceof New)) { + if ((!Config.enableNEW) && (instruction instanceof InstructionSet.New)) { throw new ClassParseException(instruction, ClassParseException.TYPE.NEW); } - if (instruction instanceof I_AASTORE) { + if (instruction instanceof InstructionSet.I_AASTORE) { throw new ClassParseException(instruction, ClassParseException.TYPE.ARRAYALIAS); } - if ((!Config.enableSWITCH) && ((instruction instanceof I_LOOKUPSWITCH) || (instruction instanceof I_TABLESWITCH))) { + if ((!Config.enableSWITCH) && ((instruction instanceof InstructionSet.I_LOOKUPSWITCH) || (instruction instanceof InstructionSet.I_TABLESWITCH))) { throw new ClassParseException(instruction, ClassParseException.TYPE.SWITCH); } if (!Config.enableMETHODARRAYPASSING) { - if (instruction instanceof MethodCall) { - final MethodCall methodCall = (MethodCall) instruction; + if (instruction instanceof InstructionSet.MethodCall) { + final InstructionSet.MethodCall methodCall = (InstructionSet.MethodCall) instruction; - final MethodReferenceEntry methodReferenceEntry = methodCall.getConstantPoolMethodEntry(); + final ClassModel.ConstantPool.MethodReferenceEntry methodReferenceEntry = methodCall.getConstantPoolMethodEntry(); if (!Kernel.isMappedMethod(methodReferenceEntry)) { // we will allow trusted methods to violate this rule - for (final Arg arg : methodReferenceEntry.getArgs()) { + for (final ClassModel.ConstantPool.MethodReferenceEntry.Arg arg : methodReferenceEntry.getArgs()) { if (arg.isArray()) { throw new ClassParseException(instruction, ClassParseException.TYPE.METHODARRAYARG); } @@ -310,7 +308,7 @@ public class MethodModel{ public void buildBranchGraphs(Map<Integer, Instruction> pcMap) { for (Instruction instruction = pcHead; instruction != null; instruction = instruction.getNextPC()) { if (instruction.isBranch()) { - final Branch branch = instruction.asBranch(); + final InstructionSet.Branch branch = instruction.asBranch(); final Instruction targetInstruction = pcMap.get(branch.getAbsolute()); branch.setTarget(targetInstruction); } @@ -333,12 +331,12 @@ public class MethodModel{ for (Instruction instruction = pcHead; instruction != null; instruction = instruction.getNextPC()) { if (instruction.isBranch()) { - final Branch branch = instruction.asBranch(); + final InstructionSet.Branch branch = instruction.asBranch(); if (branch.isReverse()) { final Instruction target = branch.getTarget(); - final LinkedList<Branch> list = target.getReverseUnconditionalBranches(); + final LinkedList<InstructionSet.Branch> list = target.getReverseUnconditionalBranches(); if ((list != null) && (list.size() > 0) && (list.get(list.size() - 1) != branch)) { - final Branch unconditional = list.get(list.size() - 1).asBranch(); + final InstructionSet.Branch unconditional = list.get(list.size() - 1).asBranch(); branch.retarget(unconditional); } @@ -437,15 +435,15 @@ public class MethodModel{ * @throws ClassParseException */ public void txFormDups(ExpressionList _expressionList, final Instruction _instruction) throws ClassParseException { - if (_instruction instanceof I_DUP) { + if (_instruction instanceof InstructionSet.I_DUP) { Instruction e = _expressionList.getTail(); while (!e.producesStack()) { e = e.getPrevExpr(); } - _expressionList.add(new CloneInstruction(this, e)); + _expressionList.add(new InstructionSet.CloneInstruction(this, e)); System.out.println("clone of " + e); - } else if (_instruction instanceof I_DUP2) { + } else if (_instruction instanceof InstructionSet.I_DUP2) { Instruction e = _expressionList.getTail(); while (!e.producesStack()) { e = e.getPrevPC(); @@ -457,16 +455,16 @@ public class MethodModel{ e = e.getPrevExpr(); } - _expressionList.add(new CloneInstruction(this, e)); - _expressionList.add(new CloneInstruction(this, clone)); - } else if (_instruction instanceof I_DUP_X1) { + _expressionList.add(new InstructionSet.CloneInstruction(this, e)); + _expressionList.add(new InstructionSet.CloneInstruction(this, clone)); + } else if (_instruction instanceof InstructionSet.I_DUP_X1) { Instruction e = _expressionList.getTail(); while (!e.producesStack()) { e = e.getPrevExpr(); } - final Instruction clone1 = new CloneInstruction(this, e); + final Instruction clone1 = new InstructionSet.CloneInstruction(this, e); e = e.getPrevExpr(); while (!e.producesStack()) { e = e.getPrevExpr(); @@ -474,7 +472,7 @@ public class MethodModel{ _expressionList.insertBetween(e.getPrevExpr(), e, clone1); - } else if (_instruction instanceof I_DUP_X2) { + } else if (_instruction instanceof InstructionSet.I_DUP_X2) { // dup_x2 duplicates top operand and jams a copy in 3 down from the top // ...word3, word2, word1 => ...word1, word3, word2, word1 @@ -494,7 +492,7 @@ public class MethodModel{ } // Clone it, this will replace the dup action - final Instruction clone1 = new CloneInstruction(this, e); + final Instruction clone1 = new InstructionSet.CloneInstruction(this, e); if (logger.isLoggable(Level.FINE)) { logger.fine("DUP_X2 cloning: clone1=" + clone1); @@ -522,7 +520,7 @@ public class MethodModel{ // Add our clone in between those two writes _expressionList.insertBetween(e.getPrevExpr(), e, clone1); - } else if (_instruction instanceof DUP) { + } else if (_instruction instanceof InstructionSet.DUP) { throw new ClassParseException(_instruction, ClassParseException.TYPE.UNSUPPORTEDBYTECODE); } @@ -549,7 +547,7 @@ public class MethodModel{ expressionList.foldComposite(instruction); // If we find a DUP then we need to txform the DUP into a set of clones on the xpressionlist - if (instruction instanceof DUP) { + if (instruction instanceof InstructionSet.DUP) { txFormDups(expressionList, instruction); } else { if (instruction.consumesStack()) { @@ -623,28 +621,28 @@ public class MethodModel{ */ @Override public Instruction transform(final ExpressionList _expressionList, final Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if (Config.enablePUTFIELD && (result = InstructionPattern.accessInstanceField.matches(i, InstructionPattern.assignToInstanceField)).ok) { final Instruction accessRaw = i; final Instruction assignRaw = i.getNextExpr(); - final AccessInstanceField access = (AccessInstanceField) i.getReal(); - final AssignToInstanceField assign = (AssignToInstanceField) i.getNextExpr().getReal(); + final InstructionSet.AccessInstanceField access = (InstructionSet.AccessInstanceField) i.getReal(); + final InstructionSet.AssignToInstanceField assign = (InstructionSet.AssignToInstanceField) i.getNextExpr().getReal(); if (access.getConstantPoolFieldIndex() == assign.getConstantPoolFieldIndex()) { Instruction child = ((Instruction) assign).getFirstChild().getNextExpr(); - if (child instanceof CastOperator) { + if (child instanceof InstructionSet.CastOperator) { child = child.getFirstChild(); } - if (child instanceof I_IADD) { - final I_IADD add = (I_IADD) child; + if (child instanceof InstructionSet.I_IADD) { + final InstructionSet.I_IADD add = (InstructionSet.I_IADD) child; final Instruction lhs = add.getLhs(); final Instruction rhs = add.getRhs(); - if (lhs instanceof AccessInstanceField) { - if (rhs instanceof I_ICONST_1) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, + if (lhs instanceof InstructionSet.AccessInstanceField) { + if (rhs instanceof InstructionSet.I_ICONST_1) { + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, true, false); _expressionList.replaceInclusive(accessRaw, assignRaw, inc); return (inc); @@ -672,31 +670,31 @@ public class MethodModel{ */ @Override public Instruction transform(final ExpressionList _expressionList, final Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if (Config.enablePUTFIELD && (result = InstructionPattern.fieldPlusOne.matches(i, InstructionPattern.assignToInstanceField)).ok) { final Instruction topAddRaw = i; final Instruction assignRaw = i.getNextExpr(); - final I_IADD topAdd = (I_IADD) i.getReal(); - final AssignToInstanceField assign = (AssignToInstanceField) i.getNextExpr().getReal(); + final InstructionSet.I_IADD topAdd = (InstructionSet.I_IADD) i.getReal(); + final InstructionSet.AssignToInstanceField assign = (InstructionSet.AssignToInstanceField) i.getNextExpr().getReal(); final Instruction topLhs = topAdd.getLhs().getReal(); final Instruction topRhs = topAdd.getRhs().getReal(); - if (topLhs instanceof AccessInstanceField) { - final AccessInstanceField topLhsAccess = (AccessInstanceField) topLhs; - if (topRhs instanceof I_ICONST_1) { + if (topLhs instanceof InstructionSet.AccessInstanceField) { + final InstructionSet.AccessInstanceField topLhsAccess = (InstructionSet.AccessInstanceField) topLhs; + if (topRhs instanceof InstructionSet.I_ICONST_1) { if (topLhsAccess.getConstantPoolFieldIndex() == assign.getConstantPoolFieldIndex()) { final Instruction child = ((Instruction) assign).getFirstChild().getNextExpr(); final Instruction valueToAssign = assign.getValueToAssign(); - if (valueToAssign instanceof I_IADD) { + if (valueToAssign instanceof InstructionSet.I_IADD) { - final I_IADD add = (I_IADD) child; + final InstructionSet.I_IADD add = (InstructionSet.I_IADD) child; final Instruction lhs = add.getLhs(); final Instruction rhs = add.getRhs(); - if (lhs instanceof AccessInstanceField) { - if (rhs instanceof I_ICONST_1) { + if (lhs instanceof InstructionSet.AccessInstanceField) { + if (rhs instanceof InstructionSet.I_ICONST_1) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) topLhsAccess, true, true); _expressionList.replaceInclusive(topAddRaw, assignRaw, inc); @@ -735,13 +733,13 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { // looking for a post increment on a local variable - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.accessLocalVariable.matches(i, InstructionPattern.longHandIncLocalVariable)).ok) { - final AccessLocalVariable access = (AccessLocalVariable) i; - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i; + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); if (access.getLocalVariableTableIndex() == assign.getLocalVariableTableIndex()) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, true, false); + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, true, false); _expressionList.replaceInclusive((Instruction) access, (Instruction) assign, inc); return (inc); } @@ -772,13 +770,13 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.accessLocalVariable.matches(i, InstructionPattern.longHandDecLocalVariable)).ok) { - final AccessLocalVariable access = (AccessLocalVariable) i; - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i; + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); if (access.getLocalVariableTableIndex() == assign.getLocalVariableTableIndex()) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, false, false); + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, false, false); _expressionList.replaceInclusive((Instruction) access, (Instruction) assign, inc); return (inc); } @@ -809,14 +807,14 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; // pre increment local variable if ((result = InstructionPattern.longHandIncLocalVariable.matches(i, InstructionPattern.accessLocalVariable)).ok) { - final AssignToLocalVariable assign = (AssignToLocalVariable) i; - final AccessLocalVariable access = (AccessLocalVariable) i.getNextExpr(); + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i; + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i.getNextExpr(); if (access.getLocalVariableTableIndex() == assign.getLocalVariableTableIndex()) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, true, true); + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, true, true); _expressionList.replaceInclusive((Instruction) assign, (Instruction) access, inc); return (inc); } @@ -841,15 +839,15 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.accessLocalVariable.matches(i, InstructionPattern.assignToLocalVariable)).ok) { - final AccessLocalVariable access = (AccessLocalVariable) i; + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i; if (access.getLocalVariableTableIndex() != 0) { // we don;t want to trap on 'this' references ;) - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); if (access.getLocalVariableTableIndex() != assign.getLocalVariableTableIndex()) { - final InlineAssignInstruction inlineAssign = new InlineAssignInstruction(MethodModel.this, assign, + final InstructionSet.InlineAssignInstruction inlineAssign = new InstructionSet.InlineAssignInstruction(MethodModel.this, assign, (Instruction) access); _expressionList.replaceInclusive((Instruction) access, (Instruction) assign, inlineAssign); return (inlineAssign); @@ -865,14 +863,14 @@ public class MethodModel{ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.inc.matches(i, InstructionPattern.accessLocalVariable)).ok) { - final I_IINC iinc = (I_IINC) i; - final AccessLocalVariable access = (AccessLocalVariable) i.getNextExpr(); + final InstructionSet.I_IINC iinc = (InstructionSet.I_IINC) i; + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i.getNextExpr(); if (iinc.getLocalVariableTableIndex() == access.getLocalVariableTableIndex()) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, iinc.isInc(), true); _expressionList.replaceInclusive(iinc, (Instruction) access, inc); return (inc); @@ -886,16 +884,16 @@ public class MethodModel{ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.accessLocalVariable.matches(i, InstructionPattern.inc)).ok) { - final AccessLocalVariable access = (AccessLocalVariable) i; - final I_IINC iinc = (I_IINC) i.getNextExpr(); + final InstructionSet.AccessLocalVariable access = (InstructionSet.AccessLocalVariable) i; + final InstructionSet.I_IINC iinc = (InstructionSet.I_IINC) i.getNextExpr(); if (iinc.getLocalVariableTableIndex() == access.getLocalVariableTableIndex()) { - final IncrementInstruction inc = new IncrementInstruction(MethodModel.this, (Instruction) access, + final InstructionSet.IncrementInstruction inc = new InstructionSet.IncrementInstruction(MethodModel.this, (Instruction) access, iinc.isInc(), false); _expressionList.replaceInclusive((Instruction) access, iinc, inc); return (inc); @@ -919,14 +917,14 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.cast.matches(i, InstructionPattern.assignToLocalVariable)).ok) { - final CastOperator cast = (CastOperator) i; + final InstructionSet.CastOperator cast = (InstructionSet.CastOperator) i; - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); - final InlineAssignInstruction inlineAssign = new InlineAssignInstruction(MethodModel.this, assign, cast); + final InstructionSet.InlineAssignInstruction inlineAssign = new InstructionSet.InlineAssignInstruction(MethodModel.this, assign, cast); _expressionList.replaceInclusive((Instruction) cast, (Instruction) assign, inlineAssign); return (inlineAssign); @@ -955,15 +953,15 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.fieldArrayElementPlusOne.matches(i, InstructionPattern.longHandFieldArrayElementIncrement)).ok) { final Instruction addRaw = i; final Instruction assignArrayRaw = i.getNextExpr(); // I_IADD add = (I_IADD) addRaw.getReal(); - final AssignToArrayElement assignArray = (AssignToArrayElement) assignArrayRaw.getReal(); - final FieldArrayElementIncrement inlineAssign = new FieldArrayElementIncrement(MethodModel.this, assignArray, + final InstructionSet.AssignToArrayElement assignArray = (InstructionSet.AssignToArrayElement) assignArrayRaw.getReal(); + final InstructionSet.FieldArrayElementIncrement inlineAssign = new InstructionSet.FieldArrayElementIncrement(MethodModel.this, assignArray, true, true); _expressionList.replaceInclusive(addRaw, assignArrayRaw, inlineAssign); return (inlineAssign); @@ -994,15 +992,15 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.fieldArrayElementMinusOne.matches(i, InstructionPattern.longHandFieldArrayElementDecrement)).ok) { final Instruction subRaw = i; final Instruction assignArrayRaw = i.getNextExpr(); // I_IADD add = (I_IADD) addRaw.getReal(); - final AssignToArrayElement assignArray = (AssignToArrayElement) assignArrayRaw.getReal(); - final FieldArrayElementIncrement inlineAssign = new FieldArrayElementIncrement(MethodModel.this, assignArray, + final InstructionSet.AssignToArrayElement assignArray = (InstructionSet.AssignToArrayElement) assignArrayRaw.getReal(); + final InstructionSet.FieldArrayElementIncrement inlineAssign = new InstructionSet.FieldArrayElementIncrement(MethodModel.this, assignArray, false, true); _expressionList.replaceInclusive(subRaw, assignArrayRaw, inlineAssign); return (inlineAssign); @@ -1016,7 +1014,7 @@ public class MethodModel{ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.fieldArrayElementAccess.matches(i, InstructionPattern.longHandFieldArrayElementIncrement)).ok) { /** @@ -1037,17 +1035,17 @@ public class MethodModel{ */ final Instruction accessArrayRaw = i; final Instruction assignArrayRaw = i.getNextExpr(); - final AccessArrayElement accessArray = (AccessArrayElement) accessArrayRaw.getReal(); - final AssignToArrayElement assignArray = (AssignToArrayElement) assignArrayRaw.getReal(); - final AccessField accessField1 = (AccessField) accessArray.getArrayRef().getReal(); - final AccessField accessField2 = (AccessField) assignArray.getArrayRef().getReal(); + final InstructionSet.AccessArrayElement accessArray = (InstructionSet.AccessArrayElement) accessArrayRaw.getReal(); + final InstructionSet.AssignToArrayElement assignArray = (InstructionSet.AssignToArrayElement) assignArrayRaw.getReal(); + final InstructionSet.AccessField accessField1 = (InstructionSet.AccessField) accessArray.getArrayRef().getReal(); + final InstructionSet.AccessField accessField2 = (InstructionSet.AccessField) assignArray.getArrayRef().getReal(); if (accessField1.getConstantPoolFieldIndex() == accessField2.getConstantPoolFieldIndex()) { // we accessing the same field at least //AccessLocalVariable accessLocalVariable1 = (AccessLocalVariable) accessArray.getArrayIndex().getReal(); //AccessLocalVariable accessLocalVariable2 = (AccessLocalVariable) assignArray.getArrayIndex().getReal(); // if (accessLocalVariable1.getLocalVariableTableIndex() == accessLocalVariable2.getLocalVariableTableIndex()) { // and both arrays are referencing the array element using the same variable - final FieldArrayElementIncrement inlineAssign = new FieldArrayElementIncrement(MethodModel.this, assignArray, + final InstructionSet.FieldArrayElementIncrement inlineAssign = new InstructionSet.FieldArrayElementIncrement(MethodModel.this, assignArray, true, false); _expressionList.replaceInclusive(accessArrayRaw, assignArrayRaw, inlineAssign); return (inlineAssign); @@ -1079,23 +1077,23 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.fieldArrayElementAccess.matches(i, InstructionPattern.longHandFieldArrayElementDecrement)).ok) { final Instruction accessArrayRaw = i; final Instruction assignArrayRaw = i.getNextExpr(); - final AccessArrayElement accessArray = (AccessArrayElement) accessArrayRaw.getReal(); - final AssignToArrayElement assignArray = (AssignToArrayElement) assignArrayRaw.getReal(); - final AccessField accessField1 = (AccessField) accessArray.getArrayRef().getReal(); - final AccessField accessField2 = (AccessField) assignArray.getArrayRef().getReal(); + final InstructionSet.AccessArrayElement accessArray = (InstructionSet.AccessArrayElement) accessArrayRaw.getReal(); + final InstructionSet.AssignToArrayElement assignArray = (InstructionSet.AssignToArrayElement) assignArrayRaw.getReal(); + final InstructionSet.AccessField accessField1 = (InstructionSet.AccessField) accessArray.getArrayRef().getReal(); + final InstructionSet.AccessField accessField2 = (InstructionSet.AccessField) assignArray.getArrayRef().getReal(); if (accessField1.getConstantPoolFieldIndex() == accessField2.getConstantPoolFieldIndex()) { // we accessing the same field at least - final AccessLocalVariable accessLocalVariable1 = (AccessLocalVariable) accessArray.getArrayIndex().getReal(); - final AccessLocalVariable accessLocalVariable2 = (AccessLocalVariable) assignArray.getArrayIndex().getReal(); + final InstructionSet.AccessLocalVariable accessLocalVariable1 = (InstructionSet.AccessLocalVariable) accessArray.getArrayIndex().getReal(); + final InstructionSet.AccessLocalVariable accessLocalVariable2 = (InstructionSet.AccessLocalVariable) assignArray.getArrayIndex().getReal(); if (accessLocalVariable1.getLocalVariableTableIndex() == accessLocalVariable2.getLocalVariableTableIndex()) { // and both arrays are referencing the array element using the same variable - final FieldArrayElementIncrement inlineAssign = new FieldArrayElementIncrement(MethodModel.this, + final InstructionSet.FieldArrayElementIncrement inlineAssign = new InstructionSet.FieldArrayElementIncrement(MethodModel.this, assignArray, false, false); _expressionList.replaceInclusive(accessArrayRaw, assignArrayRaw, inlineAssign); return (inlineAssign); @@ -1122,14 +1120,14 @@ public class MethodModel{ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.methodCall.matches(i, InstructionPattern.assignToLocalVariable)).ok) { final Instruction invoke = i; - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); - final InlineAssignInstruction inlineAssign = new InlineAssignInstruction(MethodModel.this, assign, invoke); + final InstructionSet.InlineAssignInstruction inlineAssign = new InstructionSet.InlineAssignInstruction(MethodModel.this, assign, invoke); _expressionList.replaceInclusive(invoke, (Instruction) assign, inlineAssign); return (inlineAssign); @@ -1153,15 +1151,15 @@ public class MethodModel{ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.constant.matches(i, InstructionPattern.assignToLocalVariable)).ok) { final Instruction constant = i; - final AssignToLocalVariable assign = (AssignToLocalVariable) i.getNextExpr(); + final InstructionSet.AssignToLocalVariable assign = (InstructionSet.AssignToLocalVariable) i.getNextExpr(); - final InlineAssignInstruction inlineAssign = new InlineAssignInstruction(MethodModel.this, assign, constant); + final InstructionSet.InlineAssignInstruction inlineAssign = new InstructionSet.InlineAssignInstruction(MethodModel.this, assign, constant); _expressionList.replaceInclusive(constant, (Instruction) assign, inlineAssign); return (inlineAssign); @@ -1185,14 +1183,14 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.methodCall.matches(i, InstructionPattern.assignToArrayElement)).ok) { final Instruction invoke = i; - final AssignToArrayElement assign = (AssignToArrayElement) i.getNextExpr(); + final InstructionSet.AssignToArrayElement assign = (InstructionSet.AssignToArrayElement) i.getNextExpr(); - final FieldArrayElementAssign inlineAssign = new FieldArrayElementAssign(MethodModel.this, assign, invoke); + final InstructionSet.FieldArrayElementAssign inlineAssign = new InstructionSet.FieldArrayElementAssign(MethodModel.this, assign, invoke); _expressionList.replaceInclusive(invoke, assign, inlineAssign); return (inlineAssign); @@ -1216,15 +1214,15 @@ public class MethodModel{ */ @Override public Instruction transform(ExpressionList _expressionList, Instruction i) { - InstructionMatch result = null; + InstructionPattern.InstructionMatch result = null; if ((result = InstructionPattern.assignToArrayElement.matches(i, InstructionPattern.longHandFieldArrayElementIncrement)).ok) { final Instruction invoke = i; - final AssignToArrayElement assign = (AssignToArrayElement) i.getNextExpr(); + final InstructionSet.AssignToArrayElement assign = (InstructionSet.AssignToArrayElement) i.getNextExpr(); - final FieldArrayElementAssign inlineAssign = new FieldArrayElementAssign(MethodModel.this, assign, invoke); + final InstructionSet.FieldArrayElementAssign inlineAssign = new InstructionSet.FieldArrayElementAssign(MethodModel.this, assign, invoke); _expressionList.replaceInclusive(invoke, assign, inlineAssign); return (inlineAssign); @@ -1254,17 +1252,17 @@ public class MethodModel{ * * a=b=c=<exp>; */ - if ((_instruction instanceof AssignToLocalVariable) && _operandStart.producesStack() - && (_operandStart.getNextExpr() instanceof AssignToLocalVariable)) { + if ((_instruction instanceof InstructionSet.AssignToLocalVariable) && _operandStart.producesStack() + && (_operandStart.getNextExpr() instanceof InstructionSet.AssignToLocalVariable)) { final Instruction assignFirst = _operandStart.getNextExpr(); Instruction assign = assignFirst; int count = 0; - while ((assign != null) && (assign instanceof AssignToLocalVariable)) { + while ((assign != null) && (assign instanceof InstructionSet.AssignToLocalVariable)) { assign = assign.getNextExpr(); count++; } if (assign == null) { - final Instruction newOne = new MultiAssignInstruction(this, _operandStart, assignFirst, assign); + final Instruction newOne = new InstructionSet.MultiAssignInstruction(this, _operandStart, assignFirst, assign); _expressionList.replaceInclusive(_operandStart, assign, newOne); txformed = true; } @@ -1329,10 +1327,10 @@ public class MethodModel{ Instruction instruction = expressionList.getHead(); - if ((instruction instanceof Return) && (expressionList.getHead() == expressionList.getTail())) { + if ((instruction instanceof InstructionSet.Return) && (expressionList.getHead() == expressionList.getTail())) { instruction = instruction.getPrevPC(); - if (instruction instanceof AccessInstanceField) { - final FieldEntry field = ((AccessInstanceField) instruction).getConstantPoolFieldEntry(); + if (instruction instanceof InstructionSet.AccessInstanceField) { + final ClassModel.ConstantPool.FieldEntry field = ((InstructionSet.AccessInstanceField) instruction).getConstantPoolFieldEntry(); accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); if (accessedFieldName.equals(varNameCandidateCamelCased)) { @@ -1366,7 +1364,7 @@ public class MethodModel{ throw new ClassParseException(ClassParseException.TYPE.BADGETTERNAMENOTFOUND, methodName); } } else { - FieldEntry fieldEntry = getMethod().getOwnerClassModel().getConstantPool().getFieldEntry(varNameCandidateCamelCased); + ClassModel.ConstantPool.FieldEntry fieldEntry = getMethod().getOwnerClassModel().getConstantPool().getFieldEntry(varNameCandidateCamelCased); setAccessorVariableFieldEntry(fieldEntry); if (getAccessorVariableFieldEntry() == null) { throw new ClassParseException(ClassParseException.TYPE.BADGETTERNAMEMISMATCH, methodName); @@ -1383,7 +1381,7 @@ public class MethodModel{ } } - private void setAccessorVariableFieldEntry(FieldEntry field) { + private void setAccessorVariableFieldEntry(ClassModel.ConstantPool.FieldEntry field) { accessorVariableFieldEntry = field; } @@ -1401,10 +1399,10 @@ public class MethodModel{ final Instruction instruction = expressionList.getHead(); // setters should be aload_0, ?load_1, putfield, return - if ((instruction instanceof AssignToInstanceField) && (expressionList.getTail() instanceof Return) && (pcMap.size() == 4)) { + if ((instruction instanceof InstructionSet.AssignToInstanceField) && (expressionList.getTail() instanceof InstructionSet.Return) && (pcMap.size() == 4)) { final Instruction prev = instruction.getPrevPC(); - if (prev instanceof AccessLocalVariable) { - final FieldEntry field = ((AssignToInstanceField) instruction).getConstantPoolFieldEntry(); + if (prev instanceof InstructionSet.AccessLocalVariable) { + final ClassModel.ConstantPool.FieldEntry field = ((InstructionSet.AssignToInstanceField) instruction).getConstantPoolFieldEntry(); accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); if (accessedFieldName.equals(varNameCandidateCamelCased)) { @@ -1445,18 +1443,18 @@ public class MethodModel{ // The entrypoint is used to make checks on object accessors Entrypoint entrypoint = null; - MethodModel(ClassModelMethod _method, Entrypoint _entrypoint) throws AparapiException { + MethodModel(ClassModel.ClassModelMethod _method, Entrypoint _entrypoint) throws AparapiException { entrypoint = _entrypoint; init(_method); } - MethodModel(ClassModelMethod _method) throws AparapiException { + MethodModel(ClassModel.ClassModelMethod _method) throws AparapiException { init(_method); } - public static class FakeLocalVariableTableEntry implements LocalVariableTableEntry<LocalVariableInfo>{ + public static class FakeLocalVariableTableEntry implements ClassModel.LocalVariableTableEntry<ClassModel.LocalVariableInfo> { - class Var implements LocalVariableInfo{ + class Var implements ClassModel.LocalVariableInfo { int startPc = 0; @@ -1470,11 +1468,11 @@ public class MethodModel{ int slotIndex; - Var(StoreSpec _storeSpec, int _slotIndex, int _startPc, boolean _arg) { + Var(InstructionSet.StoreSpec _storeSpec, int _slotIndex, int _startPc, boolean _arg) { slotIndex = _slotIndex; arg = _arg; startPc = _startPc; - if (_storeSpec.equals(StoreSpec.A)) { + if (_storeSpec.equals(InstructionSet.StoreSpec.A)) { name = "arr_" + _slotIndex; descriptor = "/* arg */"; } else { @@ -1524,29 +1522,29 @@ public class MethodModel{ } } - List<LocalVariableInfo> list = new ArrayList<LocalVariableInfo>(); + List<ClassModel.LocalVariableInfo> list = new ArrayList<ClassModel.LocalVariableInfo>(); - public FakeLocalVariableTableEntry(Map<Integer, Instruction> _pcMap, ClassModelMethod _method) { + public FakeLocalVariableTableEntry(Map<Integer, Instruction> _pcMap, ClassModel.ClassModelMethod _method) { int numberOfSlots = _method.getCodeEntry().getMaxLocals(); - MethodDescription description = ClassModel.getMethodDescription(_method.getDescriptor()); + ClassModel.MethodDescription description = ClassModel.getMethodDescription(_method.getDescriptor()); String[] args = description.getArgs(); int thisOffset = _method.isStatic() ? 0 : 1; Var[] vars = new Var[numberOfSlots + thisOffset]; - StoreSpec[] argsAsStoreSpecs = new StoreSpec[args.length + thisOffset]; + InstructionSet.StoreSpec[] argsAsStoreSpecs = new InstructionSet.StoreSpec[args.length + thisOffset]; if (thisOffset == 1) { - argsAsStoreSpecs[0] = StoreSpec.O; + argsAsStoreSpecs[0] = InstructionSet.StoreSpec.O; vars[0] = new Var(argsAsStoreSpecs[0], 0, 0, true); list.add(vars[0]); } for (int i = 0; i < args.length; i++) { if (args[i].startsWith("[")) { - argsAsStoreSpecs[i + thisOffset] = StoreSpec.A; + argsAsStoreSpecs[i + thisOffset] = InstructionSet.StoreSpec.A; } else { - argsAsStoreSpecs[i + thisOffset] = StoreSpec.valueOf(args[i].substring(0, 1)); + argsAsStoreSpecs[i + thisOffset] = InstructionSet.StoreSpec.valueOf(args[i].substring(0, 1)); } vars[i + thisOffset] = new Var(argsAsStoreSpecs[i + thisOffset], i + thisOffset, 0, true); list.add(vars[i + thisOffset]); @@ -1561,9 +1559,9 @@ public class MethodModel{ pc = entry.getKey(); instruction = entry.getValue(); - StoreSpec storeSpec = instruction.getByteCode().getStore(); + InstructionSet.StoreSpec storeSpec = instruction.getByteCode().getStore(); - if (storeSpec != StoreSpec.NONE) { + if (storeSpec != InstructionSet.StoreSpec.NONE) { int slotIndex = ((InstructionSet.LocalVariableTableIndexAccessor) instruction).getLocalVariableTableIndex(); Var prevVar = vars[slotIndex]; Var var = new Var(storeSpec, slotIndex, pc + instruction.getLength(), false); // will get collected pretty soon if this is not the same as the previous in this slot @@ -1578,8 +1576,8 @@ public class MethodModel{ vars[i].endPc = pc + instruction.getLength(); } - Collections.sort(list, new Comparator<LocalVariableInfo>(){ - @Override public int compare(LocalVariableInfo o1, LocalVariableInfo o2) { + Collections.sort(list, new Comparator<ClassModel.LocalVariableInfo>(){ + @Override public int compare(ClassModel.LocalVariableInfo o1, ClassModel.LocalVariableInfo o2) { return o1.getStart() - o2.getStart(); } }); @@ -1587,7 +1585,7 @@ public class MethodModel{ if (Config.enableShowFakeLocalVariableTable) { System.out.println("FakeLocalVariableTable:"); System.out.println(" Start Length Slot Name Signature"); - for (LocalVariableInfo lvi : list) { + for (ClassModel.LocalVariableInfo lvi : list) { Var var = (Var) lvi; System.out.println(String.format(" %5d %5d %4d %8s %s", var.startPc, var.getLength(), var.slotIndex, var.name, var.descriptor)); @@ -1595,10 +1593,10 @@ public class MethodModel{ } } - @Override public LocalVariableInfo getVariable(int _pc, int _index) { - LocalVariableInfo returnValue = null; + @Override public ClassModel.LocalVariableInfo getVariable(int _pc, int _index) { + ClassModel.LocalVariableInfo returnValue = null; // System.out.println("pc = " + _pc + " index = " + _index); - for (LocalVariableInfo localVariableInfo : list) { + for (ClassModel.LocalVariableInfo localVariableInfo : list) { // System.out.println(" start=" + localVariableInfo.getStart() + " length=" + localVariableInfo.getLength() // + " varidx=" + localVariableInfo.getVariableIndex()); if (_pc >= localVariableInfo.getStart() - 1 && _pc <= (localVariableInfo.getStart() + localVariableInfo.getLength()) @@ -1610,13 +1608,13 @@ public class MethodModel{ return (returnValue); } - @Override public Iterator<LocalVariableInfo> iterator() { + @Override public Iterator<ClassModel.LocalVariableInfo> iterator() { return list.iterator(); } } - private void init(ClassModelMethod _method) throws AparapiException { + private void init(ClassModel.ClassModelMethod _method) throws AparapiException { try { method = _method; expressionList = new ExpressionList(this); @@ -1641,7 +1639,7 @@ public class MethodModel{ // Pass #1 create a linked list of instructions from head to tail final Map<Integer, Instruction> pcMap = createListOfInstructions(); - LocalVariableTableEntry<LocalVariableInfo> localVariableTableEntry = method.getLocalVariableTableEntry(); + ClassModel.LocalVariableTableEntry<ClassModel.LocalVariableInfo> localVariableTableEntry = method.getLocalVariableTableEntry(); if (localVariableTableEntry == null) { localVariableTableEntry = new FakeLocalVariableTableEntry(pcMap, method); method.setLocalVariableTableEntry(localVariableTableEntry); @@ -1691,15 +1689,15 @@ public class MethodModel{ } } - public LocalVariableTableEntry<LocalVariableInfo> getLocalVariableTableEntry() { + public ClassModel.LocalVariableTableEntry<ClassModel.LocalVariableInfo> getLocalVariableTableEntry() { return (method.getLocalVariableTableEntry()); } - public ConstantPool getConstantPool() { + public ClassModel.ConstantPool getConstantPool() { return (method.getConstantPool()); } - public LocalVariableInfo getLocalVariable(int _pc, int _index) { + public ClassModel.LocalVariableInfo getLocalVariable(int _pc, int _index) { return (method.getLocalVariable(_pc, _index)); } @@ -1708,7 +1706,7 @@ public class MethodModel{ } /* - * @return the fully qualified name such as "com_amd_javalabs_opencl_demo_PaternityTest$SimpleKernel__actuallyDoIt" + * @return the fully qualified name such as "com_aparapi_javalabs_opencl_demo_PaternityTest$SimpleKernel__actuallyDoIt" */ public String getName() { return (method.getClassModel().getMethod(method.getName(), method.getDescriptor()).getClassModel().getClassWeAreModelling() @@ -1722,12 +1720,12 @@ public class MethodModel{ return (returnType.substring(index + 1)); } - public List<MethodCall> getMethodCalls() { - final List<MethodCall> methodCalls = new ArrayList<MethodCall>(); + public List<InstructionSet.MethodCall> getMethodCalls() { + final List<InstructionSet.MethodCall> methodCalls = new ArrayList<InstructionSet.MethodCall>(); for (Instruction i = getPCHead(); i != null; i = i.getNextPC()) { - if (i instanceof MethodCall) { - final MethodCall methodCall = (MethodCall) i; + if (i instanceof InstructionSet.MethodCall) { + final InstructionSet.MethodCall methodCall = (InstructionSet.MethodCall) i; methodCalls.add(methodCall); } } diff --git a/src/main/java/com/syncleus/aparapi/internal/model/Supplier.java b/src/main/java/com/aparapi/internal/model/Supplier.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/model/Supplier.java rename to src/main/java/com/aparapi/internal/model/Supplier.java index d110e6b679df12d3e821d5578c279c2f5e52c6bd..e72a69605b384741945ac892d8af5e624cb2fc47 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/Supplier.java +++ b/src/main/java/com/aparapi/internal/model/Supplier.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; /** * Substitute of Java8's Supplier<V> interface, used in Java7 backport of caches. diff --git a/src/main/java/com/syncleus/aparapi/internal/model/ValueCache.java b/src/main/java/com/aparapi/internal/model/ValueCache.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/internal/model/ValueCache.java rename to src/main/java/com/aparapi/internal/model/ValueCache.java index 33e69e5669accdced10d30bca86b7c32a2a867eb..12bd227b448fd3bb67fb85cff1fdbeefc23456d5 100644 --- a/src/main/java/com/syncleus/aparapi/internal/model/ValueCache.java +++ b/src/main/java/com/aparapi/internal/model/ValueCache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.model; +package com.aparapi.internal.model; import java.lang.ref.*; import java.util.concurrent.*; diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLArgDescriptor.java b/src/main/java/com/aparapi/internal/opencl/OpenCLArgDescriptor.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLArgDescriptor.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLArgDescriptor.java index 1b14921b65bb7fd4be0f9227cfd256dc8696230f..d1fda9fc2de2a5790e056c1fa0a8797a1b650059 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLArgDescriptor.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLArgDescriptor.java @@ -16,7 +16,7 @@ /** * */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; public class OpenCLArgDescriptor{ diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLKernel.java b/src/main/java/com/aparapi/internal/opencl/OpenCLKernel.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLKernel.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLKernel.java index f540bef5734132df2be9d19366924d411a56c439..10ce52eaf439bb943f429a96c5f4db7f6d2db500 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLKernel.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLKernel.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; import java.util.List; -import com.syncleus.aparapi.internal.jni.OpenCLJNI; +import com.aparapi.internal.jni.OpenCLJNI; public class OpenCLKernel extends OpenCLJNI{ diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLLoader.java b/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLLoader.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java index e2294f6fd00aec10368fee81a822cadeea4f526a..193fed42e693a7a2841914eb2401eb8e55630e52 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLLoader.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; import java.util.logging.Level; import java.util.logging.Logger; -import com.syncleus.aparapi.Config; -import com.syncleus.aparapi.internal.jni.OpenCLJNI; +import com.aparapi.internal.jni.OpenCLJNI; +import com.aparapi.Config; /** * This class is intended to be a singleton which determines if OpenCL is available upon startup of Aparapi */ -public class OpenCLLoader extends OpenCLJNI{ +public class OpenCLLoader extends OpenCLJNI { private static final Logger logger = Logger.getLogger(Config.getLoggerName()); diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLMem.java b/src/main/java/com/aparapi/internal/opencl/OpenCLMem.java similarity index 92% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLMem.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLMem.java index 2088378b62f08e02e5ba05e45b1f31dfe528e5c6..3b2fee6dc9cc8e2cddaeef346190a1cc607ac5ab 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLMem.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLMem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; public class OpenCLMem{ diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLPlatform.java b/src/main/java/com/aparapi/internal/opencl/OpenCLPlatform.java similarity index 89% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLPlatform.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLPlatform.java index 9f746393c6e80b652900fcc57b39686119351333..fe4bf99d6a08fed12636b71015b8fdb23036c9b9 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLPlatform.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLPlatform.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; -import com.syncleus.aparapi.device.*; -import com.syncleus.aparapi.internal.jni.*; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.jni.OpenCLJNI; import java.util.*; -public class OpenCLPlatform extends OpenCLJNI{ +public class OpenCLPlatform extends OpenCLJNI { private long platformId; diff --git a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLProgram.java b/src/main/java/com/aparapi/internal/opencl/OpenCLProgram.java similarity index 89% rename from src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLProgram.java rename to src/main/java/com/aparapi/internal/opencl/OpenCLProgram.java index 3f29ce74dc6d4f1e8160694e46a033b73041064f..85d6f4134e51e06d6396ba76a835d9f5485894ed 100644 --- a/src/main/java/com/syncleus/aparapi/internal/opencl/OpenCLProgram.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLProgram.java @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.opencl; +package com.aparapi.internal.opencl; -import com.syncleus.aparapi.ProfileInfo; +import com.aparapi.device.OpenCLDevice; +import com.aparapi.internal.jni.OpenCLJNI; +import com.aparapi.ProfileInfo; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.syncleus.aparapi.device.OpenCLDevice; -import com.syncleus.aparapi.internal.jni.OpenCLJNI; - -public class OpenCLProgram extends OpenCLJNI{ +public class OpenCLProgram extends OpenCLJNI { private final long programId; diff --git a/src/main/java/com/syncleus/aparapi/internal/reader/ByteBuffer.java b/src/main/java/com/aparapi/internal/reader/ByteBuffer.java similarity index 96% rename from src/main/java/com/syncleus/aparapi/internal/reader/ByteBuffer.java rename to src/main/java/com/aparapi/internal/reader/ByteBuffer.java index b57a859af4498139f36db9b1feb72256d6f50fde..6d5ee85662d3f00daac6a96ac8e82afb87bee082 100644 --- a/src/main/java/com/syncleus/aparapi/internal/reader/ByteBuffer.java +++ b/src/main/java/com/aparapi/internal/reader/ByteBuffer.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.reader; +package com.aparapi.internal.reader; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -63,7 +63,7 @@ import java.io.InputStream; * * Does not keep track of accesses. For this you will need a <code>ByteReader</code> * - * @see com.syncleus.aparapi.internal.reader.ByteReader + * @see ByteReader * * @author gfrost * diff --git a/src/main/java/com/syncleus/aparapi/internal/reader/ByteReader.java b/src/main/java/com/aparapi/internal/reader/ByteReader.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/reader/ByteReader.java rename to src/main/java/com/aparapi/internal/reader/ByteReader.java index b30ed253d5a3357b6beb01dc4321cafb54c57adc..1310640f1872e3dc27b30d25e6ff00afc86131bd 100644 --- a/src/main/java/com/syncleus/aparapi/internal/reader/ByteReader.java +++ b/src/main/java/com/aparapi/internal/reader/ByteReader.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.reader; +package com.aparapi.internal.reader; import java.io.InputStream; @@ -60,7 +60,7 @@ import java.io.InputStream; * Basically wraps a <code>ByteBuffer</code> and keeps track of the current offset. All requests on * this <code>ByteReader</code> will be delegated to wrapped<code>ByteBuffer</code>. * </p> - * @see com.syncleus.aparapi.internal.reader.ByteBuffer + * @see ByteBuffer * * @author gfrost * diff --git a/src/main/java/com/syncleus/aparapi/internal/tool/InstructionHelper.java b/src/main/java/com/aparapi/internal/tool/InstructionHelper.java similarity index 90% rename from src/main/java/com/syncleus/aparapi/internal/tool/InstructionHelper.java rename to src/main/java/com/aparapi/internal/tool/InstructionHelper.java index 975d0478e74b5e532cca6e44648954d40c29a80e..243d644d377d56fac61e5662cd39a7267e543f0c 100644 --- a/src/main/java/com/syncleus/aparapi/internal/tool/InstructionHelper.java +++ b/src/main/java/com/aparapi/internal/tool/InstructionHelper.java @@ -13,33 +13,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.tool; +package com.aparapi.internal.tool; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; -import com.syncleus.aparapi.internal.exception.CodeGenException; -import com.syncleus.aparapi.internal.instruction.Instruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AssignToLocalVariable; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Branch; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ByteCode; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CloneInstruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CompositeInstruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.ConditionalBranch16; -import com.syncleus.aparapi.internal.instruction.InstructionSet.Constant; -import com.syncleus.aparapi.internal.instruction.InstructionSet.FieldReference; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_ACONST_NULL; -import com.syncleus.aparapi.internal.instruction.InstructionSet.I_IINC; -import com.syncleus.aparapi.internal.instruction.InstructionSet.LocalVariableTableIndexAccessor; -import com.syncleus.aparapi.internal.instruction.InstructionSet.MethodCall; -import com.syncleus.aparapi.internal.instruction.InstructionSet.OperatorInstruction; -import com.syncleus.aparapi.internal.model.ClassModel; -import com.syncleus.aparapi.internal.model.Entrypoint; -import com.syncleus.aparapi.internal.model.MethodModel; -import com.syncleus.aparapi.internal.model.ClassModel.LocalVariableInfo; -import com.syncleus.aparapi.internal.writer.BlockWriter; +import com.aparapi.internal.exception.CodeGenException; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.InstructionSet.AssignToLocalVariable; +import com.aparapi.internal.instruction.InstructionSet.Branch; +import com.aparapi.internal.instruction.InstructionSet.ByteCode; +import com.aparapi.internal.instruction.InstructionSet.CloneInstruction; +import com.aparapi.internal.instruction.InstructionSet.CompositeInstruction; +import com.aparapi.internal.instruction.InstructionSet.ConditionalBranch16; +import com.aparapi.internal.instruction.InstructionSet.Constant; +import com.aparapi.internal.instruction.InstructionSet.FieldReference; +import com.aparapi.internal.instruction.InstructionSet.I_ACONST_NULL; +import com.aparapi.internal.instruction.InstructionSet.I_IINC; +import com.aparapi.internal.instruction.InstructionSet.LocalVariableTableIndexAccessor; +import com.aparapi.internal.instruction.InstructionSet.MethodCall; +import com.aparapi.internal.instruction.InstructionSet.OperatorInstruction; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.internal.model.ClassModel.LocalVariableInfo; +import com.aparapi.internal.writer.BlockWriter; public class InstructionHelper{ diff --git a/src/main/java/com/syncleus/aparapi/internal/tool/InstructionViewer.java b/src/main/java/com/aparapi/internal/tool/InstructionViewer.java similarity index 95% rename from src/main/java/com/syncleus/aparapi/internal/tool/InstructionViewer.java rename to src/main/java/com/aparapi/internal/tool/InstructionViewer.java index 4ba986dde8913f9409f9725f0369467304818b43..3416af5b3119612cf7303fde6998ce4fa3377b92 100644 --- a/src/main/java/com/syncleus/aparapi/internal/tool/InstructionViewer.java +++ b/src/main/java/com/aparapi/internal/tool/InstructionViewer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.tool; +package com.aparapi.internal.tool; import java.awt.BasicStroke; import java.awt.BorderLayout; @@ -64,17 +64,17 @@ import javax.swing.UnsupportedLookAndFeelException; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import com.syncleus.aparapi.Config; -import com.syncleus.aparapi.internal.exception.AparapiException; -import com.syncleus.aparapi.internal.exception.ClassParseException; -import com.syncleus.aparapi.internal.instruction.Instruction; -import com.syncleus.aparapi.internal.instruction.InstructionSet.CompositeInstruction; -import com.syncleus.aparapi.internal.model.ClassModel; -import com.syncleus.aparapi.internal.model.Entrypoint; -import com.syncleus.aparapi.internal.model.MethodModel; -import com.syncleus.aparapi.internal.tool.InstructionViewer.Form.Check; -import com.syncleus.aparapi.internal.tool.InstructionViewer.Form.Template; -import com.syncleus.aparapi.internal.tool.InstructionViewer.Form.Toggle; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.Config; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.tool.InstructionViewer.Form.Check; +import com.aparapi.internal.tool.InstructionViewer.Form.Template; +import com.aparapi.internal.tool.InstructionViewer.Form.Toggle; public class InstructionViewer implements Config.InstructionListener{ @@ -890,7 +890,7 @@ public class InstructionViewer implements Config.InstructionListener{ lastInstruction = instruction; } lastInstruction.getRootExpr(); - while (lastInstruction instanceof CompositeInstruction) { + while (lastInstruction instanceof InstructionSet.CompositeInstruction) { lastInstruction = lastInstruction.getLastChild(); } for (Instruction instruction = lastInstruction.getNextPC(); instruction != null; instruction = instruction.getNextPC()) { diff --git a/src/main/java/com/syncleus/aparapi/annotation/package-info.java b/src/main/java/com/aparapi/internal/tool/package-info.java similarity index 91% rename from src/main/java/com/syncleus/aparapi/annotation/package-info.java rename to src/main/java/com/aparapi/internal/tool/package-info.java index 1265249a52584098568ddf0b550bbbadaec2891a..a41bb28082626f4f61291e9a98560a59b0a5750d 100644 --- a/src/main/java/com/syncleus/aparapi/annotation/package-info.java +++ b/src/main/java/com/aparapi/internal/tool/package-info.java @@ -16,4 +16,4 @@ /** * */ -package com.syncleus.aparapi.annotation; \ No newline at end of file +package com.aparapi.internal.tool; \ No newline at end of file diff --git a/src/main/java/com/syncleus/aparapi/internal/util/OpenCLUtil.java b/src/main/java/com/aparapi/internal/util/OpenCLUtil.java similarity index 88% rename from src/main/java/com/syncleus/aparapi/internal/util/OpenCLUtil.java rename to src/main/java/com/aparapi/internal/util/OpenCLUtil.java index 7e5f5415cd004183ff77868b33d904649a5d311b..f4f813979c208b6a6e788781a09b7d3482610be2 100644 --- a/src/main/java/com/syncleus/aparapi/internal/util/OpenCLUtil.java +++ b/src/main/java/com/aparapi/internal/util/OpenCLUtil.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.util; +package com.aparapi.internal.util; import java.util.List; -import com.syncleus.aparapi.internal.opencl.OpenCLPlatform; +import com.aparapi.internal.opencl.OpenCLPlatform; /** * This utility class encapsulates the necessary actions required to query underlying OpenCL information diff --git a/src/main/java/com/syncleus/aparapi/internal/util/Reflection.java b/src/main/java/com/aparapi/internal/util/Reflection.java similarity index 93% rename from src/main/java/com/syncleus/aparapi/internal/util/Reflection.java rename to src/main/java/com/aparapi/internal/util/Reflection.java index e0a7966e65c0fce38dabea114b549248e9532f73..e6d41388b25437ec015b26016a1a6f2d7821da46 100644 --- a/src/main/java/com/syncleus/aparapi/internal/util/Reflection.java +++ b/src/main/java/com/aparapi/internal/util/Reflection.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.internal.util; +package com.aparapi.internal.util; /** * Created by Barney on 03/09/2015. diff --git a/src/main/java/com/syncleus/aparapi/internal/util/UnsafeWrapper.java b/src/main/java/com/aparapi/internal/util/UnsafeWrapper.java similarity index 97% rename from src/main/java/com/syncleus/aparapi/internal/util/UnsafeWrapper.java rename to src/main/java/com/aparapi/internal/util/UnsafeWrapper.java index 3d1f6576a4df69076f4fd9910d38c6c6a4663098..670c13610f6725bbd403e4eefbf6179d4033eb95 100644 --- a/src/main/java/com/syncleus/aparapi/internal/util/UnsafeWrapper.java +++ b/src/main/java/com/aparapi/internal/util/UnsafeWrapper.java @@ -50,7 +50,7 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.util; +package com.aparapi.internal.util; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/com/syncleus/aparapi/internal/writer/BlockWriter.java b/src/main/java/com/aparapi/internal/writer/BlockWriter.java similarity index 64% rename from src/main/java/com/syncleus/aparapi/internal/writer/BlockWriter.java rename to src/main/java/com/aparapi/internal/writer/BlockWriter.java index 66309b6ec9aa0e4536bba73102e7fb8ad1253398..d40d7b85396ee8d6e0eef76c651e92745f3079e7 100644 --- a/src/main/java/com/syncleus/aparapi/internal/writer/BlockWriter.java +++ b/src/main/java/com/aparapi/internal/writer/BlockWriter.java @@ -50,19 +50,17 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.writer; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.*; -import com.syncleus.aparapi.internal.instruction.BranchSet.LogicalExpressionNode; -import com.syncleus.aparapi.internal.instruction.InstructionSet.AccessInstanceField; -import com.syncleus.aparapi.internal.instruction.BranchSet.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.*; -import com.syncleus.aparapi.internal.model.ClassModel.*; -import com.syncleus.aparapi.internal.model.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.NameAndTypeEntry; +package com.aparapi.internal.writer; + +import com.aparapi.Config; +import com.aparapi.internal.exception.CodeGenException; +import com.aparapi.internal.instruction.BranchSet; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.*; import java.util.*; @@ -104,16 +102,16 @@ public abstract class BlockWriter{ } } - public void writeConditionalBranch16(ConditionalBranch16 _branch16, boolean _invert) throws CodeGenException { + public void writeConditionalBranch16(InstructionSet.ConditionalBranch16 _branch16, boolean _invert) throws CodeGenException { - if (_branch16 instanceof If) { - final If iff = (If) _branch16; + if (_branch16 instanceof InstructionSet.If) { + final InstructionSet.If iff = (InstructionSet.If) _branch16; writeInstruction(iff.getLhs()); write(_branch16.getOperator().getText(_invert)); writeInstruction(iff.getRhs()); - } else if (_branch16 instanceof I_IFNULL) { - final I_IFNULL iff = (I_IFNULL) _branch16; + } else if (_branch16 instanceof InstructionSet.I_IFNULL) { + final InstructionSet.I_IFNULL iff = (InstructionSet.I_IFNULL) _branch16; writeInstruction(iff.getFirstChild()); if (_invert) { @@ -122,8 +120,8 @@ public abstract class BlockWriter{ write(" == NULL"); } - } else if (_branch16 instanceof I_IFNONNULL) { - final I_IFNONNULL iff = (I_IFNONNULL) _branch16; + } else if (_branch16 instanceof InstructionSet.I_IFNONNULL) { + final InstructionSet.I_IFNONNULL iff = (InstructionSet.I_IFNONNULL) _branch16; writeInstruction(iff.getFirstChild()); if (_invert) { @@ -131,10 +129,10 @@ public abstract class BlockWriter{ } else { write(" != NULL"); } - } else if (_branch16 instanceof IfUnary) { - final IfUnary branch16 = (IfUnary) _branch16; + } else if (_branch16 instanceof InstructionSet.IfUnary) { + final InstructionSet.IfUnary branch16 = (InstructionSet.IfUnary) _branch16; final Instruction comparison = branch16.getUnary(); - final ByteCode comparisonByteCode = comparison.getByteCode(); + final InstructionSet.ByteCode comparisonByteCode = comparison.getByteCode(); final String comparisonOperator = _branch16.getOperator().getText(_invert); switch (comparisonByteCode) { @@ -160,19 +158,19 @@ public abstract class BlockWriter{ } } - public void writeComposite(CompositeInstruction instruction) throws CodeGenException { - if (instruction instanceof CompositeArbitraryScopeInstruction) { + public void writeComposite(InstructionSet.CompositeInstruction instruction) throws CodeGenException { + if (instruction instanceof InstructionSet.CompositeArbitraryScopeInstruction) { newLine(); writeBlock(instruction.getFirstChild(), null); - } else if (instruction instanceof CompositeIfInstruction) { + } else if (instruction instanceof InstructionSet.CompositeIfInstruction) { newLine(); write("if ("); final Instruction blockStart = writeConditional(instruction.getBranchSet()); write(")"); writeBlock(blockStart, null); - } else if (instruction instanceof CompositeIfElseInstruction) { + } else if (instruction instanceof InstructionSet.CompositeIfElseInstruction) { newLine(); write("if ("); final Instruction blockStart = writeConditional(instruction.getBranchSet()); @@ -184,11 +182,11 @@ public abstract class BlockWriter{ writeBlock(blockStart, elseGoto); write(" else "); writeBlock(elseGoto.getNextExpr(), null); - } else if (instruction instanceof CompositeForSunInstruction) { + } else if (instruction instanceof InstructionSet.CompositeForSunInstruction) { newLine(); write("for ("); Instruction topBranch = instruction.getFirstChild(); - if (topBranch instanceof AssignToLocalVariable) { + if (topBranch instanceof InstructionSet.AssignToLocalVariable) { writeInstruction(topBranch); topBranch = topBranch.getNextExpr(); } @@ -204,7 +202,7 @@ public abstract class BlockWriter{ } else { final Instruction delta = lastGoto.getPrevExpr(); write("; "); - if (!(delta instanceof CompositeInstruction)) { + if (!(delta instanceof InstructionSet.CompositeInstruction)) { writeInstruction(delta); write(")"); writeBlock(blockStart, delta); @@ -222,7 +220,7 @@ public abstract class BlockWriter{ } } - } else if (instruction instanceof CompositeWhileInstruction) { + } else if (instruction instanceof InstructionSet.CompositeWhileInstruction) { newLine(); write("while ("); final BranchSet branchSet = instruction.getBranchSet(); @@ -231,11 +229,11 @@ public abstract class BlockWriter{ final Instruction lastGoto = instruction.getLastChild(); writeBlock(blockStart, lastGoto); - } else if (instruction instanceof CompositeEmptyLoopInstruction) { + } else if (instruction instanceof InstructionSet.CompositeEmptyLoopInstruction) { newLine(); write("for ("); Instruction topBranch = instruction.getFirstChild(); - if (topBranch instanceof AssignToLocalVariable) { + if (topBranch instanceof InstructionSet.AssignToLocalVariable) { writeInstruction(topBranch); topBranch = topBranch.getNextExpr(); } @@ -243,11 +241,11 @@ public abstract class BlockWriter{ writeConditional(instruction.getBranchSet()); write(";){}"); - } else if (instruction instanceof CompositeForEclipseInstruction) { + } else if (instruction instanceof InstructionSet.CompositeForEclipseInstruction) { newLine(); write("for ("); Instruction topGoto = instruction.getFirstChild(); - if (topGoto instanceof AssignToLocalVariable) { + if (topGoto instanceof InstructionSet.AssignToLocalVariable) { writeInstruction(topGoto); topGoto = topGoto.getNextExpr(); } @@ -259,7 +257,7 @@ public abstract class BlockWriter{ writeConditional(instruction.getBranchSet(), true); write("; "); final Instruction delta = last.getPrevExpr(); - if (!(delta instanceof CompositeInstruction)) { + if (!(delta instanceof InstructionSet.CompositeInstruction)) { writeInstruction(delta); write(")"); writeBlock(topGoto.getNextExpr(), delta); @@ -276,14 +274,14 @@ public abstract class BlockWriter{ } - } else if (instruction instanceof CompositeDoWhileInstruction) { + } else if (instruction instanceof InstructionSet.CompositeDoWhileInstruction) { newLine(); write("do"); Instruction blockStart = instruction.getFirstChild(); Instruction blockEnd = instruction.getLastChild(); writeBlock(blockStart, blockEnd); write("while("); - writeConditional(((CompositeInstruction) instruction).getBranchSet(), true); + writeConditional(((InstructionSet.CompositeInstruction) instruction).getBranchSet(), true); write(");"); newLine(); } @@ -292,9 +290,9 @@ public abstract class BlockWriter{ public void writeSequence(Instruction _first, Instruction _last) throws CodeGenException { for (Instruction instruction = _first; instruction != _last; instruction = instruction.getNextExpr()) { - if (instruction instanceof CompositeInstruction) { - writeComposite((CompositeInstruction) instruction); - } else if (!instruction.getByteCode().equals(ByteCode.NONE)) { + if (instruction instanceof InstructionSet.CompositeInstruction) { + writeComposite((InstructionSet.CompositeInstruction) instruction); + } else if (!instruction.getByteCode().equals(InstructionSet.ByteCode.NONE)) { newLine(); writeInstruction(instruction); write(";"); @@ -304,7 +302,7 @@ public abstract class BlockWriter{ } - protected void writeGetterBlock(FieldEntry accessorVariableFieldEntry) { + protected void writeGetterBlock(ClassModel.ConstantPool.FieldEntry accessorVariableFieldEntry) { write("{"); in(); newLine(); @@ -333,20 +331,20 @@ public abstract class BlockWriter{ public Instruction writeConditional(BranchSet _branchSet, boolean _invert) throws CodeGenException { - final LogicalExpressionNode logicalExpression = _branchSet.getLogicalExpression(); + final BranchSet.LogicalExpressionNode logicalExpression = _branchSet.getLogicalExpression(); write(_invert ? logicalExpression : logicalExpression.cloneInverted()); return (_branchSet.getLast().getNextExpr()); } - public void write(LogicalExpressionNode _node) throws CodeGenException { - if (_node instanceof SimpleLogicalExpressionNode) { - final SimpleLogicalExpressionNode sn = (SimpleLogicalExpressionNode) _node; + public void write(BranchSet.LogicalExpressionNode _node) throws CodeGenException { + if (_node instanceof BranchSet.SimpleLogicalExpressionNode) { + final BranchSet.SimpleLogicalExpressionNode sn = (BranchSet.SimpleLogicalExpressionNode) _node; - writeConditionalBranch16((ConditionalBranch16) sn.getBranch(), sn.isInvert()); + writeConditionalBranch16((InstructionSet.ConditionalBranch16) sn.getBranch(), sn.isInvert()); } else { - final CompoundLogicalExpressionNode ln = (CompoundLogicalExpressionNode) _node; + final BranchSet.CompoundLogicalExpressionNode ln = (BranchSet.CompoundLogicalExpressionNode) _node; boolean needParenthesis = false; - final CompoundLogicalExpressionNode parent = (CompoundLogicalExpressionNode) ln.getParent(); + final BranchSet.CompoundLogicalExpressionNode parent = (BranchSet.CompoundLogicalExpressionNode) ln.getParent(); if (parent != null) { if (!ln.isAnd() && parent.isAnd()) { needParenthesis = true; @@ -378,13 +376,13 @@ public abstract class BlockWriter{ } public void writeInstruction(Instruction _instruction) throws CodeGenException { - if (_instruction instanceof CompositeIfElseInstruction) { + if (_instruction instanceof InstructionSet.CompositeIfElseInstruction) { boolean needParenthesis = isNeedParenthesis(_instruction); if(needParenthesis){ write("("); } write("("); - final Instruction lhs = writeConditional(((CompositeInstruction) _instruction).getBranchSet()); + final Instruction lhs = writeConditional(((InstructionSet.CompositeInstruction) _instruction).getBranchSet()); write(")?"); writeInstruction(lhs); write(":"); @@ -392,13 +390,13 @@ public abstract class BlockWriter{ if(needParenthesis){ write(")"); } - } else if (_instruction instanceof CompositeInstruction) { - writeComposite((CompositeInstruction) _instruction); + } else if (_instruction instanceof InstructionSet.CompositeInstruction) { + writeComposite((InstructionSet.CompositeInstruction) _instruction); - } else if (_instruction instanceof AssignToLocalVariable) { - final AssignToLocalVariable assignToLocalVariable = (AssignToLocalVariable) _instruction; + } else if (_instruction instanceof InstructionSet.AssignToLocalVariable) { + final InstructionSet.AssignToLocalVariable assignToLocalVariable = (InstructionSet.AssignToLocalVariable) _instruction; - final LocalVariableInfo localVariableInfo = assignToLocalVariable.getLocalVariableInfo(); + final ClassModel.LocalVariableInfo localVariableInfo = assignToLocalVariable.getLocalVariableInfo(); if (assignToLocalVariable.isDeclaration()) { final String descriptor = localVariableInfo.getVariableDescriptor(); // Arrays always map to __global arrays @@ -417,8 +415,8 @@ public abstract class BlockWriter{ writeInstruction(operand); } - } else if (_instruction instanceof AssignToArrayElement) { - final AssignToArrayElement arrayAssignmentInstruction = (AssignToArrayElement) _instruction; + } else if (_instruction instanceof InstructionSet.AssignToArrayElement) { + final InstructionSet.AssignToArrayElement arrayAssignmentInstruction = (InstructionSet.AssignToArrayElement) _instruction; writeInstruction(arrayAssignmentInstruction.getArrayRef()); write("["); writeInstruction(arrayAssignmentInstruction.getArrayIndex()); @@ -426,7 +424,7 @@ public abstract class BlockWriter{ write(" "); write(" = "); writeInstruction(arrayAssignmentInstruction.getValue()); - } else if (_instruction instanceof AccessArrayElement) { + } else if (_instruction instanceof InstructionSet.AccessArrayElement) { //we're getting an element from an array //if the array is a primitive then we just return the value @@ -436,10 +434,10 @@ public abstract class BlockWriter{ //a pointer to our index our position in the array. The code will look like //&(arrayName[arrayIndex * this->arrayNameLen_dimension] // - final AccessArrayElement arrayLoadInstruction = (AccessArrayElement) _instruction; + final InstructionSet.AccessArrayElement arrayLoadInstruction = (InstructionSet.AccessArrayElement) _instruction; //object array, get address - boolean isMultiDimensional = arrayLoadInstruction instanceof I_AALOAD && isMultiDimensionalArray(arrayLoadInstruction); + boolean isMultiDimensional = arrayLoadInstruction instanceof InstructionSet.I_AALOAD && isMultiDimensionalArray(arrayLoadInstruction); if (isMultiDimensional) { write("(&"); } @@ -452,12 +450,12 @@ public abstract class BlockWriter{ if (isMultiDimensional) { int dim = 0; Instruction load = arrayLoadInstruction.getArrayRef(); - while (load instanceof I_AALOAD) { + while (load instanceof InstructionSet.I_AALOAD) { load = load.getFirstChild(); dim++; } - NameAndTypeEntry nameAndTypeEntry = ((AccessInstanceField) load).getConstantPoolFieldEntry().getNameAndTypeEntry(); + ClassModel.ConstantPool.NameAndTypeEntry nameAndTypeEntry = ((InstructionSet.AccessInstanceField) load).getConstantPoolFieldEntry().getNameAndTypeEntry(); if (isMultiDimensionalArray(nameAndTypeEntry)) { String arrayName = nameAndTypeEntry.getNameUTF8Entry().getUTF8(); write(" * this->" + arrayName + arrayDimMangleSuffix + dim); @@ -470,14 +468,14 @@ public abstract class BlockWriter{ if (isMultiDimensional) { write(")"); } - } else if (_instruction instanceof AccessField) { - final AccessField accessField = (AccessField) _instruction; - if (accessField instanceof AccessInstanceField) { - Instruction accessInstanceField = ((AccessInstanceField) accessField).getInstance(); - if (accessInstanceField instanceof CloneInstruction) { - accessInstanceField = ((CloneInstruction) accessInstanceField).getReal(); + } else if (_instruction instanceof InstructionSet.AccessField) { + final InstructionSet.AccessField accessField = (InstructionSet.AccessField) _instruction; + if (accessField instanceof InstructionSet.AccessInstanceField) { + Instruction accessInstanceField = ((InstructionSet.AccessInstanceField) accessField).getInstance(); + if (accessInstanceField instanceof InstructionSet.CloneInstruction) { + accessInstanceField = ((InstructionSet.CloneInstruction) accessInstanceField).getReal(); } - if (!(accessInstanceField instanceof I_ALOAD_0)) { + if (!(accessInstanceField instanceof InstructionSet.I_ALOAD_0)) { writeInstruction(accessInstanceField); write("."); } else { @@ -486,7 +484,7 @@ public abstract class BlockWriter{ } write(accessField.getConstantPoolFieldEntry().getNameAndTypeEntry().getNameUTF8Entry().getUTF8()); - } else if (_instruction instanceof I_ARRAYLENGTH) { + } else if (_instruction instanceof InstructionSet.I_ARRAYLENGTH) { //getting the length of an array. //if this is a primitive array, then this is trivial @@ -494,21 +492,21 @@ public abstract class BlockWriter{ //we're looking at int dim = 0; Instruction load = _instruction.getFirstChild(); - while (load instanceof I_AALOAD) { + while (load instanceof InstructionSet.I_AALOAD) { load = load.getFirstChild(); dim++; } - NameAndTypeEntry nameAndTypeEntry = ((AccessInstanceField) load).getConstantPoolFieldEntry().getNameAndTypeEntry(); + ClassModel.ConstantPool.NameAndTypeEntry nameAndTypeEntry = ((InstructionSet.AccessInstanceField) load).getConstantPoolFieldEntry().getNameAndTypeEntry(); final String arrayName = nameAndTypeEntry.getNameUTF8Entry().getUTF8(); String dimSuffix = isMultiDimensionalArray(nameAndTypeEntry) ? Integer.toString(dim) : ""; write("this->" + arrayName + arrayLengthMangleSuffix + dimSuffix); - } else if (_instruction instanceof AssignToField) { - final AssignToField assignedField = (AssignToField) _instruction; + } else if (_instruction instanceof InstructionSet.AssignToField) { + final InstructionSet.AssignToField assignedField = (InstructionSet.AssignToField) _instruction; - if (assignedField instanceof AssignToInstanceField) { - final Instruction accessInstanceField = ((AssignToInstanceField) assignedField).getInstance().getReal(); + if (assignedField instanceof InstructionSet.AssignToInstanceField) { + final Instruction accessInstanceField = ((InstructionSet.AssignToInstanceField) assignedField).getInstance().getReal(); - if (!(accessInstanceField instanceof I_ALOAD_0)) { + if (!(accessInstanceField instanceof InstructionSet.I_ALOAD_0)) { writeInstruction(accessInstanceField); write("."); } else { @@ -518,8 +516,8 @@ public abstract class BlockWriter{ write(assignedField.getConstantPoolFieldEntry().getNameAndTypeEntry().getNameUTF8Entry().getUTF8()); write("="); writeInstruction(assignedField.getValueToAssign()); - } else if (_instruction instanceof Constant<?>) { - final Constant<?> constantInstruction = (Constant<?>) _instruction; + } else if (_instruction instanceof InstructionSet.Constant<?>) { + final InstructionSet.Constant<?> constantInstruction = (InstructionSet.Constant<?>) _instruction; final Object value = constantInstruction.getValue(); if (value instanceof Float) { @@ -556,13 +554,13 @@ public abstract class BlockWriter{ } } - } else if (_instruction instanceof AccessLocalVariable) { - final AccessLocalVariable localVariableLoadInstruction = (AccessLocalVariable) _instruction; - final LocalVariableInfo localVariable = localVariableLoadInstruction.getLocalVariableInfo(); + } else if (_instruction instanceof InstructionSet.AccessLocalVariable) { + final InstructionSet.AccessLocalVariable localVariableLoadInstruction = (InstructionSet.AccessLocalVariable) _instruction; + final ClassModel.LocalVariableInfo localVariable = localVariableLoadInstruction.getLocalVariableInfo(); write(localVariable.getVariableName()); - } else if (_instruction instanceof I_IINC) { - final I_IINC location = (I_IINC) _instruction; - final LocalVariableInfo localVariable = location.getLocalVariableInfo(); + } else if (_instruction instanceof InstructionSet.I_IINC) { + final InstructionSet.I_IINC location = (InstructionSet.I_IINC) _instruction; + final ClassModel.LocalVariableInfo localVariable = location.getLocalVariableInfo(); final int adjust = location.getAdjust(); write(localVariable.getVariableName()); @@ -575,8 +573,8 @@ public abstract class BlockWriter{ } else if (adjust < -1) { write("-=" + (-adjust)); } - } else if (_instruction instanceof BinaryOperator) { - final BinaryOperator binaryInstruction = (BinaryOperator) _instruction; + } else if (_instruction instanceof InstructionSet.BinaryOperator) { + final InstructionSet.BinaryOperator binaryInstruction = (InstructionSet.BinaryOperator) _instruction; final Instruction parent = binaryInstruction.getParentExpr(); boolean needsParenthesis = isNeedParenthesis(binaryInstruction); @@ -593,23 +591,23 @@ public abstract class BlockWriter{ write(")"); } - } else if (_instruction instanceof CastOperator) { - final CastOperator castInstruction = (CastOperator) _instruction; + } else if (_instruction instanceof InstructionSet.CastOperator) { + final InstructionSet.CastOperator castInstruction = (InstructionSet.CastOperator) _instruction; // write("("); write(convertCast(castInstruction.getOperator().getText())); writeInstruction(castInstruction.getUnary()); // write(")"); - } else if (_instruction instanceof UnaryOperator) { - final UnaryOperator unaryInstruction = (UnaryOperator) _instruction; + } else if (_instruction instanceof InstructionSet.UnaryOperator) { + final InstructionSet.UnaryOperator unaryInstruction = (InstructionSet.UnaryOperator) _instruction; // write("("); write(unaryInstruction.getOperator().getText()); writeInstruction(unaryInstruction.getUnary()); // write(")"); - } else if (_instruction instanceof Return) { + } else if (_instruction instanceof InstructionSet.Return) { - final Return ret = (Return) _instruction; + final InstructionSet.Return ret = (InstructionSet.Return) _instruction; write("return"); if (ret.getStackConsumeCount() > 0) { write("("); @@ -617,17 +615,17 @@ public abstract class BlockWriter{ write(")"); } - } else if (_instruction instanceof MethodCall) { - final MethodCall methodCall = (MethodCall) _instruction; + } else if (_instruction instanceof InstructionSet.MethodCall) { + final InstructionSet.MethodCall methodCall = (InstructionSet.MethodCall) _instruction; - final MethodEntry methodEntry = methodCall.getConstantPoolMethodEntry(); + final ClassModel.ConstantPool.MethodEntry methodEntry = methodCall.getConstantPoolMethodEntry(); writeMethod(methodCall, methodEntry); - } else if (_instruction.getByteCode().equals(ByteCode.CLONE)) { - final CloneInstruction cloneInstruction = (CloneInstruction) _instruction; + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.CLONE)) { + final InstructionSet.CloneInstruction cloneInstruction = (InstructionSet.CloneInstruction) _instruction; writeInstruction(cloneInstruction.getReal()); - } else if (_instruction.getByteCode().equals(ByteCode.INCREMENT)) { - final IncrementInstruction incrementInstruction = (IncrementInstruction) _instruction; + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.INCREMENT)) { + final InstructionSet.IncrementInstruction incrementInstruction = (InstructionSet.IncrementInstruction) _instruction; if (incrementInstruction.isPre()) { if (incrementInstruction.isInc()) { @@ -645,21 +643,21 @@ public abstract class BlockWriter{ write("--"); } } - } else if (_instruction.getByteCode().equals(ByteCode.MULTI_ASSIGN)) { - final MultiAssignInstruction multiAssignInstruction = (MultiAssignInstruction) _instruction; - AssignToLocalVariable from = (AssignToLocalVariable) multiAssignInstruction.getFrom(); - final AssignToLocalVariable last = (AssignToLocalVariable) multiAssignInstruction.getTo(); + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.MULTI_ASSIGN)) { + final InstructionSet.MultiAssignInstruction multiAssignInstruction = (InstructionSet.MultiAssignInstruction) _instruction; + InstructionSet.AssignToLocalVariable from = (InstructionSet.AssignToLocalVariable) multiAssignInstruction.getFrom(); + final InstructionSet.AssignToLocalVariable last = (InstructionSet.AssignToLocalVariable) multiAssignInstruction.getTo(); final Instruction common = multiAssignInstruction.getCommon(); - final Stack<AssignToLocalVariable> stack = new Stack<AssignToLocalVariable>(); + final Stack<InstructionSet.AssignToLocalVariable> stack = new Stack<InstructionSet.AssignToLocalVariable>(); while (from != last) { stack.push(from); - from = (AssignToLocalVariable) ((Instruction) from).getNextExpr(); + from = (InstructionSet.AssignToLocalVariable) ((Instruction) from).getNextExpr(); } - for (AssignToLocalVariable alv = stack.pop(); alv != null; alv = stack.size() > 0 ? stack.pop() : null) { + for (InstructionSet.AssignToLocalVariable alv = stack.pop(); alv != null; alv = stack.size() > 0 ? stack.pop() : null) { - final LocalVariableInfo localVariableInfo = alv.getLocalVariableInfo(); + final ClassModel.LocalVariableInfo localVariableInfo = alv.getLocalVariableInfo(); if (alv.isDeclaration()) { write(convertType(localVariableInfo.getVariableDescriptor(), true)); } @@ -671,11 +669,11 @@ public abstract class BlockWriter{ } writeInstruction(common); - } else if (_instruction.getByteCode().equals(ByteCode.INLINE_ASSIGN)) { - final InlineAssignInstruction inlineAssignInstruction = (InlineAssignInstruction) _instruction; - final AssignToLocalVariable assignToLocalVariable = inlineAssignInstruction.getAssignToLocalVariable(); + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.INLINE_ASSIGN)) { + final InstructionSet.InlineAssignInstruction inlineAssignInstruction = (InstructionSet.InlineAssignInstruction) _instruction; + final InstructionSet.AssignToLocalVariable assignToLocalVariable = inlineAssignInstruction.getAssignToLocalVariable(); - final LocalVariableInfo localVariableInfo = assignToLocalVariable.getLocalVariableInfo(); + final ClassModel.LocalVariableInfo localVariableInfo = assignToLocalVariable.getLocalVariableInfo(); if (assignToLocalVariable.isDeclaration()) { // this is bad! we need a general way to hoist up a required declaration throw new CodeGenException("/* we can't declare this " + convertType(localVariableInfo.getVariableDescriptor(), true) @@ -684,9 +682,9 @@ public abstract class BlockWriter{ write(localVariableInfo.getVariableName()); write("="); writeInstruction(inlineAssignInstruction.getRhs()); - } else if (_instruction.getByteCode().equals(ByteCode.FIELD_ARRAY_ELEMENT_ASSIGN)) { - final FieldArrayElementAssign inlineAssignInstruction = (FieldArrayElementAssign) _instruction; - final AssignToArrayElement arrayAssignmentInstruction = inlineAssignInstruction.getAssignToArrayElement(); + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.FIELD_ARRAY_ELEMENT_ASSIGN)) { + final InstructionSet.FieldArrayElementAssign inlineAssignInstruction = (InstructionSet.FieldArrayElementAssign) _instruction; + final InstructionSet.AssignToArrayElement arrayAssignmentInstruction = inlineAssignInstruction.getAssignToArrayElement(); writeInstruction(arrayAssignmentInstruction.getArrayRef()); write("["); @@ -696,10 +694,10 @@ public abstract class BlockWriter{ write(" = "); writeInstruction(inlineAssignInstruction.getRhs()); - } else if (_instruction.getByteCode().equals(ByteCode.FIELD_ARRAY_ELEMENT_INCREMENT)) { + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.FIELD_ARRAY_ELEMENT_INCREMENT)) { - final FieldArrayElementIncrement fieldArrayElementIncrement = (FieldArrayElementIncrement) _instruction; - final AssignToArrayElement arrayAssignmentInstruction = fieldArrayElementIncrement.getAssignToArrayElement(); + final InstructionSet.FieldArrayElementIncrement fieldArrayElementIncrement = (InstructionSet.FieldArrayElementIncrement) _instruction; + final InstructionSet.AssignToArrayElement arrayAssignmentInstruction = fieldArrayElementIncrement.getAssignToArrayElement(); if (fieldArrayElementIncrement.isPre()) { if (fieldArrayElementIncrement.isInc()) { write("++"); @@ -720,12 +718,12 @@ public abstract class BlockWriter{ } } - } else if (_instruction.getByteCode().equals(ByteCode.NONE)) { + } else if (_instruction.getByteCode().equals(InstructionSet.ByteCode.NONE)) { // we are done - } else if (_instruction instanceof Branch) { + } else if (_instruction instanceof InstructionSet.Branch) { throw new CodeGenException(String.format("%s -> %04d", _instruction.getByteCode().toString().toLowerCase(), - ((Branch) _instruction).getTarget().getThisPC())); - } else if (_instruction instanceof I_POP) { + ((InstructionSet.Branch) _instruction).getTarget().getThisPC())); + } else if (_instruction instanceof InstructionSet.I_POP) { //POP discarded void call return? writeInstruction(_instruction.getFirstChild()); } else { @@ -738,11 +736,11 @@ public abstract class BlockWriter{ final Instruction parent = instruction.getParentExpr(); boolean needsParenthesis = true; - if (parent instanceof AssignToLocalVariable) { + if (parent instanceof InstructionSet.AssignToLocalVariable) { needsParenthesis = false; - } else if (parent instanceof AssignToField) { + } else if (parent instanceof InstructionSet.AssignToField) { needsParenthesis = false; - } else if (parent instanceof AssignToArrayElement) { + } else if (parent instanceof InstructionSet.AssignToArrayElement) { needsParenthesis = false; } else { /** @@ -757,43 +755,43 @@ public abstract class BlockWriter{ return needsParenthesis; } - private boolean isMultiDimensionalArray(NameAndTypeEntry nameAndTypeEntry) { + private boolean isMultiDimensionalArray(ClassModel.ConstantPool.NameAndTypeEntry nameAndTypeEntry) { return nameAndTypeEntry.getDescriptorUTF8Entry().getUTF8().startsWith("[["); } - private boolean isObjectArray(NameAndTypeEntry nameAndTypeEntry) { + private boolean isObjectArray(ClassModel.ConstantPool.NameAndTypeEntry nameAndTypeEntry) { return nameAndTypeEntry.getDescriptorUTF8Entry().getUTF8().startsWith("[L"); } - private boolean isMultiDimensionalArray(final AccessArrayElement arrayLoadInstruction) { - AccessInstanceField accessInstanceField = getUltimateInstanceFieldAccess(arrayLoadInstruction); + private boolean isMultiDimensionalArray(final InstructionSet.AccessArrayElement arrayLoadInstruction) { + InstructionSet.AccessInstanceField accessInstanceField = getUltimateInstanceFieldAccess(arrayLoadInstruction); return isMultiDimensionalArray(accessInstanceField.getConstantPoolFieldEntry().getNameAndTypeEntry()); } - private boolean isObjectArray(final AccessArrayElement arrayLoadInstruction) { - AccessInstanceField accessInstanceField = getUltimateInstanceFieldAccess(arrayLoadInstruction); + private boolean isObjectArray(final InstructionSet.AccessArrayElement arrayLoadInstruction) { + InstructionSet.AccessInstanceField accessInstanceField = getUltimateInstanceFieldAccess(arrayLoadInstruction); return isObjectArray(accessInstanceField.getConstantPoolFieldEntry().getNameAndTypeEntry()); } - private AccessInstanceField getUltimateInstanceFieldAccess(final AccessArrayElement arrayLoadInstruction) { + private InstructionSet.AccessInstanceField getUltimateInstanceFieldAccess(final InstructionSet.AccessArrayElement arrayLoadInstruction) { Instruction load = arrayLoadInstruction.getArrayRef(); - while (load instanceof I_AALOAD) { + while (load instanceof InstructionSet.I_AALOAD) { load = load.getFirstChild(); } - return (AccessInstanceField) load; + return (InstructionSet.AccessInstanceField) load; } - public void writeMethod(MethodCall _methodCall, MethodEntry _methodEntry) throws CodeGenException { + public void writeMethod(InstructionSet.MethodCall _methodCall, ClassModel.ConstantPool.MethodEntry _methodEntry) throws CodeGenException { boolean noCL = _methodEntry.getOwnerClassModel().getNoCLMethods() .contains(_methodEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8()); if (noCL) { return; } - if (_methodCall instanceof VirtualMethodCall) { - final Instruction instanceInstruction = ((VirtualMethodCall) _methodCall).getInstanceReference(); - if (!(instanceInstruction instanceof I_ALOAD_0)) { + if (_methodCall instanceof InstructionSet.VirtualMethodCall) { + final Instruction instanceInstruction = ((InstructionSet.VirtualMethodCall) _methodCall).getInstanceReference(); + if (!(instanceInstruction instanceof InstructionSet.I_ALOAD_0)) { writeInstruction(instanceInstruction); write("."); } else { @@ -820,7 +818,7 @@ public abstract class BlockWriter{ public void writeMethodBody(MethodModel _methodModel) throws CodeGenException { if (_methodModel.isGetter() && !_methodModel.isNoCL()) { - FieldEntry accessorVariableFieldEntry = _methodModel.getAccessorVariableFieldEntry(); + ClassModel.ConstantPool.FieldEntry accessorVariableFieldEntry = _methodModel.getAccessorVariableFieldEntry(); writeGetterBlock(accessorVariableFieldEntry); } else { writeBlock(_methodModel.getExprHead(), null); diff --git a/src/main/java/com/syncleus/aparapi/internal/writer/KernelWriter.java b/src/main/java/com/aparapi/internal/writer/KernelWriter.java similarity index 87% rename from src/main/java/com/syncleus/aparapi/internal/writer/KernelWriter.java rename to src/main/java/com/aparapi/internal/writer/KernelWriter.java index 9fa26214c973098552589a00c5d55b4db3d5fe8a..815bedd51e604438c74e373314d2d9323366a7f9 100644 --- a/src/main/java/com/syncleus/aparapi/internal/writer/KernelWriter.java +++ b/src/main/java/com/aparapi/internal/writer/KernelWriter.java @@ -50,17 +50,18 @@ of EAR). For the most current Country Group listings, or for additional informa under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.syncleus.aparapi.internal.writer; - -import com.syncleus.aparapi.*; -import com.syncleus.aparapi.internal.exception.*; -import com.syncleus.aparapi.internal.instruction.*; -import com.syncleus.aparapi.internal.instruction.InstructionSet.*; -import com.syncleus.aparapi.internal.model.*; -import com.syncleus.aparapi.internal.model.ClassModel.AttributePool.*; -import com.syncleus.aparapi.internal.model.ClassModel.AttributePool.RuntimeAnnotationsEntry.*; -import com.syncleus.aparapi.internal.model.ClassModel.*; -import com.syncleus.aparapi.internal.model.ClassModel.ConstantPool.*; +package com.aparapi.internal.writer; + +import com.aparapi.Config; +import com.aparapi.Kernel; +import com.aparapi.internal.exception.ClassParseException; +import com.aparapi.internal.exception.CodeGenException; +import com.aparapi.internal.instruction.Instruction; +import com.aparapi.internal.instruction.InstructionSet; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.model.MethodModel; +import com.aparapi.*; import java.util.*; @@ -183,7 +184,7 @@ public abstract class KernelWriter extends BlockWriter{ } } - @Override public void writeMethod(MethodCall _methodCall, MethodEntry _methodEntry) throws CodeGenException { + @Override public void writeMethod(InstructionSet.MethodCall _methodCall, ClassModel.ConstantPool.MethodEntry _methodEntry) throws CodeGenException { final int argc = _methodEntry.getStackConsumeCount(); final String methodName = _methodEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); @@ -208,10 +209,10 @@ public abstract class KernelWriter extends BlockWriter{ write(barrierAndGetterMappings); } } else { - final boolean isSpecial = _methodCall instanceof I_INVOKESPECIAL; + final boolean isSpecial = _methodCall instanceof InstructionSet.I_INVOKESPECIAL; MethodModel m = entryPoint.getCallTarget(_methodEntry, isSpecial); - FieldEntry getterField = null; + ClassModel.ConstantPool.FieldEntry getterField = null; if (m != null && m.isGetter()) { getterField = m.getAccessorVariableFieldEntry(); } @@ -248,17 +249,17 @@ public abstract class KernelWriter extends BlockWriter{ write("("); - if ((intrinsicMapping == null) && (_methodCall instanceof VirtualMethodCall) && (!isIntrinsic)) { + if ((intrinsicMapping == null) && (_methodCall instanceof InstructionSet.VirtualMethodCall) && (!isIntrinsic)) { - final Instruction i = ((VirtualMethodCall) _methodCall).getInstanceReference(); + final Instruction i = ((InstructionSet.VirtualMethodCall) _methodCall).getInstanceReference(); - if (i instanceof I_ALOAD_0) { + if (i instanceof InstructionSet.I_ALOAD_0) { write("this"); - } else if (i instanceof AccessArrayElement) { - final AccessArrayElement arrayAccess = (AccessArrayElement) ((VirtualMethodCall) _methodCall).getInstanceReference(); + } else if (i instanceof InstructionSet.AccessArrayElement) { + final InstructionSet.AccessArrayElement arrayAccess = (InstructionSet.AccessArrayElement) ((InstructionSet.VirtualMethodCall) _methodCall).getInstanceReference(); final Instruction refAccess = arrayAccess.getArrayRef(); //assert refAccess instanceof I_GETFIELD : "ref should come from getfield"; - final String fieldName = ((AccessField) refAccess).getConstantPoolFieldEntry().getNameAndTypeEntry() + final String fieldName = ((InstructionSet.AccessField) refAccess).getConstantPoolFieldEntry().getNameAndTypeEntry() .getNameUTF8Entry().getUTF8(); write(" &(this->" + fieldName); write("["); @@ -269,7 +270,7 @@ public abstract class KernelWriter extends BlockWriter{ } } for (int arg = 0; arg < argc; arg++) { - if (((intrinsicMapping == null) && (_methodCall instanceof VirtualMethodCall) && (!isIntrinsic)) || (arg != 0)) { + if (((intrinsicMapping == null) && (_methodCall instanceof InstructionSet.VirtualMethodCall) && (!isIntrinsic)) || (arg != 0)) { write(", "); } writeInstruction(_methodCall.getArg(arg)); @@ -279,7 +280,7 @@ public abstract class KernelWriter extends BlockWriter{ } private boolean isThis(Instruction instruction) { - return instruction instanceof I_ALOAD_0; + return instruction instanceof InstructionSet.I_ALOAD_0; } public void writePragma(String _name, boolean _enable) { @@ -295,9 +296,9 @@ public abstract class KernelWriter extends BlockWriter{ public final static String __private = "__private"; - public final static String LOCAL_ANNOTATION_NAME = "L" + com.syncleus.aparapi.Kernel.Local.class.getName().replace('.', '/') + ";"; + public final static String LOCAL_ANNOTATION_NAME = "L" + Kernel.Local.class.getName().replace('.', '/') + ";"; - public final static String CONSTANT_ANNOTATION_NAME = "L" + com.syncleus.aparapi.Kernel.Constant.class.getName().replace('.', '/') + public final static String CONSTANT_ANNOTATION_NAME = "L" + Kernel.Constant.class.getName().replace('.', '/') + ";"; @Override public void write(Entrypoint _entryPoint) throws CodeGenException { @@ -307,7 +308,7 @@ public abstract class KernelWriter extends BlockWriter{ entryPoint = _entryPoint; - for (final ClassModelField field : _entryPoint.getReferencedClassModelFields()) { + for (final ClassModel.ClassModelField field : _entryPoint.getReferencedClassModelFields()) { // Field field = _entryPoint.getClassModel().getField(f.getName()); final StringBuilder thisStructLine = new StringBuilder(); final StringBuilder argLine = new StringBuilder(); @@ -333,10 +334,10 @@ public abstract class KernelWriter extends BlockWriter{ if (privateMemorySize != null) { type = __private; } - final RuntimeAnnotationsEntry visibleAnnotations = field.getAttributePool().getRuntimeVisibleAnnotationsEntry(); + final ClassModel.AttributePool.RuntimeAnnotationsEntry visibleAnnotations = field.getAttributePool().getRuntimeVisibleAnnotationsEntry(); if (visibleAnnotations != null) { - for (final AnnotationInfo ai : visibleAnnotations) { + for (final ClassModel.AttributePool.RuntimeAnnotationsEntry.AnnotationInfo ai : visibleAnnotations) { final String typeDescriptor = ai.getTypeDescriptor(); if (typeDescriptor.equals(LOCAL_ANNOTATION_NAME)) { type = __local; @@ -365,7 +366,7 @@ public abstract class KernelWriter extends BlockWriter{ // If it is a converted array of objects, emit the struct param String className = null; if (signature.startsWith("L")) { - // Turn Lcom/syncleus/javalabs/opencl/demo/DummyOOA; into com_amd_javalabs_opencl_demo_DummyOOA for example + // Turn Lcom/aparapi/javalabs/opencl/demo/DummyOOA; into com_aparapi_javalabs_opencl_demo_DummyOOA for example className = (signature.substring(1, signature.length() - 1)).replace('/', '_'); // if (logger.isLoggable(Level.FINE)) { // logger.fine("Examining object parameter: " + signature + " new: " + className); @@ -415,7 +416,7 @@ public abstract class KernelWriter extends BlockWriter{ final StringBuilder lenAssignLine = new StringBuilder(); String suffix = numDimensions == 1 ? "" : Integer.toString(i); - String lenName = field.getName() + BlockWriter.arrayLengthMangleSuffix + suffix; + String lenName = field.getName() + arrayLengthMangleSuffix + suffix; lenStructLine.append("int " + lenName); @@ -434,7 +435,7 @@ public abstract class KernelWriter extends BlockWriter{ final StringBuilder dimStructLine = new StringBuilder(); final StringBuilder dimArgLine = new StringBuilder(); final StringBuilder dimAssignLine = new StringBuilder(); - String dimName = field.getName() + BlockWriter.arrayDimMangleSuffix + suffix; + String dimName = field.getName() + arrayDimMangleSuffix + suffix; dimStructLine.append("int " + dimName); @@ -498,7 +499,7 @@ public abstract class KernelWriter extends BlockWriter{ // Emit structs for oop transformation accessors for (final ClassModel cm : _entryPoint.getObjectArrayFieldsClasses().values()) { - final ArrayList<FieldEntry> fieldSet = cm.getStructMembers(); + final ArrayList<ClassModel.ConstantPool.FieldEntry> fieldSet = cm.getStructMembers(); if (fieldSet.size() > 0) { final String mangledClassName = cm.getClassWeAreModelling().getName().replace('.', '_'); newLine(); @@ -509,9 +510,9 @@ public abstract class KernelWriter extends BlockWriter{ int totalSize = 0; int alignTo = 0; - final Iterator<FieldEntry> it = fieldSet.iterator(); + final Iterator<ClassModel.ConstantPool.FieldEntry> it = fieldSet.iterator(); while (it.hasNext()) { - final FieldEntry field = it.next(); + final ClassModel.ConstantPool.FieldEntry field = it.next(); final String fType = field.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8(); final int fSize = InstructionSet.TypeSpec.valueOf(fType.equals("Z") ? "B" : fType).getSize(); @@ -610,8 +611,8 @@ public abstract class KernelWriter extends BlockWriter{ boolean alreadyHasFirstArg = !mm.getMethod().isStatic(); - final LocalVariableTableEntry<LocalVariableInfo> lvte = mm.getLocalVariableTableEntry(); - for (final LocalVariableInfo lvi : lvte) { + final ClassModel.LocalVariableTableEntry<ClassModel.LocalVariableInfo> lvte = mm.getLocalVariableTableEntry(); + for (final ClassModel.LocalVariableInfo lvi : lvte) { if ((lvi.getStart() == 0) && ((lvi.getVariableIndex() != 0) || mm.getMethod().isStatic())) { // full scope but skip this final String descriptor = lvi.getVariableDescriptor(); if (alreadyHasFirstArg) { @@ -682,23 +683,23 @@ public abstract class KernelWriter extends BlockWriter{ } @Override public void writeInstruction(Instruction _instruction) throws CodeGenException { - if ((_instruction instanceof I_IUSHR) || (_instruction instanceof I_LUSHR)) { - final BinaryOperator binaryInstruction = (BinaryOperator) _instruction; + if ((_instruction instanceof InstructionSet.I_IUSHR) || (_instruction instanceof InstructionSet.I_LUSHR)) { + final InstructionSet.BinaryOperator binaryInstruction = (InstructionSet.BinaryOperator) _instruction; final Instruction parent = binaryInstruction.getParentExpr(); boolean needsParenthesis = true; - if (parent instanceof AssignToLocalVariable) { + if (parent instanceof InstructionSet.AssignToLocalVariable) { needsParenthesis = false; - } else if (parent instanceof AssignToField) { + } else if (parent instanceof InstructionSet.AssignToField) { needsParenthesis = false; - } else if (parent instanceof AssignToArrayElement) { + } else if (parent instanceof InstructionSet.AssignToArrayElement) { needsParenthesis = false; } if (needsParenthesis) { write("("); } - if (binaryInstruction instanceof I_IUSHR) { + if (binaryInstruction instanceof InstructionSet.I_IUSHR) { write("((unsigned int)"); } else { write("((unsigned long)"); diff --git a/src/main/java/com/syncleus/aparapi/opencl/OpenCL.java b/src/main/java/com/aparapi/opencl/OpenCL.java similarity index 94% rename from src/main/java/com/syncleus/aparapi/opencl/OpenCL.java rename to src/main/java/com/aparapi/opencl/OpenCL.java index 9c2824c564e65cbe995aa890a1976e10d86778b6..f15e0d2a0b1db8f48de6d1e23dfba27960f2b2dd 100644 --- a/src/main/java/com/syncleus/aparapi/opencl/OpenCL.java +++ b/src/main/java/com/aparapi/opencl/OpenCL.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.opencl; +package com.aparapi.opencl; -import com.syncleus.aparapi.ProfileInfo; +import com.aparapi.ProfileInfo; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/src/main/java/com/syncleus/aparapi/opencl/OpenCLAdapter.java b/src/main/java/com/aparapi/opencl/OpenCLAdapter.java similarity index 93% rename from src/main/java/com/syncleus/aparapi/opencl/OpenCLAdapter.java rename to src/main/java/com/aparapi/opencl/OpenCLAdapter.java index 75c313c4ce62e4a02d747249c4d990e52f3c287c..50695c344ca77b891c2e94618b0ab15ce588d3e7 100644 --- a/src/main/java/com/syncleus/aparapi/opencl/OpenCLAdapter.java +++ b/src/main/java/com/aparapi/opencl/OpenCLAdapter.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.opencl; +package com.aparapi.opencl; -import com.syncleus.aparapi.ProfileInfo; +import com.aparapi.ProfileInfo; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/syncleus/aparapi/package-info.java b/src/main/java/com/aparapi/opencl/package-info.java similarity index 92% rename from src/main/java/com/syncleus/aparapi/package-info.java rename to src/main/java/com/aparapi/opencl/package-info.java index fba2283746bdca378629d7c632d2c12df3a481b3..3f6ff47ce4adfa89b531239aea3feba35461c8fc 100644 --- a/src/main/java/com/syncleus/aparapi/package-info.java +++ b/src/main/java/com/aparapi/opencl/package-info.java @@ -16,4 +16,4 @@ /** * */ -package com.syncleus.aparapi; \ No newline at end of file +package com.aparapi.opencl; \ No newline at end of file diff --git a/src/main/java/com/aparapi/package-info.java b/src/main/java/com/aparapi/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..8a4492be69f7da41e69e1c0aaffaeb38dc1aa698 --- /dev/null +++ b/src/main/java/com/aparapi/package-info.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * + */ +package com.aparapi; \ No newline at end of file diff --git a/src/main/java/com/syncleus/aparapi/util/swing/MultiPassKernelSwingWorker.java b/src/main/java/com/aparapi/util/swing/MultiPassKernelSwingWorker.java similarity index 93% rename from src/main/java/com/syncleus/aparapi/util/swing/MultiPassKernelSwingWorker.java rename to src/main/java/com/aparapi/util/swing/MultiPassKernelSwingWorker.java index d4d61f6d02406970a5c684a21c573c42360b153a..96bbafd8a46103f668de70227247d50b0c9a68d7 100644 --- a/src/main/java/com/syncleus/aparapi/util/swing/MultiPassKernelSwingWorker.java +++ b/src/main/java/com/aparapi/util/swing/MultiPassKernelSwingWorker.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.syncleus.aparapi.util.swing; +package com.aparapi.util.swing; -import com.syncleus.aparapi.Kernel; -import com.syncleus.aparapi.internal.kernel.KernelRunner; +import com.aparapi.Kernel; +import com.aparapi.internal.kernel.KernelRunner; import javax.swing.*; import java.awt.event.ActionEvent; diff --git a/src/main/java/com/syncleus/aparapi/internal/tool/package-info.java b/src/main/java/com/syncleus/aparapi/internal/tool/package-info.java deleted file mode 100644 index 8ecae39a106bed091b68fd831f20772f2cf4610a..0000000000000000000000000000000000000000 --- a/src/main/java/com/syncleus/aparapi/internal/tool/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016 - 2017 Syncleus, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * - */ -package com.syncleus.aparapi.internal.tool; \ No newline at end of file diff --git a/src/test/java/ConvolutionLargeTest.java b/src/test/java/ConvolutionLargeTest.java index 9bd0409caae3ec378e88486d77676340e0d5c1e2..8056314c4ea8740ccce3e9149215c7ce0d966d93 100644 --- a/src/test/java/ConvolutionLargeTest.java +++ b/src/test/java/ConvolutionLargeTest.java @@ -55,9 +55,9 @@ import java.io.IOException; import java.text.MessageFormat; import java.util.concurrent.TimeUnit; -import com.syncleus.aparapi.Kernel; -import com.syncleus.aparapi.internal.model.CacheEnabler; -import com.syncleus.aparapi.internal.model.Supplier; +import com.aparapi.Kernel; +import com.aparapi.internal.model.CacheEnabler; +import com.aparapi.internal.model.Supplier; public class ConvolutionLargeTest{