diff --git a/cr-examples/spirv/src/main/java/intel/code/spirv/SpirvModuleGenerator.java b/cr-examples/spirv/src/main/java/intel/code/spirv/SpirvModuleGenerator.java index 5902ee09eaa..4344ca07335 100644 --- a/cr-examples/spirv/src/main/java/intel/code/spirv/SpirvModuleGenerator.java +++ b/cr-examples/spirv/src/main/java/intel/code/spirv/SpirvModuleGenerator.java @@ -52,7 +52,7 @@ import java.lang.reflect.code.Body; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.TypeElement; import java.lang.reflect.code.type.MethodRef; import java.lang.reflect.code.type.ClassType; @@ -68,7 +68,7 @@ import uk.ac.manchester.beehivespirvtoolkit.lib.disassembler.SPVByteStreamReader; public class SpirvModuleGenerator { - public static MemorySegment generateModule(String moduleName, CoreOps.FuncOp func) { + public static MemorySegment generateModule(String moduleName, CoreOp.FuncOp func) { SpirvOps.FuncOp spirvFunc = TranslateToSpirvModel.translateFunction(func); MemorySegment module = SpirvModuleGenerator.generateModule(moduleName, spirvFunc); return module; diff --git a/cr-examples/spirv/src/main/java/intel/code/spirv/TranslateToSpirvModel.java b/cr-examples/spirv/src/main/java/intel/code/spirv/TranslateToSpirvModel.java index 9501c72ec42..36be60fcc66 100644 --- a/cr-examples/spirv/src/main/java/intel/code/spirv/TranslateToSpirvModel.java +++ b/cr-examples/spirv/src/main/java/intel/code/spirv/TranslateToSpirvModel.java @@ -31,7 +31,7 @@ import java.util.HashMap; import java.lang.reflect.code.Block; import java.lang.reflect.code.Body; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; import java.lang.reflect.code.TypeElement; @@ -41,8 +41,8 @@ public class TranslateToSpirvModel { private Map<Block, Block.Builder> blockMap; // Java block to spirv block builder private Map<Value, Value> valueMap; // Java model Value to Spirv model Value - public static SpirvOps.FuncOp translateFunction(CoreOps.FuncOp func) { - CoreOps.FuncOp lowFunc = lowerMethod(func); + public static SpirvOps.FuncOp translateFunction(CoreOp.FuncOp func) { + CoreOp.FuncOp lowFunc = lowerMethod(func); TranslateToSpirvModel instance = new TranslateToSpirvModel(); Body.Builder bodyBuilder = instance.translateBody(lowFunc.body(), lowFunc, null); return new SpirvOps.FuncOp(lowFunc.funcName(), lowFunc.invokableType(), bodyBuilder); @@ -72,7 +72,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo int paramCount = entryBlock.parameters().size(); for (int i = 0; i < paramCount; i++) { Block.Parameter bp = entryBlock.parameters().get(i); - assert entryBlock.ops().get(i) instanceof CoreOps.VarOp; + assert entryBlock.ops().get(i) instanceof CoreOp.VarOp; SpirvOp funcParam = new SpirvOps.FunctionParameterOp(bp.type(), List.of()); spirvBlock.op(funcParam); valueMap.put(bp, funcParam.result()); @@ -81,7 +81,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo // SPIR-V Variable ops must be the first ops in a function's entry block and do not include initialization. // Emit all SPIR-V Variable ops first and emit initializing stores afterward, at the CR model VarOp position. for (int i = 0; i < paramCount; i++) { - CoreOps.VarOp jvop = (CoreOps.VarOp)entryBlock.ops().get(i); + CoreOp.VarOp jvop = (CoreOp.VarOp)entryBlock.ops().get(i); TypeElement resultType = new PointerType(jvop.varType(), StorageType.CROSSWORKGROUP); SpirvOps.VariableOp svop = new SpirvOps.VariableOp((String)jvop.attributes().get(""), resultType, jvop.varType()); spirvBlock.op(svop); @@ -96,7 +96,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo for (int i = (bi == 0 ? paramCount : 0); i < ops.size(); i++) { if (bi > 0) spirvBlock = blockMap.get(block); Op op = ops.get(i); - if (op instanceof CoreOps.VarOp jvop) { + if (op instanceof CoreOp.VarOp jvop) { TypeElement resultType = new PointerType(jvop.varType(), StorageType.CROSSWORKGROUP); SpirvOps.VariableOp svop = new SpirvOps.VariableOp((String)jvop.attributes().get(""), resultType, jvop.varType()); bodyBuilder.entryBlock().op(svop); @@ -110,27 +110,27 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock = blockMap.get(block); for (Op op : block.ops()) { switch (op) { - case CoreOps.ReturnOp rop -> { + case CoreOp.ReturnOp rop -> { spirvBlock.op(new SpirvOps.ReturnOp(rop.resultType(), mapOperands(rop))); } - case CoreOps.VarOp vop -> { + case CoreOp.VarOp vop -> { Value dest = valueMap.get(vop.result()); Value value = valueMap.get(vop.operands().get(0)); // init variable here; declaration has been moved to top of function spirvBlock.op(new SpirvOps.StoreOp(dest, value)); } - case CoreOps.VarAccessOp.VarLoadOp vlo -> { + case CoreOp.VarAccessOp.VarLoadOp vlo -> { List<Value> operands = mapOperands(vlo); SpirvOps.LoadOp load = new SpirvOps.LoadOp(vlo.resultType(), operands); spirvBlock.op(load); valueMap.put(vlo.result(), load.result()); } - case CoreOps.VarAccessOp.VarStoreOp vso -> { + case CoreOp.VarAccessOp.VarStoreOp vso -> { Value dest = valueMap.get(vso.varOp().result()); Value value = valueMap.get(vso.operands().get(1)); spirvBlock.op(new SpirvOps.StoreOp(dest, value)); } - case CoreOps.ArrayAccessOp.ArrayLoadOp alo -> { + case CoreOp.ArrayAccessOp.ArrayLoadOp alo -> { Value array = valueMap.get(alo.operands().get(0)); Value index = valueMap.get(alo.operands().get(1)); TypeElement arrayType = array.type(); @@ -143,7 +143,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(load); valueMap.put(alo.result(), load.result()); } - case CoreOps.ArrayAccessOp.ArrayStoreOp aso -> { + case CoreOp.ArrayAccessOp.ArrayStoreOp aso -> { Value array = valueMap.get(aso.operands().get(0)); Value index = valueMap.get(aso.operands().get(1)); TypeElement arrayType = array.type(); @@ -151,12 +151,12 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(ibac); spirvBlock.op(new SpirvOps.StoreOp(ibac.result(), valueMap.get(aso.operands().get(2)))); } - case CoreOps.ArrayLengthOp alo -> { + case CoreOp.ArrayLengthOp alo -> { Op len = new SpirvOps.ArrayLengthOp(JavaType.INT, List.of(valueMap.get(alo.operands().get(0)))); spirvBlock.op(len); valueMap.put(alo.result(), len.result()); } - case CoreOps.AddOp aop -> { + case CoreOp.AddOp aop -> { TypeElement type = aop.operands().get(0).type(); List<Value> operands = mapOperands(aop); SpirvOp addOp; @@ -166,7 +166,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(addOp); valueMap.put(aop.result(), addOp.result()); } - case CoreOps.SubOp sop -> { + case CoreOp.SubOp sop -> { TypeElement type = sop.operands().get(0).type(); List<Value> operands = mapOperands(sop); SpirvOp subOp; @@ -176,7 +176,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(subOp); valueMap.put(sop.result(), subOp.result()); } - case CoreOps.MulOp mop -> { + case CoreOp.MulOp mop -> { TypeElement type = mop.operands().get(0).type(); List<Value> operands = mapOperands(mop); SpirvOp mulOp; @@ -186,7 +186,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(mulOp); valueMap.put(mop.result(), mulOp.result()); } - case CoreOps.DivOp dop -> { + case CoreOp.DivOp dop -> { TypeElement type = dop.operands().get(0).type(); List<Value> operands = mapOperands(dop); SpirvOp divOp; @@ -196,14 +196,14 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(divOp); valueMap.put(dop.result(), divOp.result()); } - case CoreOps.ModOp mop -> { + case CoreOp.ModOp mop -> { TypeElement type = mop.operands().get(0).type(); List<Value> operands = mapOperands(mop); SpirvOp modOp = new SpirvOps.ModOp(type, operands); spirvBlock.op(modOp); valueMap.put(mop.result(), modOp.result()); } - case CoreOps.EqOp eqop -> { + case CoreOp.EqOp eqop -> { TypeElement type = eqop.operands().get(0).type(); List<Value> operands = mapOperands(eqop); SpirvOp seqop; @@ -213,7 +213,7 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(seqop); valueMap.put(eqop.result(), seqop.result()); } - case CoreOps.NeqOp neqop -> { + case CoreOp.NeqOp neqop -> { TypeElement type = neqop.operands().get(0).type(); List<Value> operands = mapOperands(neqop); SpirvOp sneqop; @@ -223,40 +223,40 @@ private Body.Builder translateBody(Body body, Op parentOp, Body.Builder parentBo spirvBlock.op(sneqop); valueMap.put(neqop.result(), sneqop.result()); } - case CoreOps.LtOp ltop -> { + case CoreOp.LtOp ltop -> { TypeElement type = ltop.operands().get(0).type(); List<Value> operands = mapOperands(ltop); SpirvOp sltop = new SpirvOps.LtOp(type, operands); spirvBlock.op(sltop); valueMap.put(ltop.result(), sltop.result()); } - case CoreOps.InvokeOp inv -> { + case CoreOp.InvokeOp inv -> { List<Value> operands = mapOperands(inv); SpirvOp spirvCall = new SpirvOps.CallOp(inv.invokeDescriptor(), operands); spirvBlock.op(spirvCall); valueMap.put(inv.result(), spirvCall.result()); } - case CoreOps.ConstantOp cop -> { + case CoreOp.ConstantOp cop -> { SpirvOp scop = new SpirvOps.ConstantOp(cop.resultType(), cop.value()); spirvBlock.op(scop); valueMap.put(cop.result(), scop.result()); } - case CoreOps.ConvOp cop -> { + case CoreOp.ConvOp cop -> { List<Value> operands = mapOperands(cop); SpirvOp scop = new SpirvOps.ConvertOp(cop.resultType(), operands); spirvBlock.op(scop); valueMap.put(cop.result(), scop.result()); } - case CoreOps.FieldAccessOp.FieldLoadOp flo -> { + case CoreOp.FieldAccessOp.FieldLoadOp flo -> { SpirvOp load = new SpirvOps.FieldLoadOp(flo.resultType(), flo.fieldDescriptor(), mapOperands(flo)); spirvBlock.op(load); valueMap.put(flo.result(), load.result()); } - case CoreOps.BranchOp bop -> { + case CoreOp.BranchOp bop -> { Block.Reference successor = blockMap.get(bop.branch().targetBlock()).successor(); spirvBlock.op(new SpirvOps.BranchOp(successor)); } - case CoreOps.ConditionalBranchOp cbop -> { + case CoreOp.ConditionalBranchOp cbop -> { Block trueBlock = cbop.trueBranch().targetBlock(); Block falseBlock = cbop.falseBranch().targetBlock(); Block.Reference spvTrueBlock = blockMap.get(trueBlock).successor(); @@ -274,8 +274,8 @@ private RuntimeException unsupported(String message, Object value) { return new RuntimeException("Unsupported " + message + ": " + value); } - private static CoreOps.FuncOp lowerMethod(CoreOps.FuncOp fop) { - CoreOps.FuncOp lfop = fop.transform((block, op) -> { + private static CoreOp.FuncOp lowerMethod(CoreOp.FuncOp fop) { + CoreOp.FuncOp lfop = fop.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } diff --git a/cr-examples/spirv/src/test/java/intel/code/spirv/ExampleUseTest.java b/cr-examples/spirv/src/test/java/intel/code/spirv/ExampleUseTest.java index 86163cd0126..206e27b68ae 100644 --- a/cr-examples/spirv/src/test/java/intel/code/spirv/ExampleUseTest.java +++ b/cr-examples/spirv/src/test/java/intel/code/spirv/ExampleUseTest.java @@ -28,7 +28,7 @@ import java.lang.reflect.Method; import java.lang.foreign.MemorySegment; import java.lang.runtime.CodeReflection; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import org.junit.jupiter.api.Test; public class ExampleUseTest { @@ -51,7 +51,7 @@ public void test() throws Exception { String methodName = "matrixMultiply"; Method method = ExampleUseTest.class.getDeclaredMethod(methodName, float[].class, float[].class, float[].class, int.class); - CoreOps.FuncOp javaFunc = method.getCodeModel().get(); + CoreOp.FuncOp javaFunc = method.getCodeModel().get(); SpirvOps.FuncOp spirvFunc = TranslateToSpirvModel.translateFunction(javaFunc); MemorySegment spirvBinary = SpirvModuleGenerator.generateModule(methodName, spirvFunc); diff --git a/cr-examples/triton/src/main/java/oracle/code/triton/Functions.java b/cr-examples/triton/src/main/java/oracle/code/triton/Functions.java index c57ebbe52e5..5592fbeca8f 100644 --- a/cr-examples/triton/src/main/java/oracle/code/triton/Functions.java +++ b/cr-examples/triton/src/main/java/oracle/code/triton/Functions.java @@ -26,7 +26,7 @@ package oracle.code.triton; import java.lang.reflect.Method; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.runtime.CodeReflection; import java.util.Optional; import java.util.stream.Stream; @@ -50,7 +50,7 @@ static int cdiv(int x, int div) { return (x + div - 1) / div; } - static CoreOps.FuncOp getJavaCodeModel(String name) { + static CoreOp.FuncOp getJavaCodeModel(String name) { Optional<Method> om = Stream.of(Functions.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .filter(m -> m.getAnnotation(CodeReflection.class) != null) diff --git a/cr-examples/triton/src/main/java/oracle/code/triton/SimpleCountedForLoopInfo.java b/cr-examples/triton/src/main/java/oracle/code/triton/SimpleCountedForLoopInfo.java index c56f3f681fc..62ddb6f1888 100644 --- a/cr-examples/triton/src/main/java/oracle/code/triton/SimpleCountedForLoopInfo.java +++ b/cr-examples/triton/src/main/java/oracle/code/triton/SimpleCountedForLoopInfo.java @@ -28,10 +28,10 @@ import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; import java.lang.reflect.code.analysis.Patterns; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.CoreOps.VarAccessOp.VarLoadOp; -import java.lang.reflect.code.op.CoreOps.VarAccessOp.VarStoreOp; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.CoreOp.VarAccessOp.VarLoadOp; +import java.lang.reflect.code.op.CoreOp.VarAccessOp.VarStoreOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.type.JavaType; import java.util.ArrayList; import java.util.List; @@ -41,9 +41,9 @@ // @@@ Very basic, limited, and partially correct public class SimpleCountedForLoopInfo { - final ExtendedOps.JavaForOp fop; + final ExtendedOp.JavaForOp fop; - SimpleCountedForLoopInfo(ExtendedOps.JavaForOp fop) { + SimpleCountedForLoopInfo(ExtendedOp.JavaForOp fop) { this.fop = fop; if (fop.init().yieldType().equals(JavaType.VOID)) { @@ -63,8 +63,8 @@ public List<Op> startExpression() { } */ - Patterns.OpPattern p = opP(CoreOps.YieldOp.class, - opP(CoreOps.VarOp.class, + Patterns.OpPattern p = opP(CoreOp.YieldOp.class, + opP(CoreOp.VarOp.class, opResultP())); // match against yieldOp @@ -90,8 +90,8 @@ public List<Op> endExpression() { } */ - Patterns.OpPattern p = opP(CoreOps.YieldOp.class, - opP(CoreOps.LtOp.class, + Patterns.OpPattern p = opP(CoreOp.YieldOp.class, + opP(CoreOp.LtOp.class, opP(VarLoadOp.class, blockParameterP()), opResultP())); @@ -122,7 +122,7 @@ public List<Op> stepExpression() { Patterns.OpPattern p = opP(VarStoreOp.class, blockParameterP(), - opP(CoreOps.AddOp.class, + opP(CoreOp.AddOp.class, opP(VarLoadOp.class, blockParameterP()), opResultP())); diff --git a/cr-examples/triton/src/main/java/oracle/code/triton/TritonOps.java b/cr-examples/triton/src/main/java/oracle/code/triton/TritonOps.java index 60ab3600ebc..eb7cbad2d01 100644 --- a/cr-examples/triton/src/main/java/oracle/code/triton/TritonOps.java +++ b/cr-examples/triton/src/main/java/oracle/code/triton/TritonOps.java @@ -86,7 +86,7 @@ static Map<String, FuncOp> createTable(Body body) { for (var op : body.entryBlock().ops()) { if (op instanceof FuncOp fop) { table.put(fop.funcName(), fop); - } else if (op instanceof CoreOps.UnreachableOp _) { + } else if (op instanceof CoreOp.UnreachableOp _) { // no operation } else { throw new IllegalArgumentException("Bad operation in module: " + op); @@ -115,7 +115,7 @@ public ModuleOp transform(OpTransformer ot) { entryBlock.op(f); table.put(f.funcName(), f); } - entryBlock.op(CoreOps.unreachable()); + entryBlock.op(CoreOp.unreachable()); this.table = Collections.unmodifiableMap(table); this.body = bodyC.build(this); } diff --git a/cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java b/cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java index 1d5aca23399..48e5fa22c29 100644 --- a/cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java +++ b/cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java @@ -31,15 +31,15 @@ import java.lang.reflect.Method; import java.lang.reflect.code.*; import java.lang.reflect.code.analysis.SSA; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.type.JavaType; import java.lang.reflect.code.type.VarType; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; public final class TritonTransformer { @@ -188,7 +188,7 @@ public static <O extends Op & Op.Invokable> void typeCheckKernel( TypeElement t = checkWithTypeInterpreter(op, iop.invokeDescriptor().name(), valueTypeMap); valueTypeMap.put(op.result(), t); } - case ExtendedOps.JavaForOp fop -> { + case ExtendedOp.JavaForOp fop -> { SimpleCountedForLoopInfo li = new SimpleCountedForLoopInfo(fop); opData.put(fop, li); @@ -203,7 +203,7 @@ public static <O extends Op & Op.Invokable> void typeCheckKernel( } case TestOperation _ -> { } - case ExtendedOps.JavaContinueOp _ -> { + case ExtendedOp.JavaContinueOp _ -> { } case YieldOp _ -> { } @@ -622,7 +622,7 @@ static Block.Builder transformToTritonOperation(Block.Builder kblock, Op op, // contributing to the computation Value a = op.operands().get(0); TensorType aType = (TensorType) valueTypeMap.get(a); - Op.Result result = kblock.op(CoreOps.constant(iop.resultType(), aType)); + Op.Result result = kblock.op(CoreOp.constant(iop.resultType(), aType)); cc.mapValue(op.result(), result); valueTypeMap.put(result, aType); } @@ -640,7 +640,7 @@ static Block.Builder transformToTritonOperation(Block.Builder kblock, Op op, cc.mapValue(op.result(), result); } } - case ExtendedOps.JavaForOp fop -> { + case ExtendedOp.JavaForOp fop -> { transformToSCFFor(cc, kblock, fop, valueTypeMap, opData, fsymTable); } case ReturnOp rop -> { @@ -656,7 +656,7 @@ static Block.Builder transformToTritonOperation(Block.Builder kblock, Op op, return kblock; } - static void transformToSCFFor(CopyContext cc, Block.Builder kblock, ExtendedOps.JavaForOp fop, + static void transformToSCFFor(CopyContext cc, Block.Builder kblock, ExtendedOp.JavaForOp fop, Map<Value, TypeElement> valueTypeMap, Map<Op, Object> opData, Map<String, TritonOps.FuncOp> fsymTable) { Body body = fop.loopBody(); @@ -727,7 +727,7 @@ static void transformToSCFFor(CopyContext cc, Block.Builder kblock, ExtendedOps. // Transform the Java for body into the SCF for body builder.transformBody(body, List.of(), (block, op) -> { // Yield iter values - if (op instanceof ExtendedOps.JavaContinueOp) { + if (op instanceof ExtendedOp.JavaContinueOp) { // Replace with yield of loaded vars List<Value> yieldValues = new ArrayList<>(); for (Value value : capturedAndStoredVars) { @@ -944,7 +944,7 @@ public Value joinShape(TensorType rType, Op.Result r, // Replace with constant operation to produce tensor type. // Result may be used, but transitively it will be removed due to no uses // contributing to the computation - return block.op(CoreOps.constant(JavaType.type(TensorType.class), r.type())); + return block.op(CoreOp.constant(JavaType.type(TensorType.class), r.type())); } diff --git a/cr-examples/triton/src/test/java/oracle/code/triton/TritonTestExtension.java b/cr-examples/triton/src/test/java/oracle/code/triton/TritonTestExtension.java index 4af46d109d9..b96d1e1e58a 100644 --- a/cr-examples/triton/src/test/java/oracle/code/triton/TritonTestExtension.java +++ b/cr-examples/triton/src/test/java/oracle/code/triton/TritonTestExtension.java @@ -34,7 +34,7 @@ import java.lang.annotation.Target; import java.lang.reflect.Method; import java.lang.reflect.code.TypeElement; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.parser.OpParser; import java.lang.reflect.code.type.JavaType; import java.lang.runtime.CodeReflection; @@ -94,12 +94,12 @@ public TritonOps.ModuleOp expectedTritonKernel(TritonCodeModel tcm) { TritonOps.FACTORY.andThen(ArithMathOps.FACTORY) .andThen(TritonTestOps.FACTORY) .andThen(SCFOps.FACTORY) - .andThen(CoreOps.FACTORY), + .andThen(CoreOp.FACTORY), TritonOps.TYPE_FACTORY, tcm.value()).get(0); } - void test(CoreOps.FuncOp javaKernel, + void test(CoreOp.FuncOp javaKernel, List<? extends TypeElement> argTypes, TritonOps.ModuleOp expectedTritonKernel, boolean doSSA) { diff --git a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 468ef9f02a7..80db55355e5 100644 --- a/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -34,7 +34,7 @@ import java.io.Serializable; import java.lang.constant.ConstantDescs; -import java.lang.reflect.code.op.CoreOps.FuncOp; +import java.lang.reflect.code.op.CoreOp.FuncOp; import java.lang.reflect.code.Quoted; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.code.parser.OpParser; diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java index 610a5173ab4..e6fa4d8e6f1 100644 --- a/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/src/java.base/share/classes/java/lang/reflect/Method.java @@ -45,8 +45,7 @@ import sun.reflect.annotation.AnnotationParser; import java.lang.annotation.Annotation; import java.lang.annotation.AnnotationFormatError; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.parser.OpParser; import java.nio.ByteBuffer; @@ -54,7 +53,7 @@ import java.util.Optional; import java.util.StringJoiner; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; /** * A {@code Method} provides information about, and access to, a single method @@ -297,7 +296,7 @@ private Optional<FuncOp> createCodeModel() { FuncOp op; try { - List<Op> ops = OpParser.fromString(ExtendedOps.FACTORY, modelText); + List<Op> ops = OpParser.fromString(ExtendedOp.FACTORY, modelText); op = (FuncOp) ops.get(0); } catch (RuntimeException e) { // @@@ Error or Exception? diff --git a/src/java.base/share/classes/java/lang/reflect/code/Block.java b/src/java.base/share/classes/java/lang/reflect/code/Block.java index 592606148cd..5be9c2333ca 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/Block.java +++ b/src/java.base/share/classes/java/lang/reflect/code/Block.java @@ -25,14 +25,14 @@ package java.lang.reflect.code; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.*; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.branch; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.branch; /** * A (basic) block containing an ordered sequence of operations, where the last operation is @@ -71,11 +71,11 @@ public Set<Value> dependsOn() { * * @apiNote * This method may be used to pattern match on the returned result: - * {@snippet lang = "java" : - * if (p.invokableOperation() instanceof CoreOps.FuncOp f) { + * {@snippet lang = "java": + * if (p.invokableOperation() instanceof CoreOp.FuncOp f) { * assert f.parameters().indexOf(p) == p.index(); // @link substring="parameters()" target="Op.Invokable#parameters()" * } - * } + *} * * @return the invokable operation, otherwise {@code null} if the operation * is not an instance of {@link Op.Invokable}. @@ -630,7 +630,7 @@ public <O extends Op & Op.Invokable> Block.Builder inline(O invokableOp, List<? // Create new context, ensuring inlining is isolated transformBody(invokableOp.body(), args, CopyContext.create(), (block, op) -> { // If the return operation is associated with the invokable operation - if (op instanceof CoreOps.ReturnOp rop && getNearestInvokeableAncestorOp(op) == invokableOp) { + if (op instanceof CoreOp.ReturnOp rop && getNearestInvokeableAncestorOp(op) == invokableOp) { // Compute the return block Block.Builder returnBlock = returnBlocks.computeIfAbsent(rop.ancestorBody(), _body -> { Block.Builder rb; diff --git a/src/java.base/share/classes/java/lang/reflect/code/CodeElement.java b/src/java.base/share/classes/java/lang/reflect/code/CodeElement.java index 55ca3af6a19..9affaa1c6b0 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/CodeElement.java +++ b/src/java.base/share/classes/java/lang/reflect/code/CodeElement.java @@ -38,6 +38,7 @@ * * @param <E> the code element type * @param <C> the child code element type. + * @sealedGraph */ // @@@ E may not be needed public sealed interface CodeElement< diff --git a/src/java.base/share/classes/java/lang/reflect/code/CodeItem.java b/src/java.base/share/classes/java/lang/reflect/code/CodeItem.java index 2f010717ad6..9fb22953ac5 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/CodeItem.java +++ b/src/java.base/share/classes/java/lang/reflect/code/CodeItem.java @@ -2,6 +2,7 @@ /** * A code item, one of {@link CodeElement}, {@link Value}, or {@link TypeElement}. + * @sealedGraph */ public sealed interface CodeItem permits CodeElement, Value, TypeElement { diff --git a/src/java.base/share/classes/java/lang/reflect/code/Value.java b/src/java.base/share/classes/java/lang/reflect/code/Value.java index a7593b3055d..91df1c30efc 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/Value.java +++ b/src/java.base/share/classes/java/lang/reflect/code/Value.java @@ -32,8 +32,9 @@ /** * A value, that is the result of an operation or a block parameter. + * @sealedGraph */ -public abstract sealed class Value implements Comparable<Value>, CodeItem +public sealed abstract class Value implements Comparable<Value>, CodeItem permits Block.Parameter, Op.Result { final Block block; final TypeElement type; diff --git a/src/java.base/share/classes/java/lang/reflect/code/analysis/Patterns.java b/src/java.base/share/classes/java/lang/reflect/code/analysis/Patterns.java index 3c3ff2a2fdf..8749e36e4ab 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/analysis/Patterns.java +++ b/src/java.base/share/classes/java/lang/reflect/code/analysis/Patterns.java @@ -29,7 +29,7 @@ import java.lang.reflect.code.Op; import java.lang.reflect.code.CodeElement; import java.lang.reflect.code.Value; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.*; import java.util.function.BiFunction; import java.util.function.Predicate; @@ -305,7 +305,7 @@ void resetOnNoMatch() { /** * A pattern matching against a value or operation. */ - public static sealed abstract class Pattern { + public sealed static abstract class Pattern { Pattern() { } @@ -494,7 +494,7 @@ public static OpPattern opP(Class<?> opClass, Pattern... patterns) { } /** - * Creates an operation pattern that tests if the operation is a {@link CoreOps.ConstantOp constant} operation + * Creates an operation pattern that tests if the operation is a {@link CoreOp.ConstantOp constant} operation * and whose constant value is equal to the given value. * This operation pattern matches an operation if the test returns {@code true}. * @@ -503,7 +503,7 @@ public static OpPattern opP(Class<?> opClass, Pattern... patterns) { */ public static OpPattern constantP(Object value) { return opP(op -> { - if (op instanceof CoreOps.ConstantOp cop) { + if (op instanceof CoreOp.ConstantOp cop) { return Objects.equals(value, cop.value()); } diff --git a/src/java.base/share/classes/java/lang/reflect/code/analysis/SSA.java b/src/java.base/share/classes/java/lang/reflect/code/analysis/SSA.java index 2bf8e1ce66b..abf6f3b9e41 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/analysis/SSA.java +++ b/src/java.base/share/classes/java/lang/reflect/code/analysis/SSA.java @@ -26,7 +26,7 @@ package java.lang.reflect.code.analysis; import java.lang.reflect.code.*; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; @@ -62,12 +62,12 @@ private SSA() { * @param <T> the invokable type */ public static <T extends Op & Op.Invokable> T transform(T iop) { - Map<Block, Set<CoreOps.VarOp>> joinPoints = new HashMap<>(); - Map<CoreOps.VarAccessOp.VarLoadOp, Object> loadValues = new HashMap<>(); + Map<Block, Set<CoreOp.VarOp>> joinPoints = new HashMap<>(); + Map<CoreOp.VarAccessOp.VarLoadOp, Object> loadValues = new HashMap<>(); Map<Block.Reference, List<Object>> joinSuccessorValues = new HashMap<>(); Map<Body, Boolean> visited = new HashMap<>(); - Map<Block, Map<CoreOps.VarOp, Block.Parameter>> joinBlockArguments = new HashMap<>(); + Map<Block, Map<CoreOp.VarOp, Block.Parameter>> joinBlockArguments = new HashMap<>(); @SuppressWarnings("unchecked") T liop = (T) iop.transform(CopyContext.create(), (block, op) -> { // Compute join points and value mappings for body @@ -77,9 +77,9 @@ public static <T extends Op & Op.Invokable> T transform(T iop) { return true; }); - if (op instanceof CoreOps.VarOp || op instanceof CoreOps.VarAccessOp) { + if (op instanceof CoreOp.VarOp || op instanceof CoreOp.VarAccessOp) { // Drop var operations - if (op instanceof CoreOps.VarAccessOp.VarLoadOp vl) { + if (op instanceof CoreOp.VarAccessOp.VarLoadOp vl) { // Replace result of load Object loadValue = loadValues.get(vl); CopyContext cc = block.context(); @@ -130,7 +130,7 @@ public static <T extends Op & Op.Invokable> T transform(T iop) { return liop; } - record VarOpBlockArgument(Block b, CoreOps.VarOp vop) { + record VarOpBlockArgument(Block b, CoreOp.VarOp vop) { } // @@@ Check for var uses in exception regions @@ -138,10 +138,10 @@ record VarOpBlockArgument(Block b, CoreOps.VarOp vop) { // to in an exception region and accessed from an associated catch region static void variableToValue(Body body, - Map<Block, Set<CoreOps.VarOp>> joinPoints, - Map<CoreOps.VarAccessOp.VarLoadOp, Object> loadValues, + Map<Block, Set<CoreOp.VarOp>> joinPoints, + Map<CoreOp.VarAccessOp.VarLoadOp, Object> loadValues, Map<Block.Reference, List<Object>> joinSuccessorValues) { - Map<CoreOps.VarOp, Deque<Object>> variableStack = new HashMap<>(); + Map<CoreOp.VarOp, Deque<Object>> variableStack = new HashMap<>(); Node top = buildDomTree(body.entryBlock(), body.immediateDominators()); variableToValue(top, variableStack, joinPoints, loadValues, joinSuccessorValues); } @@ -161,16 +161,16 @@ static void variableToValue(Body body, * Section 5.2 and Figure 12. */ static void variableToValue(Node n, - Map<CoreOps.VarOp, Deque<Object>> variableStack, - Map<Block, Set<CoreOps.VarOp>> joinPoints, - Map<CoreOps.VarAccessOp.VarLoadOp, Object> loadValues, + Map<CoreOp.VarOp, Deque<Object>> variableStack, + Map<Block, Set<CoreOp.VarOp>> joinPoints, + Map<CoreOp.VarAccessOp.VarLoadOp, Object> loadValues, Map<Block.Reference, List<Object>> joinSuccessorValues) { int size = n.b().ops().size(); // Check if V is associated with block argument (phi) // Push argument onto V's stack { - Set<CoreOps.VarOp> varOps = joinPoints.get(n.b()); + Set<CoreOp.VarOp> varOps = joinPoints.get(n.b()); if (varOps != null) { varOps.forEach(v -> { assert variableStack.get(v) != null; @@ -183,24 +183,24 @@ static void variableToValue(Node n, for (int i = 0; i < size - 1; i++) { Op op = n.b().ops().get(i); - if (op instanceof CoreOps.VarOp varOp) { + if (op instanceof CoreOp.VarOp varOp) { // Initial value assigned to variable Value current = op.operands().get(0); variableStack.computeIfAbsent(varOp, _k -> new ArrayDeque<>()) .push(current); - } else if (op instanceof CoreOps.VarAccessOp.VarStoreOp storeOp) { + } else if (op instanceof CoreOp.VarAccessOp.VarStoreOp storeOp) { // Value assigned to variable Value current = op.operands().get(1); variableStack.computeIfAbsent(storeOp.varOp(), _k -> new ArrayDeque<>()) .push(current); - } else if (op instanceof CoreOps.VarAccessOp.VarLoadOp loadOp) { + } else if (op instanceof CoreOp.VarAccessOp.VarLoadOp loadOp) { Object to = variableStack.get(loadOp.varOp()).peek(); loadValues.put(loadOp, to); } else if (op instanceof Op.Nested) { // Traverse descendant variable loads for variables // declared in the block's parent body op.traverse(null, (o, codeElement) -> { - if (o instanceof CoreOps.VarAccessOp.VarLoadOp loadOp && + if (o instanceof CoreOp.VarAccessOp.VarLoadOp loadOp && loadOp.varOp().ancestorBody() == op.ancestorBody()) { Object to = variableStack.get(loadOp.varOp()).peek(); loadValues.put(loadOp, to); @@ -212,7 +212,7 @@ static void variableToValue(Node n, // Add successor args for joint points for (Block.Reference succ : n.b().successors()) { - Set<CoreOps.VarOp> varOps = joinPoints.get(succ.targetBlock()); + Set<CoreOp.VarOp> varOps = joinPoints.get(succ.targetBlock()); if (varOps != null) { List<Object> joinValues = varOps.stream() .map(vop -> variableStack.get(vop).peek()).toList(); @@ -231,7 +231,7 @@ static void variableToValue(Node n, // Pop off values for variables { - Set<CoreOps.VarOp> varOps = joinPoints.get(n.b()); + Set<CoreOp.VarOp> varOps = joinPoints.get(n.b()); if (varOps != null) { varOps.forEach(v -> { variableStack.get(v).pop(); @@ -241,9 +241,9 @@ static void variableToValue(Node n, for (int i = 0; i < size - 1; i++) { Op op = n.b().ops().get(i); - if (op instanceof CoreOps.VarOp varOp) { + if (op instanceof CoreOp.VarOp varOp) { variableStack.get(varOp).pop(); - } else if (op instanceof CoreOps.VarAccessOp.VarStoreOp storeOp) { + } else if (op instanceof CoreOp.VarAccessOp.VarStoreOp storeOp) { variableStack.get(storeOp.varOp()).pop(); } } @@ -268,9 +268,9 @@ static void variableToValue(Node n, * @implNote See "Efficiently Computing Static Single Assignment Form and the Control Dependence Graph" by Ron Cytron et. al. * Section 5.1 and Figure 11. */ - public static void findJoinPoints(Body body, Map<Block, Set<CoreOps.VarOp>> joinPoints) { + public static void findJoinPoints(Body body, Map<Block, Set<CoreOp.VarOp>> joinPoints) { Map<Block, Set<Block>> df = body.dominanceFrontier(); - Map<CoreOps.VarOp, Set<Block>> a = findVarStores(body); + Map<CoreOp.VarOp, Set<Block>> a = findVarStores(body); int iterCount = 0; int[] hasAlready = new int[body.blocks().size()]; @@ -278,7 +278,7 @@ public static void findJoinPoints(Body body, Map<Block, Set<CoreOps.VarOp>> join Deque<Block> w = new ArrayDeque<>(); - for (CoreOps.VarOp v : a.keySet()) { + for (CoreOp.VarOp v : a.keySet()) { iterCount++; for (Block x : a.get(v)) { @@ -310,9 +310,9 @@ public static void findJoinPoints(Body body, Map<Block, Set<CoreOps.VarOp>> join // Returns map of variable to blocks that contain stores to the variables declared in the body // Throws ISE if a descendant store operation is encountered // @@@ Compute map for whole tree, then traverse keys with filter - static Map<CoreOps.VarOp, Set<Block>> findVarStores(Body r) { + static Map<CoreOp.VarOp, Set<Block>> findVarStores(Body r) { return r.traverse(new LinkedHashMap<>(), CodeElement.opVisitor((stores, op) -> { - if (op instanceof CoreOps.VarAccessOp.VarStoreOp storeOp) { + if (op instanceof CoreOp.VarAccessOp.VarStoreOp storeOp) { if (storeOp.varOp().ancestorBody() != storeOp.ancestorBody()) { throw new IllegalStateException("Descendant variable store operation"); } diff --git a/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java b/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java index d797550878c..824630fecb7 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java +++ b/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeGenerator.java @@ -29,7 +29,8 @@ import java.lang.classfile.CodeBuilder; import java.lang.classfile.Label; import java.lang.constant.*; -import java.lang.reflect.code.op.CoreOps.*; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.CoreOp.*; import java.lang.classfile.ClassBuilder; import java.lang.classfile.Opcode; @@ -37,7 +38,6 @@ import java.lang.classfile.attribute.ConstantValueAttribute; import java.lang.invoke.LambdaMetafactory; import java.lang.reflect.code.Block; -import java.lang.reflect.code.op.CoreOps; import java.lang.reflect.code.Op; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -177,7 +177,7 @@ private static <O extends Op & Op.Invokable> void generateMethod(MethodHandles.L } private record Slot(int slot, TypeKind typeKind) {} - private record ExceptionRegionWithBlocks(CoreOps.ExceptionRegionEnter ere, BitSet blocks) {} + private record ExceptionRegionWithBlocks(CoreOp.ExceptionRegionEnter ere, BitSet blocks) {} private final MethodHandles.Lookup lookup; private final ClassDesc className; @@ -262,7 +262,7 @@ private void storeIfUsed(Value v) { private Slot load(Value v) { if (v instanceof Op.Result or && - or.op() instanceof CoreOps.ConstantOp constantOp && + or.op() instanceof CoreOp.ConstantOp constantOp && !constantOp.resultType().equals(JavaType.J_L_CLASS)) { cob.constantInstruction(((Constable)constantOp.value()).describeConstable().orElseThrow()); return null; @@ -339,7 +339,7 @@ private static boolean isFirstOperand(Op nextOp, Op.Result opr) { case LambdaOp op -> !op.capturedValues().isEmpty() && op.capturedValues().getFirst() == opr; // Conditional branch may delegate to its binary test operation - case ConditionalBranchOp op when getConditionForCondBrOp(op) instanceof CoreOps.BinaryTestOp bto -> + case ConditionalBranchOp op when getConditionForCondBrOp(op) instanceof CoreOp.BinaryTestOp bto -> isFirstOperand(bto, opr); // Var store effective first operand is not the first one case VarAccessOp.VarStoreOp op -> @@ -360,7 +360,7 @@ private static boolean isNextUse(Op.Result opr) { return isFirstOperand(nextOp, opr); } - private static boolean isConditionForCondBrOp(CoreOps.BinaryTestOp op) { + private static boolean isConditionForCondBrOp(CoreOp.BinaryTestOp op) { // Result of op has one use as the operand of a CondBrOp op, // and both ops are in the same block @@ -381,7 +381,7 @@ private static boolean isConditionForCondBrOp(CoreOps.BinaryTestOp op) { } } - return use.op() instanceof CoreOps.ConditionalBranchOp; + return use.op() instanceof CoreOp.ConditionalBranchOp; } private static ClassDesc toClassDesc(TypeElement t) { @@ -437,13 +437,13 @@ private void generate() { Block b = blocks.get(blockIndex); Op top = b.terminatingOp(); switch (top) { - case CoreOps.BranchOp bop -> + case CoreOp.BranchOp bop -> setExceptionRegionStack(bop.branch(), activeRegionStack); - case CoreOps.ConditionalBranchOp cop -> { + case CoreOp.ConditionalBranchOp cop -> { setExceptionRegionStack(cop.falseBranch(), activeRegionStack); setExceptionRegionStack(cop.trueBranch(), activeRegionStack); } - case CoreOps.ExceptionRegionEnter er -> { + case CoreOp.ExceptionRegionEnter er -> { for (Block.Reference catchBlock : er.catchBlocks().reversed()) { catchingBlocks.set(catchBlock.targetBlock().index()); setExceptionRegionStack(catchBlock, activeRegionStack); @@ -454,7 +454,7 @@ private void generate() { allExceptionRegions.add(newNode); setExceptionRegionStack(er.start(), activeRegionStack); } - case CoreOps.ExceptionRegionExit er -> { + case CoreOp.ExceptionRegionExit er -> { activeRegionStack = (BitSet)activeRegionStack.clone(); activeRegionStack.clear(activeRegionStack.length() - 1); setExceptionRegionStack(er.end(), activeRegionStack); @@ -882,7 +882,7 @@ private void generate() { } Op top = b.terminatingOp(); switch (top) { - case CoreOps.ReturnOp op -> { + case CoreOp.ReturnOp op -> { Value a = op.returnValue(); if (a == null) { cob.return_(); @@ -900,7 +900,7 @@ private void generate() { cob.goto_(getLabel(op.branch())); } case ConditionalBranchOp op -> { - if (getConditionForCondBrOp(op) instanceof CoreOps.BinaryTestOp btop) { + if (getConditionForCondBrOp(op) instanceof CoreOp.BinaryTestOp btop) { // Processing of the BinaryTestOp was deferred, so it can be merged with CondBrOp processOperands(btop); conditionalBranch(btop, op.trueBranch(), op.falseBranch()); @@ -958,7 +958,7 @@ private void adjustRightTypeToInt(Op op) { } } - private static Op getConditionForCondBrOp(CoreOps.ConditionalBranchOp op) { + private static Op getConditionForCondBrOp(CoreOp.ConditionalBranchOp op) { Value p = op.predicate(); if (p.uses().size() != 1) { return null; @@ -1129,17 +1129,17 @@ static DirectMethodHandleDesc resolveToMethodHandleDesc(MethodHandles.Lookup l, return dmhd; } - static CoreOps.FuncOp quote(CoreOps.LambdaOp lop) { + static CoreOp.FuncOp quote(CoreOp.LambdaOp lop) { List<Value> captures = lop.capturedValues(); // Build the function type List<TypeElement> params = captures.stream() .map(v -> v.type() instanceof VarType vt ? vt.valueType() : v.type()) .toList(); - FunctionType ft = FunctionType.functionType(CoreOps.QuotedOp.QUOTED_TYPE, params); + FunctionType ft = FunctionType.functionType(CoreOp.QuotedOp.QUOTED_TYPE, params); // Build the function that quotes the lambda - return CoreOps.func("q", ft).body(b -> { + return CoreOp.func("q", ft).body(b -> { // Create variables as needed and obtain the captured values // for the copied lambda List<Value> outputCaptures = new ArrayList<>(); @@ -1147,7 +1147,7 @@ static CoreOps.FuncOp quote(CoreOps.LambdaOp lop) { Value c = captures.get(i); Block.Parameter p = b.parameters().get(i); if (c.type() instanceof VarType _) { - Value var = b.op(CoreOps.var(String.valueOf(i), p)); + Value var = b.op(CoreOp.var(String.valueOf(i), p)); outputCaptures.add(var); } else { outputCaptures.add(p); @@ -1155,7 +1155,7 @@ static CoreOps.FuncOp quote(CoreOps.LambdaOp lop) { } // Quoted the lambda expression - Value q = b.op(CoreOps.quoted(b.parentBody(), qb -> { + Value q = b.op(CoreOp.quoted(b.parentBody(), qb -> { // Map the lambda's parent block to the quoted block // We are copying lop in the context of the quoted block qb.context().mapBlock(lop.parentBlock(), qb); @@ -1164,7 +1164,7 @@ static CoreOps.FuncOp quote(CoreOps.LambdaOp lop) { // Return the lambda to be copied in the quoted operation return lop; })); - b.op(CoreOps._return(q)); + b.op(CoreOp._return(q)); }); } } diff --git a/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeLift.java b/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeLift.java index d6bbac71405..1cdba043195 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeLift.java +++ b/src/java.base/share/classes/java/lang/reflect/code/bytecode/BytecodeLift.java @@ -42,7 +42,7 @@ import java.lang.reflect.code.Block; import java.lang.reflect.code.TypeElement; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; import java.lang.reflect.code.type.FieldRef; @@ -122,9 +122,9 @@ private BytecodeLift(Block.Builder entryBlock, MethodModel methodModel) { private void varStore(int slot, TypeKind tk, Value value) { varMap.compute(varName(slot, tk), (varName, var) -> { if (var == null) { - return op(CoreOps.var(varName, value)); + return op(CoreOp.var(varName, value)); } else { - op(CoreOps.varStore(var, value)); + op(CoreOp.varStore(var, value)); return var; } }); @@ -141,11 +141,11 @@ private Op.Result op(Op op) { } // Lift to core dialect - public static CoreOps.FuncOp lift(byte[] classdata, String methodName) { + public static CoreOp.FuncOp lift(byte[] classdata, String methodName) { return lift(classdata, methodName, null); } - public static CoreOps.FuncOp lift(byte[] classdata, String methodName, MethodTypeDesc methodType) { + public static CoreOp.FuncOp lift(byte[] classdata, String methodName, MethodTypeDesc methodType) { return lift(ClassFile.of( ClassFile.DebugElementsOption.DROP_DEBUG, ClassFile.LineNumbersOption.DROP_LINE_NUMBERS).parse(classdata).methods().stream() @@ -153,8 +153,8 @@ public static CoreOps.FuncOp lift(byte[] classdata, String methodName, MethodTyp .findFirst().orElseThrow(() -> new IllegalArgumentException("Unknown method: " + methodName))); } - public static CoreOps.FuncOp lift(MethodModel methodModel) { - return CoreOps.func( + public static CoreOp.FuncOp lift(MethodModel methodModel) { + return CoreOp.func( methodModel.methodName().stringValue(), MethodRef.ofNominalDescriptor(methodModel.methodTypeSymbol())).body(entryBlock -> new BytecodeLift(entryBlock, methodModel).lift()); @@ -206,7 +206,7 @@ private void lift() { if (currentBlock != null) { // Implicit goto next block, add explicitly // Use stack content as next block arguments - op(CoreOps.branch(next.successor(List.copyOf(stack)))); + op(CoreOp.branch(next.successor(List.copyOf(stack)))); } moveTo(next); // Insert relevant tryStart and construct handler blocks, all in reversed order @@ -215,7 +215,7 @@ private void lift() { Block.Builder handler = getBlock(ec.handler()); // Create start block next = newBlock(); - Op ere = CoreOps.exceptionRegionEnter(next.successor(List.copyOf(stack)), handler.successor()); + Op ere = CoreOp.exceptionRegionEnter(next.successor(List.copyOf(stack)), handler.successor()); op(ere); // Store ERE into map for exit exceptionRegionsMap.put(ec, ere.result()); @@ -227,42 +227,42 @@ private void lift() { if (lt.label() == ec.tryEnd()) { // Create exit block with parameters constructed from the stack next = newBlock(); - op(CoreOps.exceptionRegionExit(exceptionRegionsMap.get(ec), next.successor())); + op(CoreOp.exceptionRegionExit(exceptionRegionsMap.get(ec), next.successor())); moveTo(next); } } } case BranchInstruction inst when inst.opcode().isUnconditionalBranch() -> { - op(CoreOps.branch(getBlock(inst.target()).successor(List.copyOf(stack)))); + op(CoreOp.branch(getBlock(inst.target()).successor(List.copyOf(stack)))); endOfFlow(); } case BranchInstruction inst -> { // Conditional branch Value operand = stack.pop(); Op cop = switch (inst.opcode()) { - case IFNE -> CoreOps.eq(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFEQ -> CoreOps.neq(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFGE -> CoreOps.lt(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFLE -> CoreOps.gt(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFGT -> CoreOps.le(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFLT -> CoreOps.ge(operand, op(CoreOps.constant(JavaType.INT, 0))); - case IFNULL -> CoreOps.neq(operand, op(CoreOps.constant(JavaType.J_L_OBJECT, null))); - case IFNONNULL -> CoreOps.eq(operand, op(CoreOps.constant(JavaType.J_L_OBJECT, null))); - case IF_ICMPNE -> CoreOps.eq(stack.pop(), operand); - case IF_ICMPEQ -> CoreOps.neq(stack.pop(), operand); - case IF_ICMPGE -> CoreOps.lt(stack.pop(), operand); - case IF_ICMPLE -> CoreOps.gt(stack.pop(), operand); - case IF_ICMPGT -> CoreOps.le(stack.pop(), operand); - case IF_ICMPLT -> CoreOps.ge(stack.pop(), operand); - case IF_ACMPEQ -> CoreOps.neq(stack.pop(), operand); - case IF_ACMPNE -> CoreOps.eq(stack.pop(), operand); + case IFNE -> CoreOp.eq(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFEQ -> CoreOp.neq(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFGE -> CoreOp.lt(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFLE -> CoreOp.gt(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFGT -> CoreOp.le(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFLT -> CoreOp.ge(operand, op(CoreOp.constant(JavaType.INT, 0))); + case IFNULL -> CoreOp.neq(operand, op(CoreOp.constant(JavaType.J_L_OBJECT, null))); + case IFNONNULL -> CoreOp.eq(operand, op(CoreOp.constant(JavaType.J_L_OBJECT, null))); + case IF_ICMPNE -> CoreOp.eq(stack.pop(), operand); + case IF_ICMPEQ -> CoreOp.neq(stack.pop(), operand); + case IF_ICMPGE -> CoreOp.lt(stack.pop(), operand); + case IF_ICMPLE -> CoreOp.gt(stack.pop(), operand); + case IF_ICMPGT -> CoreOp.le(stack.pop(), operand); + case IF_ICMPLT -> CoreOp.ge(stack.pop(), operand); + case IF_ACMPEQ -> CoreOp.neq(stack.pop(), operand); + case IF_ACMPNE -> CoreOp.eq(stack.pop(), operand); default -> throw new UnsupportedOperationException("Unsupported branch instruction: " + inst); }; if (!stack.isEmpty()) { throw new UnsupportedOperationException("Operands on stack for branch not supported"); } Block.Builder next = currentBlock.block(); - op(CoreOps.conditionalBranch(op(cop), + op(CoreOp.conditionalBranch(op(cop), next.successor(), getBlock(inst.target()).successor())); moveTo(next); @@ -278,43 +278,43 @@ private void lift() { // addSuccessors(si.cases(), blockMap, b); // } case ReturnInstruction inst when inst.typeKind() == TypeKind.VoidType -> { - op(CoreOps._return()); + op(CoreOp._return()); endOfFlow(); } case ReturnInstruction _ -> { - op(CoreOps._return(stack.pop())); + op(CoreOp._return(stack.pop())); endOfFlow(); } case ThrowInstruction _ -> { - op(CoreOps._throw(stack.pop())); + op(CoreOp._throw(stack.pop())); endOfFlow(); } case LoadInstruction inst -> { - stack.push(op(CoreOps.varLoad(var(inst.slot(), inst.typeKind())))); + stack.push(op(CoreOp.varLoad(var(inst.slot(), inst.typeKind())))); } case StoreInstruction inst -> { varStore(inst.slot(), inst.typeKind(), stack.pop()); } case IncrementInstruction inst -> { - varStore(inst.slot(), TypeKind.IntType, op(CoreOps.add( - op(CoreOps.varLoad(var(inst.slot(), TypeKind.IntType))), - op(CoreOps.constant(JavaType.INT, inst.constant()))))); + varStore(inst.slot(), TypeKind.IntType, op(CoreOp.add( + op(CoreOp.varLoad(var(inst.slot(), TypeKind.IntType))), + op(CoreOp.constant(JavaType.INT, inst.constant()))))); } case ConstantInstruction inst -> { stack.push(op(switch (inst.constantValue()) { - case ClassDesc v -> CoreOps.constant(JavaType.J_L_CLASS, JavaType.type(v)); - case Double v -> CoreOps.constant(JavaType.DOUBLE, v); - case Float v -> CoreOps.constant(JavaType.FLOAT, v); - case Integer v -> CoreOps.constant(JavaType.INT, v); - case Long v -> CoreOps.constant(JavaType.LONG, v); - case String v -> CoreOps.constant(JavaType.J_L_STRING, v); + case ClassDesc v -> CoreOp.constant(JavaType.J_L_CLASS, JavaType.type(v)); + case Double v -> CoreOp.constant(JavaType.DOUBLE, v); + case Float v -> CoreOp.constant(JavaType.FLOAT, v); + case Integer v -> CoreOp.constant(JavaType.INT, v); + case Long v -> CoreOp.constant(JavaType.LONG, v); + case String v -> CoreOp.constant(JavaType.J_L_STRING, v); default -> // @@@ MethodType, MethodHandle, ConstantDynamic throw new IllegalArgumentException("Unsupported constant value: " + inst.constantValue()); })); } case ConvertInstruction inst -> { - stack.push(op(CoreOps.conv(switch (inst.toType()) { + stack.push(op(CoreOp.conv(switch (inst.toType()) { case ByteType -> JavaType.BYTE; case ShortType -> JavaType.SHORT; case IntType -> JavaType.INT; @@ -331,25 +331,25 @@ private void lift() { Value operand = stack.pop(); stack.push(op(switch (inst.opcode()) { case IADD, LADD, FADD, DADD -> - CoreOps.add(stack.pop(), operand); + CoreOp.add(stack.pop(), operand); case ISUB, LSUB, FSUB, DSUB -> - CoreOps.sub(stack.pop(), operand); + CoreOp.sub(stack.pop(), operand); case IMUL, LMUL, FMUL, DMUL -> - CoreOps.mul(stack.pop(), operand); + CoreOp.mul(stack.pop(), operand); case IDIV, LDIV, FDIV, DDIV -> - CoreOps.div(stack.pop(), operand); + CoreOp.div(stack.pop(), operand); case IREM, LREM, FREM, DREM -> - CoreOps.mod(stack.pop(), operand); + CoreOp.mod(stack.pop(), operand); case INEG, LNEG, FNEG, DNEG -> - CoreOps.neg(operand); + CoreOp.neg(operand); case ARRAYLENGTH -> - CoreOps.arrayLength(operand); + CoreOp.arrayLength(operand); case IAND, LAND -> - CoreOps.and(stack.pop(), operand); + CoreOp.and(stack.pop(), operand); case IOR, LOR -> - CoreOps.or(stack.pop(), operand); + CoreOp.or(stack.pop(), operand); case IXOR, LXOR -> - CoreOps.xor(stack.pop(), operand); + CoreOp.xor(stack.pop(), operand); default -> throw new IllegalArgumentException("Unsupported operator opcode: " + inst.opcode()); })); @@ -361,15 +361,15 @@ private void lift() { JavaType.type(inst.typeSymbol())); switch (inst.opcode()) { case GETFIELD -> - stack.push(op(CoreOps.fieldLoad(fd, stack.pop()))); + stack.push(op(CoreOp.fieldLoad(fd, stack.pop()))); case GETSTATIC -> - stack.push(op(CoreOps.fieldLoad(fd))); + stack.push(op(CoreOp.fieldLoad(fd))); case PUTFIELD -> { Value value = stack.pop(); - stack.push(op(CoreOps.fieldStore(fd, stack.pop(), value))); + stack.push(op(CoreOp.fieldStore(fd, stack.pop(), value))); } case PUTSTATIC -> - stack.push(op(CoreOps.fieldStore(fd, stack.pop()))); + stack.push(op(CoreOp.fieldStore(fd, stack.pop()))); default -> throw new IllegalArgumentException("Unsupported field opcode: " + inst.opcode()); } @@ -377,11 +377,11 @@ private void lift() { case ArrayStoreInstruction _ -> { Value value = stack.pop(); Value index = stack.pop(); - op(CoreOps.arrayStoreOp(stack.pop(), index, value)); + op(CoreOp.arrayStoreOp(stack.pop(), index, value)); } case ArrayLoadInstruction _ -> { Value index = stack.pop(); - stack.push(op(CoreOps.arrayLoadOp(stack.pop(), index))); + stack.push(op(CoreOp.arrayLoadOp(stack.pop(), index))); } case InvokeInstruction inst -> { FunctionType mType = MethodRef.ofNominalDescriptor(inst.typeSymbol()); @@ -396,20 +396,20 @@ private void lift() { Op.Result result = switch (inst.opcode()) { case INVOKEVIRTUAL, INVOKEINTERFACE -> { operands.add(stack.pop()); - yield op(CoreOps.invoke(mDesc, operands.reversed())); + yield op(CoreOp.invoke(mDesc, operands.reversed())); } case INVOKESTATIC -> - op(CoreOps.invoke(mDesc, operands.reversed())); + op(CoreOp.invoke(mDesc, operands.reversed())); case INVOKESPECIAL -> { if (inst.name().equalsString(ConstantDescs.INIT_NAME)) { - yield op(CoreOps._new( + yield op(CoreOp._new( FunctionType.functionType( mDesc.refType(), mType.parameterTypes()), operands.reversed())); } else { operands.add(stack.pop()); - yield op(CoreOps.invoke(mDesc, operands.reversed())); + yield op(CoreOp.invoke(mDesc, operands.reversed())); } } default -> @@ -430,7 +430,7 @@ yield op(CoreOps._new( } } case NewPrimitiveArrayInstruction inst -> { - stack.push(op(CoreOps.newArray( + stack.push(op(CoreOp.newArray( switch (inst.typeKind()) { case BooleanType -> JavaType.BOOLEAN_ARRAY; case ByteType -> JavaType.BYTE_ARRAY; @@ -446,19 +446,19 @@ yield op(CoreOps._new( stack.pop()))); } case NewReferenceArrayInstruction inst -> { - stack.push(op(CoreOps.newArray( + stack.push(op(CoreOp.newArray( JavaType.type(inst.componentType().asSymbol().arrayType()), stack.pop()))); } case NewMultiArrayInstruction inst -> { - stack.push(op(CoreOps._new( + stack.push(op(CoreOp._new( FunctionType.functionType( JavaType.type(inst.arrayType().asSymbol()), Collections.nCopies(inst.dimensions(), JavaType.INT)), IntStream.range(0, inst.dimensions()).mapToObj(_ -> stack.pop()).toList().reversed()))); } case TypeCheckInstruction inst when inst.opcode() == Opcode.CHECKCAST -> { - stack.push(op(CoreOps.cast(JavaType.type(inst.type().asSymbol()), stack.pop()))); + stack.push(op(CoreOp.cast(JavaType.type(inst.type().asSymbol()), stack.pop()))); } case StackInstruction inst -> { switch (inst.opcode()) { diff --git a/src/java.base/share/classes/java/lang/reflect/code/interpreter/Interpreter.java b/src/java.base/share/classes/java/lang/reflect/code/interpreter/Interpreter.java index 62a4b9047f6..dc817ff0d31 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/interpreter/Interpreter.java +++ b/src/java.base/share/classes/java/lang/reflect/code/interpreter/Interpreter.java @@ -29,10 +29,10 @@ import java.lang.reflect.Array; import java.lang.reflect.Proxy; import java.lang.reflect.code.*; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.ArrayType; import java.lang.reflect.code.type.FieldRef; import java.lang.reflect.code.type.MethodRef; -import java.lang.reflect.code.op.CoreOps; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; import java.lang.reflect.code.TypeElement; @@ -128,7 +128,7 @@ void pushExceptionRegion(ExceptionRegionRecord erb) { erStack.push(erb); } - void popExceptionRegion(CoreOps.ExceptionRegionEnter ers) { + void popExceptionRegion(CoreOp.ExceptionRegionEnter ers) { if (erStack.peek().ers != ers) { // @@@ Use internal exception type throw interpreterException(new IllegalStateException("Mismatched exception regions")); @@ -156,7 +156,7 @@ Block exception(MethodHandles.Lookup l, Throwable e) { } static final class VarBox - implements CoreOps.Var<Object> { + implements CoreOp.Var<Object> { Object value; public Object value() { @@ -168,7 +168,7 @@ public Object value() { } } - record ClosureRecord(CoreOps.ClosureOp op, + record ClosureRecord(CoreOp.ClosureOp op, Map<Value, Object> capturedValues) { } @@ -184,8 +184,8 @@ TupleRecord with(int index, Object value) { } } - record ExceptionRegionRecord(BlockContext mark, CoreOps.ExceptionRegionEnter ers) - implements CoreOps.ExceptionRegion { + record ExceptionRegionRecord(BlockContext mark, CoreOp.ExceptionRegionEnter ers) + implements CoreOp.ExceptionRegion { Block match(MethodHandles.Lookup l, Throwable e) { for (Block.Reference catchBlock : ers.catchBlocks()) { Block target = catchBlock.targetBlock(); @@ -294,7 +294,7 @@ private static Object invoke(MethodHandles.Lookup l, Block first, // Execute the terminating operation Op to = bc.b.terminatingOp(); - if (to instanceof CoreOps.ConditionalBranchOp cb) { + if (to instanceof CoreOp.ConditionalBranchOp cb) { boolean p; Object bop = oc.getValue(cb.predicate()); if (bop instanceof Boolean bp) { @@ -310,27 +310,27 @@ private static Object invoke(MethodHandles.Lookup l, Block first, } Block.Reference sb = p ? cb.trueBranch() : cb.falseBranch(); oc.successor(sb); - } else if (to instanceof CoreOps.BranchOp b) { + } else if (to instanceof CoreOp.BranchOp b) { Block.Reference sb = b.branch(); oc.successor(sb); - } else if (to instanceof CoreOps.ThrowOp _throw) { + } else if (to instanceof CoreOp.ThrowOp _throw) { Throwable t = (Throwable) oc.getValue(_throw.argument()); processThrowable(oc, l, t); - } else if (to instanceof CoreOps.ReturnOp ret) { + } else if (to instanceof CoreOp.ReturnOp ret) { Value rv = ret.returnValue(); return rv == null ? null : oc.getValue(rv); - } else if (to instanceof CoreOps.YieldOp yop) { + } else if (to instanceof CoreOp.YieldOp yop) { Value yv = yop.yieldValue(); return yv == null ? null : oc.getValue(yv); - } else if (to instanceof CoreOps.ExceptionRegionEnter ers) { + } else if (to instanceof CoreOp.ExceptionRegionEnter ers) { var er = new ExceptionRegionRecord(oc.stack.peek(), ers); oc.setValue(ers.result(), er); oc.pushExceptionRegion(er); oc.successor(ers.start()); - } else if (to instanceof CoreOps.ExceptionRegionExit ere) { + } else if (to instanceof CoreOp.ExceptionRegionExit ere) { oc.popExceptionRegion(ere.regionStart()); oc.successor(ere.end()); @@ -375,13 +375,13 @@ public static <E extends Throwable> void eraseAndThrow(Throwable e) throws E { } static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { - if (o instanceof CoreOps.ConstantOp co) { + if (o instanceof CoreOp.ConstantOp co) { if (co.resultType().equals(JavaType.J_L_CLASS)) { return resolveToClass(l, (JavaType) co.value()); } else { return co.value(); } - } else if (o instanceof CoreOps.FuncCallOp fco) { + } else if (o instanceof CoreOp.FuncCallOp fco) { String name = fco.funcName(); // Find top-level op @@ -392,8 +392,8 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { // Ensure top-level op is a module and function name // is in the module's function table - if (top instanceof CoreOps.ModuleOp mop) { - CoreOps.FuncOp funcOp = mop.functionTable().get(name); + if (top instanceof CoreOp.ModuleOp mop) { + CoreOp.FuncOp funcOp = mop.functionTable().get(name); if (funcOp == null) { throw interpreterException( new IllegalStateException @@ -407,7 +407,7 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { new IllegalStateException( "Function " + name + " cannot be resolved: top level op is not a module")); } - } else if (o instanceof CoreOps.InvokeOp co) { + } else if (o instanceof CoreOp.InvokeOp co) { MethodHandle mh; if (co.hasReceiver()) { mh = methodHandle(l, co.invokeDescriptor()); @@ -418,7 +418,7 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { mh = mh.asType(target).asFixedArity(); Object[] values = o.operands().stream().map(oc::getValue).toArray(); return invoke(mh, values); - } else if (o instanceof CoreOps.NewOp no) { + } else if (o instanceof CoreOp.NewOp no) { Object[] values = o.operands().stream().map(oc::getValue).toArray(); JavaType nType = (JavaType) no.constructorType().returnType(); if (nType instanceof ArrayType at) { @@ -434,11 +434,11 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { MethodHandle mh = constructorHandle(l, no.constructorType()); return invoke(mh, values); } - } else if (o instanceof CoreOps.QuotedOp qo) { + } else if (o instanceof CoreOp.QuotedOp qo) { Map<Value, Object> capturedValues = qo.capturedValues().stream() .collect(toMap(v -> v, oc::getValue, (v, _) -> v, LinkedHashMap::new)); return new Quoted(qo.quotedOp(), capturedValues); - } else if (o instanceof CoreOps.LambdaOp lo) { + } else if (o instanceof CoreOp.LambdaOp lo) { Map<Value, Object> capturedValues = lo.capturedValues().stream() .collect(toMap(v -> v, oc::getValue, (v, _) -> v, LinkedHashMap::new)); Class<?> fi = resolveToClass(l, lo.functionalInterface()); @@ -462,36 +462,36 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { } else { return fiInstance; } - } else if (o instanceof CoreOps.ClosureOp co) { + } else if (o instanceof CoreOp.ClosureOp co) { Map<Value, Object> capturedValues = co.capturedValues().stream() .collect(toMap(v -> v, oc::getValue)); return new ClosureRecord(co, capturedValues); - } else if (o instanceof CoreOps.ClosureCallOp cco) { + } else if (o instanceof CoreOp.ClosureCallOp cco) { List<Object> values = o.operands().stream().map(oc::getValue).toList(); ClosureRecord cr = (ClosureRecord) values.get(0); return Interpreter.invoke(l, cr.op(), cr.capturedValues, values.subList(1, values.size())); - } else if (o instanceof CoreOps.VarOp vo) { + } else if (o instanceof CoreOp.VarOp vo) { return new VarBox(oc.getValue(o.operands().get(0))); - } else if (o instanceof CoreOps.VarAccessOp.VarLoadOp vlo) { - // Cast to CoreOps.Var, since the instance may have originated as an external instance + } else if (o instanceof CoreOp.VarAccessOp.VarLoadOp vlo) { + // Cast to CoreOp.Var, since the instance may have originated as an external instance // via a captured value map - CoreOps.Var<?> vb = (CoreOps.Var<?>) oc.getValue(o.operands().get(0)); + CoreOp.Var<?> vb = (CoreOp.Var<?>) oc.getValue(o.operands().get(0)); return vb.value(); - } else if (o instanceof CoreOps.VarAccessOp.VarStoreOp vso) { + } else if (o instanceof CoreOp.VarAccessOp.VarStoreOp vso) { VarBox vb = (VarBox) oc.getValue(o.operands().get(0)); vb.value = oc.getValue(o.operands().get(1)); return null; - } else if (o instanceof CoreOps.TupleOp to) { + } else if (o instanceof CoreOp.TupleOp to) { List<Object> values = o.operands().stream().map(oc::getValue).toList(); return new TupleRecord(values); - } else if (o instanceof CoreOps.TupleLoadOp tlo) { + } else if (o instanceof CoreOp.TupleLoadOp tlo) { TupleRecord tb = (TupleRecord) oc.getValue(o.operands().get(0)); return tb.getComponent(tlo.index()); - } else if (o instanceof CoreOps.TupleWithOp two) { + } else if (o instanceof CoreOp.TupleWithOp two) { TupleRecord tb = (TupleRecord) oc.getValue(o.operands().get(0)); return tb.with(two.index(), oc.getValue(o.operands().get(1))); - } else if (o instanceof CoreOps.FieldAccessOp.FieldLoadOp fo) { + } else if (o instanceof CoreOp.FieldAccessOp.FieldLoadOp fo) { if (fo.operands().isEmpty()) { VarHandle vh = fieldStaticHandle(l, fo.fieldDescriptor()); return vh.get(); @@ -500,7 +500,7 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { VarHandle vh = fieldHandle(l, fo.fieldDescriptor()); return vh.get(v); } - } else if (o instanceof CoreOps.FieldAccessOp.FieldStoreOp fo) { + } else if (o instanceof CoreOp.FieldAccessOp.FieldStoreOp fo) { if (fo.operands().size() == 1) { Object v = oc.getValue(o.operands().get(0)); VarHandle vh = fieldStaticHandle(l, fo.fieldDescriptor()); @@ -512,34 +512,34 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { vh.set(r, v); } return null; - } else if (o instanceof CoreOps.InstanceOfOp io) { + } else if (o instanceof CoreOp.InstanceOfOp io) { Object v = oc.getValue(o.operands().get(0)); return isInstance(l, io.type(), v); - } else if (o instanceof CoreOps.CastOp co) { + } else if (o instanceof CoreOp.CastOp co) { Object v = oc.getValue(o.operands().get(0)); return cast(l, co.type(), v); - } else if (o instanceof CoreOps.ArrayLengthOp) { + } else if (o instanceof CoreOp.ArrayLengthOp) { Object a = oc.getValue(o.operands().get(0)); return Array.getLength(a); - } else if (o instanceof CoreOps.ArrayAccessOp.ArrayLoadOp) { + } else if (o instanceof CoreOp.ArrayAccessOp.ArrayLoadOp) { Object a = oc.getValue(o.operands().get(0)); Object index = oc.getValue(o.operands().get(1)); return Array.get(a, (int) index); - } else if (o instanceof CoreOps.ArrayAccessOp.ArrayStoreOp) { + } else if (o instanceof CoreOp.ArrayAccessOp.ArrayStoreOp) { Object a = oc.getValue(o.operands().get(0)); Object index = oc.getValue(o.operands().get(1)); Object v = oc.getValue(o.operands().get(2)); Array.set(a, (int) index, v); return null; - } else if (o instanceof CoreOps.ArithmeticOperation || o instanceof CoreOps.TestOperation) { + } else if (o instanceof CoreOp.ArithmeticOperation || o instanceof CoreOp.TestOperation) { MethodHandle mh = opHandle(o.opName(), o.opType()); Object[] values = o.operands().stream().map(oc::getValue).toArray(); return invoke(mh, values); - } else if (o instanceof CoreOps.ConvOp) { + } else if (o instanceof CoreOp.ConvOp) { MethodHandle mh = opHandle(o.opName() + "_" + o.opType().returnType(), o.opType()); Object[] values = o.operands().stream().map(oc::getValue).toArray(); return invoke(mh, values); - } else if (o instanceof CoreOps.AssertOp _assert) { + } else if (o instanceof CoreOp.AssertOp _assert) { //Note: The nature of asserts and munged bodies may require a re-visiting. //This code seems to work without poisoning contexts. See TestAssert.java in tests for relevant test coverage. Body testBody = _assert.bodies.get(0); @@ -554,7 +554,7 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { } } return null; - } else if (o instanceof CoreOps.ConcatOp) { + } else if (o instanceof CoreOp.ConcatOp) { return o.operands().stream() .map(oc::getValue) .map(String::valueOf) @@ -570,13 +570,13 @@ static Object exec(MethodHandles.Lookup l, OpContext oc, Op o) { try { INVOKE_LAMBDA_MH = MethodHandles.lookup().findStatic(Interpreter.class, "invokeLambda", MethodType.methodType(Object.class, MethodHandles.Lookup.class, - CoreOps.LambdaOp.class, Map.class, Object[].class)); + CoreOp.LambdaOp.class, Map.class, Object[].class)); } catch (Throwable t) { throw new InternalError(t); } } - static Object invokeLambda(MethodHandles.Lookup l, CoreOps.LambdaOp op, Map<Value, Object> capturedValues, Object[] args) { + static Object invokeLambda(MethodHandles.Lookup l, CoreOp.LambdaOp op, Map<Value, Object> capturedValues, Object[] args) { return invoke(l, op, capturedValues, args); } diff --git a/src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java b/src/java.base/share/classes/java/lang/reflect/code/op/CoreOp.java similarity index 95% rename from src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java rename to src/java.base/share/classes/java/lang/reflect/code/op/CoreOp.java index 028b17e28e9..428d358c7ea 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/op/CoreOps.java +++ b/src/java.base/share/classes/java/lang/reflect/code/op/CoreOp.java @@ -36,26 +36,37 @@ import java.util.function.Predicate; /** - * The set of core operations. A code model, produced by the Java compiler from Java program source and lowered to - * consist only of core operations, represents the same Java program and preserves the program meaning as defined by - * the Java Language Specification. + * The top-level operation class for the set of enclosed core operations. + * <p> + * A code model, produced by the Java compiler from Java program source, may consist of extended operations and core + * operations. Such a model represents the same Java program and preserves the program meaning as defined by the + * Java Language Specification */ -public final class CoreOps { - +public sealed abstract class CoreOp extends ExternalizableOp { // Split string to ensure the name does not get rewritten // when the script copies this source to the jdk.compiler module static final String PACKAGE_NAME = "java.lang" + ".reflect.code"; - static final String CoreOps_CLASS_NAME = PACKAGE_NAME + "." + CoreOps.class.getSimpleName(); + static final String CoreOp_CLASS_NAME = PACKAGE_NAME + "." + CoreOp.class.getSimpleName(); + + protected CoreOp(Op that, CopyContext cc) { + super(that, cc); + } + + protected CoreOp(String name, List<? extends Value> operands) { + super(name, operands); + } - private CoreOps() { + protected CoreOp(ExternalizedOp def) { + super(def); } + /** * The function operation, that can model a Java method. */ @OpFactory.OpDeclaration(FuncOp.NAME) - public static final class FuncOp extends ExternalizableOp implements Op.Invokable, Op.Isolated, Op.Lowerable { + public static final class FuncOp extends CoreOp implements Op.Invokable, Op.Isolated, Op.Lowerable { public static class Builder { final Body.Builder ancestorBody; @@ -179,7 +190,7 @@ public TypeElement resultType() { */ // @@@ stack effects equivalent to the call operation as if the function were a Java method? @OpFactory.OpDeclaration(FuncCallOp.NAME) - public static final class FuncCallOp extends ExternalizableOp { + public static final class FuncCallOp extends CoreOp { public static final String NAME = "func.call"; public static final String ATTRIBUTE_FUNC_NAME = NAME + ".name"; @@ -244,7 +255,7 @@ public TypeElement resultType() { * and creating a symbol table of function name to function */ @OpFactory.OpDeclaration(ModuleOp.NAME) - public static final class ModuleOp extends ExternalizableOp implements Op.Isolated { + public static final class ModuleOp extends CoreOp implements Op.Isolated { public static final String NAME = "module"; @@ -328,7 +339,7 @@ public TypeElement resultType() { * The quoted operation, that models the quoting of an operation. */ @OpFactory.OpDeclaration(QuotedOp.NAME) - public static final class QuotedOp extends ExternalizableOp implements Op.Nested, Op.Lowerable, Op.Pure { + public static final class QuotedOp extends CoreOp implements Op.Nested, Op.Lowerable, Op.Pure { public static final String NAME = "quoted"; // Type name must be the same in the java.base and jdk.compiler module @@ -414,7 +425,7 @@ public TypeElement resultType() { * The lambda operation, that can model a Java lambda expression. */ @OpFactory.OpDeclaration(LambdaOp.NAME) - public static final class LambdaOp extends ExternalizableOp implements Op.Invokable, Op.Lowerable { + public static final class LambdaOp extends CoreOp implements Op.Invokable, Op.Lowerable { public static class Builder { final Body.Builder ancestorBody; @@ -548,7 +559,7 @@ public Optional<InvokeOp> methodReference() { } Map<Value, Value> valueMapping = new HashMap<>(); - CoreOps.InvokeOp methodRefInvokeOp = extractMethodInvoke(valueMapping, body().entryBlock().ops()); + CoreOp.InvokeOp methodRefInvokeOp = extractMethodInvoke(valueMapping, body().entryBlock().ops()); if (methodRefInvokeOp == null) { return Optional.empty(); } @@ -567,24 +578,24 @@ public Optional<InvokeOp> methodReference() { return Optional.of(methodRefInvokeOp); } - static CoreOps.InvokeOp extractMethodInvoke(Map<Value, Value> valueMapping, List<Op> ops) { - CoreOps.InvokeOp methodRefInvokeOp = null; + static CoreOp.InvokeOp extractMethodInvoke(Map<Value, Value> valueMapping, List<Op> ops) { + CoreOp.InvokeOp methodRefInvokeOp = null; for (Op op : ops) { switch (op) { - case CoreOps.VarOp varOp -> { - if (isValueUsedWithOp(varOp.result(), o -> o instanceof CoreOps.VarAccessOp.VarStoreOp)) { + case CoreOp.VarOp varOp -> { + if (isValueUsedWithOp(varOp.result(), o -> o instanceof CoreOp.VarAccessOp.VarStoreOp)) { return null; } } - case CoreOps.VarAccessOp.VarLoadOp varLoadOp -> { + case CoreOp.VarAccessOp.VarLoadOp varLoadOp -> { Value v = varLoadOp.varOp().operands().getFirst(); valueMapping.put(varLoadOp.result(), valueMapping.getOrDefault(v, v)); } - case CoreOps.InvokeOp iop when isBoxOrUnboxInvocation(iop) -> { + case CoreOp.InvokeOp iop when isBoxOrUnboxInvocation(iop) -> { Value v = iop.operands().getFirst(); valueMapping.put(iop.result(), valueMapping.getOrDefault(v, v)); } - case CoreOps.InvokeOp iop -> { + case CoreOp.InvokeOp iop -> { if (methodRefInvokeOp != null) { return null; } @@ -594,7 +605,7 @@ case CoreOps.InvokeOp iop when isBoxOrUnboxInvocation(iop) -> { } methodRefInvokeOp = iop; } - case CoreOps.ReturnOp rop -> { + case CoreOp.ReturnOp rop -> { if (methodRefInvokeOp == null) { return null; } @@ -636,7 +647,7 @@ private static boolean isValueUsedWithOp(Value value, Predicate<Op> opPredicate) "doubleValue", "booleanValue"); - private static boolean isBoxOrUnboxInvocation(CoreOps.InvokeOp iop) { + private static boolean isBoxOrUnboxInvocation(CoreOp.InvokeOp iop) { MethodRef mr = iop.invokeDescriptor(); return mr.refType() instanceof ClassType ct && ct.unbox().isPresent() && (UNBOX_NAMES.contains(mr.name()) || mr.name().equals("valueOf")); @@ -648,7 +659,7 @@ private static boolean isBoxOrUnboxInvocation(CoreOps.InvokeOp iop) { * that has no target type (a functional interface). */ @OpFactory.OpDeclaration(ClosureOp.NAME) - public static final class ClosureOp extends ExternalizableOp implements Op.Invokable, Op.Lowerable { + public static final class ClosureOp extends CoreOp implements Op.Invokable, Op.Lowerable { public static class Builder { final Body.Builder ancestorBody; @@ -740,7 +751,7 @@ public TypeElement resultType() { // @@@ stack effects equivalent to the invocation of an SAM of on an instance of an anonymous functional interface // that is the target of the closures lambda expression. @OpFactory.OpDeclaration(ClosureCallOp.NAME) - public static final class ClosureCallOp extends ExternalizableOp { + public static final class ClosureCallOp extends CoreOp { public static final String NAME = "closure.call"; public ClosureCallOp(ExternalizedOp def) { @@ -773,7 +784,7 @@ public TypeElement resultType() { * This operation exits an isolated body. */ @OpFactory.OpDeclaration(ReturnOp.NAME) - public static final class ReturnOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class ReturnOp extends CoreOp implements Op.BodyTerminating { public static final String NAME = "return"; public ReturnOp(ExternalizedOp def) { @@ -820,7 +831,7 @@ public TypeElement resultType() { * The terminating throw operation, that can model the Java language throw statement. */ @OpFactory.OpDeclaration(ThrowOp.NAME) - public static final class ThrowOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class ThrowOp extends CoreOp implements Op.BodyTerminating { public static final String NAME = "throw"; public ThrowOp(ExternalizedOp def) { @@ -858,7 +869,7 @@ public TypeElement resultType() { * The assertion operation. Supporting assertions in statement form. */ @OpFactory.OpDeclaration(AssertOp.NAME) - public static final class AssertOp extends ExternalizableOp implements Op.Nested { + public static final class AssertOp extends CoreOp implements Op.Nested { public static final String NAME = "assert"; public final List<Body> bodies; @@ -909,7 +920,7 @@ public List<Body> bodies() { * This operation models termination that is unreachable. */ @OpFactory.OpDeclaration(UnreachableOp.NAME) - public static class UnreachableOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class UnreachableOp extends CoreOp implements Op.BodyTerminating { public static final String NAME = "unreachable"; public UnreachableOp(ExternalizedOp def) { @@ -946,7 +957,7 @@ public TypeElement resultType() { * or void) */ @OpFactory.OpDeclaration(YieldOp.NAME) - public static class YieldOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class YieldOp extends CoreOp implements Op.BodyTerminating { public static final String NAME = "yield"; public YieldOp(ExternalizedOp def) { @@ -995,7 +1006,7 @@ public TypeElement resultType() { * This operation accepts a successor to the next block to branch to. */ @OpFactory.OpDeclaration(BranchOp.NAME) - public static class BranchOp extends ExternalizableOp implements Op.BlockTerminating { + public static final class BranchOp extends CoreOp implements Op.BlockTerminating { public static final String NAME = "branch"; final Block.Reference b; @@ -1050,7 +1061,7 @@ public TypeElement resultType() { * The selected successor refers to the next block to branch to. */ @OpFactory.OpDeclaration(ConditionalBranchOp.NAME) - public static class ConditionalBranchOp extends ExternalizableOp implements Op.BlockTerminating { + public static final class ConditionalBranchOp extends CoreOp implements Op.BlockTerminating { public static final String NAME = "cbranch"; final Block.Reference t; @@ -1113,7 +1124,7 @@ public TypeElement resultType() { * The constant operation, that can model Java language literal and constant expressions. */ @OpFactory.OpDeclaration(ConstantOp.NAME) - public static class ConstantOp extends ExternalizableOp implements Op.Pure { + public static final class ConstantOp extends CoreOp implements Op.Pure { public static final String NAME = "constant"; public static final String ATTRIBUTE_CONSTANT_VALUE = NAME + ".value"; @@ -1248,7 +1259,7 @@ public sealed interface ReflectiveOp { * The invoke operation, that can model Java language method invocation expressions. */ @OpFactory.OpDeclaration(InvokeOp.NAME) - public static final class InvokeOp extends ExternalizableOp implements ReflectiveOp { + public static final class InvokeOp extends CoreOp implements ReflectiveOp { public static final String NAME = "invoke"; public static final String ATTRIBUTE_INVOKE_DESCRIPTOR = NAME + ".descriptor"; @@ -1322,7 +1333,7 @@ public TypeElement resultType() { * conversions such as widening and narrowing. */ @OpFactory.OpDeclaration(ConvOp.NAME) - public static final class ConvOp extends ExternalizableOp implements Op.Pure { + public static final class ConvOp extends CoreOp implements Op.Pure { public static final String NAME = "conv"; final TypeElement resultType; @@ -1360,7 +1371,7 @@ public TypeElement resultType() { * The new operation, that can models Java language instance creation expressions. */ @OpFactory.OpDeclaration(NewOp.NAME) - public static final class NewOp extends ExternalizableOp implements ReflectiveOp { + public static final class NewOp extends CoreOp implements ReflectiveOp { public static final String NAME = "new"; public static final String ATTRIBUTE_NEW_DESCRIPTOR = NAME + ".descriptor"; @@ -1444,7 +1455,7 @@ public sealed interface AccessOp { /** * A field access operation, that can model Java langauge field access expressions. */ - public abstract static sealed class FieldAccessOp extends ExternalizableOp implements AccessOp, ReflectiveOp { + public sealed abstract static class FieldAccessOp extends CoreOp implements AccessOp, ReflectiveOp { public static final String ATTRIBUTE_FIELD_DESCRIPTOR = "field.descriptor"; final FieldRef fieldDescriptor; @@ -1601,7 +1612,7 @@ public TypeElement resultType() { * array. */ @OpFactory.OpDeclaration(ArrayLengthOp.NAME) - public static final class ArrayLengthOp extends ExternalizableOp implements ReflectiveOp { + public static final class ArrayLengthOp extends CoreOp implements ReflectiveOp { public static final String NAME = "array.length"; public ArrayLengthOp(ExternalizedOp def) { @@ -1630,7 +1641,7 @@ public TypeElement resultType() { /** * The array access operation, that can model Java language array access expressions. */ - public abstract static sealed class ArrayAccessOp extends ExternalizableOp implements AccessOp, ReflectiveOp { + public sealed abstract static class ArrayAccessOp extends CoreOp implements AccessOp, ReflectiveOp { ArrayAccessOp(ExternalizedOp def) { super(def); @@ -1744,7 +1755,7 @@ public TypeElement resultType() { * type comparison operator. */ @OpFactory.OpDeclaration(InstanceOfOp.NAME) - public static final class InstanceOfOp extends ExternalizableOp implements Op.Pure, ReflectiveOp { + public static final class InstanceOfOp extends CoreOp implements Op.Pure, ReflectiveOp { public static final String NAME = "instanceof"; public static final String ATTRIBUTE_TYPE_DESCRIPTOR = NAME + ".descriptor"; @@ -1809,7 +1820,7 @@ public TypeElement resultType() { * The cast operation, that can model Java language cast expressions. */ @OpFactory.OpDeclaration(CastOp.NAME) - public static final class CastOp extends ExternalizableOp implements Op.Pure, ReflectiveOp { + public static final class CastOp extends CoreOp implements Op.Pure, ReflectiveOp { public static final String NAME = "cast"; public static final String ATTRIBUTE_TYPE_DESCRIPTOR = NAME + ".descriptor"; @@ -1904,7 +1915,7 @@ static <T> Var<T> of(T value) { * lambda parameters. */ @OpFactory.OpDeclaration(VarOp.NAME) - public static final class VarOp extends ExternalizableOp { + public static final class VarOp extends CoreOp { public static final String NAME = "var"; public static final String ATTRIBUTE_NAME = NAME + ".name"; @@ -1983,7 +1994,7 @@ public TypeElement resultType() { * The var access operation, that can model access to Java language local variables, method parameters, or * lambda parameters. */ - public abstract static sealed class VarAccessOp extends ExternalizableOp implements AccessOp { + public sealed abstract static class VarAccessOp extends CoreOp implements AccessOp { VarAccessOp(ExternalizedOp opdef) { super(opdef); } @@ -2101,7 +2112,7 @@ public TypeElement resultType() { * The tuple operation. A tuple contain a fixed set of values accessible by their component index. */ @OpFactory.OpDeclaration(TupleOp.NAME) - public static final class TupleOp extends ExternalizableOp { + public static final class TupleOp extends CoreOp { public static final String NAME = "tuple"; public TupleOp(ExternalizedOp def) { @@ -2131,7 +2142,7 @@ public TypeElement resultType() { * The tuple component load operation, that access the component of a tuple at a given, constant, component index. */ @OpFactory.OpDeclaration(TupleLoadOp.NAME) - public static final class TupleLoadOp extends ExternalizableOp { + public static final class TupleLoadOp extends CoreOp { public static final String NAME = "tuple.load"; public static final String ATTRIBUTE_INDEX = NAME + ".index"; @@ -2202,7 +2213,7 @@ public TypeElement resultType() { * The tuple component set operation, that access the component of a tuple at a given, constant, component index. */ @OpFactory.OpDeclaration(TupleWithOp.NAME) - public static final class TupleWithOp extends ExternalizableOp { + public static final class TupleWithOp extends CoreOp { public static final String NAME = "tuple.with"; public static final String ATTRIBUTE_INDEX = NAME + ".index"; @@ -2291,7 +2302,7 @@ public interface ExceptionRegion { * The exception region start operation. */ @OpFactory.OpDeclaration(ExceptionRegionEnter.NAME) - public static final class ExceptionRegionEnter extends ExternalizableOp implements Op.BlockTerminating { + public static final class ExceptionRegionEnter extends CoreOp implements Op.BlockTerminating { public static final String NAME = "exception.region.enter"; // First successor is the non-exceptional successor whose target indicates @@ -2354,7 +2365,7 @@ public TypeElement resultType() { * The exception region end operation. */ @OpFactory.OpDeclaration(ExceptionRegionExit.NAME) - public static final class ExceptionRegionExit extends ExternalizableOp implements Op.BlockTerminating { + public static final class ExceptionRegionExit extends CoreOp implements Op.BlockTerminating { public static final String NAME = "exception.region.exit"; final Block.Reference end; @@ -2427,7 +2438,7 @@ public TypeElement resultType() { */ @OpFactory.OpDeclaration(ConcatOp.NAME) - public static final class ConcatOp extends ExternalizableOp implements Op.Pure { + public static final class ConcatOp extends CoreOp implements Op.Pure { public static final String NAME = "concat"; public ConcatOp(ConcatOp that, CopyContext cc) { @@ -2462,7 +2473,7 @@ public TypeElement resultType() { /** * The arithmetic operation. */ - public static abstract class ArithmeticOperation extends ExternalizableOp implements Op.Pure { + public sealed static abstract class ArithmeticOperation extends CoreOp implements Op.Pure { protected ArithmeticOperation(ExternalizedOp def) { super(def); @@ -2483,7 +2494,7 @@ protected ArithmeticOperation(String name, List<Value> operands) { /** * The test operation. */ - public static abstract class TestOperation extends ExternalizableOp implements Op.Pure { + public sealed static abstract class TestOperation extends CoreOp implements Op.Pure { protected TestOperation(ExternalizedOp def) { super(def); @@ -2504,7 +2515,7 @@ protected TestOperation(String name, List<Value> operands) { /** * The binary arithmetic operation. */ - public static abstract class BinaryOp extends ArithmeticOperation { + public sealed static abstract class BinaryOp extends ArithmeticOperation { protected BinaryOp(ExternalizedOp def) { super(def); @@ -2530,7 +2541,7 @@ public TypeElement resultType() { /** * The unary arithmetic operation. */ - public static abstract class UnaryOp extends ArithmeticOperation { + public sealed static abstract class UnaryOp extends ArithmeticOperation { protected UnaryOp(ExternalizedOp def) { super(def); @@ -2553,31 +2564,10 @@ public TypeElement resultType() { } } - /** - * The unary test operation. - */ - public static abstract class UnaryTestOp extends TestOperation { - protected UnaryTestOp(ExternalizedOp def) { - super(def); - - if (def.operands().size() != 1) { - throw new IllegalArgumentException("Number of operands must be 1: " + def.operands().size()); - } - } - - protected UnaryTestOp(UnaryTestOp that, CopyContext cc) { - super(that, cc); - } - - protected UnaryTestOp(String name, Value v) { - super(name, List.of(v)); - } - } - /** * The binary test operation. */ - public static abstract class BinaryTestOp extends TestOperation { + public sealed static abstract class BinaryTestOp extends TestOperation { protected BinaryTestOp(ExternalizedOp def) { super(def); @@ -2832,7 +2822,7 @@ public LshlOp transform(CopyContext cc, OpTransformer ot) { * The (arithmetic) shift right operation, that can model the Java language binary {@code >>} operator for integral types */ @OpFactory.OpDeclaration(AshrOp.NAME) - public static final class AshrOp extends CoreOps.BinaryOp { + public static final class AshrOp extends CoreOp.BinaryOp { public static final String NAME = "ashr"; public AshrOp(ExternalizedOp opdef) { @@ -2857,7 +2847,7 @@ public AshrOp transform(CopyContext cc, OpTransformer ot) { * The unsigned (logical) shift right operation, that can model the Java language binary {@code >>>} operator for integral types */ @OpFactory.OpDeclaration(LshrOp.NAME) - public static final class LshrOp extends CoreOps.BinaryOp { + public static final class LshrOp extends CoreOp.BinaryOp { public static final String NAME = "lshr"; public LshrOp(ExternalizedOp opdef) { @@ -3088,7 +3078,7 @@ public LeOp transform(CopyContext cc, OpTransformer ot) { * A factory for core operations. */ // @@@ Compute lazily - public static final OpFactory FACTORY = OpFactory.OP_FACTORY.get(CoreOps.class); + public static final OpFactory FACTORY = OpFactory.OP_FACTORY.get(CoreOp.class); /** * Creates a function operation builder diff --git a/src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java b/src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java similarity index 93% rename from src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java rename to src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java index ea7e45ec64c..be67024031e 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOps.java +++ b/src/java.base/share/classes/java/lang/reflect/code/op/ExtendedOp.java @@ -42,13 +42,15 @@ import java.util.function.Function; import java.util.stream.Stream; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.JavaType.*; /** - * The set of extended operations. A code model, produced by the Java compiler from Java program source, may consist of - * extended operations and core operations. Such a model represents the same Java program and preserves the program - * meaning as defined by the Java Language Specification + * The top-level operation class for the enclosed set of extended operations. + * <p> + * A code model, produced by the Java compiler from Java program source, may consist of extended operations and core + * operations. Such a model represents the same Java program and preserves the program meaning as defined by the + * Java Language Specification * <p> * Extended operations model specific Java language constructs, often those with structured control flow and nested * code. Each operation is transformable into a sequence of core operations, commonly referred to as lowering. Those @@ -59,20 +61,30 @@ * can be transformed to one consisting only of core operations, where all extended operations are lowered. This * transformation preserves programing meaning. The resulting lowered code model also represents the same Java program. */ -public class ExtendedOps { +public sealed abstract class ExtendedOp extends ExternalizableOp { // Split string to ensure the name does not get rewritten // when the script copies this source to the jdk.compiler module static final String PACKAGE_NAME = "java.lang" + ".reflect.code"; - static final String ExtendedOps_CLASS_NAME = PACKAGE_NAME + "." + ExtendedOps.class.getSimpleName(); + static final String ExtendedOp_CLASS_NAME = PACKAGE_NAME + "." + ExtendedOp.class.getSimpleName(); + + protected ExtendedOp(Op that, CopyContext cc) { + super(that, cc); + } + + protected ExtendedOp(String name, List<? extends Value> operands) { + super(name, operands); + } - ExtendedOps() { + protected ExtendedOp(ExternalizableOp.ExternalizedOp def) { + super(def); } + /** * The label operation, that can model Java language statements with label identifiers. */ - public static sealed abstract class JavaLabelOp extends ExternalizableOp implements Op.Lowerable, Op.BodyTerminating { + public sealed static abstract class JavaLabelOp extends ExtendedOp implements Op.Lowerable, Op.BodyTerminating { JavaLabelOp(ExternalizedOp def) { super(def); @@ -245,7 +257,7 @@ static void setBranchTarget(CopyContext cc, Op label, BranchTarget t) { * The yield operation, that can model Java language yield statements. */ @OpFactory.OpDeclaration(JavaYieldOp.NAME) - public static final class JavaYieldOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class JavaYieldOp extends ExtendedOp implements Op.BodyTerminating { public static final String NAME = "java.yield"; public JavaYieldOp(ExternalizedOp def) { @@ -290,7 +302,7 @@ public TypeElement resultType() { */ @OpFactory.OpDeclaration(JavaBlockOp.NAME) // @@@ Support synchronized attribute - public static final class JavaBlockOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaBlockOp extends ExtendedOp implements Op.Nested, Op.Lowerable { public static final String NAME = "java.block"; final Body body; @@ -371,7 +383,7 @@ public TypeElement resultType() { * The labeled operation, that can model Java language labeled statements. */ @OpFactory.OpDeclaration(JavaLabeledOp.NAME) - public static final class JavaLabeledOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaLabeledOp extends ExtendedOp implements Op.Nested, Op.Lowerable { public static final String NAME = "java.labeled"; final Body body; @@ -462,7 +474,7 @@ public TypeElement resultType() { * The if operation, that can model Java language if, if-then, and if-then-else statements. */ @OpFactory.OpDeclaration(JavaIfOp.NAME) - public static final class JavaIfOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaIfOp extends ExtendedOp implements Op.Nested, Op.Lowerable { static final FunctionType PREDICATE_TYPE = FunctionType.functionType(BOOLEAN); @@ -687,7 +699,7 @@ public TypeElement resultType() { * The switch expression operation, that can model Java language switch expressions. */ @OpFactory.OpDeclaration(JavaSwitchExpressionOp.NAME) - public static final class JavaSwitchExpressionOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaSwitchExpressionOp extends ExtendedOp implements Op.Nested, Op.Lowerable { public static final String NAME = "java.switch.expression"; final TypeElement resultType; @@ -754,7 +766,7 @@ public TypeElement resultType() { * the last statement of the current switch label. */ @OpFactory.OpDeclaration(JavaSwitchFallthroughOp.NAME) - public static final class JavaSwitchFallthroughOp extends ExternalizableOp implements Op.BodyTerminating { + public static final class JavaSwitchFallthroughOp extends ExtendedOp implements Op.BodyTerminating { public static final String NAME = "java.switch.fallthrough"; public JavaSwitchFallthroughOp(ExternalizedOp def) { @@ -784,7 +796,7 @@ public TypeElement resultType() { * The for operation, that can model a Java language for statement. */ @OpFactory.OpDeclaration(JavaForOp.NAME) - public static final class JavaForOp extends ExternalizableOp implements Op.Loop, Op.Lowerable { + public static final class JavaForOp extends ExtendedOp implements Op.Loop, Op.Lowerable { public static final class InitBuilder { final Body.Builder ancestorBody; @@ -966,7 +978,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { // @@@ Init body has one yield operation yielding // void, a single variable, or a tuple of one or more variables b.transformBody(init, List.of(), opT.andThen((block, op) -> { - if (op instanceof CoreOps.TupleOp) { + if (op instanceof CoreOp.TupleOp) { // Drop Tuple if a yielded boolean isResult = op.result().uses().size() == 1 && op.result().uses().stream().allMatch(r -> r.op() instanceof YieldOp); @@ -978,7 +990,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { block.op(branch(header.successor())); return block; } else if (yop.yieldValue() instanceof Result or) { - if (or.op() instanceof CoreOps.TupleOp top) { + if (or.op() instanceof CoreOp.TupleOp top) { initValues.addAll(block.context().getValues(top.operands())); } else { initValues.addAll(block.context().getValues(yop.operands())); @@ -1043,7 +1055,7 @@ public TypeElement resultType() { * The enhanced for operation, that can model a Java language enhanced for statement. */ @OpFactory.OpDeclaration(JavaEnhancedForOp.NAME) - public static final class JavaEnhancedForOp extends ExternalizableOp implements Op.Loop, Op.Lowerable { + public static final class JavaEnhancedForOp extends ExtendedOp implements Op.Loop, Op.Lowerable { public static final class ExpressionBuilder { final Body.Builder ancestorBody; @@ -1258,13 +1270,13 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { update.op(branch(header.successor(i))); } else { JavaType iterable = parameterized(type(Iterator.class), elementType); - Value iterator = preHeader.op(CoreOps.invoke(iterable, ITERABLE_ITERATOR, preHeader.parameters().get(0))); + Value iterator = preHeader.op(CoreOp.invoke(iterable, ITERABLE_ITERATOR, preHeader.parameters().get(0))); preHeader.op(branch(header.successor())); - Value p = header.op(CoreOps.invoke(ITERATOR_HAS_NEXT, iterator)); + Value p = header.op(CoreOp.invoke(ITERATOR_HAS_NEXT, iterator)); header.op(conditionalBranch(p, init.successor(), exit.successor())); - Value e = init.op(CoreOps.invoke(elementType, ITERATOR_NEXT, iterator)); + Value e = init.op(CoreOp.invoke(elementType, ITERATOR_NEXT, iterator)); List<Value> initValues = new ArrayList<>(); init.transformBody(this.init, List.of(e), opT.andThen((block, op) -> { if (op instanceof YieldOp yop) { @@ -1303,7 +1315,7 @@ public TypeElement resultType() { * The while operation, that can model a Java language while statement. */ @OpFactory.OpDeclaration(JavaWhileOp.NAME) - public static final class JavaWhileOp extends ExternalizableOp implements Op.Loop, Op.Lowerable { + public static final class JavaWhileOp extends ExtendedOp implements Op.Loop, Op.Lowerable { public static class PredicateBuilder { final Body.Builder ancestorBody; @@ -1410,7 +1422,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { b.op(branch(header.successor())); header.transformBody(predicateBody(), List.of(), opT.andThen((block, op) -> { - if (op instanceof CoreOps.YieldOp yo) { + if (op instanceof CoreOp.YieldOp yo) { block.op(conditionalBranch(block.context().getValue(yo.yieldValue()), body.successor(), exit.successor())); } else if (op instanceof Lowerable lop) { @@ -1448,7 +1460,7 @@ public TypeElement resultType() { */ // @@@ Unify JavaDoWhileOp and JavaWhileOp with common abstract superclass @OpFactory.OpDeclaration(JavaDoWhileOp.NAME) - public static final class JavaDoWhileOp extends ExternalizableOp implements Op.Loop, Op.Lowerable { + public static final class JavaDoWhileOp extends ExtendedOp implements Op.Loop, Op.Lowerable { public static class PredicateBuilder { final Body.Builder ancestorBody; @@ -1566,7 +1578,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { })); header.transformBody(predicateBody(), List.of(), opT.andThen((block, op) -> { - if (op instanceof CoreOps.YieldOp yo) { + if (op instanceof CoreOp.YieldOp yo) { block.op(conditionalBranch(block.context().getValue(yo.yieldValue()), body.successor(), exit.successor())); } else if (op instanceof Lowerable lop) { @@ -1590,7 +1602,7 @@ public TypeElement resultType() { /** * The conditional-and-or operation, that can model Java language condition-or or conditional-and expressions. */ - public static sealed abstract class JavaConditionalOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public sealed static abstract class JavaConditionalOp extends ExtendedOp implements Op.Nested, Op.Lowerable { final List<Body> bodies; public JavaConditionalOp(ExternalizedOp def) { @@ -1648,7 +1660,7 @@ static Block.Builder lower(Block.Builder startBlock, OpTransformer opT, JavaCond OpTransformer opt; if (i == bodies.size() - 1) { opt = (block, op) -> { - if (op instanceof CoreOps.YieldOp yop) { + if (op instanceof CoreOp.YieldOp yop) { Value p = block.context().getValue(yop.yieldValue()); block.op(branch(exit.successor(p))); } else if (op instanceof Lowerable lop) { @@ -1663,7 +1675,7 @@ static Block.Builder lower(Block.Builder startBlock, OpTransformer opT, JavaCond } else { Block.Builder nextPred = pred; opt = (block, op) -> { - if (op instanceof CoreOps.YieldOp yop) { + if (op instanceof CoreOp.YieldOp yop) { Value p = block.context().getValue(yop.yieldValue()); if (cop instanceof JavaConditionalAndOp) { block.op(conditionalBranch(p, nextPred.successor(), exit.successor(p))); @@ -1813,7 +1825,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { * The conditional operation, that can model Java language conditional operator {@code ?} expressions. */ @OpFactory.OpDeclaration(JavaConditionalExpressionOp.NAME) - public static final class JavaConditionalExpressionOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaConditionalExpressionOp extends ExtendedOp implements Op.Nested, Op.Lowerable { public static final String NAME = "java.cexpression"; @@ -1918,7 +1930,7 @@ public TypeElement resultType() { * The try operation, that can model Java language try statements. */ @OpFactory.OpDeclaration(JavaTryOp.NAME) - public static final class JavaTryOp extends ExternalizableOp implements Op.Nested, Op.Lowerable { + public static final class JavaTryOp extends ExtendedOp implements Op.Nested, Op.Lowerable { public static final class BodyBuilder { final Body.Builder ancestorBody; @@ -2159,9 +2171,9 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { OpTransformer tryExitTransformer; if (finalizer != null) { tryExitTransformer = opT.compose((block, op) -> { - if (op instanceof CoreOps.ReturnOp) { + if (op instanceof CoreOp.ReturnOp) { return inlineFinalizer(block, tryExceptionRegion, opT); - } else if (op instanceof ExtendedOps.JavaLabelOp lop && ifExitFromTry(lop)) { + } else if (op instanceof ExtendedOp.JavaLabelOp lop && ifExitFromTry(lop)) { return inlineFinalizer(block, tryExceptionRegion, opT); } else { return block; @@ -2171,7 +2183,7 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { tryExitTransformer = opT.compose((block, op) -> { // @@@ break and continue // when target break/continue is enclosing the try - if (op instanceof CoreOps.ReturnOp) { + if (op instanceof CoreOp.ReturnOp) { Block.Builder tryRegionReturnExit = block.block(); block.op(exceptionRegionExit(tryExceptionRegion, tryRegionReturnExit.successor())); return tryRegionReturnExit; @@ -2225,9 +2237,9 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { exceptionRegionEnter(catchRegionEnter.successor(), catcherFinally.successor())); OpTransformer catchExitTransformer = opT.compose((block, op) -> { - if (op instanceof CoreOps.ReturnOp) { + if (op instanceof CoreOp.ReturnOp) { return inlineFinalizer(block, catchExceptionRegion, opT); - } else if (op instanceof ExtendedOps.JavaLabelOp lop && ifExitFromTry(lop)) { + } else if (op instanceof ExtendedOp.JavaLabelOp lop && ifExitFromTry(lop)) { return inlineFinalizer(block, catchExceptionRegion, opT); } else { return block; @@ -2360,7 +2372,7 @@ public TypeElement resultType() { // // Patterns - static final String Pattern_CLASS_NAME = ExtendedOps_CLASS_NAME + "$" + Pattern.class.getSimpleName(); + static final String Pattern_CLASS_NAME = ExtendedOp_CLASS_NAME + "$" + Pattern.class.getSimpleName(); // Reified pattern nodes @@ -2420,7 +2432,7 @@ public static final class PatternOps { /** * The pattern operation. */ - public static sealed abstract class PatternOp extends ExternalizableOp implements Op.Pure { + public sealed static abstract class PatternOp extends ExtendedOp implements Op.Pure { PatternOp(ExternalizedOp def) { super(def); } @@ -2450,7 +2462,8 @@ public static BindingPatternOp create(ExternalizedOp def) { String name = def.extractAttributeValue(ATTRIBUTE_BINDING_NAME, true, v -> switch (v) { case String s -> s; - default -> throw new UnsupportedOperationException("Unsupported pattern binding name value:" + v); + default -> + throw new UnsupportedOperationException("Unsupported pattern binding name value:" + v); }); return new BindingPatternOp(def, name); } @@ -2514,11 +2527,12 @@ public static final class RecordPatternOp extends PatternOp { final RecordTypeRef recordDescriptor; public static RecordPatternOp create(ExternalizedOp def) { - RecordTypeRef recordDescriptor = def.extractAttributeValue(ATTRIBUTE_RECORD_DESCRIPTOR,true, + RecordTypeRef recordDescriptor = def.extractAttributeValue(ATTRIBUTE_RECORD_DESCRIPTOR, true, v -> switch (v) { case String s -> RecordTypeRef.ofString(s); case RecordTypeRef rtd -> rtd; - default -> throw new UnsupportedOperationException("Unsupported record type descriptor value:" + v); + default -> + throw new UnsupportedOperationException("Unsupported record type descriptor value:" + v); }); return new RecordPatternOp(def, recordDescriptor); @@ -2574,7 +2588,7 @@ public TypeElement resultType() { * The match operation, that can model Java language pattern matching. */ @OpFactory.OpDeclaration(MatchOp.NAME) - public static final class MatchOp extends ExternalizableOp implements Op.Isolated, Op.Lowerable { + public static final class MatchOp extends ExtendedOp implements Op.Isolated, Op.Lowerable { public static final String NAME = "pattern.match"; final Body pattern; @@ -2671,9 +2685,9 @@ public Block.Builder lower(Block.Builder b, OpTransformer opT) { static Block.Builder lower(Block.Builder endNoMatchBlock, Block.Builder currentBlock, List<Value> bindings, Op pattern, Value target) { - if (pattern instanceof ExtendedOps.PatternOps.RecordPatternOp rp) { + if (pattern instanceof ExtendedOp.PatternOps.RecordPatternOp rp) { return lowerRecordPattern(endNoMatchBlock, currentBlock, bindings, rp, target); - } else if (pattern instanceof ExtendedOps.PatternOps.BindingPatternOp bp) { + } else if (pattern instanceof ExtendedOp.PatternOps.BindingPatternOp bp) { return lowerBindingPattern(endNoMatchBlock, currentBlock, bindings, bp, target); } else { throw new UnsupportedOperationException("Unknown pattern op: " + pattern); @@ -2681,26 +2695,26 @@ static Block.Builder lower(Block.Builder endNoMatchBlock, Block.Builder currentB } static Block.Builder lowerRecordPattern(Block.Builder endNoMatchBlock, Block.Builder currentBlock, - List<Value> bindings, - ExtendedOps.PatternOps.RecordPatternOp rpOp, Value target) { + List<Value> bindings, + ExtendedOp.PatternOps.RecordPatternOp rpOp, Value target) { TypeElement targetType = rpOp.targetType(); Block.Builder nextBlock = currentBlock.block(); // Check if instance of target type - Op.Result isInstance = currentBlock.op(CoreOps.instanceOf(targetType, target)); + Op.Result isInstance = currentBlock.op(CoreOp.instanceOf(targetType, target)); currentBlock.op(conditionalBranch(isInstance, nextBlock.successor(), endNoMatchBlock.successor())); currentBlock = nextBlock; - target = currentBlock.op(CoreOps.cast(targetType, target)); + target = currentBlock.op(CoreOp.cast(targetType, target)); // Access component values of record and match on each as nested target List<Value> dArgs = rpOp.operands(); for (int i = 0; i < dArgs.size(); i++) { Op.Result nestedPattern = (Op.Result) dArgs.get(i); // @@@ Handle exceptions? - Value nestedTarget = currentBlock.op(CoreOps.invoke(rpOp.recordDescriptor().methodForComponent(i), target)); + Value nestedTarget = currentBlock.op(CoreOp.invoke(rpOp.recordDescriptor().methodForComponent(i), target)); currentBlock = lower(endNoMatchBlock, currentBlock, bindings, nestedPattern.op(), nestedTarget); } @@ -2709,19 +2723,19 @@ static Block.Builder lowerRecordPattern(Block.Builder endNoMatchBlock, Block.Bui } static Block.Builder lowerBindingPattern(Block.Builder endNoMatchBlock, Block.Builder currentBlock, - List<Value> bindings, - ExtendedOps.PatternOps.BindingPatternOp bpOp, Value target) { + List<Value> bindings, + ExtendedOp.PatternOps.BindingPatternOp bpOp, Value target) { TypeElement targetType = bpOp.targetType(); Block.Builder nextBlock = currentBlock.block(); // Check if instance of target type - currentBlock.op(conditionalBranch(currentBlock.op(CoreOps.instanceOf(targetType, target)), + currentBlock.op(conditionalBranch(currentBlock.op(CoreOp.instanceOf(targetType, target)), nextBlock.successor(), endNoMatchBlock.successor())); currentBlock = nextBlock; - target = currentBlock.op(CoreOps.cast(targetType, target)); + target = currentBlock.op(CoreOp.cast(targetType, target)); bindings.add(target); return currentBlock; @@ -2739,11 +2753,12 @@ public TypeElement resultType() { * A factory for extended and core operations. */ // @@@ Compute lazily - public static final OpFactory FACTORY = CoreOps.FACTORY.andThen(OpFactory.OP_FACTORY.get(ExtendedOps.class)); + public static final OpFactory FACTORY = CoreOp.FACTORY.andThen(OpFactory.OP_FACTORY.get(ExtendedOp.class)); /** * Creates a continue operation. + * * @return the continue operation */ public static JavaContinueOp _continue() { @@ -2752,6 +2767,7 @@ public static JavaContinueOp _continue() { /** * Creates a continue operation. + * * @param label the value associated with where to continue from * @return the continue operation */ @@ -2761,6 +2777,7 @@ public static JavaContinueOp _continue(Value label) { /** * Creates a break operation. + * * @return the break operation */ public static JavaBreakOp _break() { @@ -2769,6 +2786,7 @@ public static JavaBreakOp _break() { /** * Creates a break operation. + * * @param label the value associated with where to continue from * @return the break operation */ @@ -2778,6 +2796,7 @@ public static JavaBreakOp _break(Value label) { /** * Creates a yield operation. + * * @return the yield operation */ public static JavaYieldOp java_yield() { @@ -2786,6 +2805,7 @@ public static JavaYieldOp java_yield() { /** * Creates a yield operation. + * * @param operand the value to yield * @return the yield operation */ @@ -2795,6 +2815,7 @@ public static JavaYieldOp java_yield(Value operand) { /** * Creates a block operation. + * * @param body the body builder of the operation to be built and become its child * @return the block operation */ @@ -2804,6 +2825,7 @@ public static JavaBlockOp block(Body.Builder body) { /** * Creates a labeled operation. + * * @param body the body builder of the operation to be built and become its child * @return the block operation */ @@ -2813,8 +2835,9 @@ public static JavaLabeledOp labeled(Body.Builder body) { /** * Creates an if operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation + * body builders for this operation * @return the if operation builder */ public static JavaIfOp.IfBuilder _if(Body.Builder ancestorBody) { @@ -2827,6 +2850,7 @@ public static JavaIfOp.IfBuilder _if(Body.Builder ancestorBody) { /** * Creates an if operation. + * * @param bodies the body builders of operation to be built and become its children * @return the if operation */ @@ -2838,6 +2862,7 @@ public static JavaIfOp _if(List<Body.Builder> bodies) { * Creates a switch expression operation. * <p> * The result type of the operation will be derived from the yield type of the second body + * * @param target the switch target value * @param bodies the body builders of the operation to be built and become its children * @return the switch expression operation @@ -2850,8 +2875,8 @@ public static JavaSwitchExpressionOp switchExpression(Value target, List<Body.Bu * Creates a switch expression operation. * * @param resultType the result type of the expression - * @param target the switch target value - * @param bodies the body builders of the operation to be built and become its children + * @param target the switch target value + * @param bodies the body builders of the operation to be built and become its children * @return the switch expression operation */ public static JavaSwitchExpressionOp switchExpression(TypeElement resultType, Value target, @@ -2862,6 +2887,7 @@ public static JavaSwitchExpressionOp switchExpression(TypeElement resultType, Va /** * Creates a switch fallthrough operation. + * * @return the switch fallthrough operation */ public static JavaSwitchFallthroughOp switchFallthroughOp() { @@ -2870,9 +2896,10 @@ public static JavaSwitchFallthroughOp switchFallthroughOp() { /** * Creates a for operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param initTypes the types of initialized variables + * body builders for this operation + * @param initTypes the types of initialized variables * @return the for operation builder */ public static JavaForOp.InitBuilder _for(Body.Builder ancestorBody, TypeElement... initTypes) { @@ -2881,9 +2908,10 @@ public static JavaForOp.InitBuilder _for(Body.Builder ancestorBody, TypeElement. /** * Creates a for operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param initTypes the types of initialized variables + * body builders for this operation + * @param initTypes the types of initialized variables * @return the for operation builder */ public static JavaForOp.InitBuilder _for(Body.Builder ancestorBody, List<? extends TypeElement> initTypes) { @@ -2893,10 +2921,11 @@ public static JavaForOp.InitBuilder _for(Body.Builder ancestorBody, List<? exten /** * Creates a for operation. - * @param init the init body builder of the operation to be built and become its child - * @param cond the cond body builder of the operation to be built and become its child + * + * @param init the init body builder of the operation to be built and become its child + * @param cond the cond body builder of the operation to be built and become its child * @param update the update body builder of the operation to be built and become its child - * @param body the main body builder of the operation to be built and become its child + * @param body the main body builder of the operation to be built and become its child * @return the for operation */ // init ()Tuple<Var<T1>, Var<T2>, ..., Var<TN>>, or init ()void @@ -2912,10 +2941,11 @@ public static JavaForOp _for(Body.Builder init, /** * Creates an enhanced for operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation + * body builders for this operation * @param iterableType the iterable type - * @param elementType the element type + * @param elementType the element type * @return the enhanced for operation builder */ public static JavaEnhancedForOp.ExpressionBuilder enhancedFor(Body.Builder ancestorBody, @@ -2929,9 +2959,10 @@ public static JavaEnhancedForOp.ExpressionBuilder enhancedFor(Body.Builder ances /** * Creates an enhanced for operation. + * * @param expression the expression body builder of the operation to be built and become its child - * @param init the init body builder of the operation to be built and become its child - * @param body the main body builder of the operation to be built and become its child + * @param init the init body builder of the operation to be built and become its child + * @param body the main body builder of the operation to be built and become its child * @return the enhanced for operation */ public static JavaEnhancedForOp enhancedFor(Body.Builder expression, @@ -2942,8 +2973,9 @@ public static JavaEnhancedForOp enhancedFor(Body.Builder expression, /** * Creates a while operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation + * body builders for this operation * @return the while operation builder */ public static JavaWhileOp.PredicateBuilder _while(Body.Builder ancestorBody) { @@ -2952,8 +2984,9 @@ public static JavaWhileOp.PredicateBuilder _while(Body.Builder ancestorBody) { /** * Creates a while operation. + * * @param predicate the predicate body builder of the operation to be built and become its child - * @param body the main body builder of the operation to be built and become its child + * @param body the main body builder of the operation to be built and become its child * @return the while operation */ // predicate, ()boolean, may be null for predicate returning true @@ -2964,8 +2997,9 @@ public static JavaWhileOp _while(Body.Builder predicate, Body.Builder body) { /** * Creates a do operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation + * body builders for this operation * @return the do operation builder */ public static JavaDoWhileOp.BodyBuilder doWhile(Body.Builder ancestorBody) { @@ -2974,8 +3008,9 @@ public static JavaDoWhileOp.BodyBuilder doWhile(Body.Builder ancestorBody) { /** * Creates a do operation. + * * @param predicate the predicate body builder of the operation to be built and become its child - * @param body the main body builder of the operation to be built and become its child + * @param body the main body builder of the operation to be built and become its child * @return the do operation */ public static JavaDoWhileOp doWhile(Body.Builder body, Body.Builder predicate) { @@ -2984,10 +3019,11 @@ public static JavaDoWhileOp doWhile(Body.Builder body, Body.Builder predicate) { /** * Creates a conditional-and operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param lhs a consumer that builds the left-hand side body - * @param rhs a consumer that builds the right-hand side body + * body builders for this operation + * @param lhs a consumer that builds the left-hand side body + * @param rhs a consumer that builds the right-hand side body * @return the conditional-and operation builder */ public static JavaConditionalAndOp.Builder conditionalAnd(Body.Builder ancestorBody, @@ -2997,10 +3033,11 @@ public static JavaConditionalAndOp.Builder conditionalAnd(Body.Builder ancestorB /** * Creates a conditional-or operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param lhs a consumer that builds the left-hand side body - * @param rhs a consumer that builds the right-hand side body + * body builders for this operation + * @param lhs a consumer that builds the left-hand side body + * @param rhs a consumer that builds the right-hand side body * @return the conditional-or operation builder */ public static JavaConditionalOrOp.Builder conditionalOr(Body.Builder ancestorBody, @@ -3010,6 +3047,7 @@ public static JavaConditionalOrOp.Builder conditionalOr(Body.Builder ancestorBod /** * Creates a conditional-and operation + * * @param bodies the body builders of operation to be built and become its children * @return the conditional-and operation */ @@ -3020,6 +3058,7 @@ public static JavaConditionalAndOp conditionalAnd(List<Body.Builder> bodies) { /** * Creates a conditional-or operation + * * @param bodies the body builders of operation to be built and become its children * @return the conditional-or operation */ @@ -3030,8 +3069,9 @@ public static JavaConditionalOrOp conditionalOr(List<Body.Builder> bodies) { /** * Creates a conditional operation + * * @param expressionType the result type of the expression - * @param bodies the body builders of operation to be built and become its children + * @param bodies the body builders of operation to be built and become its children * @return the conditional operation */ public static JavaConditionalExpressionOp conditionalExpression(TypeElement expressionType, @@ -3044,6 +3084,7 @@ public static JavaConditionalExpressionOp conditionalExpression(TypeElement expr * Creates a conditional operation * <p> * The result type of the operation will be derived from the yield type of the second body + * * @param bodies the body builders of operation to be built and become its children * @return the conditional operation */ @@ -3053,9 +3094,10 @@ public static JavaConditionalExpressionOp conditionalExpression(List<Body.Builde /** * Creates try operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param c a consumer that builds the try body + * body builders for this operation + * @param c a consumer that builds the try body * @return the try operation builder */ public static JavaTryOp.CatchBuilder _try(Body.Builder ancestorBody, Consumer<Block.Builder> c) { @@ -3066,9 +3108,10 @@ public static JavaTryOp.CatchBuilder _try(Body.Builder ancestorBody, Consumer<Bl /** * Creates try-with-resources operation builder. + * * @param ancestorBody the nearest ancestor body builder from which to construct - * body builders for this operation - * @param c a consumer that builds the resources body + * body builders for this operation + * @param c a consumer that builds the resources body * @return the try-with-resources operation builder */ public static JavaTryOp.BodyBuilder tryWithResources(Body.Builder ancestorBody, @@ -3088,10 +3131,11 @@ public static JavaTryOp.BodyBuilder tryWithResources(Body.Builder ancestorBody, /** * Creates a try or try-with-resources operation. + * * @param resources the try body builder of the operation to be built and become its child, * may be null - * @param body the try body builder of the operation to be built and become its child - * @param catchers the catch body builders of the operation to be built and become its children + * @param body the try body builder of the operation to be built and become its child + * @param catchers the catch body builders of the operation to be built and become its children * @param finalizer the finalizer body builder of the operation to be built and become its child * @return the try or try-with-resources operation */ @@ -3107,9 +3151,10 @@ public static JavaTryOp _try(Body.Builder resources, /** * Creates a pattern match operation. - * @param target the target value + * + * @param target the target value * @param pattern the pattern body builder of the operation to be built and become its child - * @param match the match body builder of the operation to be built and become its child + * @param match the match body builder of the operation to be built and become its child * @return the pattern match operation */ public static PatternOps.MatchOp match(Value target, @@ -3119,7 +3164,8 @@ public static PatternOps.MatchOp match(Value target, /** * Creates a pattern binding operation. - * @param type the type of value to be bound + * + * @param type the type of value to be bound * @param bindingName the binding name * @return the pattern binding operation */ @@ -3129,8 +3175,9 @@ public static PatternOps.BindingPatternOp bindingPattern(TypeElement type, Strin /** * Creates a record pattern operation. + * * @param recordDescriptor the record descriptor - * @param nestedPatterns the nested pattern values + * @param nestedPatterns the nested pattern values * @return the record pattern operation */ public static PatternOps.RecordPatternOp recordPattern(RecordTypeRef recordDescriptor, Value... nestedPatterns) { @@ -3139,8 +3186,9 @@ public static PatternOps.RecordPatternOp recordPattern(RecordTypeRef recordDescr /** * Creates a record pattern operation. + * * @param recordDescriptor the record descriptor - * @param nestedPatterns the nested pattern values + * @param nestedPatterns the nested pattern values * @return the record pattern operation */ public static PatternOps.RecordPatternOp recordPattern(RecordTypeRef recordDescriptor, List<Value> nestedPatterns) { diff --git a/src/java.base/share/classes/java/lang/reflect/code/parser/OpParser.java b/src/java.base/share/classes/java/lang/reflect/code/parser/OpParser.java index 9730f6aaadb..52a1634c9d8 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/parser/OpParser.java +++ b/src/java.base/share/classes/java/lang/reflect/code/parser/OpParser.java @@ -163,8 +163,8 @@ public static List<Op> fromString(OpFactory opFactory, TypeElementFactory typeFa * @return the func operation */ public static Op fromStringOfFuncOp(String in) { - Op op = fromString(ExtendedOps.FACTORY, in).get(0); - if (!(op instanceof CoreOps.FuncOp)) { + Op op = fromString(ExtendedOp.FACTORY, in).get(0); + if (!(op instanceof CoreOp.FuncOp)) { throw new IllegalArgumentException("Op is not a FuncOp: " + op); } return op; diff --git a/src/java.base/share/classes/java/lang/reflect/code/type/MethodRef.java b/src/java.base/share/classes/java/lang/reflect/code/type/MethodRef.java index 5a04f9db251..41a8026d712 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/type/MethodRef.java +++ b/src/java.base/share/classes/java/lang/reflect/code/type/MethodRef.java @@ -27,8 +27,7 @@ import java.lang.constant.ClassDesc; import java.lang.constant.MethodTypeDesc; -import java.lang.reflect.Constructor; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.impl.MethodRefImpl; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -66,7 +65,7 @@ public sealed interface MethodRef extends TypeVarRef.Owner permits MethodRefImpl MethodHandle resolveToHandle(MethodHandles.Lookup l) throws ReflectiveOperationException; - Optional<CoreOps.FuncOp> codeModel(MethodHandles.Lookup l) throws ReflectiveOperationException; + Optional<CoreOp.FuncOp> codeModel(MethodHandles.Lookup l) throws ReflectiveOperationException; // Factories diff --git a/src/java.base/share/classes/java/lang/reflect/code/type/impl/MethodRefImpl.java b/src/java.base/share/classes/java/lang/reflect/code/type/impl/MethodRefImpl.java index 43d67404488..856fe8e8bd9 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/type/impl/MethodRefImpl.java +++ b/src/java.base/share/classes/java/lang/reflect/code/type/impl/MethodRefImpl.java @@ -25,7 +25,7 @@ package java.lang.reflect.code.type.impl; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.MethodRef; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandleInfo; @@ -116,7 +116,7 @@ static Class<?> resolve(MethodHandles.Lookup l, TypeElement t) throws Reflective // Copied code in jdk.compiler module throws UOE @Override - public Optional<CoreOps.FuncOp> codeModel(MethodHandles.Lookup l) throws ReflectiveOperationException { + public Optional<CoreOp.FuncOp> codeModel(MethodHandles.Lookup l) throws ReflectiveOperationException { /*__throw new UnsupportedOperationException();__*/ return resolveToMember(l).getCodeModel(); } diff --git a/src/java.base/share/classes/java/lang/reflect/code/writer/OpBuilder.java b/src/java.base/share/classes/java/lang/reflect/code/writer/OpBuilder.java index 497a7be15b5..68a85d46e7a 100644 --- a/src/java.base/share/classes/java/lang/reflect/code/writer/OpBuilder.java +++ b/src/java.base/share/classes/java/lang/reflect/code/writer/OpBuilder.java @@ -31,7 +31,7 @@ import java.lang.reflect.code.type.*; import java.util.*; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.*; diff --git a/src/jdk.code.tools/share/classes/jdk/code/tools/renderer/SRRenderer.java b/src/jdk.code.tools/share/classes/jdk/code/tools/renderer/SRRenderer.java index 359e1d54265..091a9c7190e 100644 --- a/src/jdk.code.tools/share/classes/jdk/code/tools/renderer/SRRenderer.java +++ b/src/jdk.code.tools/share/classes/jdk/code/tools/renderer/SRRenderer.java @@ -27,7 +27,7 @@ import java.lang.reflect.code.Block; import java.lang.reflect.code.Body; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; @@ -241,7 +241,7 @@ public void writeValueDecl(GlobalValueBlockNaming gn, Value v) { } // @@@ Not used - public void write(GlobalValueBlockNaming gn, CoreOps.FuncOp fRep) { + public void write(GlobalValueBlockNaming gn, CoreOp.FuncOp fRep) { this.append(fRep.opName());// w.write(name); if (!fRep.operands().isEmpty()) { space().spaceSeparatedList(); diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 34c1077dc88..fb016628f3b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -642,8 +642,8 @@ public <R, P> R accept(ElementVisitor<R, P> v, P p) { codeReflectionType = enterClass("java.lang.runtime.CodeReflection"); quotedType = enterClass("java.lang.reflect.code.Quoted"); quotableType = enterClass("java.lang.reflect.code.Quotable"); - closureOpType = enterClass("java.lang.reflect.code.op.CoreOps$ClosureOp"); - lambdaOpType = enterClass("java.lang.reflect.code.op.CoreOps$LambdaOp"); + closureOpType = enterClass("java.lang.reflect.code.op.CoreOp$ClosureOp"); + lambdaOpType = enterClass("java.lang.reflect.code.op.CoreOp$LambdaOp"); opInterpreterType = enterClass("java.lang.reflect.code.interpreter.Interpreter"); opType = enterClass("java.lang.reflect.code.Op"); opInterpreterInvoke = new MethodSymbol(PUBLIC | STATIC | VARARGS, diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java index 24a15542580..107a67d2e37 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ReflectMethods.java @@ -80,8 +80,8 @@ import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Options; import jdk.internal.java.lang.reflect.code.*; -import jdk.internal.java.lang.reflect.code.op.CoreOps; -import jdk.internal.java.lang.reflect.code.op.ExtendedOps; +import jdk.internal.java.lang.reflect.code.op.CoreOp; +import jdk.internal.java.lang.reflect.code.op.ExtendedOp; import jdk.internal.java.lang.reflect.code.type.*; import jdk.internal.java.lang.reflect.code.type.WildcardType.BoundKind; @@ -180,7 +180,7 @@ public void visitMethodDef(JCMethodDecl tree) { // if the method is annotated, scan it BodyScanner bodyScanner = new BodyScanner(tree); try { - CoreOps.FuncOp funcOp = bodyScanner.scanMethod(); + CoreOp.FuncOp funcOp = bodyScanner.scanMethod(); if (dumpIR) { // dump the method IR if requested log.note(Notes.MethodIrDump(tree.sym.enclClass(), tree.sym, funcOp.toText())); @@ -222,7 +222,7 @@ public void visitLambda(JCLambda tree) { // quoted lambda - scan it BodyScanner bodyScanner = new BodyScanner(tree, kind); try { - CoreOps.FuncOp funcOp = bodyScanner.scanLambda(); + CoreOp.FuncOp funcOp = bodyScanner.scanLambda(); if (dumpIR) { // dump the method IR if requested log.note(Notes.QuotedIrDump(funcOp.toText())); @@ -276,7 +276,7 @@ public void visitReference(JCMemberReference tree) { // quoted lambda - scan it BodyScanner bodyScanner = new BodyScanner(lambdaTree, kind); try { - CoreOps.FuncOp funcOp = bodyScanner.scanLambda(); + CoreOp.FuncOp funcOp = bodyScanner.scanLambda(); if (dumpIR) { // dump the method IR if requested log.note(Notes.QuotedIrDump(funcOp.toText())); @@ -350,7 +350,7 @@ Name lambdaName() { return names.fromString("lambda").append('$', names.fromString(String.valueOf(lambdaCount++))); } - private JCVariableDecl opFieldDecl(Name prefix, long flags, CoreOps.FuncOp op) { + private JCVariableDecl opFieldDecl(Name prefix, long flags, CoreOp.FuncOp op) { VarSymbol opFieldSym = new VarSymbol(flags | Flags.STATIC | Flags.FINAL | Flags.SYNTHETIC, prefix.append('$', names.fromString("op")), syms.stringType, @@ -369,7 +369,7 @@ public JCTree translateTopLevelClass(JCTree cdef, TreeMaker make) { return res; } - public CoreOps.FuncOp getMethodBody(Symbol.ClassSymbol classSym, JCMethodDecl methodDecl, JCBlock attributedBody, TreeMaker make) { + public CoreOp.FuncOp getMethodBody(Symbol.ClassSymbol classSym, JCMethodDecl methodDecl, JCBlock attributedBody, TreeMaker make) { // if the method is annotated, scan it // Called from JavacElements::getBody try { @@ -486,7 +486,7 @@ class BodyScanner extends FilterScanner { // @@@ this as local variable? (it can never be stored to) for (int i = 0 ; i < tree.params.size() ; i++) { - Op.Result paramOp = append(CoreOps.var( + Op.Result paramOp = append(CoreOp.var( tree.params.get(i).name.toString(), top.block.parameters().get(blockArgOffset + i))); top.localToOp.put(tree.params.get(i).sym, paramOp); @@ -554,7 +554,7 @@ Value capturedOpValue(Symbol sym) { var capturedVar = top.localToOp.get(sym); if (capturedVar == null) { var capturedArg = top.block.parameter(typeToTypeElement(sym.type)); - capturedVar = top.block.op(CoreOps.var(sym.name.toString(), capturedArg)); + capturedVar = top.block.op(CoreOp.var(sym.name.toString(), capturedArg)); top.localToOp.put(sym, capturedVar); } return capturedVar; @@ -644,7 +644,7 @@ public Value toValue(JCTree tree, Type target) { Value coerce(Value sourceValue, Type sourceType, Type targetType) { if (sourceType.isReference() && targetType.isReference() && !types.isSubtype(types.erasure(sourceType), types.erasure(targetType))) { - return append(CoreOps.cast(typeToTypeElement(targetType), sourceValue)); + return append(CoreOp.cast(typeToTypeElement(targetType), sourceValue)); } else { return convert(sourceValue, targetType); } @@ -673,7 +673,7 @@ Value convert(Value exprVal, Type target) { return exprVal; } else { // implicit primitive conversion - return append(CoreOps.conv(typeToTypeElement(target), exprVal)); + return append(CoreOp.conv(typeToTypeElement(target), exprVal)); } } else if (sourcePrimitive) { // we need to box @@ -695,7 +695,7 @@ Value box(Value valueExpr, Type box) { // Boxing is a static method e.g., java.lang.Integer::valueOf(int)java.lang.Integer MethodRef boxMethod = MethodRef.method(typeToTypeElement(box), names.valueOf.toString(), FunctionType.functionType(typeToTypeElement(box), typeToTypeElement(types.unboxedType(box)))); - return append(CoreOps.invoke(boxMethod, valueExpr)); + return append(CoreOp.invoke(boxMethod, valueExpr)); } Value unbox(Value valueExpr, Type box, Type primitive, Type unboxedType) { @@ -703,13 +703,13 @@ Value unbox(Value valueExpr, Type box, Type primitive, Type unboxedType) { // Object target, first downcast to correct wrapper type unboxedType = primitive; box = types.boxedClass(unboxedType).type; - valueExpr = append(CoreOps.cast(typeToTypeElement(box), valueExpr)); + valueExpr = append(CoreOp.cast(typeToTypeElement(box), valueExpr)); } // Unboxing is a virtual method e.g., java.lang.Integer::intValue()int MethodRef unboxMethod = MethodRef.method(typeToTypeElement(box), unboxedType.tsym.name.append(names.Value).toString(), FunctionType.functionType(typeToTypeElement(unboxedType))); - return append(CoreOps.invoke(unboxMethod, valueExpr)); + return append(CoreOp.invoke(unboxMethod, valueExpr)); } @Override @@ -726,7 +726,7 @@ public void visitVarDef(JCVariableDecl tree) { } else { initOp = append(defaultValue(tree.type)); } - result = append(CoreOps.var(tree.name.toString(), typeToTypeElement(tree.type), initOp)); + result = append(CoreOp.var(tree.name.toString(), typeToTypeElement(tree.type), initOp)); stack.localToOp.put(tree.sym, result); } @@ -746,14 +746,14 @@ public void visitAssign(JCAssign tree) { switch (sym.getKind()) { case LOCAL_VARIABLE, PARAMETER -> { Value varOp = varOpValue(sym); - append(CoreOps.varStore(varOp, result)); + append(CoreOp.varStore(varOp, result)); } case FIELD -> { FieldRef fd = symbolToFieldRef(sym, symbolSiteType(sym)); if (sym.isStatic()) { - append(CoreOps.fieldStore(fd, result)); + append(CoreOp.fieldStore(fd, result)); } else { - append(CoreOps.fieldStore(fd, thisValue(), result)); + append(CoreOp.fieldStore(fd, thisValue(), result)); } } default -> { @@ -774,9 +774,9 @@ public void visitAssign(JCAssign tree) { Symbol sym = assign.sym; FieldRef fr = symbolToFieldRef(sym, assign.selected.type); if (sym.isStatic()) { - append(CoreOps.fieldStore(fr, result)); + append(CoreOp.fieldStore(fr, result)); } else { - append(CoreOps.fieldStore(fr, receiver, result)); + append(CoreOp.fieldStore(fr, receiver, result)); } break; } @@ -789,7 +789,7 @@ public void visitAssign(JCAssign tree) { // Scan the rhs, the assign expression result is its input result = toValue(tree.rhs, target); - append(CoreOps.arrayStoreOp(array, index, result)); + append(CoreOp.arrayStoreOp(array, index, result)); break; } default: @@ -809,11 +809,11 @@ public void visitAssignop(JCTree.JCAssignOp tree) { Value assignOpResult = switch (tree.getTag()) { // Arithmetic operations - case PLUS_ASG -> append(CoreOps.add(lhs, rhs)); - case MINUS_ASG -> append(CoreOps.sub(lhs, rhs)); - case MUL_ASG -> append(CoreOps.mul(lhs, rhs)); - case DIV_ASG -> append(CoreOps.div(lhs, rhs)); - case MOD_ASG -> append(CoreOps.mod(lhs, rhs)); + case PLUS_ASG -> append(CoreOp.add(lhs, rhs)); + case MINUS_ASG -> append(CoreOp.sub(lhs, rhs)); + case MUL_ASG -> append(CoreOp.mul(lhs, rhs)); + case DIV_ASG -> append(CoreOp.div(lhs, rhs)); + case MOD_ASG -> append(CoreOp.mod(lhs, rhs)); default -> throw unsupported(tree); }; @@ -835,11 +835,11 @@ void applyCompoundAssign(JCTree.JCExpression lhs, Function<Value, Value> scanRhs case LOCAL_VARIABLE, PARAMETER -> { Value varOp = varOpValue(sym); - Op.Result lhsOpValue = append(CoreOps.varLoad(varOp)); + Op.Result lhsOpValue = append(CoreOp.varLoad(varOp)); // Scan the rhs Value r = scanRhs.apply(lhsOpValue); - append(CoreOps.varStore(varOp, r)); + append(CoreOp.varStore(varOp, r)); } case FIELD -> { FieldRef fr = symbolToFieldRef(sym, symbolSiteType(sym)); @@ -847,17 +847,17 @@ void applyCompoundAssign(JCTree.JCExpression lhs, Function<Value, Value> scanRhs Op.Result lhsOpValue; TypeElement resultType = typeToTypeElement(sym.type); if (sym.isStatic()) { - lhsOpValue = append(CoreOps.fieldLoad(resultType, fr)); + lhsOpValue = append(CoreOp.fieldLoad(resultType, fr)); } else { - lhsOpValue = append(CoreOps.fieldLoad(resultType, fr, thisValue())); + lhsOpValue = append(CoreOp.fieldLoad(resultType, fr, thisValue())); } // Scan the rhs Value r = scanRhs.apply(lhsOpValue); if (sym.isStatic()) { - append(CoreOps.fieldStore(fr, r)); + append(CoreOp.fieldStore(fr, r)); } else { - append(CoreOps.fieldStore(fr, thisValue(), r)); + append(CoreOp.fieldStore(fr, thisValue(), r)); } } default -> { @@ -877,17 +877,17 @@ void applyCompoundAssign(JCTree.JCExpression lhs, Function<Value, Value> scanRhs Op.Result lhsOpValue; TypeElement resultType = typeToTypeElement(sym.type); if (sym.isStatic()) { - lhsOpValue = append(CoreOps.fieldLoad(resultType, fr)); + lhsOpValue = append(CoreOp.fieldLoad(resultType, fr)); } else { - lhsOpValue = append(CoreOps.fieldLoad(resultType, fr, receiver)); + lhsOpValue = append(CoreOp.fieldLoad(resultType, fr, receiver)); } // Scan the rhs Value r = scanRhs.apply(lhsOpValue); if (sym.isStatic()) { - append(CoreOps.fieldStore(fr, r)); + append(CoreOp.fieldStore(fr, r)); } else { - append(CoreOps.fieldStore(fr, receiver, r)); + append(CoreOp.fieldStore(fr, receiver, r)); } } case INDEXED -> { @@ -896,11 +896,11 @@ void applyCompoundAssign(JCTree.JCExpression lhs, Function<Value, Value> scanRhs Value array = toValue(assign.indexed); Value index = toValue(assign.index); - Op.Result lhsOpValue = append(CoreOps.arrayLoadOp(array, index)); + Op.Result lhsOpValue = append(CoreOp.arrayLoadOp(array, index)); // Scan the rhs Value r = scanRhs.apply(lhsOpValue); - append(CoreOps.arrayStoreOp(array, index, r)); + append(CoreOp.arrayStoreOp(array, index, r)); } default -> throw unsupported(lhs); } @@ -916,7 +916,7 @@ public void visitIdent(JCIdent tree) { Value varOp = varOpValue(sym); if (varOp.type() instanceof VarType) { // regular var - result = append(CoreOps.varLoad(varOp)); + result = append(CoreOp.varLoad(varOp)); } else { // captured value result = varOp; @@ -929,9 +929,9 @@ public void visitIdent(JCIdent tree) { FieldRef fr = symbolToFieldRef(sym, symbolSiteType(sym)); TypeElement resultType = typeToTypeElement(sym.type); if (sym.isStatic()) { - result = append(CoreOps.fieldLoad(resultType, fr)); + result = append(CoreOp.fieldLoad(resultType, fr)); } else { - result = append(CoreOps.fieldLoad(resultType, fr, thisValue())); + result = append(CoreOp.fieldLoad(resultType, fr, thisValue())); } } } @@ -964,10 +964,10 @@ public void visitSelect(JCFieldAccess tree) { Value receiver = toValue(tree.selected); if (tree.name.equals(names._class)) { - result = append(CoreOps.constant(JavaType.J_L_CLASS, typeToTypeElement(tree.selected.type))); + result = append(CoreOp.constant(JavaType.J_L_CLASS, typeToTypeElement(tree.selected.type))); } else if (types.isArray(tree.selected.type)) { if (tree.sym.equals(syms.lengthVar)) { - result = append(CoreOps.arrayLength(receiver)); + result = append(CoreOp.arrayLength(receiver)); } else { // Should not reach here throw unsupported(tree); @@ -980,9 +980,9 @@ public void visitSelect(JCFieldAccess tree) { tree.selected.type : qualifierTarget); TypeElement resultType = typeToTypeElement(types.memberType(tree.selected.type, sym)); if (sym.isStatic()) { - result = append(CoreOps.fieldLoad(resultType, fr)); + result = append(CoreOp.fieldLoad(resultType, fr)); } else { - result = append(CoreOps.fieldLoad(resultType, fr, receiver)); + result = append(CoreOp.fieldLoad(resultType, fr, receiver)); } } case INTERFACE, CLASS, ENUM -> { @@ -1004,7 +1004,7 @@ public void visitIndexed(JCArrayAccess tree) { Value index = toValue(tree.index); - result = append(CoreOps.arrayLoadOp(array, index)); + result = append(CoreOp.arrayLoadOp(array, index)); } @Override @@ -1031,7 +1031,7 @@ public void visitApply(JCTree.JCMethodInvocation tree) { args.addAll(scanMethodArguments(tree.args, tree.meth.type, tree.varargsElement)); MethodRef mr = symbolToErasedMethodRef(sym, symbolSiteType(sym)); - Value res = append(CoreOps.invoke(typeToTypeElement(meth.type.getReturnType()), mr, args)); + Value res = append(CoreOp.invoke(typeToTypeElement(meth.type.getReturnType()), mr, args)); if (sym.type.getReturnType().getTag() != TypeTag.VOID) { result = res; } @@ -1053,7 +1053,7 @@ public void visitApply(JCTree.JCMethodInvocation tree) { MethodRef mr = symbolToErasedMethodRef(sym, qualifierTarget.hasTag(NONE) ? access.selected.type : qualifierTarget); - Value res = append(CoreOps.invoke(typeToTypeElement(meth.type.getReturnType()), mr, args)); + Value res = append(CoreOp.invoke(typeToTypeElement(meth.type.getReturnType()), mr, args)); if (sym.type.getReturnType().getTag() != TypeTag.VOID) { result = res; } @@ -1110,7 +1110,7 @@ public void visitTypeCast(JCTree.JCTypeCast tree) { // Redundant cast result = v; } else { - result = append(CoreOps.conv(typeToTypeElement(type), v)); + result = append(CoreOp.conv(typeToTypeElement(type), v)); } } else if (expressionType.isPrimitive() || type.isPrimitive()) { result = convert(v, tree.type); @@ -1121,7 +1121,7 @@ public void visitTypeCast(JCTree.JCTypeCast tree) { } else { // Reference cast JavaType jt = typeToTypeElement(types.erasure(type)); - result = append(CoreOps.cast(typeToTypeElement(type), jt, v)); + result = append(CoreOp.cast(typeToTypeElement(type), jt, v)); } } @@ -1132,7 +1132,7 @@ public void visitTypeTest(JCTree.JCInstanceOf tree) { if (tree.pattern.getTag() != Tag.IDENT) { result = scanPattern(tree.getPattern(), target); } else { - result = append(CoreOps.instanceOf(typeToTypeElement(tree.pattern.type), target)); + result = append(CoreOp.instanceOf(typeToTypeElement(tree.pattern.type), target)); } } @@ -1140,9 +1140,9 @@ Value scanPattern(JCTree.JCPattern pattern, Value target) { // Type of pattern JavaType patternType; if (pattern instanceof JCTree.JCBindingPattern p) { - patternType = ExtendedOps.Pattern.bindingType(typeToTypeElement(p.type)); + patternType = ExtendedOp.Pattern.bindingType(typeToTypeElement(p.type)); } else if (pattern instanceof JCTree.JCRecordPattern p) { - patternType = ExtendedOps.Pattern.recordType(typeToTypeElement(p.record.type)); + patternType = ExtendedOp.Pattern.recordType(typeToTypeElement(p.record.type)); } else { throw unsupported(pattern); } @@ -1166,7 +1166,7 @@ public void visitBindingPattern(JCTree.JCBindingPattern binding) { JCVariableDecl var = binding.var; variables.add(var); - result = append(ExtendedOps.bindingPattern(typeToTypeElement(var.type), var.name.toString())); + result = append(ExtendedOp.bindingPattern(typeToTypeElement(var.type), var.name.toString())); } @Override @@ -1179,7 +1179,7 @@ public void visitRecordPattern(JCTree.JCRecordPattern record) { nestedValues.add(toValue(jcPattern)); } - result = append(ExtendedOps.recordPattern(symbolToRecordTypeRef(record.record), nestedValues)); + result = append(ExtendedOp.recordPattern(symbolToRecordTypeRef(record.record), nestedValues)); } Value toValue(JCTree tree) { @@ -1190,7 +1190,7 @@ Value toValue(JCTree tree) { } // Scan pattern Value patternValue = new PatternScanner().toValue(pattern); - append(CoreOps._yield(patternValue)); + append(CoreOp._yield(patternValue)); Body.Builder patternBody = stack.body; // Pop body @@ -1208,7 +1208,7 @@ Value toValue(JCTree tree) { // builder associated with the nearest statement tree for (JCVariableDecl jcVar : variables) { Value init = variablesStack.block.op(defaultValue(jcVar.type)); - Op.Result op = variablesStack.block.op(CoreOps.var(jcVar.name.toString(), typeToTypeElement(jcVar.type), init)); + Op.Result op = variablesStack.block.op(CoreOp.var(jcVar.name.toString(), typeToTypeElement(jcVar.type), init)); variablesStack.localToOp.put(jcVar.sym, op); } @@ -1222,12 +1222,12 @@ Value toValue(JCTree tree) { for (int i = 0; i < variables.size(); i++) { Value v = matchBuilder.parameters().get(i); Value var = variablesStack.localToOp.get(variables.get(i).sym); - matchBuilder.op(CoreOps.varStore(var, v)); + matchBuilder.op(CoreOp.varStore(var, v)); } - matchBuilder.op(CoreOps._yield()); + matchBuilder.op(CoreOp._yield()); // Create the match operation - return append(ExtendedOps.match(target, patternBody, matchBody)); + return append(ExtendedOp.match(target, patternBody, matchBody)); } @Override @@ -1262,22 +1262,22 @@ public void visitNewClass(JCTree.JCNewClass tree) { args.addAll(scanMethodArguments(tree.args, tree.constructorType, tree.varargsElement)); - result = append(CoreOps._new(typeToTypeElement(type), constructorType, args)); + result = append(CoreOp._new(typeToTypeElement(type), constructorType, args)); } @Override public void visitNewArray(JCTree.JCNewArray tree) { if (tree.elems != null) { int length = tree.elems.size(); - Op.Result a = append(CoreOps.newArray( + Op.Result a = append(CoreOp.newArray( typeToTypeElement(tree.type), - append(CoreOps.constant(JavaType.INT, length)))); + append(CoreOp.constant(JavaType.INT, length)))); int i = 0; for (JCExpression elem : tree.elems) { Value element = toValue(elem, types.elemtype(tree.type)); - append(CoreOps.arrayStoreOp( + append(CoreOp.arrayStoreOp( a, - append(CoreOps.constant(JavaType.INT, i)), + append(CoreOp.constant(JavaType.INT, i)), element)); i++; } @@ -1292,7 +1292,7 @@ public void visitNewArray(JCTree.JCNewArray tree) { JavaType arrayType = typeToTypeElement(tree.type); FunctionType constructorType = FunctionType.functionType(arrayType, indexes.stream().map(Value::type).toList()); - result = append(CoreOps._new(arrayType, constructorType, indexes)); + result = append(CoreOp._new(arrayType, constructorType, indexes)); } } @@ -1317,7 +1317,7 @@ public void visitLambda(JCTree.JCLambda tree) { // Map lambda parameters to varOp values for (int i = 0; i < tree.params.size(); i++) { JCVariableDecl p = tree.params.get(i); - Op.Result paramOp = append(CoreOps.var( + Op.Result paramOp = append(CoreOp.var( p.name.toString(), stack.block.parameters().get(i))); stack.localToOp.put(p.sym, paramOp); @@ -1327,9 +1327,9 @@ public void visitLambda(JCTree.JCLambda tree) { if (tree.getBodyKind() == LambdaExpressionTree.BodyKind.EXPRESSION) { Value exprVal = toValue(tree.body, tree.getDescriptorType(types).getReturnType()); if (!tree.body.type.hasTag(TypeTag.VOID)) { - append(CoreOps._return(exprVal)); + append(CoreOp._return(exprVal)); } else { - appendTerminating(CoreOps::_return); + appendTerminating(CoreOp::_return); } } else { Type prevBodyTarget = bodyTarget; @@ -1337,7 +1337,7 @@ public void visitLambda(JCTree.JCLambda tree) { bodyTarget = tree.getDescriptorType(types).getReturnType(); toValue(tree.body); // @@@ Check if unreachable - appendTerminating(CoreOps::_return); + appendTerminating(CoreOp::_return); } finally { bodyTarget = prevBodyTarget; } @@ -1345,13 +1345,13 @@ public void visitLambda(JCTree.JCLambda tree) { Op lambdaOp = switch (kind) { case QUOTED_STRUCTURAL -> { - yield CoreOps.closure(stack.body); + yield CoreOp.closure(stack.body); } case QUOTABLE, NOT_QUOTED -> { // Get the functional interface type JavaType fiType = typeToTypeElement(tree.target); // build functional lambda - yield CoreOps.lambda(fiType, stack.body); + yield CoreOp.lambda(fiType, stack.body); } }; @@ -1366,8 +1366,8 @@ public void visitLambda(JCTree.JCLambda tree) { } if (isQuoted || kind == FunctionalExpressionKind.QUOTED_STRUCTURAL) { - append(CoreOps._yield(lambdaResult)); - CoreOps.QuotedOp quotedOp = CoreOps.quoted(stack.body); + append(CoreOp._yield(lambdaResult)); + CoreOp.QuotedOp quotedOp = CoreOp.quoted(stack.body); // Pop quoted body popBody(); @@ -1392,7 +1392,7 @@ public void visitIf(JCTree.JCIf tree) { FunctionType.functionType(JavaType.BOOLEAN)); Value last = toValue(cond); // Yield the boolean result of the condition - append(CoreOps._yield(last)); + append(CoreOp._yield(last)); bodies.add(stack.body); // Pop if condition @@ -1402,7 +1402,7 @@ public void visitIf(JCTree.JCIf tree) { pushBody(tree.thenpart, FunctionType.VOID); scan(tree.thenpart); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); bodies.add(stack.body); // Pop if body @@ -1417,7 +1417,7 @@ else if (elsepart.getTag() == Tag.BLOCK) { pushBody(elsepart, FunctionType.VOID); scan(elsepart); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); bodies.add(stack.body); // Pop else body @@ -1430,7 +1430,7 @@ else if (elsepart.getTag() == Tag.BLOCK) { first = false; } - append(ExtendedOps._if(bodies)); + append(ExtendedOp._if(bodies)); result = null; } @@ -1459,21 +1459,21 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { pushBody(pcl.pat, FunctionType.functionType(JavaType.BOOLEAN)); Value patVal = scanPattern(pcl.pat, localTarget); - append(CoreOps._yield(patVal)); + append(CoreOp._yield(patVal)); clBodies.add(stack.body); popBody(); pushBody(c.guard, FunctionType.functionType(JavaType.BOOLEAN)); - append(CoreOps._yield(toValue(c.guard))); + append(CoreOp._yield(toValue(c.guard))); clBodies.add(stack.body); popBody(); - localResult = append(ExtendedOps.conditionalAnd(clBodies)); + localResult = append(ExtendedOp.conditionalAnd(clBodies)); } else { localResult = scanPattern(pcl.pat, localTarget); } // Yield the boolean result of the condition - append(CoreOps._yield(localResult)); + append(CoreOp._yield(localResult)); bodies.add(stack.body); // Pop label @@ -1487,9 +1487,9 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { Value expr = toValue(ccl.expr); // @@@ Conversion of localTarget if (ccl.expr.type.isPrimitive()) { - localResult = append(CoreOps.eq(localTarget, expr)); + localResult = append(CoreOp.eq(localTarget, expr)); } else { - localResult = append(CoreOps.invoke( + localResult = append(CoreOp.invoke( MethodRef.method(Objects.class, "equals", boolean.class, Object.class, Object.class), localTarget, expr)); } @@ -1503,24 +1503,24 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { // @@@ Conversion of localTarget final Value labelResult; if (ccl.expr.type.isPrimitive()) { - labelResult = append(CoreOps.eq(localTarget, expr)); + labelResult = append(CoreOp.eq(localTarget, expr)); } else { - labelResult = append(CoreOps.invoke( + labelResult = append(CoreOp.invoke( MethodRef.method(Objects.class, "equals", boolean.class, Object.class, Object.class), localTarget, expr)); } - append(CoreOps._yield(labelResult)); + append(CoreOp._yield(labelResult)); clBodies.add(stack.body); // Pop label popBody(); } - localResult = append(ExtendedOps.conditionalOr(clBodies)); + localResult = append(ExtendedOp.conditionalOr(clBodies)); } - append(CoreOps._yield(localResult)); + append(CoreOp._yield(localResult)); bodies.add(stack.body); // Pop labels @@ -1529,7 +1529,7 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { // @@@ Do we need to model the default label body? pushBody(headCl, FunctionType.VOID); - append(CoreOps._yield()); + append(CoreOp._yield()); bodies.add(stack.body); // Pop label @@ -1546,7 +1546,7 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { if (c.body instanceof JCExpression) { // Yield the boolean result of the condition Value bodyVal = toValue(c.body, yieldType); - append(CoreOps._yield(bodyVal)); + append(CoreOp._yield(bodyVal)); } else { // Otherwise there is a yield statement Type prevBodyTarget = bodyTarget; @@ -1570,8 +1570,8 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { scan(c.stats); appendTerminating(c.completesNormally - ? ExtendedOps::switchFallthroughOp - : CoreOps::unreachable); + ? ExtendedOp::switchFallthroughOp + : CoreOp::unreachable); bodies.add(stack.body); @@ -1581,16 +1581,16 @@ public void visitSwitchExpression(JCTree.JCSwitchExpression tree) { }; } - result = append(ExtendedOps.switchExpression(actionType.returnType(), target, bodies)); + result = append(ExtendedOp.switchExpression(actionType.returnType(), target, bodies)); } @Override public void visitYield(JCTree.JCYield tree) { Value retVal = toValue(tree.value, bodyTarget); if (retVal == null) { - result = append(ExtendedOps.java_yield()); + result = append(ExtendedOp.java_yield()); } else { - result = append(ExtendedOps.java_yield(retVal)); + result = append(ExtendedOp.java_yield(retVal)); } } @@ -1604,7 +1604,7 @@ public void visitWhileLoop(JCTree.JCWhileLoop tree) { pushBody(cond, FunctionType.functionType(JavaType.BOOLEAN)); Value last = toValue(cond); // Yield the boolean result of the condition - append(CoreOps._yield(last)); + append(CoreOp._yield(last)); Body.Builder condition = stack.body; // Pop while condition @@ -1613,13 +1613,13 @@ public void visitWhileLoop(JCTree.JCWhileLoop tree) { // Push while body pushBody(tree.body, FunctionType.VOID); scan(tree.body); - appendTerminating(ExtendedOps::_continue); + appendTerminating(ExtendedOp::_continue); Body.Builder body = stack.body; // Pop while body popBody(); - append(ExtendedOps._while(condition, body)); + append(ExtendedOp._while(condition, body)); result = null; } @@ -1632,7 +1632,7 @@ public void visitDoLoop(JCTree.JCDoWhileLoop tree) { // Push while body pushBody(tree.body, FunctionType.VOID); scan(tree.body); - appendTerminating(ExtendedOps::_continue); + appendTerminating(ExtendedOp::_continue); Body.Builder body = stack.body; // Pop while body @@ -1642,13 +1642,13 @@ public void visitDoLoop(JCTree.JCDoWhileLoop tree) { pushBody(cond, FunctionType.functionType(JavaType.BOOLEAN)); Value last = toValue(cond); // Yield the boolean result of the condition - append(CoreOps._yield(last)); + append(CoreOp._yield(last)); Body.Builder condition = stack.body; // Pop while condition popBody(); - append(ExtendedOps.doWhile(body, condition)); + append(ExtendedOp.doWhile(body, condition)); result = null; } @@ -1658,7 +1658,7 @@ public void visitForeachLoop(JCTree.JCEnhancedForLoop tree) { pushBody(tree.expr, FunctionType.functionType(typeToTypeElement(tree.expr.type))); Value last = toValue(tree.expr); // Yield the Iterable result of the expression - append(CoreOps._yield(last)); + append(CoreOp._yield(last)); Body.Builder expression = stack.body; // Pop expression @@ -1672,8 +1672,8 @@ public void visitForeachLoop(JCTree.JCEnhancedForLoop tree) { // @@@ When lhs assignment is a pattern we embed the pattern match into the init body and // return the bound variables pushBody(var, FunctionType.functionType(varEType, eType)); - Op.Result varEResult = append(CoreOps.var(var.name.toString(), stack.block.parameters().get(0))); - append(CoreOps._yield(varEResult)); + Op.Result varEResult = append(CoreOp.var(var.name.toString(), stack.block.parameters().get(0))); + append(CoreOp._yield(varEResult)); Body.Builder init = stack.body; // Pop init popBody(); @@ -1683,12 +1683,12 @@ public void visitForeachLoop(JCTree.JCEnhancedForLoop tree) { stack.localToOp.put(var.sym, stack.block.parameters().get(0)); scan(tree.body); - appendTerminating(ExtendedOps::_continue); + appendTerminating(ExtendedOp::_continue); Body.Builder body = stack.body; // Pop body popBody(); - append(ExtendedOps.enhancedFor(expression, init, body)); + append(ExtendedOp.enhancedFor(expression, init, body)); result = null; } @@ -1737,17 +1737,17 @@ List<Value> varValues() { scan(tree.init); // Capture all local variable declarations in tuple - append(CoreOps._yield(append(CoreOps.tuple(vds.varValues())))); + append(CoreOp._yield(append(CoreOp.tuple(vds.varValues())))); } else if (varTypes.size() == 1) { pushBody(null, FunctionType.functionType(varTypes.get(0))); scan(tree.init); - append(CoreOps._yield(vds.varValues().get(0))); + append(CoreOp._yield(vds.varValues().get(0))); } else { pushBody(null, FunctionType.VOID); scan(tree.init); - append(CoreOps._yield()); + append(CoreOp._yield()); } Body.Builder init = stack.body; @@ -1761,9 +1761,9 @@ List<Value> varValues() { Value last = toValue(tree.cond); // Yield the boolean result of the condition - append(CoreOps._yield(last)); + append(CoreOp._yield(last)); } else { - append(CoreOps._yield(append(CoreOps.constant(JavaType.BOOLEAN, true)))); + append(CoreOp._yield(append(CoreOp.constant(JavaType.BOOLEAN, true)))); } Body.Builder cond = stack.body; @@ -1778,7 +1778,7 @@ List<Value> varValues() { scan(tree.step); } - append(CoreOps._yield()); + append(CoreOp._yield()); Body.Builder update = stack.body; // Pop update @@ -1791,13 +1791,13 @@ List<Value> varValues() { scan(tree.body); } - appendTerminating(ExtendedOps::_continue); + appendTerminating(ExtendedOp::_continue); Body.Builder body = stack.body; // Pop update popBody(); - append(ExtendedOps._for(init, cond, update, body)); + append(ExtendedOp._for(init, cond, update, body)); result = null; } @@ -1812,7 +1812,7 @@ public void visitConditional(JCTree.JCConditional tree) { FunctionType.functionType(JavaType.BOOLEAN)); Value condVal = toValue(cond); // Yield the boolean result of the condition - append(CoreOps._yield(condVal)); + append(CoreOp._yield(condVal)); bodies.add(stack.body); // Pop condition @@ -1828,7 +1828,7 @@ public void visitConditional(JCTree.JCConditional tree) { Value trueVal = toValue(truepart, condType); // Yield the result - append(CoreOps._yield(trueVal)); + append(CoreOp._yield(trueVal)); bodies.add(stack.body); // Pop true body @@ -1842,13 +1842,13 @@ public void visitConditional(JCTree.JCConditional tree) { Value falseVal = toValue(falsepart, condType); // Yield the result - append(CoreOps._yield(falseVal)); + append(CoreOp._yield(falseVal)); bodies.add(stack.body); // Pop false body popBody(); - result = append(ExtendedOps.conditionalExpression(typeToTypeElement(condType), bodies)); + result = append(ExtendedOp.conditionalExpression(typeToTypeElement(condType), bodies)); } private Type condType(JCExpression tree, Type type) { @@ -1878,7 +1878,7 @@ public void visitAssert(JCAssert tree) { Value condVal = toValue(cond); // Yield the boolean result of the condition - append(CoreOps._yield(condVal)); + append(CoreOp._yield(condVal)); bodies.add(stack.body); // Pop condition @@ -1891,14 +1891,14 @@ public void visitAssert(JCAssert tree) { FunctionType.functionType(typeToTypeElement(tree.detail.type))); Value detailVal = toValue(detail); - append(CoreOps._yield(detailVal)); + append(CoreOp._yield(detailVal)); bodies.add(stack.body); //Pop detail popBody(); } - result = append(CoreOps._assert(bodies)); + result = append(CoreOp._assert(bodies)); } @@ -1913,13 +1913,13 @@ public void visitBlock(JCTree.JCBlock tree) { // Push block pushBody(tree, FunctionType.VOID); scan(tree.stats); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); Body.Builder body = stack.body; // Pop block popBody(); - append(ExtendedOps.block(body)); + append(ExtendedOp.block(body)); } result = null; } @@ -1930,17 +1930,17 @@ public void visitLabelled(JCTree.JCLabeledStatement tree) { pushBody(tree, FunctionType.VOID); // Create constant for label String labelName = tree.label.toString(); - Op.Result label = append(CoreOps.constant(JavaType.J_L_STRING, labelName)); + Op.Result label = append(CoreOp.constant(JavaType.J_L_STRING, labelName)); // Set label on body stack stack.setLabel(labelName, label); scan(tree.body); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); Body.Builder body = stack.body; // Pop block popBody(); - result = append(ExtendedOps.labeled(body)); + result = append(ExtendedOp.labeled(body)); } @Override @@ -1968,7 +1968,7 @@ public void visitTry(JCTree.JCTry tree) { rValues.add(toValue(resource)); } - append(CoreOps._yield(append(CoreOps.tuple(rValues)))); + append(CoreOp._yield(append(CoreOp.tuple(rValues)))); resources = stack.body; // Pop resources body @@ -1989,7 +1989,7 @@ public void visitTry(JCTree.JCTry tree) { stack.localToOp.put(rVariableDecls.get(i).sym, stack.block.parameters().get(i)); } scan(tree.body); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); Body.Builder body = stack.body; // Pop block @@ -1999,12 +1999,12 @@ public void visitTry(JCTree.JCTry tree) { for (JCTree.JCCatch catcher : tree.catchers) { // Push body pushBody(catcher.body, FunctionType.functionType(JavaType.VOID, typeToTypeElement(catcher.param.type))); - Op.Result exVariable = append(CoreOps.var( + Op.Result exVariable = append(CoreOp.var( catcher.param.name.toString(), stack.block.parameters().get(0))); stack.localToOp.put(catcher.param.sym, exVariable); scan(catcher.body); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); catchers.add(stack.body); // Pop block @@ -2016,7 +2016,7 @@ public void visitTry(JCTree.JCTry tree) { // Push body pushBody(tree.finalizer, FunctionType.VOID); scan(tree.finalizer); - appendTerminating(CoreOps::_yield); + appendTerminating(CoreOp::_yield); finalizer = stack.body; // Pop block @@ -2026,7 +2026,7 @@ public void visitTry(JCTree.JCTry tree) { finalizer = null; } - result = append(ExtendedOps._try(resources, body, catchers, finalizer)); + result = append(ExtendedOp._try(resources, body, catchers, finalizer)); } @Override @@ -2041,8 +2041,8 @@ public void visitUnary(JCTree.JCUnary tree) { Value unboxedLhsPlusOne = switch (tree.getTag()) { // Arithmetic operations - case POSTINC, PREINC -> append(CoreOps.add(unboxedLhs, one)); - case POSTDEC, PREDEC -> append(CoreOps.sub(unboxedLhs, one)); + case POSTINC, PREINC -> append(CoreOp.add(unboxedLhs, one)); + case POSTDEC, PREDEC -> append(CoreOp.sub(unboxedLhs, one)); default -> throw unsupported(tree); }; @@ -2062,11 +2062,11 @@ public void visitUnary(JCTree.JCUnary tree) { } case NEG -> { Value rhs = toValue(tree.arg, tree.type); - result = append(CoreOps.neg(rhs)); + result = append(CoreOp.neg(rhs)); } case NOT -> { Value rhs = toValue(tree.arg, tree.type); - result = append(CoreOps.not(rhs)); + result = append(CoreOp.not(rhs)); } default -> throw unsupported(tree); } @@ -2083,7 +2083,7 @@ public void visitBinary(JCBinary tree) { pushBody(tree.lhs, FunctionType.functionType(JavaType.BOOLEAN)); Value lhs = toValue(tree.lhs); // Yield the boolean result of the condition - append(CoreOps._yield(lhs)); + append(CoreOp._yield(lhs)); Body.Builder bodyLhs = stack.body; // Pop lhs @@ -2093,7 +2093,7 @@ public void visitBinary(JCBinary tree) { pushBody(tree.rhs, FunctionType.functionType(JavaType.BOOLEAN)); Value rhs = toValue(tree.rhs); // Yield the boolean result of the condition - append(CoreOps._yield(rhs)); + append(CoreOp._yield(rhs)); Body.Builder bodyRhs = stack.body; // Pop lhs @@ -2101,8 +2101,8 @@ public void visitBinary(JCBinary tree) { List<Body.Builder> bodies = List.of(bodyLhs, bodyRhs); result = append(tag == Tag.AND - ? ExtendedOps.conditionalAnd(bodies) - : ExtendedOps.conditionalOr(bodies)); + ? ExtendedOp.conditionalAnd(bodies) + : ExtendedOp.conditionalOr(bodies)); } else if (tag == Tag.PLUS && tree.operator.opcode == ByteCodes.string_add) { //Ignore the operator and query both subexpressions for their type with concats Type lhsType = tree.lhs.type; @@ -2111,7 +2111,7 @@ public void visitBinary(JCBinary tree) { Value lhs = toValue(tree.lhs, lhsType); Value rhs = toValue(tree.rhs, rhsType); - result = append(CoreOps.concat(lhs, rhs)); + result = append(CoreOp.concat(lhs, rhs)); } else { Type opType = tree.operator.type.getParameterTypes().getFirst(); @@ -2122,30 +2122,30 @@ public void visitBinary(JCBinary tree) { result = switch (tag) { // Arithmetic operations - case PLUS -> append(CoreOps.add(lhs, rhs)); - case MINUS -> append(CoreOps.sub(lhs, rhs)); - case MUL -> append(CoreOps.mul(lhs, rhs)); - case DIV -> append(CoreOps.div(lhs, rhs)); - case MOD -> append(CoreOps.mod(lhs, rhs)); + case PLUS -> append(CoreOp.add(lhs, rhs)); + case MINUS -> append(CoreOp.sub(lhs, rhs)); + case MUL -> append(CoreOp.mul(lhs, rhs)); + case DIV -> append(CoreOp.div(lhs, rhs)); + case MOD -> append(CoreOp.mod(lhs, rhs)); // Test operations - case EQ -> append(CoreOps.eq(lhs, rhs)); - case NE -> append(CoreOps.neq(lhs, rhs)); + case EQ -> append(CoreOp.eq(lhs, rhs)); + case NE -> append(CoreOp.neq(lhs, rhs)); // - case LT -> append(CoreOps.lt(lhs, rhs)); - case LE -> append(CoreOps.le(lhs, rhs)); - case GT -> append(CoreOps.gt(lhs, rhs)); - case GE -> append(CoreOps.ge(lhs, rhs)); + case LT -> append(CoreOp.lt(lhs, rhs)); + case LE -> append(CoreOp.le(lhs, rhs)); + case GT -> append(CoreOp.gt(lhs, rhs)); + case GE -> append(CoreOp.ge(lhs, rhs)); // Bitwise operations (including their boolean variants) - case BITOR -> append(CoreOps.or(lhs, rhs)); - case BITAND -> append(CoreOps.and(lhs, rhs)); - case BITXOR -> append(CoreOps.xor(lhs, rhs)); + case BITOR -> append(CoreOp.or(lhs, rhs)); + case BITAND -> append(CoreOp.and(lhs, rhs)); + case BITXOR -> append(CoreOp.xor(lhs, rhs)); // Shift operations - case SL -> append(CoreOps.lshl(lhs, rhs)); - case SR -> append(CoreOps.ashr(lhs, rhs)); - case USR -> append(CoreOps.lshr(lhs, rhs)); + case SL -> append(CoreOp.lshl(lhs, rhs)); + case SR -> append(CoreOp.ashr(lhs, rhs)); + case USR -> append(CoreOp.lshr(lhs, rhs)); default -> throw unsupported(tree); }; @@ -2160,23 +2160,23 @@ public void visitLiteral(JCLiteral tree) { default -> tree.value; }; Type constantType = adaptBottom(tree.type); - result = append(CoreOps.constant(typeToTypeElement(constantType), value)); + result = append(CoreOp.constant(typeToTypeElement(constantType), value)); } @Override public void visitReturn(JCReturn tree) { Value retVal = toValue(tree.expr, bodyTarget); if (retVal == null) { - result = append(CoreOps._return()); + result = append(CoreOp._return()); } else { - result = append(CoreOps._return(retVal)); + result = append(CoreOp._return(retVal)); } } @Override public void visitThrow(JCTree.JCThrow tree) { Value throwVal = toValue(tree.expr); - result = append(CoreOps._throw(throwVal)); + result = append(CoreOp._throw(throwVal)); } @Override @@ -2184,7 +2184,7 @@ public void visitBreak(JCTree.JCBreak tree) { Value label = tree.label != null ? getLabel(tree.label.toString()) : null; - result = append(ExtendedOps._break(label)); + result = append(ExtendedOp._break(label)); } @Override @@ -2192,7 +2192,7 @@ public void visitContinue(JCTree.JCContinue tree) { Value label = tree.label != null ? getLabel(tree.label.toString()) : null; - result = append(ExtendedOps._continue(label)); + result = append(ExtendedOp._continue(label)); } @Override @@ -2205,19 +2205,19 @@ UnsupportedASTException unsupported(JCTree tree) { return new UnsupportedASTException(tree); } - CoreOps.FuncOp scanMethod() { + CoreOp.FuncOp scanMethod() { scan(body); // @@@ Check if unreachable - appendTerminating(CoreOps::_return); - CoreOps.FuncOp func = CoreOps.func(name.toString(), stack.body); + appendTerminating(CoreOp::_return); + CoreOp.FuncOp func = CoreOp.func(name.toString(), stack.body); func.setLocation(generateLocation(currentNode, true)); return func; } - CoreOps.FuncOp scanLambda() { + CoreOp.FuncOp scanLambda() { scan(body); - append(CoreOps._return(result)); - return CoreOps.func(name.toString(), stack.body); + append(CoreOp._return(result)); + return CoreOp.func(name.toString(), stack.body); } JavaType symbolToErasedDesc(Symbol s) { @@ -2332,27 +2332,27 @@ RecordTypeRef symbolToRecordTypeRef(Symbol.ClassSymbol s) { Op defaultValue(Type t) { return switch (t.getTag()) { - case BYTE -> CoreOps.constant(typeToTypeElement(t), (byte)0); - case CHAR -> CoreOps.constant(typeToTypeElement(t), (char)0); - case BOOLEAN -> CoreOps.constant(typeToTypeElement(t), false); - case SHORT -> CoreOps.constant(typeToTypeElement(t), (short)0); - case INT -> CoreOps.constant(typeToTypeElement(t), 0); - case FLOAT -> CoreOps.constant(typeToTypeElement(t), 0f); - case LONG -> CoreOps.constant(typeToTypeElement(t), 0L); - case DOUBLE -> CoreOps.constant(typeToTypeElement(t), 0d); - default -> CoreOps.constant(typeToTypeElement(t), null); + case BYTE -> CoreOp.constant(typeToTypeElement(t), (byte)0); + case CHAR -> CoreOp.constant(typeToTypeElement(t), (char)0); + case BOOLEAN -> CoreOp.constant(typeToTypeElement(t), false); + case SHORT -> CoreOp.constant(typeToTypeElement(t), (short)0); + case INT -> CoreOp.constant(typeToTypeElement(t), 0); + case FLOAT -> CoreOp.constant(typeToTypeElement(t), 0f); + case LONG -> CoreOp.constant(typeToTypeElement(t), 0L); + case DOUBLE -> CoreOp.constant(typeToTypeElement(t), 0d); + default -> CoreOp.constant(typeToTypeElement(t), null); }; } Op numericOneValue(Type t) { return switch (t.getTag()) { - case BYTE -> CoreOps.constant(typeToTypeElement(t), (byte)1); - case CHAR -> CoreOps.constant(typeToTypeElement(t), (char)1); - case SHORT -> CoreOps.constant(typeToTypeElement(t), (short)1); - case INT -> CoreOps.constant(typeToTypeElement(t), 1); - case FLOAT -> CoreOps.constant(typeToTypeElement(t), 1f); - case LONG -> CoreOps.constant(typeToTypeElement(t), 1L); - case DOUBLE -> CoreOps.constant(typeToTypeElement(t), 1d); + case BYTE -> CoreOp.constant(typeToTypeElement(t), (byte)1); + case CHAR -> CoreOp.constant(typeToTypeElement(t), (char)1); + case SHORT -> CoreOp.constant(typeToTypeElement(t), (short)1); + case INT -> CoreOp.constant(typeToTypeElement(t), 1); + case FLOAT -> CoreOp.constant(typeToTypeElement(t), 1f); + case LONG -> CoreOp.constant(typeToTypeElement(t), 1L); + case DOUBLE -> CoreOp.constant(typeToTypeElement(t), 1d); case CLASS -> numericOneValue(types.unboxedType(t)); default -> throw new UnsupportedOperationException(t.toString()); }; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java index 56285af2c31..8f39b7274f9 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java @@ -82,7 +82,7 @@ import com.sun.tools.javac.comp.Modules; import com.sun.tools.javac.comp.Resolve; import com.sun.tools.javac.resources.CompilerProperties.Notes; -import jdk.internal.java.lang.reflect.code.op.CoreOps; +import jdk.internal.java.lang.reflect.code.op.CoreOp; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -814,7 +814,7 @@ public Optional<Object> getBody(ExecutableElement e) { return Optional.empty(); } - CoreOps.FuncOp funcOp; + CoreOp.FuncOp funcOp; try { JCMethodDecl methodTree = (JCMethodDecl)getTree(e); JavacScope scope = javacTrees.getScope(javacTrees.getPath(e)); diff --git a/test/jdk/java/lang/reflect/code/CoreBinaryOpsTest.java b/test/jdk/java/lang/reflect/code/CoreBinaryOpsTest.java index 1290003805a..694b17be6d3 100644 --- a/test/jdk/java/lang/reflect/code/CoreBinaryOpsTest.java +++ b/test/jdk/java/lang/reflect/code/CoreBinaryOpsTest.java @@ -50,7 +50,7 @@ import java.lang.reflect.code.analysis.SSA; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.reflect.code.interpreter.Interpreter; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; import java.lang.runtime.CodeReflection; @@ -165,7 +165,7 @@ static int xor(int left, int right) { @ParameterizedTest @CodeReflectionExecutionSource - void test(CoreOps.FuncOp funcOp, Object left, Object right) { + void test(CoreOp.FuncOp funcOp, Object left, Object right) { Result interpret = runCatching(() -> interpret(left, right, funcOp)); Result bytecode = runCatching(() -> bytecode(left, right, funcOp)); assertResults(interpret, bytecode); @@ -203,7 +203,7 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo Method testMethod = extensionContext.getRequiredTestMethod(); return codeReflectionMethods(extensionContext.getRequiredTestClass()) .flatMap(method -> { - CoreOps.FuncOp funcOp = method.getCodeModel().orElseThrow( + CoreOp.FuncOp funcOp = method.getCodeModel().orElseThrow( () -> new IllegalStateException("Expected code model to be present for method " + method) ); SupportedTypes supportedTypes = method.getAnnotation(SupportedTypes.class); @@ -234,7 +234,7 @@ private static <T> Stream<List<T>> cartesianProduct(List<List<T>> source) { })); } - private static CoreOps.FuncOp retype(CoreOps.FuncOp original, Class<?> newType) { + private static CoreOp.FuncOp retype(CoreOp.FuncOp original, Class<?> newType) { JavaType type = JavaType.type(newType); FunctionType functionType = original.invokableType(); if (functionType.parameterTypes().stream().allMatch(t -> t.equals(type))) { @@ -248,7 +248,7 @@ private static CoreOps.FuncOp retype(CoreOps.FuncOp original, Class<?> newType) TypeElement retType = functionType.returnType().equals(functionType.parameterTypes().getFirst()) ? type : functionType.returnType(); - return CoreOps.func(original.funcName(), FunctionType.functionType(retType, type, type)) + return CoreOp.func(original.funcName(), FunctionType.functionType(retType, type, type)) .body(builder -> builder.transformBody(original.body(), builder.parameters(), (block, op) -> { block.context().mapValue(op.result(), block.op(retype(block.context(), op))); return block; @@ -258,22 +258,22 @@ private static CoreOps.FuncOp retype(CoreOps.FuncOp original, Class<?> newType) private static Op retype(CopyContext context, Op op) { return switch (op) { - case CoreOps.VarOp varOp -> - CoreOps.var(varOp.varName(), context.getValueOrDefault(varOp.operands().getFirst(), varOp.operands().getFirst())); + case CoreOp.VarOp varOp -> + CoreOp.var(varOp.varName(), context.getValueOrDefault(varOp.operands().getFirst(), varOp.operands().getFirst())); default -> op; }; } - private static Stream<Arguments> argumentsForMethod(CoreOps.FuncOp funcOp, Method testMethod) { + private static Stream<Arguments> argumentsForMethod(CoreOp.FuncOp funcOp, Method testMethod) { Parameter[] testMethodParameters = testMethod.getParameters(); List<TypeElement> funcParameters = funcOp.invokableType().parameterTypes(); if (testMethodParameters.length - 1 != funcParameters.size()) { throw new IllegalArgumentException("method " + testMethod + " does not take the correct number of parameters"); } - if (testMethodParameters[0].getType() != CoreOps.FuncOp.class) { + if (testMethodParameters[0].getType() != CoreOp.FuncOp.class) { throw new IllegalArgumentException("method " + testMethod + " does not take a leading FuncOp argument"); } - Named<CoreOps.FuncOp> opNamed = Named.of(funcOp.funcName() + "{" + funcOp.invokableType() + "}", funcOp); + Named<CoreOp.FuncOp> opNamed = Named.of(funcOp.funcName() + "{" + funcOp.invokableType() + "}", funcOp); MethodHandles.Lookup lookup = MethodHandles.lookup(); for (int i = 1; i < testMethodParameters.length; i++) { Class<?> resolved = resolveParameter(funcParameters.get(i - 1), lookup); @@ -319,12 +319,12 @@ private static Stream<Method> codeReflectionMethods(Class<?> testClass) { } - private static Object interpret(Object left, Object right, CoreOps.FuncOp op) { + private static Object interpret(Object left, Object right, CoreOp.FuncOp op) { return Interpreter.invoke(MethodHandles.lookup(), op, left, right); } - private static Object bytecode(Object left, Object right, CoreOps.FuncOp op) throws Throwable { - CoreOps.FuncOp func = SSA.transform(op.transform((block, o) -> { + private static Object bytecode(Object left, Object right, CoreOp.FuncOp op) throws Throwable { + CoreOp.FuncOp func = SSA.transform(op.transform((block, o) -> { if (o instanceof Op.Lowerable lowerable) { return lowerable.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/TestArrayCreation.java b/test/jdk/java/lang/reflect/code/TestArrayCreation.java index 8940eeef749..88b3c809ee4 100644 --- a/test/jdk/java/lang/reflect/code/TestArrayCreation.java +++ b/test/jdk/java/lang/reflect/code/TestArrayCreation.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; import java.lang.runtime.CodeReflection; @@ -44,7 +44,7 @@ public static String[] f() { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); @@ -58,7 +58,7 @@ public static String[][] f2() { @Test public void testf2() { - CoreOps.FuncOp f = getFuncOp("f2"); + CoreOp.FuncOp f = getFuncOp("f2"); f.writeTo(System.out); @@ -72,14 +72,14 @@ public static String[][] f3() { @Test public void testf3() { - CoreOps.FuncOp f = getFuncOp("f3"); + CoreOp.FuncOp f = getFuncOp("f3"); f.writeTo(System.out); Assert.assertEquals(Interpreter.invoke(f), f3()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestArrayCreation.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestArrayTypes.java b/test/jdk/java/lang/reflect/code/TestArrayTypes.java index 684b5f499f5..453d7122a64 100644 --- a/test/jdk/java/lang/reflect/code/TestArrayTypes.java +++ b/test/jdk/java/lang/reflect/code/TestArrayTypes.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; import java.lang.runtime.CodeReflection; @@ -44,7 +44,7 @@ public static Class<?> f() { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); @@ -58,7 +58,7 @@ public static Class<?> f2() { @Test public void testf2() { - CoreOps.FuncOp f = getFuncOp("f2"); + CoreOp.FuncOp f = getFuncOp("f2"); f.writeTo(System.out); @@ -67,19 +67,19 @@ public void testf2() { @CodeReflection public static Class<?> f3() { - return CoreOps.ArrayLengthOp[][][][][][][].class; + return CoreOp.ArrayLengthOp[][][][][][][].class; } @Test public void testf3() { - CoreOps.FuncOp f = getFuncOp("f3"); + CoreOp.FuncOp f = getFuncOp("f3"); f.writeTo(System.out); Assert.assertEquals(Interpreter.invoke(f), f3()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestArrayTypes.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestBinops.java b/test/jdk/java/lang/reflect/code/TestBinops.java index 0fa75e0434d..38de9e32ed0 100644 --- a/test/jdk/java/lang/reflect/code/TestBinops.java +++ b/test/jdk/java/lang/reflect/code/TestBinops.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; import java.lang.runtime.CodeReflection; @@ -45,7 +45,7 @@ public static boolean not(boolean b) { @Test public void testNot() { - CoreOps.FuncOp f = getFuncOp("not"); + CoreOp.FuncOp f = getFuncOp("not"); f.writeTo(System.out); @@ -60,7 +60,7 @@ public static int mod(int a, int b) { @Test public void testMod() { - CoreOps.FuncOp f = getFuncOp("mod"); + CoreOp.FuncOp f = getFuncOp("mod"); f.writeTo(System.out); @@ -74,7 +74,7 @@ public static int bitand(int a, int b) { @Test public void testBitand() { - CoreOps.FuncOp f = getFuncOp("bitand"); + CoreOp.FuncOp f = getFuncOp("bitand"); f.writeTo(System.out); @@ -88,7 +88,7 @@ public static int bitor(int a, int b) { @Test public void testBitor() { - CoreOps.FuncOp f = getFuncOp("bitor"); + CoreOp.FuncOp f = getFuncOp("bitor"); f.writeTo(System.out); @@ -102,7 +102,7 @@ public static int bitxor(int a, int b) { @Test public void testBitxor() { - CoreOps.FuncOp f = getFuncOp("bitxor"); + CoreOp.FuncOp f = getFuncOp("bitxor"); f.writeTo(System.out); @@ -116,7 +116,7 @@ public static boolean booland(boolean a, boolean b) { @Test public void testBooland() { - CoreOps.FuncOp f = getFuncOp("booland"); + CoreOp.FuncOp f = getFuncOp("booland"); f.writeTo(System.out); @@ -130,7 +130,7 @@ public static boolean boolor(boolean a, boolean b) { @Test public void testBoolor() { - CoreOps.FuncOp f = getFuncOp("boolor"); + CoreOp.FuncOp f = getFuncOp("boolor"); f.writeTo(System.out); @@ -144,7 +144,7 @@ public static boolean boolxor(boolean a, boolean b) { @Test public void testBoolxor() { - CoreOps.FuncOp f = getFuncOp("boolxor"); + CoreOp.FuncOp f = getFuncOp("boolxor"); f.writeTo(System.out); @@ -158,14 +158,14 @@ public static double doublemod(double a, double b) { @Test public void testDoublemod() { - CoreOps.FuncOp f = getFuncOp("doublemod"); + CoreOp.FuncOp f = getFuncOp("doublemod"); f.writeTo(System.out); Assert.assertEquals(Interpreter.invoke(f, 15.6, 2.1), doublemod(15.6, 2.1)); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestBinops.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestBlockIndexes.java b/test/jdk/java/lang/reflect/code/TestBlockIndexes.java index 18f7805e6c5..a9cba65077a 100644 --- a/test/jdk/java/lang/reflect/code/TestBlockIndexes.java +++ b/test/jdk/java/lang/reflect/code/TestBlockIndexes.java @@ -27,7 +27,7 @@ import java.lang.reflect.Method; import java.lang.reflect.code.Block; import java.lang.reflect.code.Op; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.runtime.CodeReflection; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; @@ -51,7 +51,7 @@ static int f(int[] a) { @Test public void testBlockIndexes() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); @@ -68,7 +68,7 @@ public void testBlockIndexes() { // Create some blocks without predecessors for (int i = 0; i < 5; i++) { Block.Builder redundant = block.block(); - redundant.op(CoreOps._return()); + redundant.op(CoreOp._return()); } } block.op(op); @@ -77,13 +77,13 @@ public void testBlockIndexes() { assertBlockIndexes(f); } - static void assertBlockIndexes(CoreOps.FuncOp f) { + static void assertBlockIndexes(CoreOp.FuncOp f) { for (Block b : f.body().blocks()) { Assert.assertEquals(b.index(), b.parentBody().blocks().indexOf(b)); } } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestBlockIndexes.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestBlockOp.java b/test/jdk/java/lang/reflect/code/TestBlockOp.java index d72fb524852..4181f8f7d35 100644 --- a/test/jdk/java/lang/reflect/code/TestBlockOp.java +++ b/test/jdk/java/lang/reflect/code/TestBlockOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -54,7 +54,7 @@ public static int f() { return i; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestBlockOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); @@ -65,11 +65,11 @@ static CoreOps.FuncOp getFuncOp(String name) { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/TestBlockParameters.java b/test/jdk/java/lang/reflect/code/TestBlockParameters.java index c7971bcc775..a777ddd28b1 100644 --- a/test/jdk/java/lang/reflect/code/TestBlockParameters.java +++ b/test/jdk/java/lang/reflect/code/TestBlockParameters.java @@ -35,7 +35,7 @@ import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.INT; diff --git a/test/jdk/java/lang/reflect/code/TestBreakContinue.java b/test/jdk/java/lang/reflect/code/TestBreakContinue.java index 75f085c0114..4822d86e6a8 100644 --- a/test/jdk/java/lang/reflect/code/TestBreakContinue.java +++ b/test/jdk/java/lang/reflect/code/TestBreakContinue.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -59,11 +59,11 @@ public static BitSet forLoopBreakContinue(IntUnaryOperator f) { @Test public void testForLoopBreakContinue() { - CoreOps.FuncOp f = getFuncOp("forLoopBreakContinue"); + CoreOp.FuncOp f = getFuncOp("forLoopBreakContinue"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -110,11 +110,11 @@ public static BitSet nestedForLoopBreakContinue(IntUnaryOperator f) { @Test public void testNestedForLoopBreakContinue() { - CoreOps.FuncOp f = getFuncOp("nestedForLoopBreakContinue"); + CoreOp.FuncOp f = getFuncOp("nestedForLoopBreakContinue"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -165,11 +165,11 @@ public static BitSet forLoopLabeledBreakContinue(IntUnaryOperator f) { @Test public void testForLoopLabeledBreakContinue() { - CoreOps.FuncOp f = getFuncOp("forLoopLabeledBreakContinue"); + CoreOp.FuncOp f = getFuncOp("forLoopLabeledBreakContinue"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -222,11 +222,11 @@ public static BitSet blockBreak(IntUnaryOperator f) { @Test public void testBlockBreak() { - CoreOps.FuncOp f = getFuncOp("blockBreak"); + CoreOp.FuncOp f = getFuncOp("blockBreak"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -245,7 +245,7 @@ public void testBlockBreak() { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestBreakContinue.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestBuild.java b/test/jdk/java/lang/reflect/code/TestBuild.java index 68372997ccb..dd6922723d0 100644 --- a/test/jdk/java/lang/reflect/code/TestBuild.java +++ b/test/jdk/java/lang/reflect/code/TestBuild.java @@ -28,7 +28,7 @@ import java.lang.reflect.code.analysis.SSA; import java.util.function.IntBinaryOperator; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.FunctionType.VOID; import static java.lang.reflect.code.type.JavaType.INT; diff --git a/test/jdk/java/lang/reflect/code/TestClosureOps.java b/test/jdk/java/lang/reflect/code/TestClosureOps.java index 44a452389ad..116113549cd 100644 --- a/test/jdk/java/lang/reflect/code/TestClosureOps.java +++ b/test/jdk/java/lang/reflect/code/TestClosureOps.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import java.lang.reflect.code.Block; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Quoted; import java.lang.reflect.code.type.MethodRef; @@ -38,13 +38,13 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.code.type.JavaType; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.add; -import static java.lang.reflect.code.op.CoreOps.closure; -import static java.lang.reflect.code.op.CoreOps.closureCall; -import static java.lang.reflect.code.op.CoreOps.constant; -import static java.lang.reflect.code.op.CoreOps.func; -import static java.lang.reflect.code.op.CoreOps.quoted; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.add; +import static java.lang.reflect.code.op.CoreOp.closure; +import static java.lang.reflect.code.op.CoreOp.closureCall; +import static java.lang.reflect.code.op.CoreOp.constant; +import static java.lang.reflect.code.op.CoreOp.func; +import static java.lang.reflect.code.op.CoreOp.quoted; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.INT; import static java.lang.reflect.code.type.JavaType.type; @@ -53,7 +53,7 @@ public class TestClosureOps { static class Builder { static final MethodRef ACCEPT_METHOD = MethodRef.method(type(TestClosureOps.Builder.class), "accept", - INT, CoreOps.QuotedOp.QUOTED_TYPE); + INT, CoreOp.QuotedOp.QUOTED_TYPE); static int accept(Quoted c) { Assert.assertEquals(1, c.capturedValues().size()); @@ -68,13 +68,13 @@ static int accept(Quoted c) { @Test public void testQuotedWithCapture() { // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(block -> { Block.Parameter i = block.parameters().get(0); // functional type = (int)int // op descriptor = ()Quoted<ClosureOp> - CoreOps.QuotedOp qop = quoted(block.parentBody(), qblock -> { + CoreOp.QuotedOp qop = quoted(block.parentBody(), qblock -> { return closure(qblock.parentBody(), functionType(INT, INT)) .body(cblock -> { Block.Parameter ci = cblock.parameters().get(0); @@ -87,7 +87,7 @@ public void testQuotedWithCapture() { }); Op.Result cquoted = block.op(qop); - Op.Result or = block.op(CoreOps.invoke(TestClosureOps.Builder.ACCEPT_METHOD, cquoted)); + Op.Result or = block.op(CoreOp.invoke(TestClosureOps.Builder.ACCEPT_METHOD, cquoted)); block.op(_return(or)); }); @@ -100,13 +100,13 @@ public void testQuotedWithCapture() { @Test public void testWithCapture() { // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(block -> { Block.Parameter i = block.parameters().get(0); // functional type = (int)int // captures i - CoreOps.ClosureOp closure = CoreOps.closure(block.parentBody(), + CoreOp.ClosureOp closure = CoreOp.closure(block.parentBody(), functionType(INT, INT)) .body(cblock -> { Block.Parameter ci = cblock.parameters().get(0); @@ -132,9 +132,9 @@ public void testQuotableModel() { Quoted quoted = () -> {}; Op qop = quoted.op(); Op top = qop.ancestorBody().parentOp().ancestorBody().parentOp(); - Assert.assertTrue(top instanceof CoreOps.FuncOp); + Assert.assertTrue(top instanceof CoreOp.FuncOp); - CoreOps.FuncOp fop = (CoreOps.FuncOp) top; + CoreOp.FuncOp fop = (CoreOp.FuncOp) top; Assert.assertEquals(JavaType.type(Quoted.class), fop.invokableType().returnType()); } } diff --git a/test/jdk/java/lang/reflect/code/TestConcat.java b/test/jdk/java/lang/reflect/code/TestConcat.java index d56a51c8ab0..6bb337da69e 100644 --- a/test/jdk/java/lang/reflect/code/TestConcat.java +++ b/test/jdk/java/lang/reflect/code/TestConcat.java @@ -29,7 +29,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.code.interpreter.Interpreter; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.runtime.CodeReflection; import java.util.*; import java.util.stream.Stream; @@ -212,7 +212,7 @@ public static void testRun(TestMethodData t) { Object[] args = new Object[] {valMap.get(t.first), valMap.get(t.second)}; Class<TestConcat> clazz = TestConcat.class; Method method = clazz.getDeclaredMethod(t.third, t.first, t.second); - CoreOps.FuncOp f = method.getCodeModel().orElseThrow(); + CoreOp.FuncOp f = method.getCodeModel().orElseThrow(); var res1 = Interpreter.invoke(MethodHandles.lookup(), f, args); var res2 = method.invoke(null, args); diff --git a/test/jdk/java/lang/reflect/code/TestConditionalExpression.java b/test/jdk/java/lang/reflect/code/TestConditionalExpression.java index 92302cd4096..e4263bc5a11 100644 --- a/test/jdk/java/lang/reflect/code/TestConditionalExpression.java +++ b/test/jdk/java/lang/reflect/code/TestConditionalExpression.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -45,11 +45,11 @@ public static int simpleExpression(boolean b, int x, int y) { @Test public void testSimpleExpression() { - CoreOps.FuncOp f = getFuncOp("simpleExpression"); + CoreOp.FuncOp f = getFuncOp("simpleExpression"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -65,7 +65,7 @@ public void testSimpleExpression() { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestConditionalExpression.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestConditionalOp.java b/test/jdk/java/lang/reflect/code/TestConditionalOp.java index 808b1993db3..668b7b944cd 100644 --- a/test/jdk/java/lang/reflect/code/TestConditionalOp.java +++ b/test/jdk/java/lang/reflect/code/TestConditionalOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -64,7 +64,7 @@ static boolean c(boolean c, List<String> l) { } } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestConditionalOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); @@ -75,11 +75,11 @@ static CoreOps.FuncOp getFuncOp(String name) { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/TestConstants.java b/test/jdk/java/lang/reflect/code/TestConstants.java index 720c6025223..71a1bdb9039 100644 --- a/test/jdk/java/lang/reflect/code/TestConstants.java +++ b/test/jdk/java/lang/reflect/code/TestConstants.java @@ -30,7 +30,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -157,7 +157,7 @@ public void testString(Class<?> c) throws Exception { .toList(); for (Method m : ms) { - CoreOps.FuncOp f = m.getCodeModel().get(); + CoreOp.FuncOp f = m.getCodeModel().get(); f.writeTo(System.out); @@ -176,11 +176,11 @@ public static String compareNull(String s) { @Test public void testCompareNull() { - CoreOps.FuncOp f = getFuncOp("compareNull"); + CoreOp.FuncOp f = getFuncOp("compareNull"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -194,7 +194,7 @@ public void testCompareNull() { Assert.assertEquals(Interpreter.invoke(lf, (Object) null), compareNull(null)); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestConstants.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestCopy.java b/test/jdk/java/lang/reflect/code/TestCopy.java index 97e6f20435e..c3640bc55eb 100644 --- a/test/jdk/java/lang/reflect/code/TestCopy.java +++ b/test/jdk/java/lang/reflect/code/TestCopy.java @@ -32,7 +32,7 @@ import java.lang.reflect.Method; import java.lang.reflect.code.CopyContext; import java.lang.reflect.code.Op; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.op.ExternalizableOp; import java.lang.runtime.CodeReflection; import java.util.Optional; @@ -49,7 +49,7 @@ static int f(int i) { @Test public void testCopy() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); Op copy = f.copy(); @@ -58,15 +58,15 @@ public void testCopy() { @Test public void testCopyWithDefinition() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); ExternalizableOp.ExternalizedOp odef = ExternalizableOp.ExternalizedOp.externalizeOp(CopyContext.create(), f); - Op copy = CoreOps.FACTORY.constructOp(odef); + Op copy = CoreOp.FACTORY.constructOp(odef); Assert.assertEquals(f.toText(), copy.toText()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestCopy.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestDominate.java b/test/jdk/java/lang/reflect/code/TestDominate.java index ab75c7b31e6..b75154b0c35 100644 --- a/test/jdk/java/lang/reflect/code/TestDominate.java +++ b/test/jdk/java/lang/reflect/code/TestDominate.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; import java.lang.reflect.code.Block; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; @@ -36,11 +36,11 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.branch; -import static java.lang.reflect.code.op.CoreOps.conditionalBranch; -import static java.lang.reflect.code.op.CoreOps.constant; -import static java.lang.reflect.code.op.CoreOps.func; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.branch; +import static java.lang.reflect.code.op.CoreOp.conditionalBranch; +import static java.lang.reflect.code.op.CoreOp.constant; +import static java.lang.reflect.code.op.CoreOp.func; /* * @test @@ -51,7 +51,7 @@ public class TestDominate { @Test public void testIfElse() { - CoreOps.FuncOp f = func("f", FunctionType.VOID).body(entry -> { + CoreOp.FuncOp f = func("f", FunctionType.VOID).body(entry -> { Block.Builder ifBlock = entry.block(); Block.Builder elseBlock = entry.block(); Block.Builder end = entry.block(); @@ -78,7 +78,7 @@ public void testIfElse() { @Test public void testForwardSuccessors() { - CoreOps.FuncOp f = func("f", FunctionType.VOID).body(entry -> { + CoreOp.FuncOp f = func("f", FunctionType.VOID).body(entry -> { Block.Builder b1 = entry.block(); Block.Builder b2 = entry.block(); Block.Builder b3 = entry.block(); @@ -114,7 +114,7 @@ public void testForwardSuccessors() { @Test public void testBackbranch() { - CoreOps.FuncOp f = func("f", FunctionType.VOID).body(entry -> { + CoreOp.FuncOp f = func("f", FunctionType.VOID).body(entry -> { Block.Builder cond = entry.block(); Block.Builder body = entry.block(); Block.Builder update = entry.block(); @@ -143,7 +143,7 @@ public void testBackbranch() { test(f, bvs); } - static void test(CoreOps.FuncOp f, boolean[][] bvs) { + static void test(CoreOp.FuncOp f, boolean[][] bvs) { Block[] bs = f.body().blocks().toArray(Block[]::new); for (int i = 0; i < bs.length; i++) { for (int j = 0; j < bs.length; j++) { @@ -157,7 +157,7 @@ static void test(CoreOps.FuncOp f, boolean[][] bvs) { @Test public void testImmediateDominators() { - CoreOps.FuncOp f = func("f", FunctionType.VOID).body(entry -> { + CoreOp.FuncOp f = func("f", FunctionType.VOID).body(entry -> { Block.Builder b6 = entry.block(); Block.Builder b5 = entry.block(); Block.Builder b4 = entry.block(); @@ -198,7 +198,7 @@ public void testImmediateDominators() { @Test public void testCytronExample() { - CoreOps.FuncOp f = func("f", FunctionType.VOID).body(entry -> { + CoreOp.FuncOp f = func("f", FunctionType.VOID).body(entry -> { Block.Builder exit = entry.block(); Block.Builder b12 = entry.block(); Block.Builder b11 = entry.block(); diff --git a/test/jdk/java/lang/reflect/code/TestEnhancedForOp.java b/test/jdk/java/lang/reflect/code/TestEnhancedForOp.java index e17059b1b03..0ee6a9849e3 100644 --- a/test/jdk/java/lang/reflect/code/TestEnhancedForOp.java +++ b/test/jdk/java/lang/reflect/code/TestEnhancedForOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -49,7 +49,7 @@ public static int f() { return j; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestEnhancedForOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); @@ -60,11 +60,11 @@ static CoreOps.FuncOp getFuncOp(String name) { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -90,11 +90,11 @@ public static int array(int[] a) { @Test public void testArray() { - CoreOps.FuncOp f = getFuncOp("array"); + CoreOp.FuncOp f = getFuncOp("array"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/TestExceptionRegionOps.java b/test/jdk/java/lang/reflect/code/TestExceptionRegionOps.java index d61ca16e0d9..f672d55de9c 100644 --- a/test/jdk/java/lang/reflect/code/TestExceptionRegionOps.java +++ b/test/jdk/java/lang/reflect/code/TestExceptionRegionOps.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.MethodRef; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -39,13 +39,13 @@ import java.util.function.Consumer; import java.util.function.IntConsumer; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps._throw; -import static java.lang.reflect.code.op.CoreOps.branch; -import static java.lang.reflect.code.op.CoreOps.constant; -import static java.lang.reflect.code.op.CoreOps.exceptionRegionEnter; -import static java.lang.reflect.code.op.CoreOps.exceptionRegionExit; -import static java.lang.reflect.code.op.CoreOps.func; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp._throw; +import static java.lang.reflect.code.op.CoreOp.branch; +import static java.lang.reflect.code.op.CoreOp.constant; +import static java.lang.reflect.code.op.CoreOp.exceptionRegionEnter; +import static java.lang.reflect.code.op.CoreOp.exceptionRegionExit; +import static java.lang.reflect.code.op.CoreOp.func; import static java.lang.reflect.code.type.FunctionType.*; import static java.lang.reflect.code.type.JavaType.*; import static java.lang.reflect.code.type.JavaType.VOID; @@ -69,7 +69,7 @@ public void testF(IntConsumer c) { @Test public void test() { - CoreOps.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) + CoreOp.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) .body(fbody -> { var fblock = fbody.entryBlock(); var catchER1ISE = fblock.block(type(IllegalStateException.class)); @@ -85,30 +85,30 @@ public void test() { // Start of exception region enterER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of exception region b.op(exceptionRegionExit(er1, end.successor())); }); // First catch block for exception region catchER1ISE.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // Second catch for exception region catchER1IAE.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // end.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(_return()); }); }); @@ -160,7 +160,7 @@ public void testCatchThrowableF(IntConsumer c) { @Test public void testCatchThrowable() { - CoreOps.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) + CoreOp.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) .body(fbody -> { var fblock = fbody.entryBlock(); var catchER1ISE = fblock.block(type(IllegalStateException.class)); @@ -176,30 +176,30 @@ public void testCatchThrowable() { // Start of exception region enterER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of exception region b.op(exceptionRegionExit(er1, end.successor())); }); // First catch block for exception region catchER1ISE.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // Second catch for exception region catchER1T.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // end.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(_return()); }); }); @@ -254,7 +254,7 @@ public void testNestedF(IntConsumer c) { @Test public void testNested() { - CoreOps.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) + CoreOp.FuncOp f = func("f", functionType(VOID, type(IntConsumer.class))) .body(fbody -> { var fblock = fbody.entryBlock(); var catchER1 = fblock.block(type(IllegalArgumentException.class)); @@ -272,8 +272,8 @@ public void testNested() { // Start of first exception region enterER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); }); var er2 = enterER1.op(exceptionRegionEnter( enterER2.successor(), @@ -281,37 +281,37 @@ public void testNested() { // Start of second exception region enterER2.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of second exception region b.op(exceptionRegionExit(er2, b3.successor())); }); // Catch block for second exception region catchER2.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(b3.successor())); }); b3.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of first exception region b.op(exceptionRegionExit(er1, end.successor())); }); // Catch block for first exception region catchER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 4)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 4)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // end.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 5)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 5)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(_return()); }); }); @@ -375,7 +375,7 @@ public void testCatchFinallyF(IntConsumer c) { @Test public void testCatchFinally() { - CoreOps.FuncOp f = func("f", functionType(VOID, JavaType.type(IntConsumer.class))) + CoreOp.FuncOp f = func("f", functionType(VOID, JavaType.type(IntConsumer.class))) .body(fbody -> { var fblock = fbody.entryBlock(); var catchRE = fblock.block(type(IllegalStateException.class)); @@ -394,15 +394,15 @@ public void testCatchFinally() { // Start of exception region enterER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 0)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of exception region b.op(exceptionRegionExit(er1, exitER1.successor())); }); // Inline finally exitER1.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); @@ -412,29 +412,29 @@ public void testCatchFinally() { catchAll.successor())); // Start of exception region enterER2.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); // End of exception region b.op(exceptionRegionExit(er2, exitER2.successor())); }); // Inline finally exitER2.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(branch(end.successor())); }); // Catch all block for finally catchAll.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 2)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(_throw(catchAll.parameters().get(0))); }); // end.ops(b -> { - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); - b.op(CoreOps.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, 3)))); + b.op(CoreOp.invoke(INT_CONSUMER_ACCEPT_METHOD, c, b.op(constant(INT, -1)))); b.op(_return()); }); }); diff --git a/test/jdk/java/lang/reflect/code/TestForOp.java b/test/jdk/java/lang/reflect/code/TestForOp.java index 54748db6578..5998765e504 100644 --- a/test/jdk/java/lang/reflect/code/TestForOp.java +++ b/test/jdk/java/lang/reflect/code/TestForOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -50,11 +50,11 @@ public static int f() { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -80,11 +80,11 @@ public static int f2() { @Test public void testf2() { - CoreOps.FuncOp f = getFuncOp("f2"); + CoreOp.FuncOp f = getFuncOp("f2"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -112,11 +112,11 @@ public static int f3() { @Test public void testf3() { - CoreOps.FuncOp f = getFuncOp("f3"); + CoreOp.FuncOp f = getFuncOp("f3"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -130,7 +130,7 @@ public void testf3() { Assert.assertEquals(Interpreter.invoke(lf), f3()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestForOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestIfOp.java b/test/jdk/java/lang/reflect/code/TestIfOp.java index 35735dff065..ab6696eca03 100644 --- a/test/jdk/java/lang/reflect/code/TestIfOp.java +++ b/test/jdk/java/lang/reflect/code/TestIfOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -56,7 +56,7 @@ public static String f(int i) { return s; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestIfOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); @@ -67,11 +67,11 @@ static CoreOps.FuncOp getFuncOp(String name) { @Test public void testf() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/TestInline.java b/test/jdk/java/lang/reflect/code/TestInline.java index 161db23ee90..937e292a1ba 100644 --- a/test/jdk/java/lang/reflect/code/TestInline.java +++ b/test/jdk/java/lang/reflect/code/TestInline.java @@ -26,7 +26,7 @@ import java.lang.reflect.code.Block; import java.lang.reflect.code.CopyContext; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Quoted; import java.lang.reflect.code.interpreter.Interpreter; @@ -34,7 +34,7 @@ import java.lang.reflect.code.type.JavaType; import java.util.List; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.INT; @@ -48,10 +48,10 @@ public class TestInline { @Test public void testInline() { Quoted q = (int a, int b) -> a + b; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(fblock -> { Block.Parameter i = fblock.parameters().get(0); @@ -70,10 +70,10 @@ public void testInline() { @Test public void testInlineVar() { Quoted q = (int a, int b) -> a + b; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(fblock -> { Block.Parameter i = fblock.parameters().get(0); @@ -104,9 +104,9 @@ public void testInlineLowerMultipleReturn() { } return a - b; }; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); cop.writeTo(System.out); - CoreOps.ClosureOp lcop = cop.transform(CopyContext.create(), (block, op) -> { + CoreOp.ClosureOp lcop = cop.transform(CopyContext.create(), (block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -117,7 +117,7 @@ public void testInlineLowerMultipleReturn() { lcop.writeTo(System.out); // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(fblock -> { Block.Parameter i = fblock.parameters().get(0); @@ -140,9 +140,9 @@ public void testInlineLowerMultipleReturnVar() { } return a - b; }; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); cop.writeTo(System.out); - CoreOps.ClosureOp lcop = cop.transform(CopyContext.create(), (block, op) -> { + CoreOp.ClosureOp lcop = cop.transform(CopyContext.create(), (block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -153,7 +153,7 @@ public void testInlineLowerMultipleReturnVar() { lcop.writeTo(System.out); // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(fblock -> { Block.Parameter i = fblock.parameters().get(0); @@ -182,10 +182,10 @@ public void testInlineMultipleReturnLower() { } return a - b; }; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); cop.writeTo(System.out); - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(fblock -> { Block.Parameter i = fblock.parameters().get(0); @@ -216,10 +216,10 @@ public void testInlineVoid() { a[0] = 42; return; }; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(JavaType.VOID, JavaType.type(int[].class))) + CoreOp.FuncOp f = func("f", functionType(JavaType.VOID, JavaType.type(int[].class))) .body(fblock -> { Block.Parameter a = fblock.parameters().get(0); diff --git a/test/jdk/java/lang/reflect/code/TestLambdaOps.java b/test/jdk/java/lang/reflect/code/TestLambdaOps.java index 413433d9c79..9025994e6c7 100644 --- a/test/jdk/java/lang/reflect/code/TestLambdaOps.java +++ b/test/jdk/java/lang/reflect/code/TestLambdaOps.java @@ -31,9 +31,9 @@ import org.testng.annotations.Test; import java.lang.reflect.code.*; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.CoreOps.FuncOp; -import java.lang.reflect.code.op.CoreOps.LambdaOp; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.CoreOp.FuncOp; +import java.lang.reflect.code.op.CoreOp.LambdaOp; import java.lang.reflect.code.type.MethodRef; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -46,8 +46,8 @@ import java.util.function.IntUnaryOperator; import java.util.stream.Stream; -import static java.lang.reflect.code.op.CoreOps.*; -import static java.lang.reflect.code.op.CoreOps.constant; +import static java.lang.reflect.code.op.CoreOp.*; +import static java.lang.reflect.code.op.CoreOp.constant; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.INT; import static java.lang.reflect.code.type.JavaType.type; @@ -56,7 +56,7 @@ public class TestLambdaOps { static class Builder { static final MethodRef ACCEPT_METHOD = MethodRef.method(type(Builder.class), "accept", - INT, CoreOps.QuotedOp.QUOTED_TYPE); + INT, CoreOp.QuotedOp.QUOTED_TYPE); static int accept(Quoted l) { Assert.assertEquals(1, l.capturedValues().size()); @@ -151,9 +151,9 @@ public void testQuotableModel() { Quotable quotable = (Runnable & Quotable) () -> {}; Op qop = quotable.quoted().op(); Op top = qop.ancestorBody().parentOp().ancestorBody().parentOp(); - Assert.assertTrue(top instanceof CoreOps.FuncOp); + Assert.assertTrue(top instanceof CoreOp.FuncOp); - CoreOps.FuncOp fop = (CoreOps.FuncOp) top; + CoreOp.FuncOp fop = (CoreOp.FuncOp) top; Assert.assertEquals(type(Quoted.class), fop.invokableType().returnType()); } @@ -186,7 +186,7 @@ public void testQuote() { Map<Value, Object> cvs = Map.of( q.capturedValues().keySet().iterator().next(), - CoreOps.Var.of(0) + CoreOp.Var.of(0) ); r = (int) Interpreter.invoke(MethodHandles.lookup(), (LambdaOp) q.op(), cvs, List.of()); Assert.assertEquals(r, 0); @@ -207,7 +207,7 @@ public void testQuote() { Map<Value, Object> cvs = Map.of( q.capturedValues().keySet().iterator().next(), - CoreOps.Var.of(0) + CoreOp.Var.of(0) ); r = (int) Interpreter.invoke(MethodHandles.lookup(), (LambdaOp) q.op(), cvs, List.of()); Assert.assertEquals(r, 0); @@ -236,7 +236,7 @@ Iterator<Quotable> methodRefLambdas() { @Test(dataProvider = "methodRefLambdas") public void testIsMethodReference(Quotable q) { Quoted quoted = q.quoted(); - CoreOps.LambdaOp lop = (CoreOps.LambdaOp) quoted.op(); + CoreOp.LambdaOp lop = (CoreOp.LambdaOp) quoted.op(); Assert.assertTrue(lop.methodReference().isPresent()); } @@ -257,7 +257,7 @@ static int m4(TestLambdaOps tl, int i) { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestLambdaOps.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestLinqUsingQuoted.java b/test/jdk/java/lang/reflect/code/TestLinqUsingQuoted.java index bae650f3ba3..99175d9efe1 100644 --- a/test/jdk/java/lang/reflect/code/TestLinqUsingQuoted.java +++ b/test/jdk/java/lang/reflect/code/TestLinqUsingQuoted.java @@ -35,7 +35,7 @@ import java.util.stream.Stream; import static java.lang.reflect.code.type.MethodRef.method; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; /* diff --git a/test/jdk/java/lang/reflect/code/TestLiveness.java b/test/jdk/java/lang/reflect/code/TestLiveness.java index f0ffdea79c3..f988e756e81 100644 --- a/test/jdk/java/lang/reflect/code/TestLiveness.java +++ b/test/jdk/java/lang/reflect/code/TestLiveness.java @@ -34,7 +34,7 @@ import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; import java.lang.reflect.code.analysis.Liveness; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.JavaType; import java.lang.reflect.code.parser.OpParser; import java.util.HashMap; @@ -55,7 +55,7 @@ public class TestLiveness { @Test public void testF() { - Op op = OpParser.fromString(CoreOps.FACTORY, F).getFirst(); + Op op = OpParser.fromString(CoreOp.FACTORY, F).getFirst(); var actual = liveness(op); var expected = Map.of( @@ -87,7 +87,7 @@ public void testF() { @Test public void testIfElse() { - Op op = OpParser.fromString(CoreOps.FACTORY, IF_ELSE).getFirst(); + Op op = OpParser.fromString(CoreOp.FACTORY, IF_ELSE).getFirst(); var actual = liveness(op); var expected = Map.of( @@ -125,7 +125,7 @@ public void testIfElse() { @Test public void testLoop() { - Op op = OpParser.fromString(CoreOps.FACTORY, LOOP).getFirst(); + Op op = OpParser.fromString(CoreOp.FACTORY, LOOP).getFirst(); var actual = liveness(op); var expected = Map.of( @@ -194,7 +194,7 @@ public void testLoop() { @Test public void testIfElseNested() { - Op op = OpParser.fromString(CoreOps.FACTORY, IF_ELSE_NESTED).getFirst(); + Op op = OpParser.fromString(CoreOp.FACTORY, IF_ELSE_NESTED).getFirst(); var actual = liveness(op); var expected = Map.of( @@ -255,7 +255,7 @@ public void testIfElseNested() { @Test public void testLoopNested() { - Op op = OpParser.fromString(CoreOps.FACTORY, LOOP_NESTED).getFirst(); + Op op = OpParser.fromString(CoreOp.FACTORY, LOOP_NESTED).getFirst(); var actual = liveness(op); var expected = Map.of( diff --git a/test/jdk/java/lang/reflect/code/TestLocalTransformationsAdaption.java b/test/jdk/java/lang/reflect/code/TestLocalTransformationsAdaption.java index a3d834d0f57..dd1ba8e5747 100644 --- a/test/jdk/java/lang/reflect/code/TestLocalTransformationsAdaption.java +++ b/test/jdk/java/lang/reflect/code/TestLocalTransformationsAdaption.java @@ -26,7 +26,7 @@ import java.io.PrintStream; import java.lang.reflect.code.CopyContext; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; import java.lang.reflect.code.type.FieldRef; @@ -45,10 +45,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static java.lang.reflect.code.op.CoreOps.arrayStoreOp; -import static java.lang.reflect.code.op.CoreOps.constant; -import static java.lang.reflect.code.op.CoreOps.fieldLoad; -import static java.lang.reflect.code.op.CoreOps.newArray; +import static java.lang.reflect.code.op.CoreOp.arrayStoreOp; +import static java.lang.reflect.code.op.CoreOp.constant; +import static java.lang.reflect.code.op.CoreOp.fieldLoad; +import static java.lang.reflect.code.op.CoreOp.newArray; import static java.lang.reflect.code.type.MethodRef.method; import static java.lang.reflect.code.type.JavaType.*; @@ -93,7 +93,7 @@ static int f(int i) { @Test public void testInvocation() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); f = f.transform((block, op) -> { @@ -119,22 +119,22 @@ public void testInvocation() { @Test public void testFuncEntryExit() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); AtomicBoolean first = new AtomicBoolean(true); - CoreOps.FuncOp fc = f.transform((block, op) -> { + CoreOp.FuncOp fc = f.transform((block, op) -> { if (first.get()) { printConstantString(block, "ENTRY"); first.set(false); } switch (op) { - case CoreOps.ReturnOp returnOp when getNearestInvokeableAncestorOp(returnOp) instanceof CoreOps.FuncOp: { + case CoreOp.ReturnOp returnOp when getNearestInvokeableAncestorOp(returnOp) instanceof CoreOp.FuncOp: { printConstantString(block, "EXIT"); break; } - case CoreOps.ThrowOp throwOp: { + case CoreOp.ThrowOp throwOp: { printConstantString(block, "EXIT"); break; } @@ -171,7 +171,7 @@ case CoreOps.ReturnOp returnOp when getNearestInvokeableAncestorOp(returnOp) ins static void printConstantString(Function<Op, Op.Result> opBuilder, String s) { Op.Result c = opBuilder.apply(constant(J_L_STRING, s)); Value System_out = opBuilder.apply(fieldLoad(FieldRef.field(System.class, "out", PrintStream.class))); - opBuilder.apply(CoreOps.invoke(method(PrintStream.class, "println", void.class, String.class), System_out, c)); + opBuilder.apply(CoreOp.invoke(method(PrintStream.class, "println", void.class, String.class), System_out, c)); } static Op getNearestInvokeableAncestorOp(Op op) { @@ -184,15 +184,15 @@ static Op getNearestInvokeableAncestorOp(Op op) { @Test public void testReplaceCall() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp fc = f.transform((block, op) -> { + CoreOp.FuncOp fc = f.transform((block, op) -> { switch (op) { - case CoreOps.InvokeOp invokeOp when invokeOp.invokeDescriptor().equals(ADD_METHOD): { + case CoreOp.InvokeOp invokeOp when invokeOp.invokeDescriptor().equals(ADD_METHOD): { // Get the adapted operands, and pass those to the new call method List<Value> adaptedOperands = block.context().getValues(op.operands()); - Op.Result adaptedResult = block.apply(CoreOps.invoke(ADD_WITH_PRINT_METHOD, adaptedOperands)); + Op.Result adaptedResult = block.apply(CoreOp.invoke(ADD_WITH_PRINT_METHOD, adaptedOperands)); // Map the old call result to the new call result, so existing operations can be // adapted to use the new result block.context().mapValue(invokeOp.result(), adaptedResult); @@ -223,12 +223,12 @@ public void testReplaceCall() { @Test public void testCallEntryExit() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); - CoreOps.FuncOp fc = f.transform((block, op) -> { + CoreOp.FuncOp fc = f.transform((block, op) -> { switch (op) { - case CoreOps.InvokeOp invokeOp: { + case CoreOp.InvokeOp invokeOp: { printCall(block.context(), invokeOp, block); break; } @@ -254,7 +254,7 @@ public void testCallEntryExit() { Assert.assertEquals(x, f(2)); } - static void printCall(CopyContext cc, CoreOps.InvokeOp invokeOp, Function<Op, Op.Result> opBuilder) { + static void printCall(CopyContext cc, CoreOp.InvokeOp invokeOp, Function<Op, Op.Result> opBuilder) { List<Value> adaptedInvokeOperands = cc.getValues(invokeOp.operands()); String prefix = "ENTER"; @@ -276,7 +276,7 @@ static void printCall(CopyContext cc, CoreOps.InvokeOp invokeOp, Function<Op, Op if (operand.type().equals(INT)) { operand = opBuilder.apply( - CoreOps.invoke(method(Integer.class, "valueOf", Integer.class, int.class), operand)); + CoreOp.invoke(method(Integer.class, "valueOf", Integer.class, int.class), operand)); // @@@ Other primitive types } opBuilder.apply( @@ -288,7 +288,7 @@ static void printCall(CopyContext cc, CoreOps.InvokeOp invokeOp, Function<Op, Op prefix + ": " + invokeOp.invokeDescriptor() + "(" + formatString(adaptedInvokeOperands) + ")%n")); Value System_out = opBuilder.apply(fieldLoad(FieldRef.field(System.class, "out", PrintStream.class))); opBuilder.apply( - CoreOps.invoke(method(PrintStream.class, "printf", PrintStream.class, String.class, Object[].class), + CoreOp.invoke(method(PrintStream.class, "printf", PrintStream.class, String.class, Object[].class), System_out, formatString, formatArray)); // Method call @@ -301,7 +301,7 @@ static void printCall(CopyContext cc, CoreOps.InvokeOp invokeOp, Function<Op, Op if (adaptedInvokeResult.type().equals(INT)) { adaptedInvokeResult = opBuilder.apply( - CoreOps.invoke(method(Integer.class, "valueOf", Integer.class, int.class), adaptedInvokeResult)); + CoreOp.invoke(method(Integer.class, "valueOf", Integer.class, int.class), adaptedInvokeResult)); // @@@ Other primitive types } opBuilder.apply( @@ -311,7 +311,7 @@ static void printCall(CopyContext cc, CoreOps.InvokeOp invokeOp, Function<Op, Op constant(J_L_STRING, prefix + ": " + invokeOp.invokeDescriptor() + " -> " + formatString(adaptedInvokeResult.type()) + "%n")); opBuilder.apply( - CoreOps.invoke(method(PrintStream.class, "printf", PrintStream.class, String.class, Object[].class), + CoreOp.invoke(method(PrintStream.class, "printf", PrintStream.class, String.class, Object[].class), System_out, formatString, formatArray)); } @@ -345,7 +345,7 @@ static int addWithPrint(int a, int b) { return a + b; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestLocalTransformationsAdaption.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestPatterns.java b/test/jdk/java/lang/reflect/code/TestPatterns.java index e4c2a5fcbaa..e0fd97b461e 100644 --- a/test/jdk/java/lang/reflect/code/TestPatterns.java +++ b/test/jdk/java/lang/reflect/code/TestPatterns.java @@ -30,7 +30,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -69,11 +69,11 @@ public static String recordPatterns(Object r) { @Test public void testRecordPatterns() { - CoreOps.FuncOp f = getFuncOp("recordPatterns"); + CoreOp.FuncOp f = getFuncOp("recordPatterns"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -112,7 +112,7 @@ public void testRecordPatterns() { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestPatterns.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestPrimitiveCast.java b/test/jdk/java/lang/reflect/code/TestPrimitiveCast.java index f86836c93f0..23e9bb3a1e9 100644 --- a/test/jdk/java/lang/reflect/code/TestPrimitiveCast.java +++ b/test/jdk/java/lang/reflect/code/TestPrimitiveCast.java @@ -30,7 +30,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; @@ -165,7 +165,7 @@ static Object[][] fromMethods() { @Test(dataProvider = "fromMethods") public void testFromDouble(String name, Object value, Function<Object, String> m) { - CoreOps.FuncOp f = getFuncOp(name); + CoreOp.FuncOp f = getFuncOp(name); Assert.assertEquals(Interpreter.invoke(MethodHandles.lookup(), f, value), m.apply(value)); } @@ -174,7 +174,7 @@ static String collect(Object... values) { return Stream.of(values).map(Object::toString).collect(joining(" ")); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestPrimitiveCast.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestRemoveFinalVars.java b/test/jdk/java/lang/reflect/code/TestRemoveFinalVars.java index b1877275d19..401ed43ade6 100644 --- a/test/jdk/java/lang/reflect/code/TestRemoveFinalVars.java +++ b/test/jdk/java/lang/reflect/code/TestRemoveFinalVars.java @@ -13,10 +13,10 @@ import java.util.function.Predicate; import java.util.stream.Stream; -import static java.lang.reflect.code.op.CoreOps.FuncOp; -import static java.lang.reflect.code.op.CoreOps.VarAccessOp.VarLoadOp; -import static java.lang.reflect.code.op.CoreOps.VarAccessOp.VarStoreOp; -import static java.lang.reflect.code.op.CoreOps.VarOp; +import static java.lang.reflect.code.op.CoreOp.FuncOp; +import static java.lang.reflect.code.op.CoreOp.VarAccessOp.VarLoadOp; +import static java.lang.reflect.code.op.CoreOp.VarAccessOp.VarStoreOp; +import static java.lang.reflect.code.op.CoreOp.VarOp; /* * @test diff --git a/test/jdk/java/lang/reflect/code/TestSSA.java b/test/jdk/java/lang/reflect/code/TestSSA.java index 869fe76ae86..52a53ad2acf 100644 --- a/test/jdk/java/lang/reflect/code/TestSSA.java +++ b/test/jdk/java/lang/reflect/code/TestSSA.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; import java.lang.reflect.code.interpreter.Interpreter; @@ -52,9 +52,9 @@ static int ifelse(int a, int b, int n) { @Test public void testIfelse() throws Throwable { - CoreOps.FuncOp f = getFuncOp("ifelse"); + CoreOp.FuncOp f = getFuncOp("ifelse"); - CoreOps.FuncOp lf = generate(f); + CoreOp.FuncOp lf = generate(f); Assert.assertEquals((int) Interpreter.invoke(lf, 0, 0, 1), ifelse(0, 0, 1)); Assert.assertEquals((int) Interpreter.invoke(lf, 0, 0, 11), ifelse(0, 0, 11)); @@ -82,9 +82,9 @@ static int ifelseNested(int a, int b, int c, int d, int n) { @Test public void testIfelseNested() throws Throwable { - CoreOps.FuncOp f = getFuncOp("ifelseNested"); + CoreOp.FuncOp f = getFuncOp("ifelseNested"); - CoreOps.FuncOp lf = generate(f); + CoreOp.FuncOp lf = generate(f); for (int i : new int[]{1, 11, 20, 21}) { Assert.assertEquals((int) Interpreter.invoke(lf, 0, 0, 0, 0, i), ifelseNested(0, 0, 0, 0, i)); @@ -102,9 +102,9 @@ static int loop(int n) { @Test public void testLoop() throws Throwable { - CoreOps.FuncOp f = getFuncOp("loop"); + CoreOp.FuncOp f = getFuncOp("loop"); - CoreOps.FuncOp lf = generate(f); + CoreOp.FuncOp lf = generate(f); Assert.assertEquals((int) Interpreter.invoke(lf, 10), loop(10)); } @@ -122,17 +122,17 @@ static int nestedLoop(int n) { @Test public void testNestedLoop() throws Throwable { - CoreOps.FuncOp f = getFuncOp("nestedLoop"); + CoreOp.FuncOp f = getFuncOp("nestedLoop"); - CoreOps.FuncOp lf = generate(f); + CoreOp.FuncOp lf = generate(f); Assert.assertEquals((int) Interpreter.invoke(lf, 10), nestedLoop(10)); } - static CoreOps.FuncOp generate(CoreOps.FuncOp f) { + static CoreOp.FuncOp generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -147,7 +147,7 @@ static CoreOps.FuncOp generate(CoreOps.FuncOp f) { return lf; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestSSA.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestTraverse.java b/test/jdk/java/lang/reflect/code/TestTraverse.java index 68d5ff5d956..953c82671c0 100644 --- a/test/jdk/java/lang/reflect/code/TestTraverse.java +++ b/test/jdk/java/lang/reflect/code/TestTraverse.java @@ -33,7 +33,7 @@ import java.lang.reflect.code.CodeElement; import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.runtime.CodeReflection; import java.util.ArrayList; import java.util.List; @@ -61,7 +61,7 @@ private static int f(String s, int i, List<Object> acc) { @Test public void test() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); testTraverse(f); f = f.transform((b, o) -> { @@ -88,7 +88,7 @@ void testTraverse(Op op) { Assert.assertEquals(op.elements().limit(2).toList(), tl.subList(0, 2)); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTraverse.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestTry.java b/test/jdk/java/lang/reflect/code/TestTry.java index c07e68734dd..b995dcf303a 100644 --- a/test/jdk/java/lang/reflect/code/TestTry.java +++ b/test/jdk/java/lang/reflect/code/TestTry.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -64,11 +64,11 @@ public static void catching(IntConsumer c) { @Test public void testCatching() { - CoreOps.FuncOp f = getFuncOp("catching"); + CoreOp.FuncOp f = getFuncOp("catching"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -128,11 +128,11 @@ public static void catchThrowable(IntConsumer c) { @Test public void testCatchThrowable() { - CoreOps.FuncOp f = getFuncOp("catchThrowable"); + CoreOp.FuncOp f = getFuncOp("catchThrowable"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -195,11 +195,11 @@ public static void catchNested(IntConsumer c) { @Test public void testCatchNested() { - CoreOps.FuncOp f = getFuncOp("catchNested"); + CoreOp.FuncOp f = getFuncOp("catchNested"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -252,7 +252,7 @@ public void testCatchNested() { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTry.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestTryFinally.java b/test/jdk/java/lang/reflect/code/TestTryFinally.java index 19f6251f6ef..aed7fe87980 100644 --- a/test/jdk/java/lang/reflect/code/TestTryFinally.java +++ b/test/jdk/java/lang/reflect/code/TestTryFinally.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -62,11 +62,11 @@ public static void tryCatchFinally(IntConsumer c) { @Test public void testCatchFinally() { - CoreOps.FuncOp f = getFuncOp("tryCatchFinally"); + CoreOp.FuncOp f = getFuncOp("tryCatchFinally"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -105,11 +105,11 @@ public static void tryReturn(IntConsumer c) { @Test public void testTryReturn() { - CoreOps.FuncOp f = getFuncOp("tryReturn"); + CoreOp.FuncOp f = getFuncOp("tryReturn"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -148,11 +148,11 @@ public static void catchThrow(IntConsumer c) { @Test public void testCatchThrow() { - CoreOps.FuncOp f = getFuncOp("catchThrow"); + CoreOp.FuncOp f = getFuncOp("catchThrow"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -189,11 +189,11 @@ public static void finallyReturn(IntConsumer c) { @Test public void finallyReturn() { - CoreOps.FuncOp f = getFuncOp("finallyReturn"); + CoreOp.FuncOp f = getFuncOp("finallyReturn"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -233,7 +233,7 @@ static void test(Consumer<IntConsumer> test) { }); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTryFinally.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestTryFinallyNested.java b/test/jdk/java/lang/reflect/code/TestTryFinallyNested.java index f5f7c7d9d09..d16b95389df 100644 --- a/test/jdk/java/lang/reflect/code/TestTryFinallyNested.java +++ b/test/jdk/java/lang/reflect/code/TestTryFinallyNested.java @@ -29,8 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.analysis.SSA; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -83,11 +82,11 @@ public static void tryCatchFinally(IntConsumer c, int i) { @Test public void testCatchFinally() { - CoreOps.FuncOp f = getFuncOp("tryCatchFinally"); + CoreOp.FuncOp f = getFuncOp("tryCatchFinally"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -159,11 +158,11 @@ public static void tryCatchFinallyBreak(IntConsumer c, int i) { @Test public void testCatchFinallyBreak() { - CoreOps.FuncOp f = getFuncOp("tryCatchFinallyBreak"); + CoreOp.FuncOp f = getFuncOp("tryCatchFinallyBreak"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -217,11 +216,11 @@ public static void tryForLoop(IntConsumer c) { @Test public void testTryForLoop() { - CoreOps.FuncOp f = getFuncOp("tryForLoop"); + CoreOp.FuncOp f = getFuncOp("tryForLoop"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -267,11 +266,11 @@ public static void tryLabeledForLoop(IntConsumer c) { @Test public void testTryLabeledForLoop() { - CoreOps.FuncOp f = getFuncOp("tryLabeledForLoop"); + CoreOp.FuncOp f = getFuncOp("tryLabeledForLoop"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -313,11 +312,11 @@ public static void tryLambda(IntConsumer c, int i) { @Test public void testTryLambda() { - CoreOps.FuncOp f = getFuncOp("tryLambda"); + CoreOp.FuncOp f = getFuncOp("tryLambda"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -339,7 +338,7 @@ public void testTryLambda() { } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTryFinallyNested.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/TestWhileOp.java b/test/jdk/java/lang/reflect/code/TestWhileOp.java index c8e2ef42d45..cfe1a219d2e 100644 --- a/test/jdk/java/lang/reflect/code/TestWhileOp.java +++ b/test/jdk/java/lang/reflect/code/TestWhileOp.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -50,11 +50,11 @@ public static int whileLoop() { @Test public void testWhileLoop() { - CoreOps.FuncOp f = getFuncOp("whileLoop"); + CoreOp.FuncOp f = getFuncOp("whileLoop"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -79,11 +79,11 @@ public static int doWhileLoop() { @Test public void testDpWhileLoop() { - CoreOps.FuncOp f = getFuncOp("doWhileLoop"); + CoreOp.FuncOp f = getFuncOp("doWhileLoop"); f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -97,7 +97,7 @@ public void testDpWhileLoop() { Assert.assertEquals(Interpreter.invoke(lf), doWhileLoop()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestWhileOp.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/ad/ActiveSet.java b/test/jdk/java/lang/reflect/code/ad/ActiveSet.java index e1ffa10c4e5..aa013a6d91d 100644 --- a/test/jdk/java/lang/reflect/code/ad/ActiveSet.java +++ b/test/jdk/java/lang/reflect/code/ad/ActiveSet.java @@ -24,7 +24,7 @@ import java.lang.reflect.code.Block; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.*; public final class ActiveSet { @@ -36,7 +36,7 @@ private ActiveSet() { // following its users and following through block arguments // to block parameters, and so on until the graph is traversed. - public static Set<Value> activeSet(CoreOps.FuncOp f, Block.Parameter fv) { + public static Set<Value> activeSet(CoreOp.FuncOp f, Block.Parameter fv) { if (!f.body().blocks().get(0).parameters().contains(fv)) { throw new IllegalArgumentException("Arg is not defined by function"); } diff --git a/test/jdk/java/lang/reflect/code/ad/ExpressionElimination.java b/test/jdk/java/lang/reflect/code/ad/ExpressionElimination.java index fa1e04c9594..71855bea500 100644 --- a/test/jdk/java/lang/reflect/code/ad/ExpressionElimination.java +++ b/test/jdk/java/lang/reflect/code/ad/ExpressionElimination.java @@ -22,14 +22,14 @@ */ import java.lang.reflect.code.*; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.JavaType; import java.util.HashMap; import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Predicate; -import static java.lang.reflect.code.op.CoreOps.sub; +import static java.lang.reflect.code.op.CoreOp.sub; import static java.lang.reflect.code.analysis.Patterns.*; public final class ExpressionElimination { @@ -39,15 +39,15 @@ private ExpressionElimination() { static final JavaType J_L_MATH = JavaType.type(Math.class); static OpPattern negP(Pattern operand) { - return opP(CoreOps.NegOp.class, operand); + return opP(CoreOp.NegOp.class, operand); } static OpPattern addP(Pattern lhs, Pattern rhs) { - return opP(CoreOps.AddOp.class, lhs, rhs); + return opP(CoreOp.AddOp.class, lhs, rhs); } static OpPattern mulP(Pattern lhs, Pattern rhs) { - return opP(CoreOps.MulOp.class, lhs, rhs); + return opP(CoreOp.MulOp.class, lhs, rhs); } public static <T extends Op> T eliminate(T f) { @@ -100,7 +100,7 @@ public static <T extends Op> T eliminate(T f) { if (op instanceof Op.Pure) { return true; } else { - return op instanceof CoreOps.InvokeOp c && c.invokeDescriptor().refType().equals(J_L_MATH); + return op instanceof CoreOp.InvokeOp c && c.invokeDescriptor().refType().equals(J_L_MATH); } }; diff --git a/test/jdk/java/lang/reflect/code/ad/ForwardDifferentiation.java b/test/jdk/java/lang/reflect/code/ad/ForwardDifferentiation.java index 6ef3c65d479..0af7d74eb4f 100644 --- a/test/jdk/java/lang/reflect/code/ad/ForwardDifferentiation.java +++ b/test/jdk/java/lang/reflect/code/ad/ForwardDifferentiation.java @@ -25,8 +25,8 @@ import java.lang.reflect.code.CopyContext; import java.lang.reflect.code.Op; import java.lang.reflect.code.Value; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.MethodRef; -import java.lang.reflect.code.op.CoreOps; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; import java.util.HashMap; @@ -35,7 +35,7 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.JavaType.DOUBLE; public final class ForwardDifferentiation { @@ -128,7 +128,7 @@ void processBlocks(Block.Builder block) { Value diffOp(Block.Builder block, Op op) { // Switch on the op, using pattern matching return switch (op) { - case CoreOps.NegOp _ -> { + case CoreOp.NegOp _ -> { // Copy input operation block.op(op); @@ -137,7 +137,7 @@ Value diffOp(Block.Builder block, Op op) { Value da = diffValueMapping.getOrDefault(a, zero); yield block.op(neg(da)); } - case CoreOps.AddOp _ -> { + case CoreOp.AddOp _ -> { // Copy input operation block.op(op); @@ -148,7 +148,7 @@ Value diffOp(Block.Builder block, Op op) { Value drhs = diffValueMapping.getOrDefault(rhs, zero); yield block.op(add(dlhs, drhs)); } - case CoreOps.MulOp _ -> { + case CoreOp.MulOp _ -> { // Copy input operation block.op(op); @@ -164,13 +164,13 @@ Value diffOp(Block.Builder block, Op op) { block.op(mul(dlhs, outputRhs)), block.op(mul(outputLhs, drhs)))); } - case CoreOps.ConstantOp _ -> { + case CoreOp.ConstantOp _ -> { // Copy input operation block.op(op); // Differential of constant is zero yield zero; } - case CoreOps.InvokeOp c -> { + case CoreOp.InvokeOp c -> { MethodRef md = c.invokeDescriptor(); String operationName = null; if (md.refType().equals(J_L_MATH)) { @@ -192,7 +192,7 @@ Value diffOp(Block.Builder block, Op op) { throw new UnsupportedOperationException("Operation not supported: " + op.opName()); } } - case CoreOps.ReturnOp _ -> { + case CoreOp.ReturnOp _ -> { // Replace with return of differentiated value Value a = op.operands().get(0); Value da = diffValueMapping.getOrDefault(a, zero); diff --git a/test/jdk/java/lang/reflect/code/ad/TestForwardAutoDiff.java b/test/jdk/java/lang/reflect/code/ad/TestForwardAutoDiff.java index a461ff84362..31932195a19 100644 --- a/test/jdk/java/lang/reflect/code/ad/TestForwardAutoDiff.java +++ b/test/jdk/java/lang/reflect/code/ad/TestForwardAutoDiff.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; import java.lang.reflect.code.Block; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; import java.lang.reflect.code.bytecode.BytecodeGenerator; @@ -48,7 +48,7 @@ public class TestForwardAutoDiff { @Test public void testExpression() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f.writeTo(System.out); f = SSA.transform(f); @@ -60,13 +60,13 @@ public void testExpression() throws Throwable { Block.Parameter x = f.body().entryBlock().parameters().get(0); Block.Parameter y = f.body().entryBlock().parameters().get(1); - CoreOps.FuncOp dff_dx = ExpressionElimination.eliminate(ForwardDifferentiation.partialDiff(f, x)); + CoreOp.FuncOp dff_dx = ExpressionElimination.eliminate(ForwardDifferentiation.partialDiff(f, x)); dff_dx.writeTo(System.out); MethodHandle dff_dx_mh = generate(dff_dx); Assert.assertEquals((double) dff_dx_mh.invoke(0.0, 1.0), df_dx(0.0, 1.0)); Assert.assertEquals((double) dff_dx_mh.invoke(PI_4, PI_4), df_dx(PI_4, PI_4)); - CoreOps.FuncOp dff_dy = ExpressionElimination.eliminate(ForwardDifferentiation.partialDiff(f, y)); + CoreOp.FuncOp dff_dy = ExpressionElimination.eliminate(ForwardDifferentiation.partialDiff(f, y)); dff_dy.writeTo(System.out); MethodHandle dff_dy_mh = generate(dff_dy); Assert.assertEquals((double) dff_dy_mh.invoke(0.0, 1.0), df_dy(0.0, 1.0)); @@ -88,7 +88,7 @@ static double df_dy(double x, double y) { @Test public void testControlFlow() throws Throwable { - CoreOps.FuncOp f = getFuncOp("fcf"); + CoreOp.FuncOp f = getFuncOp("fcf"); f.writeTo(System.out); f = f.transform((block, op) -> { @@ -110,7 +110,7 @@ public void testControlFlow() throws Throwable { Block.Parameter x = f.body().entryBlock().parameters().get(0); - CoreOps.FuncOp df_dx = ForwardDifferentiation.partialDiff(f, x); + CoreOp.FuncOp df_dx = ForwardDifferentiation.partialDiff(f, x); df_dx.writeTo(System.out); MethodHandle df_dx_mh = generate(df_dx); @@ -147,11 +147,11 @@ static double dfcf_dx(/* independent */ double x, int y) { return d_o; } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { return BytecodeGenerator.generate(MethodHandles.lookup(), f); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestForwardAutoDiff.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestArrayCreation.java b/test/jdk/java/lang/reflect/code/bytecode/TestArrayCreation.java index 21a80109b93..b59ea690e3c 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestArrayCreation.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestArrayCreation.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.invoke.MethodHandle; @@ -47,7 +47,7 @@ public static String[] f() { @Test public void testf() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); MethodHandle mh = generate(f); @@ -61,7 +61,7 @@ public static String[][] f2() { @Test public void testf2() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f2"); + CoreOp.FuncOp f = getFuncOp("f2"); MethodHandle mh = generate(f); @@ -75,7 +75,7 @@ public static String[][] f3() { @Test public void testf3() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f3"); + CoreOp.FuncOp f = getFuncOp("f3"); MethodHandle mh = generate(f); @@ -89,17 +89,17 @@ public static String[][] f4() { @Test public void testf4() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f4"); + CoreOp.FuncOp f = getFuncOp("f4"); MethodHandle mh = generate(f); Assert.assertEquals((String[][]) mh.invoke(), f4()); } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -112,7 +112,7 @@ static MethodHandle generate(CoreOps.FuncOp f) { return BytecodeGenerator.generate(MethodHandles.lookup(), lf); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestArrayCreation.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java b/test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java index b3efbc78f5d..381c050c960 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java @@ -36,7 +36,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.bytecode.BytecodeLift; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.reflect.Method; @@ -390,7 +390,7 @@ static int consume(int i, Func f) { static int consumeQuotable(int i, QuotableFunc f) { Assert.assertNotNull(f.quoted()); Assert.assertNotNull(f.quoted().op()); - Assert.assertTrue(f.quoted().op() instanceof CoreOps.LambdaOp); + Assert.assertTrue(f.quoted().op() instanceof CoreOp.LambdaOp); return f.apply(i + 1); } @@ -522,7 +522,7 @@ public void testLift(TestData d) throws Throwable { if (d.testMethod.getAnnotation(SkipLift.class) != null) { throw new SkipException("skipped"); } - CoreOps.FuncOp flift; + CoreOp.FuncOp flift; try { flift = BytecodeLift.lift(CLASS_DATA, d.testMethod.getName(), toMethodTypeDesc(d.testMethod)); } catch (Throwable e) { @@ -539,7 +539,7 @@ public void testLift(TestData d) throws Throwable { } } - private static Object invokeAndConvert(CoreOps.FuncOp func, Object[] args) { + private static Object invokeAndConvert(CoreOp.FuncOp func, Object[] args) { Object ret = Interpreter.invoke(func, args); if (ret instanceof Integer i) { TypeElement rt = func.invokableType().returnType(); @@ -558,9 +558,9 @@ private static Object invokeAndConvert(CoreOps.FuncOp func, Object[] args) { @Test(dataProvider = "testMethods") public void testGenerate(TestData d) throws Throwable { - CoreOps.FuncOp func = d.testMethod.getCodeModel().get(); + CoreOp.FuncOp func = d.testMethod.getCodeModel().get(); - CoreOps.FuncOp lfunc = func.transform(CopyContext.create(), (block, op) -> { + CoreOp.FuncOp lfunc = func.transform(CopyContext.create(), (block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestLiftCustomBytecode.java b/test/jdk/java/lang/reflect/code/bytecode/TestLiftCustomBytecode.java index d5c8ac3171e..f2ad3138b31 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestLiftCustomBytecode.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestLiftCustomBytecode.java @@ -29,7 +29,7 @@ import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDescs; import java.lang.constant.MethodTypeDesc; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.bytecode.BytecodeLift; import java.lang.reflect.code.interpreter.Interpreter; @@ -43,7 +43,7 @@ public class TestLiftCustomBytecode { @Test public void testBackJumps() throws Throwable { - CoreOps.FuncOp f = getFuncOp(ClassFile.of().build(ClassDesc.of("BackJumps"), clb -> + CoreOp.FuncOp f = getFuncOp(ClassFile.of().build(ClassDesc.of("BackJumps"), clb -> clb.withMethodBody("backJumps", MethodTypeDesc.of(ConstantDescs.CD_int, ConstantDescs.CD_int), ClassFile.ACC_STATIC, cob -> { Label l1 = cob.newLabel(); Label l2 = cob.newLabel(); @@ -65,8 +65,8 @@ public void testBackJumps() throws Throwable { Assert.assertEquals((int) Interpreter.invoke(f, 42), 42); } - static CoreOps.FuncOp getFuncOp(byte[] classdata, String method) { - CoreOps.FuncOp flift = BytecodeLift.lift(classdata, method); + static CoreOp.FuncOp getFuncOp(byte[] classdata, String method) { + CoreOp.FuncOp flift = BytecodeLift.lift(classdata, method); flift.writeTo(System.out); return flift; } diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestLiftExample.java b/test/jdk/java/lang/reflect/code/bytecode/TestLiftExample.java index 1ec0c242e6d..8a285732087 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestLiftExample.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestLiftExample.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.bytecode.BytecodeLift; import java.lang.reflect.code.interpreter.Interpreter; import java.lang.invoke.MethodHandles; @@ -65,7 +65,7 @@ static InvocationHandler handler(Function<?, ?> f) { public void testF() throws Throwable { URL resource = TestLiftExample.class.getClassLoader().getResource(TestLiftExample.class.getName().replace('.', '/') + ".class"); byte[] classdata = resource.openStream().readAllBytes(); - CoreOps.FuncOp flift = BytecodeLift.lift(classdata, "proxy"); + CoreOp.FuncOp flift = BytecodeLift.lift(classdata, "proxy"); flift.writeTo(System.out); Function<Integer, Integer> f = i -> i; diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestQuoted.java b/test/jdk/java/lang/reflect/code/bytecode/TestQuoted.java index 3e99fa8a9a6..6590265b6ea 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestQuoted.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestQuoted.java @@ -26,17 +26,11 @@ import java.lang.reflect.code.CopyContext; import java.lang.reflect.code.Quoted; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import java.lang.reflect.Method; -import java.lang.runtime.CodeReflection; -import java.util.Optional; -import java.util.function.Function; -import java.util.function.IntBinaryOperator; -import java.util.stream.Stream; /* * @test @@ -51,7 +45,7 @@ public void testQuoted() throws Throwable { i = i + j; return i; }; - CoreOps.ClosureOp cop = (CoreOps.ClosureOp) q.op(); + CoreOp.ClosureOp cop = (CoreOp.ClosureOp) q.op(); MethodHandle mh = generate(cop); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestSlots.java b/test/jdk/java/lang/reflect/code/bytecode/TestSlots.java index 266c67aeafb..5188dfffab9 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestSlots.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestSlots.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.invoke.MethodHandle; @@ -51,7 +51,7 @@ static double f(double i, double j) { @Test public void testF() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); MethodHandle mh = generate(f); @@ -65,7 +65,7 @@ static double f2(double x, double y) { @Test public void testF2() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f2"); + CoreOp.FuncOp f = getFuncOp("f2"); MethodHandle mh = generate(f); @@ -88,7 +88,7 @@ static double f3(/* independent */ double x, int y) { @Test public void testF3() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f3"); + CoreOp.FuncOp f = getFuncOp("f3"); MethodHandle mh = generate(f); @@ -104,7 +104,7 @@ static int f4(/* Unused */ int a, int b) { @Test public void testF4() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f4"); + CoreOp.FuncOp f = getFuncOp("f4"); MethodHandle mh; try { @@ -124,7 +124,7 @@ static double f5(/* Unused */ double a, double b) { @Test public void testF5() throws Throwable { - CoreOps.FuncOp f = getFuncOp("f5"); + CoreOp.FuncOp f = getFuncOp("f5"); MethodHandle mh; try { @@ -137,10 +137,10 @@ public void testF5() throws Throwable { Assert.assertEquals(f5(1.0, 2.0), (double) mh.invoke(1.0, 2.0)); } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -153,7 +153,7 @@ static MethodHandle generate(CoreOps.FuncOp f) { return BytecodeGenerator.generate(MethodHandles.lookup(), lf); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestSlots.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestSmallCorpus.java b/test/jdk/java/lang/reflect/code/bytecode/TestSmallCorpus.java index ca630a8c1b1..90226922d45 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestSmallCorpus.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestSmallCorpus.java @@ -35,7 +35,7 @@ import java.lang.reflect.code.analysis.SSA; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.reflect.code.bytecode.BytecodeLift; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.net.URI; import java.nio.file.FileSystem; import java.nio.file.FileSystems; @@ -103,15 +103,15 @@ private void testDoubleRoundtripStability(Path path) throws Exception { var clm = CF.parse(path); for (var originalModel : clm.methods()) { if (originalModel.flags().has(AccessFlag.STATIC) && originalModel.code().isPresent()) try { - CoreOps.FuncOp firstLift = lift(originalModel); + CoreOp.FuncOp firstLift = lift(originalModel); try { - CoreOps.FuncOp firstTransform = transform(firstLift); + CoreOp.FuncOp firstTransform = transform(firstLift); try { MethodModel firstModel = lower(firstTransform); try { - CoreOps.FuncOp secondLift = lift(firstModel); + CoreOp.FuncOp secondLift = lift(firstModel); try { - CoreOps.FuncOp secondTransform = transform(secondLift); + CoreOp.FuncOp secondTransform = transform(secondLift); try { MethodModel secondModel = lower(secondTransform); @@ -148,7 +148,7 @@ private void testDoubleRoundtripStability(Path path) throws Exception { } } } - private static void printInColumns(CoreOps.FuncOp first, CoreOps.FuncOp second) { + private static void printInColumns(CoreOp.FuncOp first, CoreOp.FuncOp second) { StringWriter fw = new StringWriter(); first.writeTo(fw); StringWriter sw = new StringWriter(); @@ -165,11 +165,11 @@ private static void printInColumns(List<String> first, List<String> second) { } } - private static CoreOps.FuncOp lift(MethodModel mm) { + private static CoreOp.FuncOp lift(MethodModel mm) { return BytecodeLift.lift(mm); } - private static CoreOps.FuncOp transform(CoreOps.FuncOp func) { + private static CoreOp.FuncOp transform(CoreOp.FuncOp func) { return SSA.transform(func.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); @@ -180,7 +180,7 @@ private static CoreOps.FuncOp transform(CoreOps.FuncOp func) { })); } - private static MethodModel lower(CoreOps.FuncOp func) { + private static MethodModel lower(CoreOp.FuncOp func) { return CF.parse(BytecodeGenerator.generateClassData( MethodHandles.lookup(), func)).methods().get(0); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestTry.java b/test/jdk/java/lang/reflect/code/bytecode/TestTry.java index 8a4e16ec1ff..7b0de90885f 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestTry.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestTry.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.reflect.code.interpreter.Interpreter; @@ -66,7 +66,7 @@ public static void catching(IntConsumer c) { @Test public void testCatching() { - CoreOps.FuncOp f = getFuncOp("catching"); + CoreOp.FuncOp f = getFuncOp("catching"); MethodHandle mh = generate(f); @@ -118,7 +118,7 @@ public static void catchThrowable(IntConsumer c) { @Test public void testCatchThrowable() { - CoreOps.FuncOp f = getFuncOp("catchThrowable"); + CoreOp.FuncOp f = getFuncOp("catchThrowable"); MethodHandle mh = generate(f); @@ -174,7 +174,7 @@ public static void catchNested(IntConsumer c) { @Test public void testCatchNested() { - CoreOps.FuncOp f = getFuncOp("catchNested"); + CoreOp.FuncOp f = getFuncOp("catchNested"); MethodHandle mh = generate(f); @@ -255,10 +255,10 @@ static Consumer<IntConsumer> testConsumer(Consumer<IntConsumer> actualR, Consume }; } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -286,7 +286,7 @@ public static <E extends Throwable> E erase(Throwable e) throws E { return (E) e; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTry.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestTryFinally.java b/test/jdk/java/lang/reflect/code/bytecode/TestTryFinally.java index 35f60e4fb22..f0cabc0fa14 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestTryFinally.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestTryFinally.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.reflect.code.interpreter.Interpreter; @@ -64,7 +64,7 @@ public static void tryCatchFinally(IntConsumer c) { @Test public void testCatchFinally() { - CoreOps.FuncOp f = getFuncOp("tryCatchFinally"); + CoreOp.FuncOp f = getFuncOp("tryCatchFinally"); MethodHandle mh = generate(f); @@ -96,7 +96,7 @@ public static void tryReturn(IntConsumer c) { @Test public void testTryReturn() { - CoreOps.FuncOp f = getFuncOp("tryReturn"); + CoreOp.FuncOp f = getFuncOp("tryReturn"); MethodHandle mh = generate(f); @@ -128,7 +128,7 @@ public static void catchThrow(IntConsumer c) { @Test public void testCatchThrow() { - CoreOps.FuncOp f = getFuncOp("catchThrow"); + CoreOp.FuncOp f = getFuncOp("catchThrow"); MethodHandle mh = generate(f); @@ -158,7 +158,7 @@ public static void finallyReturn(IntConsumer c) { @Test public void finallyReturn() { - CoreOps.FuncOp f = getFuncOp("finallyReturn"); + CoreOp.FuncOp f = getFuncOp("finallyReturn"); MethodHandle mh = generate(f); @@ -191,10 +191,10 @@ static void test(Consumer<IntConsumer> test) { }); } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -222,7 +222,7 @@ public static <E extends Throwable> E erase(Throwable e) throws E { return (E) e; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTryFinally.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/bytecode/TestTryFinallyNested.java b/test/jdk/java/lang/reflect/code/bytecode/TestTryFinallyNested.java index 012affc1095..5ff31871c16 100644 --- a/test/jdk/java/lang/reflect/code/bytecode/TestTryFinallyNested.java +++ b/test/jdk/java/lang/reflect/code/bytecode/TestTryFinallyNested.java @@ -24,7 +24,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.bytecode.BytecodeGenerator; import java.lang.reflect.code.interpreter.Interpreter; @@ -84,7 +84,7 @@ public static void tryCatchFinally(IntConsumer c, int i) { @Test public void testCatchFinally() { - CoreOps.FuncOp f = getFuncOp("tryCatchFinally"); + CoreOp.FuncOp f = getFuncOp("tryCatchFinally"); MethodHandle mh = generate(f); @@ -130,7 +130,7 @@ public static void tryForLoop(IntConsumer c) { @Test public void testTryForLoop() { - CoreOps.FuncOp f = getFuncOp("tryForLoop"); + CoreOp.FuncOp f = getFuncOp("tryForLoop"); MethodHandle mh = generate(f); @@ -169,7 +169,7 @@ public static void tryLabeledForLoop(IntConsumer c) { @Test public void testTryLabeledForLoop() { - CoreOps.FuncOp f = getFuncOp("tryLabeledForLoop"); + CoreOp.FuncOp f = getFuncOp("tryLabeledForLoop"); MethodHandle mh = generate(f); @@ -214,10 +214,10 @@ static Consumer<IntConsumer> testConsumer(Consumer<IntConsumer> actualR, Consume }; } - static MethodHandle generate(CoreOps.FuncOp f) { + static MethodHandle generate(CoreOp.FuncOp f) { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -253,7 +253,7 @@ public static <E extends Throwable> E erase(Throwable e) throws E { return (E) e; } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestTryFinallyNested.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/expression/ExpressionElimination.java b/test/jdk/java/lang/reflect/code/expression/ExpressionElimination.java index c7a8f10d42d..91ccfc6a42e 100644 --- a/test/jdk/java/lang/reflect/code/expression/ExpressionElimination.java +++ b/test/jdk/java/lang/reflect/code/expression/ExpressionElimination.java @@ -22,11 +22,11 @@ */ import java.lang.reflect.code.*; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.HashMap; import java.util.function.BiConsumer; -import static java.lang.reflect.code.op.CoreOps.sub; +import static java.lang.reflect.code.op.CoreOp.sub; import static java.lang.reflect.code.analysis.Patterns.*; public final class ExpressionElimination { @@ -34,15 +34,15 @@ private ExpressionElimination() { } static OpPattern negP(Pattern operand) { - return opP(CoreOps.NegOp.class, operand); + return opP(CoreOp.NegOp.class, operand); } static OpPattern addP(Pattern lhs, Pattern rhs) { - return opP(CoreOps.AddOp.class, lhs, rhs); + return opP(CoreOp.AddOp.class, lhs, rhs); } static OpPattern mulP(Pattern lhs, Pattern rhs) { - return opP(CoreOps.MulOp.class, lhs, rhs); + return opP(CoreOp.MulOp.class, lhs, rhs); } public static <T extends Op> T eliminate(T f) { diff --git a/test/jdk/java/lang/reflect/code/expression/TestExpressionElimination.java b/test/jdk/java/lang/reflect/code/expression/TestExpressionElimination.java index 4cd09e966d9..824d2bd1ed6 100644 --- a/test/jdk/java/lang/reflect/code/expression/TestExpressionElimination.java +++ b/test/jdk/java/lang/reflect/code/expression/TestExpressionElimination.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; import java.lang.reflect.code.CopyContext; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.Quoted; import java.lang.reflect.code.analysis.SSA; @@ -40,20 +40,20 @@ public class TestExpressionElimination { @Test public void testAddZero() { - CoreOps.ClosureOp lf = generate((double a) -> a + 0.0); + CoreOp.ClosureOp lf = generate((double a) -> a + 0.0); Assert.assertEquals((double) Interpreter.invoke(lf, 1.0d), 1.0d); } @Test public void testF() { - CoreOps.ClosureOp lf = generate((double a, double b) -> -a + b); + CoreOp.ClosureOp lf = generate((double a, double b) -> -a + b); Assert.assertEquals((double) Interpreter.invoke(lf, 1.0d, 1.0d), 0.0d); } - static CoreOps.ClosureOp generate(Quoted q) { - return generateF((CoreOps.ClosureOp) q.op()); + static CoreOp.ClosureOp generate(Quoted q) { + return generateF((CoreOp.ClosureOp) q.op()); } static <T extends Op & Op.Invokable> T generateF(T f) { diff --git a/test/jdk/java/lang/reflect/code/interpreter/TestAssert.java b/test/jdk/java/lang/reflect/code/interpreter/TestAssert.java index a707532b1d6..0651b5efb52 100644 --- a/test/jdk/java/lang/reflect/code/interpreter/TestAssert.java +++ b/test/jdk/java/lang/reflect/code/interpreter/TestAssert.java @@ -22,16 +22,13 @@ */ import java.lang.reflect.code.Op; import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import java.lang.reflect.code.interpreter.Interpreter; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.runtime.CodeReflection; import org.testng.Assert; -import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /* @@ -161,7 +158,7 @@ private static void testRun(String methodName, List<Class<?>> params, Object...a try { Class<TestAssert> clazz = TestAssert.class; Method method = clazz.getDeclaredMethod(methodName,params.toArray(new Class[params.size()])); - CoreOps.FuncOp f = method.getCodeModel().orElseThrow(); + CoreOp.FuncOp f = method.getCodeModel().orElseThrow(); //Ensure we're fully lowered before testing. final var fz = f.transform((b, o) -> { @@ -183,7 +180,7 @@ private static AssertionError testThrows(String methodName, List<Class<?>> param try { Class<TestAssert> clazz = TestAssert.class; Method method = clazz.getDeclaredMethod(methodName,params.toArray(new Class[params.size()])); - CoreOps.FuncOp f = method.getCodeModel().orElseThrow(); + CoreOp.FuncOp f = method.getCodeModel().orElseThrow(); //Ensure we're fully lowered before testing. final var fz = f.transform((b, o) -> { diff --git a/test/jdk/java/lang/reflect/code/linq/QueryProvider.java b/test/jdk/java/lang/reflect/code/linq/QueryProvider.java index 4544f39a59b..ad677021b9f 100644 --- a/test/jdk/java/lang/reflect/code/linq/QueryProvider.java +++ b/test/jdk/java/lang/reflect/code/linq/QueryProvider.java @@ -21,13 +21,13 @@ * questions. */ -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.JavaType; public abstract class QueryProvider { public abstract <T> Queryable<T> query(Class<T> elementType); - protected abstract Queryable<?> createQuery(JavaType elementType, CoreOps.FuncOp queryExpression); + protected abstract Queryable<?> createQuery(JavaType elementType, CoreOp.FuncOp queryExpression); - protected abstract QueryResult<?> createQueryResult(JavaType resultType, CoreOps.FuncOp expression); + protected abstract QueryResult<?> createQueryResult(JavaType resultType, CoreOp.FuncOp expression); } diff --git a/test/jdk/java/lang/reflect/code/linq/QueryResult.java b/test/jdk/java/lang/reflect/code/linq/QueryResult.java index d01620c85e8..3fce881b1c0 100644 --- a/test/jdk/java/lang/reflect/code/linq/QueryResult.java +++ b/test/jdk/java/lang/reflect/code/linq/QueryResult.java @@ -21,7 +21,7 @@ * questions. */ -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.JavaType; public interface QueryResult<T> { @@ -31,5 +31,5 @@ public interface QueryResult<T> { JavaType resultType(); // Queryable<T> -> QueryResult<T> - CoreOps.FuncOp expression(); + CoreOp.FuncOp expression(); } diff --git a/test/jdk/java/lang/reflect/code/linq/Queryable.java b/test/jdk/java/lang/reflect/code/linq/Queryable.java index f35aa796127..a6332fde297 100644 --- a/test/jdk/java/lang/reflect/code/linq/Queryable.java +++ b/test/jdk/java/lang/reflect/code/linq/Queryable.java @@ -29,7 +29,7 @@ import static java.lang.reflect.code.type.JavaType.parameterized; import static java.lang.reflect.code.type.MethodRef.method; -import static java.lang.reflect.code.op.CoreOps.*; +import static java.lang.reflect.code.op.CoreOp.*; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.type; diff --git a/test/jdk/java/lang/reflect/code/linq/TestQueryProvider.java b/test/jdk/java/lang/reflect/code/linq/TestQueryProvider.java index 4f04c75fe02..472c1708f2c 100644 --- a/test/jdk/java/lang/reflect/code/linq/TestQueryProvider.java +++ b/test/jdk/java/lang/reflect/code/linq/TestQueryProvider.java @@ -21,11 +21,11 @@ * questions. */ -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.JavaType; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.func; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.func; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.parameterized; import static java.lang.reflect.code.type.JavaType.type; @@ -40,19 +40,19 @@ public <T> Queryable<T> query(Class<T> elementType) { } @Override - protected Queryable<?> createQuery(JavaType elementType, CoreOps.FuncOp expression) { + protected Queryable<?> createQuery(JavaType elementType, CoreOp.FuncOp expression) { return new TestQueryable<>(elementType, this, expression); } @Override - protected QueryResult<?> createQueryResult(JavaType resultType, CoreOps.FuncOp expression) { + protected QueryResult<?> createQueryResult(JavaType resultType, CoreOp.FuncOp expression) { return new TestQueryResult<>(resultType, expression); } static final class TestQueryable<T> implements Queryable<T> { final JavaType elementType; final TestQueryProvider provider; - final CoreOps.FuncOp expression; + final CoreOp.FuncOp expression; TestQueryable(Class<T> tableClass, TestQueryProvider qp) { this.elementType = type(tableClass); @@ -65,7 +65,7 @@ static final class TestQueryable<T> implements Queryable<T> { .body(b -> b.op(_return(b.parameters().get(0)))); } - TestQueryable(JavaType elementType, TestQueryProvider provider, CoreOps.FuncOp expression) { + TestQueryable(JavaType elementType, TestQueryProvider provider, CoreOp.FuncOp expression) { this.elementType = elementType; this.provider = provider; this.expression = expression; @@ -82,11 +82,11 @@ public JavaType elementType() { } @Override - public CoreOps.FuncOp expression() { + public CoreOp.FuncOp expression() { return expression; } } - record TestQueryResult<T>(JavaType resultType, CoreOps.FuncOp expression) implements QueryResult<T> { + record TestQueryResult<T>(JavaType resultType, CoreOp.FuncOp expression) implements QueryResult<T> { } } diff --git a/test/jdk/java/lang/reflect/code/location/TestLocation.java b/test/jdk/java/lang/reflect/code/location/TestLocation.java index b56d621726d..79b93c68eae 100644 --- a/test/jdk/java/lang/reflect/code/location/TestLocation.java +++ b/test/jdk/java/lang/reflect/code/location/TestLocation.java @@ -34,8 +34,8 @@ import java.lang.reflect.code.Location; import java.lang.reflect.code.Op; import java.lang.reflect.code.OpTransformer; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.parser.OpParser; import java.lang.reflect.code.writer.OpWriter; import java.lang.runtime.CodeReflection; @@ -45,9 +45,9 @@ public class TestLocation { @Test public void testLocation() { - CoreOps.FuncOp f = getFuncOp(ClassWithReflectedMethod.class, "f"); + CoreOp.FuncOp f = getFuncOp(ClassWithReflectedMethod.class, "f"); f.traverse(null, (o, ce) -> { - if (ce instanceof CoreOps.ConstantOp cop) { + if (ce instanceof CoreOp.ConstantOp cop) { Location loc = cop.location(); Assert.assertNotNull(loc); @@ -72,29 +72,29 @@ static int f(int m, int n) { @Test public void dropLocationTransform() { - CoreOps.FuncOp f = getFuncOp(TestLocation.class, "f"); + CoreOp.FuncOp f = getFuncOp(TestLocation.class, "f"); - CoreOps.FuncOp tf = f.transform(OpTransformer.DROP_LOCATION_TRANSFORMER); + CoreOp.FuncOp tf = f.transform(OpTransformer.DROP_LOCATION_TRANSFORMER); tf.setLocation(Location.NO_LOCATION); testNoLocations(tf); - CoreOps.FuncOp tlf = lower(f).transform(OpTransformer.DROP_LOCATION_TRANSFORMER); + CoreOp.FuncOp tlf = lower(f).transform(OpTransformer.DROP_LOCATION_TRANSFORMER); tlf.setLocation(Location.NO_LOCATION); testNoLocations(tlf); } @Test public void dropLocationWriter() { - CoreOps.FuncOp f = getFuncOp(TestLocation.class, "f"); + CoreOp.FuncOp f = getFuncOp(TestLocation.class, "f"); StringWriter w = new StringWriter(); OpWriter.writeTo(w, f, OpWriter.LocationOption.DROP_LOCATION); String tfText = w.toString(); - CoreOps.FuncOp tf = (CoreOps.FuncOp) OpParser.fromString(ExtendedOps.FACTORY, tfText).getFirst(); + CoreOp.FuncOp tf = (CoreOp.FuncOp) OpParser.fromString(ExtendedOp.FACTORY, tfText).getFirst(); testNoLocations(tf); } - static CoreOps.FuncOp lower(CoreOps.FuncOp f) { + static CoreOp.FuncOp lower(CoreOp.FuncOp f) { return f.transform((b, op) -> { if (op instanceof Op.Lowerable l) { return l.lower(b); @@ -112,7 +112,7 @@ static void testNoLocations(Op op) { } - static CoreOps.FuncOp getFuncOp(Class<?> c, String name) { + static CoreOp.FuncOp getFuncOp(Class<?> c, String name) { Optional<Method> om = Stream.of(c.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/lower/CodeReflectionTester.java b/test/jdk/java/lang/reflect/code/lower/CodeReflectionTester.java index 6936094521c..8b7bb6f75af 100644 --- a/test/jdk/java/lang/reflect/code/lower/CodeReflectionTester.java +++ b/test/jdk/java/lang/reflect/code/lower/CodeReflectionTester.java @@ -26,8 +26,8 @@ import java.lang.reflect.Method; import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.parser.OpParser; import java.lang.reflect.code.writer.OpWriter; import java.lang.runtime.CodeReflection; @@ -55,7 +55,7 @@ static void check(Method method) throws ReflectiveOperationException { throw new AssertionError("No @IR annotation found on reflective method"); } - CoreOps.FuncOp f = method.getCodeModel().orElseThrow(() -> + CoreOp.FuncOp f = method.getCodeModel().orElseThrow(() -> new AssertionError("No code model for reflective method")); f = lower(f, lma.ssa()); @@ -66,7 +66,7 @@ static void check(Method method) throws ReflectiveOperationException { } } - static CoreOps.FuncOp lower(CoreOps.FuncOp f, boolean ssa) { + static CoreOp.FuncOp lower(CoreOp.FuncOp f, boolean ssa) { f = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); @@ -94,7 +94,7 @@ static String canonicalizeModel(Member m, Op o) { static String canonicalizeModel(Member m, String d) { Op o; try { - o = OpParser.fromString(ExtendedOps.FACTORY, d).get(0); + o = OpParser.fromString(ExtendedOp.FACTORY, d).get(0); } catch (Exception e) { throw new IllegalStateException(m.toString(), e); } diff --git a/test/jdk/java/lang/reflect/code/parser/TestParse.java b/test/jdk/java/lang/reflect/code/parser/TestParse.java index 8c04709cd47..820c0f3c05b 100644 --- a/test/jdk/java/lang/reflect/code/parser/TestParse.java +++ b/test/jdk/java/lang/reflect/code/parser/TestParse.java @@ -31,18 +31,18 @@ import org.testng.annotations.Test; import java.lang.reflect.code.Block; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.type.MethodRef; import java.lang.reflect.code.parser.OpParser; import java.util.List; import java.util.function.IntUnaryOperator; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.add; -import static java.lang.reflect.code.op.CoreOps.constant; -import static java.lang.reflect.code.op.CoreOps.func; -import static java.lang.reflect.code.op.CoreOps.lambda; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.add; +import static java.lang.reflect.code.op.CoreOp.constant; +import static java.lang.reflect.code.op.CoreOp.func; +import static java.lang.reflect.code.op.CoreOp.lambda; import static java.lang.reflect.code.type.FunctionType.functionType; import static java.lang.reflect.code.type.JavaType.INT; import static java.lang.reflect.code.type.JavaType.type; @@ -56,14 +56,14 @@ public class TestParse { @Test public void testParseLambdaOp() { // functional type = (int)int - CoreOps.FuncOp f = func("f", functionType(INT, INT)) + CoreOp.FuncOp f = func("f", functionType(INT, INT)) .body(block -> { Block.Parameter i = block.parameters().get(0); // functional type = (int)int // op type = ()IntUnaryOperator // captures i - CoreOps.LambdaOp lambda = lambda(block.parentBody(), + CoreOp.LambdaOp lambda = lambda(block.parentBody(), functionType(INT, INT), type(IntUnaryOperator.class)) .body(lbody -> { Block.Builder lblock = lbody.entryBlock(); @@ -75,11 +75,11 @@ public void testParseLambdaOp() { Op.Result fi = block.op(lambda); Op.Result fortyTwo = block.op(constant(INT, 42)); - Op.Result or = block.op(CoreOps.invoke(INT_UNARY_OPERATOR_METHOD, fi, fortyTwo)); + Op.Result or = block.op(CoreOp.invoke(INT_UNARY_OPERATOR_METHOD, fi, fortyTwo)); block.op(_return(or)); }); - List<Op> ops = OpParser.fromString(CoreOps.FACTORY, f.toText()); + List<Op> ops = OpParser.fromString(CoreOp.FACTORY, f.toText()); assertTextEquals(f, ops.get(0)); } @@ -96,8 +96,8 @@ public void testParseLambdaOp() { """; @Test void testParseNamedBody() { - Op opE = OpParser.fromString(CoreOps.FACTORY, NAMED_BODY).get(0); - Op opA = OpParser.fromString(CoreOps.FACTORY, opE.toText()).get(0); + Op opE = OpParser.fromString(CoreOp.FACTORY, NAMED_BODY).get(0); + Op opA = OpParser.fromString(CoreOp.FACTORY, opE.toText()).get(0); assertTextEquals(opA, opE); } @@ -110,11 +110,11 @@ void testParseNamedBody() { """; @Test void testEscapedString() { - Op opE = OpParser.fromString(CoreOps.FACTORY, ESCAPED_STRING).get(0); - Op opA = OpParser.fromString(CoreOps.FACTORY, opE.toText()).get(0); + Op opE = OpParser.fromString(CoreOp.FACTORY, ESCAPED_STRING).get(0); + Op opA = OpParser.fromString(CoreOp.FACTORY, opE.toText()).get(0); assertTextEquals(opA, opE); - CoreOps.ConstantOp cop = (CoreOps.ConstantOp) opE.bodies().get(0).entryBlock().firstOp(); + CoreOp.ConstantOp cop = (CoreOp.ConstantOp) opE.bodies().get(0).entryBlock().firstOp(); String v = (String) cop.value(); Assert.assertEquals(v, "\b \f \n \r \t \' \" \\"); } diff --git a/test/jdk/java/lang/reflect/code/stream/StreamFuser.java b/test/jdk/java/lang/reflect/code/stream/StreamFuser.java index 4fe885b4798..512efe6a836 100644 --- a/test/jdk/java/lang/reflect/code/stream/StreamFuser.java +++ b/test/jdk/java/lang/reflect/code/stream/StreamFuser.java @@ -22,8 +22,8 @@ */ import java.lang.reflect.code.*; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps.JavaEnhancedForOp; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.ExtendedOp.JavaEnhancedForOp; import java.lang.reflect.code.type.ClassType; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; @@ -34,9 +34,9 @@ import java.util.function.Consumer; import java.util.function.Function; -import static java.lang.reflect.code.op.CoreOps.*; -import static java.lang.reflect.code.op.ExtendedOps._continue; -import static java.lang.reflect.code.op.ExtendedOps.enhancedFor; +import static java.lang.reflect.code.op.CoreOp.*; +import static java.lang.reflect.code.op.ExtendedOp._continue; +import static java.lang.reflect.code.op.ExtendedOp.enhancedFor; import static java.lang.reflect.code.type.JavaType.parameterized; import static java.lang.reflect.code.type.JavaType.type; @@ -56,14 +56,14 @@ static class StreamOp { final Quoted quotedClosure; StreamOp(Quoted quotedClosure) { - if (!(quotedClosure.op() instanceof CoreOps.ClosureOp)) { + if (!(quotedClosure.op() instanceof CoreOp.ClosureOp)) { throw new IllegalArgumentException("Quoted operation is not closure operation"); } this.quotedClosure = quotedClosure; } - CoreOps.ClosureOp op() { - return (CoreOps.ClosureOp) quotedClosure.op(); + CoreOp.ClosureOp op() { + return (CoreOp.ClosureOp) quotedClosure.op(); } } @@ -180,7 +180,7 @@ void fuseIntermediateOperation(int i, Block.Builder body, Value element, Block.B } public FuncOp forEach(Quoted quotedConsumer) { - if (!(quotedConsumer.op() instanceof CoreOps.ClosureOp consumer)) { + if (!(quotedConsumer.op() instanceof CoreOp.ClosureOp consumer)) { throw new IllegalArgumentException("Quoted consumer is not closure operation"); } @@ -205,10 +205,10 @@ public FuncOp forEach(Quoted quotedConsumer) { // Supplier<C> supplier, BiConsumer<C, T> accumulator public FuncOp collect(Quoted quotedSupplier, Quoted quotedAccumulator) { - if (!(quotedSupplier.op() instanceof CoreOps.ClosureOp supplier)) { + if (!(quotedSupplier.op() instanceof CoreOp.ClosureOp supplier)) { throw new IllegalArgumentException("Quoted supplier is not closure operation"); } - if (!(quotedAccumulator.op() instanceof CoreOps.ClosureOp accumulator)) { + if (!(quotedAccumulator.op() instanceof CoreOp.ClosureOp accumulator)) { throw new IllegalArgumentException("Quoted accumulator is not closure operation"); } diff --git a/test/jdk/java/lang/reflect/code/stream/StreamFuserUsingQuotable.java b/test/jdk/java/lang/reflect/code/stream/StreamFuserUsingQuotable.java index f0f3636377c..6f10e079f4e 100644 --- a/test/jdk/java/lang/reflect/code/stream/StreamFuserUsingQuotable.java +++ b/test/jdk/java/lang/reflect/code/stream/StreamFuserUsingQuotable.java @@ -22,7 +22,7 @@ */ import java.lang.reflect.code.*; -import java.lang.reflect.code.op.ExtendedOps.JavaEnhancedForOp; +import java.lang.reflect.code.op.ExtendedOp.JavaEnhancedForOp; import java.lang.reflect.code.type.ClassType; import java.lang.reflect.code.type.FunctionType; import java.lang.reflect.code.type.JavaType; @@ -30,9 +30,9 @@ import java.util.List; import java.util.function.*; -import static java.lang.reflect.code.op.CoreOps.*; -import static java.lang.reflect.code.op.ExtendedOps._continue; -import static java.lang.reflect.code.op.ExtendedOps.enhancedFor; +import static java.lang.reflect.code.op.CoreOp.*; +import static java.lang.reflect.code.op.ExtendedOp._continue; +import static java.lang.reflect.code.op.ExtendedOp.enhancedFor; import static java.lang.reflect.code.type.JavaType.parameterized; import static java.lang.reflect.code.type.JavaType.type; diff --git a/test/jdk/java/lang/reflect/code/stream/TestStream.java b/test/jdk/java/lang/reflect/code/stream/TestStream.java index 0f0450653f5..2d4ba668fee 100644 --- a/test/jdk/java/lang/reflect/code/stream/TestStream.java +++ b/test/jdk/java/lang/reflect/code/stream/TestStream.java @@ -29,7 +29,7 @@ import org.testng.Assert; import org.testng.annotations.Test; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; import java.util.ArrayList; @@ -42,7 +42,7 @@ public class TestStream { @Test public void testMapFilterForEach() { - CoreOps.FuncOp f = StreamFuser.fromList(type(Integer.class)) + CoreOp.FuncOp f = StreamFuser.fromList(type(Integer.class)) .map((Integer i) -> i.toString()) .filter((String s) -> s.length() < 10) .map((String s) -> s.concat("_XXX")) @@ -51,7 +51,7 @@ public void testMapFilterForEach() { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -67,7 +67,7 @@ public void testMapFilterForEach() { @Test public void testMapFlatMapFilterCollect() { - CoreOps.FuncOp f = StreamFuser.fromList(type(Integer.class)) + CoreOp.FuncOp f = StreamFuser.fromList(type(Integer.class)) .map((Integer i) -> i.toString()) .flatMap((String s) -> List.of(s, s)) .filter((String s) -> s.length() < 10) @@ -77,7 +77,7 @@ public void testMapFlatMapFilterCollect() { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/stream/TestStreamUsingQuotable.java b/test/jdk/java/lang/reflect/code/stream/TestStreamUsingQuotable.java index 5e7c69f9430..fd97bf3a9db 100644 --- a/test/jdk/java/lang/reflect/code/stream/TestStreamUsingQuotable.java +++ b/test/jdk/java/lang/reflect/code/stream/TestStreamUsingQuotable.java @@ -31,7 +31,7 @@ import java.lang.reflect.code.Op; import java.lang.reflect.code.interpreter.Interpreter; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -40,7 +40,7 @@ public class TestStreamUsingQuotable { @Test public void testMapFilterForEach() { - CoreOps.FuncOp f = StreamFuserUsingQuotable.fromList(Integer.class) + CoreOp.FuncOp f = StreamFuserUsingQuotable.fromList(Integer.class) .map(Object::toString) .filter(s -> s.length() < 10) .map(s -> s.concat("_XXX")) @@ -50,7 +50,7 @@ public void testMapFilterForEach() { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { @@ -66,7 +66,7 @@ public void testMapFilterForEach() { @Test public void testMapFlatMapFilterCollect() { - CoreOps.FuncOp f = StreamFuserUsingQuotable.fromList(Integer.class) + CoreOp.FuncOp f = StreamFuserUsingQuotable.fromList(Integer.class) .map(Object::toString) .flatMap(s -> List.of(s, s)) .filter(s -> s.length() < 10) @@ -76,7 +76,7 @@ public void testMapFlatMapFilterCollect() { f.writeTo(System.out); - CoreOps.FuncOp lf = f.transform((block, op) -> { + CoreOp.FuncOp lf = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { return lop.lower(block); } else { diff --git a/test/jdk/java/lang/reflect/code/type/TestReferences.java b/test/jdk/java/lang/reflect/code/type/TestReferences.java index 7309673f2d1..6b58f90cb64 100644 --- a/test/jdk/java/lang/reflect/code/type/TestReferences.java +++ b/test/jdk/java/lang/reflect/code/type/TestReferences.java @@ -25,9 +25,8 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.type.FieldRef; import java.lang.reflect.code.type.MethodRef; import java.lang.reflect.code.type.RecordTypeRef; @@ -106,7 +105,7 @@ static void x() {} @Test public void testAccessCodeModel() throws ReflectiveOperationException { MethodRef xr = MethodRef.method(TestReferences.class, "x", void.class); - Optional<CoreOps.FuncOp> m = xr.codeModel(MethodHandles.lookup()); + Optional<CoreOp.FuncOp> m = xr.codeModel(MethodHandles.lookup()); Assert.assertTrue(m.isPresent()); } } diff --git a/test/jdk/java/lang/reflect/code/writer/TestCodeBuilder.java b/test/jdk/java/lang/reflect/code/writer/TestCodeBuilder.java index cc8491b4ac8..f8e7814eb5f 100644 --- a/test/jdk/java/lang/reflect/code/writer/TestCodeBuilder.java +++ b/test/jdk/java/lang/reflect/code/writer/TestCodeBuilder.java @@ -29,8 +29,8 @@ import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; import java.lang.reflect.code.interpreter.Interpreter; -import java.lang.reflect.code.op.CoreOps; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.type.CoreTypeFactory; import java.lang.reflect.code.writer.OpBuilder; import java.lang.runtime.CodeReflection; @@ -108,7 +108,7 @@ public void testBodies() { testWithTransforms(getFuncOp("bodies")); } - public void testWithTransforms(CoreOps.FuncOp f) { + public void testWithTransforms(CoreOp.FuncOp f) { test(f); f = f.transform((block, op) -> { @@ -125,14 +125,14 @@ public void testWithTransforms(CoreOps.FuncOp f) { test(f); } - static void test(CoreOps.FuncOp fExpected) { - CoreOps.FuncOp fb = OpBuilder.createBuilderFunction(fExpected); - CoreOps.FuncOp fActual = (CoreOps.FuncOp) Interpreter.invoke(MethodHandles.lookup(), - fb, ExtendedOps.FACTORY, CoreTypeFactory.CORE_TYPE_FACTORY); + static void test(CoreOp.FuncOp fExpected) { + CoreOp.FuncOp fb = OpBuilder.createBuilderFunction(fExpected); + CoreOp.FuncOp fActual = (CoreOp.FuncOp) Interpreter.invoke(MethodHandles.lookup(), + fb, ExtendedOp.FACTORY, CoreTypeFactory.CORE_TYPE_FACTORY); Assert.assertEquals(fActual.toText(), fExpected.toText()); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestCodeBuilder.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/jdk/java/lang/reflect/code/writer/TestNaming.java b/test/jdk/java/lang/reflect/code/writer/TestNaming.java index f87ebc0182d..c10ce60f647 100644 --- a/test/jdk/java/lang/reflect/code/writer/TestNaming.java +++ b/test/jdk/java/lang/reflect/code/writer/TestNaming.java @@ -34,7 +34,7 @@ import java.lang.reflect.code.CodeItem; import java.lang.reflect.code.Op; import java.lang.reflect.code.analysis.SSA; -import java.lang.reflect.code.op.CoreOps; +import java.lang.reflect.code.op.CoreOp; import java.lang.reflect.code.writer.OpWriter; import java.lang.runtime.CodeReflection; import java.util.Map; @@ -57,14 +57,14 @@ static int f(int n, int m) { @Test public void testHigh() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); testModel(f); } @Test public void testLow() { - CoreOps.FuncOp f = getFuncOp("f"); + CoreOp.FuncOp f = getFuncOp("f"); f = f.transform((block, op) -> { if (op instanceof Op.Lowerable lop) { @@ -93,7 +93,7 @@ static void testModel(Op op) { Assert.assertEquals(actual, expected); } - static CoreOps.FuncOp getFuncOp(String name) { + static CoreOp.FuncOp getFuncOp(String name) { Optional<Method> om = Stream.of(TestNaming.class.getDeclaredMethods()) .filter(m -> m.getName().equals(name)) .findFirst(); diff --git a/test/langtools/tools/javac/reflect/CodeReflectionTester.java b/test/langtools/tools/javac/reflect/CodeReflectionTester.java index c70bc41cf49..23f96957369 100644 --- a/test/langtools/tools/javac/reflect/CodeReflectionTester.java +++ b/test/langtools/tools/javac/reflect/CodeReflectionTester.java @@ -26,13 +26,13 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.code.*; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.parser.OpParser; import java.lang.reflect.code.writer.OpWriter; import java.lang.runtime.CodeReflection; -import static java.lang.reflect.code.op.CoreOps._return; -import static java.lang.reflect.code.op.CoreOps.func; +import static java.lang.reflect.code.op.CoreOp._return; +import static java.lang.reflect.code.op.CoreOp.func; import static java.lang.reflect.code.type.FunctionType.VOID; public class CodeReflectionTester { @@ -97,7 +97,7 @@ static String canonicalizeModel(Member m, Op o) { static String canonicalizeModel(Member m, String d) { Op o; try { - o = OpParser.fromString(ExtendedOps.FACTORY, d).get(0); + o = OpParser.fromString(ExtendedOp.FACTORY, d).get(0); } catch (Exception e) { throw new IllegalStateException(m.toString(), e); } diff --git a/test/langtools/tools/javac/reflect/PatternsTest.java b/test/langtools/tools/javac/reflect/PatternsTest.java index bfc37e9068f..80652f09c22 100644 --- a/test/langtools/tools/javac/reflect/PatternsTest.java +++ b/test/langtools/tools/javac/reflect/PatternsTest.java @@ -43,8 +43,8 @@ public class PatternsTest { %4 : java.lang.String = constant @null; %5 : Var<java.lang.String> = var %4 @"s"; %6 : boolean = pattern.match %3 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %7 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %7 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %7; } ^match(%8 : java.lang.String)void -> { @@ -69,8 +69,8 @@ void test1(Object o) { ()boolean -> { %5 : java.lang.Object = var.load %2; %6 : boolean = pattern.match %5 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %7 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %7 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %7; } ^match(%8 : java.lang.String)void -> { @@ -108,8 +108,8 @@ String test2(Object o) { ()boolean -> { %5 : java.lang.Object = var.load %2; %6 : boolean = pattern.match %5 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %7 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %7 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %7; } ^match(%8 : java.lang.String)void -> { @@ -166,12 +166,12 @@ record Rectangle(Point upperLeft, Point lowerRight) { ()boolean -> { %9 : PatternsTest$Rectangle = var.load %2; %10 : boolean = pattern.match %9 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Record<PatternsTest$Rectangle> -> { - %11 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<PatternsTest$ConcretePoint> = pattern.binding @"p"; - %12 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<PatternsTest$Color> = pattern.binding @"c"; - %13 : java.lang.reflect.code.ExtendedOps$Pattern$Record<PatternsTest$ColoredPoint> = pattern.record %11 %12 @"(PatternsTest$ConcretePoint p, PatternsTest$Color c)PatternsTest$ColoredPoint"; - %14 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<PatternsTest$ColoredPoint> = pattern.binding @"lr"; - %15 : java.lang.reflect.code.ExtendedOps$Pattern$Record<PatternsTest$Rectangle> = pattern.record %13 %14 @"(PatternsTest$Point upperLeft, PatternsTest$Point lowerRight)PatternsTest$Rectangle"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Record<PatternsTest$Rectangle> -> { + %11 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<PatternsTest$ConcretePoint> = pattern.binding @"p"; + %12 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<PatternsTest$Color> = pattern.binding @"c"; + %13 : java.lang.reflect.code.ExtendedOp$Pattern$Record<PatternsTest$ColoredPoint> = pattern.record %11 %12 @"(PatternsTest$ConcretePoint p, PatternsTest$Color c)PatternsTest$ColoredPoint"; + %14 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<PatternsTest$ColoredPoint> = pattern.binding @"lr"; + %15 : java.lang.reflect.code.ExtendedOp$Pattern$Record<PatternsTest$Rectangle> = pattern.record %13 %14 @"(PatternsTest$Point upperLeft, PatternsTest$Point lowerRight)PatternsTest$Rectangle"; yield %15; } ^match(%16 : PatternsTest$ConcretePoint, %17 : PatternsTest$Color, %18 : PatternsTest$ColoredPoint)void -> { @@ -227,8 +227,8 @@ void test4(Rectangle r) { ^cond()boolean -> { %5 : java.lang.Object = var.load %2; %6 : boolean = pattern.match %5 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %7 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %7 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %7; } ^match(%8 : java.lang.String)void -> { @@ -265,8 +265,8 @@ void test5(Object o) { ^cond()boolean -> { %5 : java.lang.Object = var.load %2; %6 : boolean = pattern.match %5 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %7 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %7 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %7; } ^match(%8 : java.lang.String)void -> { @@ -312,8 +312,8 @@ void test6(Object o) { ()boolean -> { %12 : java.lang.Object = var.load %2; %13 : boolean = pattern.match %12 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.Number> -> { - %14 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.Number> -> { + %14 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; yield %14; } ^match(%15 : java.lang.Number)void -> { diff --git a/test/langtools/tools/javac/reflect/QuotedTest.java b/test/langtools/tools/javac/reflect/QuotedTest.java index 9b980ee8fc5..85a7e8436a7 100644 --- a/test/langtools/tools/javac/reflect/QuotedTest.java +++ b/test/langtools/tools/javac/reflect/QuotedTest.java @@ -35,7 +35,7 @@ public class QuotedTest { @IR(""" func @"f" ()void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<void> = closure ()void -> { + %0 : func<void> = closure ()void -> { return; }; return; @@ -46,7 +46,7 @@ public class QuotedTest { @IR(""" func @"f" ()void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<int> = closure ()int -> { + %0 : func<int> = closure ()int -> { %2 : int = constant @"1"; return %2; }; @@ -57,7 +57,7 @@ public class QuotedTest { @IR(""" func @"f" ()void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<int, int> = closure (%2 : int)int -> { + %0 : func<int, int> = closure (%2 : int)int -> { %3 : Var<int> = var %2 @"x"; %4 : int = var.load %3; return %4; @@ -69,7 +69,7 @@ public class QuotedTest { @IR(""" func @"f" ()void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<int, int, int> = closure (%2 : int, %3 : int)int -> { + %0 : func<int, int, int> = closure (%2 : int, %3 : int)int -> { %4 : Var<int> = var %2 @"x"; %5 : Var<int> = var %3 @"y"; %6 : int = var.load %4; @@ -84,7 +84,7 @@ public class QuotedTest { @IR(""" func @"f" ()void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<java.lang.Object> = closure ()java.lang.Object -> { + %0 : func<java.lang.Object> = closure ()java.lang.Object -> { %2 : java.lang.AssertionError = new @"func<java.lang.AssertionError>"; throw %2; }; @@ -99,7 +99,7 @@ public class QuotedTest { @IR(""" func @"f" (%1: Var<int>)void -> { - %0 : java.lang.reflect.code.CoreOps$Closure<int, int> = closure (%4 : int)int -> { + %0 : func<int, int> = closure (%4 : int)int -> { %5 : Var<int> = var %4 @"y"; %6 : int = var.load %1; %7 : int = var.load %5; @@ -125,7 +125,7 @@ Quoted capture() { @IR(""" func @"f" (%0 : QuotedTest$Context)void -> { - %1 : java.lang.reflect.code.CoreOps$Closure<int, int> = closure (%3 : int)int -> { + %1 : func<int, int> = closure (%3 : int)int -> { %4 : Var<int> = var %3 @"z"; %5 : int = field.load %0 @"QuotedTest$Context::x()int"; %6 : int = field.load %0 @"QuotedTest$Context::y()int"; @@ -144,7 +144,7 @@ Quoted capture() { func @"captureParam" (%0 : int)void -> { %1 : Var<int> = var %0 @"x"; %2 : java.lang.reflect.code.Quoted = quoted ()void -> { - %3 : java.lang.reflect.code.CoreOps$Closure<int, int> = closure (%4 : int)int -> { + %3 : func<int, int> = closure (%4 : int)int -> { %5 : Var<int> = var %4 @"y"; %6 : int = var.load %1; %7 : int = var.load %5; @@ -167,7 +167,7 @@ static void captureParam(int x) { @IR(""" func @"captureField" (%0 : QuotedTest)void -> { %1 : java.lang.reflect.code.Quoted = quoted ()void -> { - %2 : java.lang.reflect.code.CoreOps$Closure<int, int> = closure (%3 : int)int -> { + %2 : func<int, int> = closure (%3 : int)int -> { %4 : Var<int> = var %3 @"z"; %5 : int = field.load %0 @"QuotedTest::x()int"; %6 : int = field.load %0 @"QuotedTest::y()int"; diff --git a/test/langtools/tools/javac/reflect/SwitchExpressionTest.java b/test/langtools/tools/javac/reflect/SwitchExpressionTest.java index 5c86df260d6..d28729e08f2 100644 --- a/test/langtools/tools/javac/reflect/SwitchExpressionTest.java +++ b/test/langtools/tools/javac/reflect/SwitchExpressionTest.java @@ -337,9 +337,9 @@ record A(Number n) { %7 : java.lang.Object = java.switch.expression %2 ^patternCaseLabel(%8 : java.lang.Object)boolean -> { %9 : boolean = pattern.match %8 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Record<SwitchExpressionTest$A> -> { - %10 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; - %11 : java.lang.reflect.code.ExtendedOps$Pattern$Record<SwitchExpressionTest$A> = pattern.record %10 @"(java.lang.Number n)SwitchExpressionTest$A"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Record<SwitchExpressionTest$A> -> { + %10 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; + %11 : java.lang.reflect.code.ExtendedOp$Pattern$Record<SwitchExpressionTest$A> = pattern.record %10 @"(java.lang.Number n)SwitchExpressionTest$A"; yield %11; } ^match(%12 : java.lang.Number)void -> { @@ -354,8 +354,8 @@ record A(Number n) { } ^patternCaseLabel(%14 : java.lang.Object)boolean -> { %15 : boolean = pattern.match %14 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %16 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %16 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %16; } ^match(%17 : java.lang.String)void -> { @@ -406,9 +406,9 @@ case A(Number n) -> { %9 : java.lang.Object = java.switch.expression %2 ^patternCaseLabel(%10 : java.lang.Object)boolean -> { %11 : boolean = pattern.match %10 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Record<SwitchExpressionTest$A> -> { - %12 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; - %13 : java.lang.reflect.code.ExtendedOps$Pattern$Record<SwitchExpressionTest$A> = pattern.record %12 @"(java.lang.Number n)SwitchExpressionTest$A"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Record<SwitchExpressionTest$A> -> { + %12 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.Number> = pattern.binding @"n"; + %13 : java.lang.reflect.code.ExtendedOp$Pattern$Record<SwitchExpressionTest$A> = pattern.record %12 @"(java.lang.Number n)SwitchExpressionTest$A"; yield %13; } ^match(%14 : java.lang.Number)void -> { @@ -425,8 +425,8 @@ case A(Number n) -> { %17 : boolean = java.cand ()boolean -> { %18 : boolean = pattern.match %16 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %19 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %19 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %19; } ^match(%20 : java.lang.String)void -> { @@ -452,8 +452,8 @@ case A(Number n) -> { %27 : boolean = java.cand ()boolean -> { %28 : boolean = pattern.match %26 - ^pattern()java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> -> { - %29 : java.lang.reflect.code.ExtendedOps$Pattern$Binding<java.lang.String> = pattern.binding @"s"; + ^pattern()java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> -> { + %29 : java.lang.reflect.code.ExtendedOp$Pattern$Binding<java.lang.String> = pattern.binding @"s"; yield %29; } ^match(%30 : java.lang.String)void -> { diff --git a/test/langtools/tools/javac/reflect/TestIRFromAnnotation.java b/test/langtools/tools/javac/reflect/TestIRFromAnnotation.java index 6603a8b606d..46f81eb9591 100644 --- a/test/langtools/tools/javac/reflect/TestIRFromAnnotation.java +++ b/test/langtools/tools/javac/reflect/TestIRFromAnnotation.java @@ -36,8 +36,8 @@ import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.code.Op; -import java.lang.reflect.code.op.CoreOps.FuncOp; -import java.lang.reflect.code.op.ExtendedOps; +import java.lang.reflect.code.op.CoreOp.FuncOp; +import java.lang.reflect.code.op.ExtendedOp; import java.lang.reflect.code.parser.OpParser; import java.lang.reflect.code.writer.OpWriter; import java.nio.charset.Charset; @@ -163,7 +163,7 @@ static String canonicalizeModel(Op o) { // parses, and then serializes, dropping location information static String canonicalizeModel(String d) { - return serialize(OpParser.fromString(ExtendedOps.FACTORY, d).get(0)); + return serialize(OpParser.fromString(ExtendedOp.FACTORY, d).get(0)); } // serializes, dropping location information diff --git a/test/langtools/tools/javac/reflect/quoted/TestCaptureQuotable.java b/test/langtools/tools/javac/reflect/quoted/TestCaptureQuotable.java index 1d3eb7fbe3f..75675d51d23 100644 --- a/test/langtools/tools/javac/reflect/quoted/TestCaptureQuotable.java +++ b/test/langtools/tools/javac/reflect/quoted/TestCaptureQuotable.java @@ -29,7 +29,7 @@ import org.testng.annotations.*; -import java.lang.reflect.code.op.CoreOps.Var; +import java.lang.reflect.code.op.CoreOp.Var; import java.lang.reflect.code.Op; import java.lang.reflect.code.Quotable; import java.lang.reflect.code.Quoted; diff --git a/test/langtools/tools/javac/reflect/quoted/TestCaptureQuoted.java b/test/langtools/tools/javac/reflect/quoted/TestCaptureQuoted.java index f821674468f..fdda78bd925 100644 --- a/test/langtools/tools/javac/reflect/quoted/TestCaptureQuoted.java +++ b/test/langtools/tools/javac/reflect/quoted/TestCaptureQuoted.java @@ -27,7 +27,7 @@ * @run testng TestCaptureQuoted */ -import java.lang.reflect.code.op.CoreOps.Var; +import java.lang.reflect.code.op.CoreOp.Var; import java.lang.reflect.code.Op; import java.lang.reflect.code.Quoted; import java.lang.reflect.code.interpreter.Interpreter;