changeset 18324:06756883d87e

removed annotation denoting which proxied invocations have their results cached (for now, all results are cached)
author Doug Simon <doug.simon@oracle.com>
date Mon, 10 Nov 2014 17:28:38 +0100
parents 301c5e3d683a
children 6f99dae5df57
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java
diffstat 3 files changed, 16 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java	Sun Nov 09 17:01:15 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java	Mon Nov 10 17:28:38 2014 +0100
@@ -22,19 +22,9 @@
  */
 package com.oracle.graal.api.meta;
 
-import java.lang.annotation.*;
-
 /**
  * Marker interface for classes whose values are proxied during replay compilation capture or remote
  * compilation.
  */
 public interface Remote {
-
-    /**
-     * Denotes a method whose return value is determined solely by its parameter values.
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @Target(ElementType.METHOD)
-    public @interface PureFunction {
-    }
 }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java	Sun Nov 09 17:01:15 2014 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java	Mon Nov 10 17:28:38 2014 +0100
@@ -25,16 +25,12 @@
 import java.lang.reflect.*;
 import java.util.*;
 
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.meta.Remote.PureFunction;
-
-@SuppressWarnings("unused")
 public class Handler<T> implements InvocationHandler {
 
     private final T delegate;
     private final Context context;
 
-    Map<Invocation, Object> constantDataInvocations = new HashMap<>();
+    Map<Invocation, Object> cachedInvocations = new HashMap<>();
 
     public Handler(T delegate, Context context) {
         this.delegate = delegate;
@@ -63,15 +59,23 @@
         return res;
     }
 
+    /**
+     * @param method
+     */
+    private static boolean isCacheable(Method method) {
+        // TODO: use annotations for finer control of what should be cached
+        return true;
+    }
+
     @Override
     public Object invoke(Object proxy, Method method, Object[] a) throws Throwable {
         Object[] args = unproxify(a);
-        boolean isConstantData = method.getAnnotation(PureFunction.class) != null;
+        boolean isCacheable = isCacheable(method);
         Invocation invocation = new Invocation(method, delegate, args);
-        if (isConstantData) {
-            if (constantDataInvocations.containsKey(invocation)) {
-                Object result = constantDataInvocations.get(invocation);
-                assert Objects.deepEquals(result, invocation.invoke());
+        if (isCacheable) {
+            assert method.getReturnType() != Void.TYPE : method;
+            if (cachedInvocations.containsKey(invocation)) {
+                Object result = cachedInvocations.get(invocation);
                 // System.out.println(invocation + ": " + result);
                 return result;
             }
@@ -81,8 +85,8 @@
 
         Object result = invocation.invoke();
         result = context.get(result);
-        if (isConstantData) {
-            constantDataInvocations.put(invocation, result);
+        if (isCacheable) {
+            cachedInvocations.put(invocation, result);
         }
         return result;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java	Sun Nov 09 17:01:15 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java	Mon Nov 10 17:28:38 2014 +0100
@@ -47,14 +47,12 @@
      *
      * @return {@code null} if this constant does not represent a {@link Class} object
      */
-    @PureFunction
     JavaConstant getClassLoader();
 
     /**
      * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object
      * represented by this constant.
      */
-    @PureFunction
     int getIdentityHashCode();
 
     /**