mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8339214: Remove misleading CodeBuilder.loadConstant(Opcode, ConstantDesc)
Reviewed-by: asotona
This commit is contained in:
parent
4ca2c208ea
commit
ad40a122d6
10 changed files with 48 additions and 199 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -33,6 +33,7 @@ import java.lang.classfile.Opcode;
|
|||
import java.lang.classfile.TypeKind;
|
||||
import java.lang.classfile.constantpool.LoadableConstantEntry;
|
||||
import jdk.internal.classfile.impl.AbstractInstruction;
|
||||
import jdk.internal.classfile.impl.BytecodeHelpers;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
|
@ -144,16 +145,21 @@ public sealed interface ConstantInstruction extends Instruction {
|
|||
/**
|
||||
* {@return an argument constant instruction}
|
||||
*
|
||||
* @param op the opcode for the specific type of intrinsic constant instruction,
|
||||
* which must be of kind {@link Opcode.Kind#CONSTANT}
|
||||
* @param op the opcode for the specific type of argument constant instruction,
|
||||
* which must be {@link Opcode#BIPUSH} or {@link Opcode#SIPUSH}
|
||||
* @param value the constant value
|
||||
* @throws IllegalArgumentException if the opcode is not {@link Opcode#BIPUSH}
|
||||
* or {@link Opcode#SIPUSH}
|
||||
* or {@link Opcode#SIPUSH}, or if the constant value is out of range
|
||||
* for the opcode
|
||||
*/
|
||||
static ArgumentConstantInstruction ofArgument(Opcode op, int value) {
|
||||
Util.checkKind(op, Opcode.Kind.CONSTANT);
|
||||
if (op != Opcode.BIPUSH && op != Opcode.SIPUSH)
|
||||
if (op == Opcode.BIPUSH) {
|
||||
BytecodeHelpers.validateBipush(value);
|
||||
} else if (op == Opcode.SIPUSH) {
|
||||
BytecodeHelpers.validateSipush(value);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("Wrong opcode specified; found %s, expected BIPUSH or SIPUSH", op));
|
||||
}
|
||||
return new AbstractInstruction.UnboundArgumentConstantInstruction(op, value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue