# HG changeset patch # User Doug Simon # Date 1415636918 -3600 # Node ID 06756883d87e67e80f3630b19036acd52a959321 # Parent 301c5e3d683a2630b242722444f4479e7a82948d removed annotation denoting which proxied invocations have their results cached (for now, all results are cached) diff -r 301c5e3d683a -r 06756883d87e graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java --- 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 { - } } diff -r 301c5e3d683a -r 06756883d87e graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/Handler.java --- 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 implements InvocationHandler { private final T delegate; private final Context context; - Map constantDataInvocations = new HashMap<>(); + Map 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; } diff -r 301c5e3d683a -r 06756883d87e graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java --- 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(); /**