# HG changeset patch # User Doug Simon # Date 1378969992 -7200 # Node ID d351a72596a941ae31fafcf382fd4075082411d9 # Parent 4f69a5189e778afd15ee02b3cca5d8760cdc3c37 added DelegatingMetaAccessProvider, DelegatingCodeCacheProvider, DelegatingGraalCodeCacheProvider diff -r 4f69a5189e77 -r d351a72596a9 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DelegatingCodeCacheProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DelegatingCodeCacheProvider.java Thu Sep 12 09:13:12 2013 +0200 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.code; + +import com.oracle.graal.api.meta.*; + +/** + * A {@link CodeCacheProvider} that delegates to another {@link CodeCacheProvider}. + */ +public class DelegatingCodeCacheProvider extends DelegatingMetaAccessProvider implements CodeCacheProvider { + + public DelegatingCodeCacheProvider(CodeCacheProvider delegate) { + super(delegate); + } + + @Override + protected CodeCacheProvider delegate() { + return (CodeCacheProvider) super.delegate(); + } + + public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) { + return delegate().addMethod(method, compResult); + } + + public String disassemble(CompilationResult compResult, InstalledCode installedCode) { + return delegate().disassemble(compResult, installedCode); + } + + public RegisterConfig lookupRegisterConfig() { + return delegate().lookupRegisterConfig(); + } + + public int getMinimumOutgoingSize() { + return delegate().getMinimumOutgoingSize(); + } + + public ForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) { + return delegate().lookupForeignCall(descriptor); + } + + public int encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason) { + return delegate().encodeDeoptActionAndReason(action, reason); + } + + public boolean needsDataPatch(Constant constant) { + return delegate().needsDataPatch(constant); + } + + public TargetDescription getTarget() { + return delegate().getTarget(); + } +} diff -r 4f69a5189e77 -r d351a72596a9 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DelegatingMetaAccessProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DelegatingMetaAccessProvider.java Thu Sep 12 09:13:12 2013 +0200 @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.meta; + +import java.lang.reflect.*; + +/** + * A {@link MetaAccessProvider} that delegates to another {@link MetaAccessProvider}. + */ +public class DelegatingMetaAccessProvider implements MetaAccessProvider { + + private final MetaAccessProvider delegate; + + public DelegatingMetaAccessProvider(MetaAccessProvider delegate) { + this.delegate = delegate; + } + + protected MetaAccessProvider delegate() { + return delegate; + } + + public ResolvedJavaType lookupJavaType(Class clazz) { + return delegate.lookupJavaType(clazz); + } + + public ResolvedJavaMethod lookupJavaMethod(Method reflectionMethod) { + return delegate.lookupJavaMethod(reflectionMethod); + } + + public ResolvedJavaMethod lookupJavaConstructor(Constructor reflectionConstructor) { + return delegate.lookupJavaConstructor(reflectionConstructor); + } + + public ResolvedJavaField lookupJavaField(Field reflectionField) { + return delegate.lookupJavaField(reflectionField); + } + + public ResolvedJavaType lookupJavaType(Constant constant) { + return delegate.lookupJavaType(constant); + } + + public Signature parseMethodDescriptor(String methodDescriptor) { + return delegate.parseMethodDescriptor(methodDescriptor); + } + + public boolean constantEquals(Constant x, Constant y) { + return delegate.constantEquals(x, y); + } + + public int lookupArrayLength(Constant array) { + return delegate.lookupArrayLength(array); + } + + public Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressible) { + return delegate.readUnsafeConstant(kind, base, displacement, compressible); + } + + public boolean isReexecutable(ForeignCallDescriptor descriptor) { + return delegate.isReexecutable(descriptor); + } + + public LocationIdentity[] getKilledLocations(ForeignCallDescriptor descriptor) { + return delegate.getKilledLocations(descriptor); + } + + public boolean canDeoptimize(ForeignCallDescriptor descriptor) { + return delegate.canDeoptimize(descriptor); + } +} diff -r 4f69a5189e77 -r d351a72596a9 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/DelegatingGraalCodeCacheProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/DelegatingGraalCodeCacheProvider.java Thu Sep 12 09:13:12 2013 +0200 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.spi; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; + +/** + * A {@link GraalCodeCacheProvider} that delegates to another {@link GraalCodeCacheProvider}. + */ +public class DelegatingGraalCodeCacheProvider extends DelegatingCodeCacheProvider implements GraalCodeCacheProvider { + + public DelegatingGraalCodeCacheProvider(CodeCacheProvider delegate) { + super(delegate); + } + + @Override + protected GraalCodeCacheProvider delegate() { + return (GraalCodeCacheProvider) super.delegate(); + } + + public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, Graph graph) { + return delegate().addMethod(method, compResult, graph); + } + + public void lower(Node n, LoweringTool tool) { + delegate().lower(n, tool); + } + + public ValueNode reconstructArrayIndex(LocationNode location) { + return delegate().reconstructArrayIndex(location); + } +}