mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8341277: Validate slot argument for instruction factories
Reviewed-by: asotona
This commit is contained in:
parent
0f381137cb
commit
39c17b3926
15 changed files with 366 additions and 80 deletions
|
@ -30,6 +30,7 @@ import java.lang.classfile.Instruction;
|
|||
import java.lang.classfile.Label;
|
||||
import java.lang.classfile.Opcode;
|
||||
import jdk.internal.classfile.impl.AbstractInstruction;
|
||||
import jdk.internal.classfile.impl.BytecodeHelpers;
|
||||
import jdk.internal.classfile.impl.Util;
|
||||
import jdk.internal.javac.PreviewFeature;
|
||||
|
||||
|
@ -112,10 +113,10 @@ public sealed interface DiscontinuedInstruction extends Instruction {
|
|||
* which must be of kind {@link Opcode.Kind#DISCONTINUED_RET}
|
||||
* @param slot the local variable slot to load return address from
|
||||
* @throws IllegalArgumentException if the opcode kind is not
|
||||
* {@link Opcode.Kind#DISCONTINUED_RET}.
|
||||
* {@link Opcode.Kind#DISCONTINUED_RET} or if {@code slot} is out of range
|
||||
*/
|
||||
static RetInstruction of(Opcode op, int slot) {
|
||||
Util.checkKind(op, Opcode.Kind.DISCONTINUED_RET);
|
||||
BytecodeHelpers.validateRet(op, slot);
|
||||
return new AbstractInstruction.UnboundRetInstruction(op, slot);
|
||||
}
|
||||
|
||||
|
@ -123,6 +124,7 @@ public sealed interface DiscontinuedInstruction extends Instruction {
|
|||
* {@return a RET instruction}
|
||||
*
|
||||
* @param slot the local variable slot to load return address from
|
||||
* @throws IllegalArgumentException if {@code slot} is out of range
|
||||
*/
|
||||
static RetInstruction of(int slot) {
|
||||
return of(slot < 256 ? Opcode.RET : Opcode.RET_W, slot);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue