diff options
author | 2017-01-20 16:15:49 +0000 | |
---|---|---|
committer | 2017-01-23 09:50:05 +0000 | |
commit | ea78fbe047853642592ae5d4ac1acdb8200760ae (patch) | |
tree | 3ba3a5b3dfca432683fcf8abe67a2a07bc934547 /src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.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/BinaryOperatorExpression.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java index 1e9f02352a..b9565feae2 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BinaryOperatorExpression.java @@ -13,31 +13,14 @@ // limitations under the License. package com.google.devtools.build.lib.syntax; -import static com.google.devtools.build.lib.syntax.compiler.ByteCodeUtils.append; - import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.syntax.Concatable.Concatter; import com.google.devtools.build.lib.syntax.SkylarkList.MutableList; import com.google.devtools.build.lib.syntax.SkylarkList.Tuple; -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.Jump; -import com.google.devtools.build.lib.syntax.compiler.Jump.PrimitiveComparison; -import com.google.devtools.build.lib.syntax.compiler.LabelAdder; -import com.google.devtools.build.lib.syntax.compiler.VariableScope; -import java.util.ArrayList; import java.util.Collections; -import java.util.EnumSet; import java.util.IllegalFormatException; -import java.util.List; -import net.bytebuddy.implementation.bytecode.ByteCodeAppender; -import net.bytebuddy.implementation.bytecode.Duplication; -import net.bytebuddy.implementation.bytecode.Removal; -import net.bytebuddy.implementation.bytecode.StackManipulation; /** * Syntax node for a binary operator expression. @@ -202,106 +185,6 @@ public final class BinaryOperatorExpression extends Expression { rhs.validate(env); } - @Override - ByteCodeAppender compile(VariableScope scope, DebugInfo debugInfo) throws EvalException { - AstAccessors debugAccessors = debugInfo.add(this); - List<ByteCodeAppender> code = new ArrayList<>(); - ByteCodeAppender leftCompiled = lhs.compile(scope, debugInfo); - ByteCodeAppender rightCompiled = rhs.compile(scope, debugInfo); - // generate byte code for short-circuiting operators - if (EnumSet.of(Operator.AND, Operator.OR).contains(operator)) { - LabelAdder after = new LabelAdder(); - code.add(leftCompiled); - append( - code, - // duplicate the value, one to convert to boolean, one to leave on stack - // assumes we don't compile Skylark values to long/double - Duplication.SINGLE, - EvalUtils.toBoolean, - // short-circuit and jump behind second operand expression if first is false/true - Jump.ifIntOperandToZero( - operator == Operator.AND - ? PrimitiveComparison.EQUAL - : PrimitiveComparison.NOT_EQUAL) - .to(after), - // remove the duplicated value from above, as only the rhs is still relevant - Removal.SINGLE); - code.add(rightCompiled); - append(code, after); - } else if (EnumSet.of( - Operator.LESS, Operator.LESS_EQUALS, Operator.GREATER, Operator.GREATER_EQUALS) - .contains(operator)) { - compileComparison(debugAccessors, code, leftCompiled, rightCompiled); - } else { - code.add(leftCompiled); - code.add(rightCompiled); - switch (operator) { - case PLUS: - append(code, callImplementation(scope, debugAccessors, operator)); - break; - case PIPE: - case MINUS: - case MULT: - case DIVIDE: - case PERCENT: - append(code, callImplementation(debugAccessors, operator)); - break; - case EQUALS_EQUALS: - append(code, ByteCodeMethodCalls.BCObject.equals, ByteCodeMethodCalls.BCBoolean.valueOf); - break; - case NOT_EQUALS: - append( - code, - ByteCodeMethodCalls.BCObject.equals, - ByteCodeUtils.intLogicalNegation(), - ByteCodeMethodCalls.BCBoolean.valueOf); - break; - case IN: - append( - code, - callImplementation(debugAccessors, operator), - ByteCodeMethodCalls.BCBoolean.valueOf); - break; - case NOT_IN: - append( - code, - callImplementation(debugAccessors, Operator.IN), - ByteCodeUtils.intLogicalNegation(), - ByteCodeMethodCalls.BCBoolean.valueOf); - break; - default: - throw new UnsupportedOperationException("Unsupported binary operator: " + operator); - } // endswitch - } - return ByteCodeUtils.compoundAppender(code); - } - - /** - * Compile a comparison oer - * - * @param debugAccessors - * @param code - * @param leftCompiled - * @param rightCompiled - * @throws Error - */ - private void compileComparison( - AstAccessors debugAccessors, - List<ByteCodeAppender> code, - ByteCodeAppender leftCompiled, - ByteCodeAppender rightCompiled) { - PrimitiveComparison byteCodeOperator = PrimitiveComparison.forOperator(operator); - code.add(leftCompiled); - code.add(rightCompiled); - append( - code, - debugAccessors.loadLocation, - ByteCodeUtils.invoke( - BinaryOperatorExpression.class, "compare", Object.class, Object.class, Location.class), - ByteCodeUtils.intToPrimitiveBoolean(byteCodeOperator), - ByteCodeMethodCalls.BCBoolean.valueOf); - } - /** * Implements Operator.PLUS. * @@ -472,38 +355,6 @@ public final class BinaryOperatorExpression extends Expression { } /** - * Returns a StackManipulation that calls the given operator's implementation method. - * - * <p> The method must be named exactly as the lower case name of the operator and in addition to - * the operands require an Environment and Location. - */ - private static StackManipulation callImplementation( - VariableScope scope, AstAccessors debugAccessors, Operator operator) { - Class<?>[] parameterTypes = - new Class<?>[] {Object.class, Object.class, Environment.class, Location.class}; - return new StackManipulation.Compound( - scope.loadEnvironment(), - debugAccessors.loadLocation, - ByteCodeUtils.invoke( - BinaryOperatorExpression.class, operator.name().toLowerCase(), parameterTypes)); - } - - /** - * Returns a StackManipulation that calls the given operator's implementation method. - * - * <p> The method must be named exactly as the lower case name of the operator and in addition to - * the operands require a Location. - */ - private static StackManipulation callImplementation( - AstAccessors debugAccessors, Operator operator) { - Class<?>[] parameterTypes = new Class<?>[] {Object.class, Object.class, Location.class}; - return new StackManipulation.Compound( - debugAccessors.loadLocation, - ByteCodeUtils.invoke( - BinaryOperatorExpression.class, operator.name().toLowerCase(), parameterTypes)); - } - - /** * Throws an exception signifying incorrect types for the given operator. */ private static final EvalException typeException( |