diff options
author | Laurent Le Brun <laurentlb@google.com> | 2017-01-20 16:15:49 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2017-01-23 09:50:05 +0000 |
commit | ea78fbe047853642592ae5d4ac1acdb8200760ae (patch) | |
tree | 3ba3a5b3dfca432683fcf8abe67a2a07bc934547 /src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java | |
parent | 9c390fbe4acee09c75034b94553deef7870df5a3 (diff) |
Delete the bytecode compiler experiment.
The code has been untouched and unused for over a year (it's very likely
broken) and we have other priorities for now.
--
PiperOrigin-RevId: 145087310
MOS_MIGRATED_REVID=145087310
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java index dfbf43a025..f6082d9227 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java @@ -14,8 +14,6 @@ package com.google.devtools.build.lib.syntax; -import static com.google.devtools.build.lib.syntax.compiler.ByteCodeUtils.append; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.cache.CacheBuilder; @@ -31,20 +29,12 @@ import com.google.devtools.build.lib.skylarkinterface.SkylarkInterfaceUtils; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.syntax.EvalException.EvalExceptionWithJavaCause; import com.google.devtools.build.lib.syntax.Runtime.NoneType; -import com.google.devtools.build.lib.syntax.compiler.ByteCodeMethodCalls; -import com.google.devtools.build.lib.syntax.compiler.ByteCodeUtils; -import com.google.devtools.build.lib.syntax.compiler.DebugInfo; -import com.google.devtools.build.lib.syntax.compiler.DebugInfo.AstAccessors; -import com.google.devtools.build.lib.syntax.compiler.NewObject; -import com.google.devtools.build.lib.syntax.compiler.Variable.InternalVariable; -import com.google.devtools.build.lib.syntax.compiler.VariableScope; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.util.StringUtilities; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -54,12 +44,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; -import net.bytebuddy.description.type.TypeDescription; -import net.bytebuddy.implementation.bytecode.ByteCodeAppender; -import net.bytebuddy.implementation.bytecode.Removal; -import net.bytebuddy.implementation.bytecode.StackManipulation; -import net.bytebuddy.implementation.bytecode.assign.TypeCasting; -import net.bytebuddy.implementation.bytecode.constant.TextConstant; /** * Syntax node for a function call expression. @@ -525,20 +509,6 @@ public final class FuncallExpression extends Expression { } /** - * A {@link StackManipulation} invoking addKeywordArg. - * - * <p>Kept close to the definition of the method to avoid reflection errors when changing it. - */ - private static final StackManipulation addKeywordArg = - ByteCodeUtils.invoke( - FuncallExpression.class, - "addKeywordArg", - Map.class, - String.class, - Object.class, - ImmutableList.Builder.class); - - /** * Add one argument to the keyword map, registering a duplicate in case of conflict. * * <p>public for reflection by the compiler and calls from compiled functions @@ -554,19 +524,6 @@ public final class FuncallExpression extends Expression { } /** - * A {@link StackManipulation} invoking addKeywordArgs. - * <p>Kept close to the definition of the method to avoid reflection errors when changing it. - */ - private static final StackManipulation addKeywordArgs = - ByteCodeUtils.invoke( - FuncallExpression.class, - "addKeywordArgs", - Map.class, - Object.class, - ImmutableList.Builder.class, - Location.class); - - /** * Add multiple arguments to the keyword map (**kwargs), registering duplicates * * <p>public for reflection by the compiler and calls from compiled functions @@ -593,13 +550,6 @@ public final class FuncallExpression extends Expression { } /** - * A {@link StackManipulation} invoking checkCallable. - * <p>Kept close to the definition of the method to avoid reflection errors when changing it. - */ - private static final StackManipulation checkCallable = - ByteCodeUtils.invoke(FuncallExpression.class, "checkCallable", Object.class, Location.class); - - /** * Checks whether the given object is a {@link BaseFunction}. * * <p>Public for reflection by the compiler and access from generated byte code. @@ -617,18 +567,6 @@ public final class FuncallExpression extends Expression { } /** - * A {@link StackManipulation} invoking checkDuplicates. - * <p>Kept close to the definition of the method to avoid reflection errors when changing it. - */ - private static final StackManipulation checkDuplicates = - ByteCodeUtils.invoke( - FuncallExpression.class, - "checkDuplicates", - ImmutableList.Builder.class, - String.class, - Location.class); - - /** * Check the list from the builder and report an {@link EvalException} if not empty. * * <p>public for reflection by the compiler and calls from compiled functions @@ -650,20 +588,6 @@ public final class FuncallExpression extends Expression { } /** - * A {@link StackManipulation} invoking invokeObjectMethod. - * <p>Kept close to the definition of the method to avoid reflection errors when changing it. - */ - private static final StackManipulation invokeObjectMethod = - ByteCodeUtils.invoke( - FuncallExpression.class, - "invokeObjectMethod", - String.class, - ImmutableList.class, - ImmutableMap.class, - FuncallExpression.class, - Environment.class); - - /** * Call a method depending on the type of an object it is called on. * * <p>Public for reflection by the compiler and access from generated byte code. @@ -850,119 +774,4 @@ public final class FuncallExpression extends Expression { protected boolean isNewScope() { return true; } - - @Override - ByteCodeAppender compile(VariableScope scope, DebugInfo debugInfo) throws EvalException { - AstAccessors debugAccessors = debugInfo.add(this); - List<ByteCodeAppender> code = new ArrayList<>(); - if (obj != null) { - compileObjectMethodCall(scope, debugInfo, debugAccessors, code); - } else { - compileGlobalFunctionCall(scope, debugInfo, debugAccessors, code); - } - return ByteCodeUtils.compoundAppender(code); - } - - /** - * Add code that compiles the argument expressions. - * - * <p>The byte code leaves the arguments on the stack in order of: - * positional arguments, key word arguments, this FuncallExpression, Environment - * This is the order required by {@link #invokeObjectMethod} and - * {@link BaseFunction#call(List, Map, FuncallExpression, Environment)}. - */ - private void compileArguments( - VariableScope scope, - DebugInfo debugInfo, - AstAccessors debugAccessors, - List<ByteCodeAppender> code) - throws EvalException { - InternalVariable positionalsBuilder = scope.freshVariable(ImmutableList.Builder.class); - append(code, ByteCodeMethodCalls.BCImmutableList.builder); - code.add(positionalsBuilder.store()); - - InternalVariable keyWordArgs = scope.freshVariable(Map.class); - append(code, NewObject.fromConstructor(HashMap.class).arguments()); - code.add(keyWordArgs.store()); - - InternalVariable duplicatesBuilder = - scope.freshVariable(new TypeDescription.ForLoadedType(ImmutableList.Builder.class)); - append(code, ByteCodeMethodCalls.BCImmutableList.builder); - code.add(duplicatesBuilder.store()); - - StackManipulation builderAdd = - new StackManipulation.Compound( - ByteCodeMethodCalls.BCImmutableList.Builder.add, Removal.SINGLE); - - // add an object the function is called on first - if (obj != null) { - append(code, positionalsBuilder.load()); - code.add(obj.compile(scope, debugInfo)); - append(code, builderAdd); - } - // add all arguments to their respective builder/map - for (Argument.Passed arg : args) { - ByteCodeAppender value = arg.getValue().compile(scope, debugInfo); - if (arg.isPositional()) { - append(code, positionalsBuilder.load()); - code.add(value); - append(code, builderAdd); - } else if (arg.isStar()) { - // expand the starArg by adding all it's elements to the builder - append(code, positionalsBuilder.load()); - code.add(value); - append( - code, - TypeCasting.to(new TypeDescription.ForLoadedType(Iterable.class)), - ByteCodeMethodCalls.BCImmutableList.Builder.addAll, - Removal.SINGLE); - } else if (arg.isStarStar()) { - append(code, keyWordArgs.load()); - code.add(value); - append(code, duplicatesBuilder.load(), debugAccessors.loadLocation, addKeywordArgs); - } else { - append(code, keyWordArgs.load(), new TextConstant(arg.getName())); - code.add(value); - append(code, duplicatesBuilder.load(), addKeywordArg); - } - } - append( - code, - // check for duplicates in the key word arguments - duplicatesBuilder.load(), - new TextConstant(func.getName()), - debugAccessors.loadLocation, - checkDuplicates, - // load the arguments in the correct order for invokeObjectMethod and BaseFunction.call - positionalsBuilder.load(), - ByteCodeMethodCalls.BCImmutableList.Builder.build, - keyWordArgs.load(), - ByteCodeMethodCalls.BCImmutableMap.copyOf, - debugAccessors.loadAstNode, - TypeCasting.to(new TypeDescription.ForLoadedType(FuncallExpression.class)), - scope.loadEnvironment()); - } - - private void compileObjectMethodCall( - VariableScope scope, - DebugInfo debugInfo, - AstAccessors debugAccessors, - List<ByteCodeAppender> code) - throws EvalException { - append(code, new TextConstant(func.getName())); - compileArguments(scope, debugInfo, debugAccessors, code); - append(code, invokeObjectMethod); - } - - private void compileGlobalFunctionCall( - VariableScope scope, - DebugInfo debugInfo, - AstAccessors debugAccessors, - List<ByteCodeAppender> code) - throws EvalException { - code.add(func.compile(scope, debugInfo)); - append(code, debugAccessors.loadLocation, checkCallable); - compileArguments(scope, debugInfo, debugAccessors, code); - append(code, BaseFunction.call); - } } |