1 /* 2 * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package jdk.internal.classfile.impl; 26 27 import java.lang.classfile.*; 28 import java.lang.classfile.attribute.CodeAttribute; 29 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; 30 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; 31 import java.lang.classfile.attribute.StackMapTableAttribute; 32 import java.lang.classfile.attribute.UnknownAttribute; 33 import java.lang.classfile.constantpool.ClassEntry; 34 import java.lang.classfile.instruction.*; 35 import java.util.ArrayList; 36 import java.util.Collections; 37 import java.util.List; 38 import java.util.Objects; 39 import java.util.Optional; 40 import java.util.function.Consumer; 41 42 import static jdk.internal.classfile.impl.RawBytecodeHelper.*; 43 44 public final class CodeImpl 45 extends BoundAttribute.BoundCodeAttribute 46 implements LabelContext { 47 48 static final Instruction[] SINGLETON_INSTRUCTIONS = new Instruction[256]; 49 50 static { 51 for (var o : Opcode.values()) { 52 if (o.sizeIfFixed() == 1) { 53 SINGLETON_INSTRUCTIONS[o.bytecode()] = switch (o.kind()) { 54 case ARRAY_LOAD -> ArrayLoadInstruction.of(o); 55 case ARRAY_STORE -> ArrayStoreInstruction.of(o); 56 case CONSTANT -> ConstantInstruction.ofIntrinsic(o); 57 case CONVERT -> ConvertInstruction.of(o); 58 case LOAD -> new AbstractInstruction.UnboundLoadInstruction(o, BytecodeHelpers.intrinsicLoadSlot(o)); 59 case MONITOR -> MonitorInstruction.of(o); 60 case NOP -> NopInstruction.of(); 61 case OPERATOR -> OperatorInstruction.of(o); 62 case RETURN -> ReturnInstruction.of(o); 63 case STACK -> StackInstruction.of(o); 64 case STORE -> new AbstractInstruction.UnboundStoreInstruction(o, BytecodeHelpers.intrinsicStoreSlot(o)); 65 case THROW_EXCEPTION -> ThrowInstruction.of(); 66 default -> throw new AssertionError("invalid opcode: " + o); 67 }; 68 } 69 } 70 } 71 72 List<ExceptionCatch> exceptionTable; 73 List<Attribute<?>> attributes; 74 75 // Inflated for iteration 76 LabelImpl[] labels; 77 int[] lineNumbers; 78 boolean inflated; 79 80 public CodeImpl(AttributedElement enclosing, 81 ClassReader reader, 82 AttributeMapper<CodeAttribute> mapper, 83 int payloadStart) { 84 super(enclosing, reader, mapper, payloadStart); 85 } 86 87 // LabelContext 88 89 @Override 90 public Label newLabel() { 91 throw new UnsupportedOperationException("CodeAttribute only supports fixed labels"); 92 } 93 94 @Override 95 public void setLabelTarget(Label label, int bci) { 96 throw new UnsupportedOperationException("CodeAttribute only supports fixed labels"); 97 } 98 99 @Override 100 public Label getLabel(int bci) { 101 if (bci < 0 || bci > codeLength) 102 throw new IllegalArgumentException(String.format("Bytecode offset out of range; bci=%d, codeLength=%d", 103 bci, codeLength)); 104 if (labels == null) 105 labels = new LabelImpl[codeLength + 1]; 106 LabelImpl l = labels[bci]; 107 if (l == null) 108 l = labels[bci] = new LabelImpl(this, bci); 109 return l; 110 } 111 112 @Override 113 public int labelToBci(Label label) { 114 LabelImpl lab = (LabelImpl) label; 115 if (lab.labelContext() != this) 116 throw new IllegalArgumentException(String.format("Illegal label reuse; context=%s, label=%s", 117 this, lab.labelContext())); 118 return lab.getBCI(); 119 } 120 121 private void inflateMetadata() { 122 if (!inflated) { 123 if (labels == null) 124 labels = new LabelImpl[codeLength + 1]; 125 if (classReader.context().passLineNumbers()) 126 inflateLineNumbers(); 127 inflateJumpTargets(); 128 inflateTypeAnnotations(); 129 inflated = true; 130 } 131 } 132 133 // CodeAttribute 134 135 @Override 136 public List<Attribute<?>> attributes() { 137 if (attributes == null) { 138 attributes = BoundAttribute.readAttributes(this, classReader, attributePos, classReader.customAttributes()); 139 } 140 return attributes; 141 } 142 143 @Override 144 public void writeTo(BufWriterImpl buf) { 145 if (buf.canWriteDirect(classReader)) { 146 super.writeTo(buf); 147 } 148 else { 149 DirectCodeBuilder.build((MethodInfo) enclosingMethod, 150 Util.writingAll(this), 151 (SplitConstantPool)buf.constantPool(), 152 buf.context(), 153 null).writeTo(buf); 154 } 155 } 156 157 // CodeModel 158 159 @Override 160 public Optional<MethodModel> parent() { 161 return Optional.of(enclosingMethod); 162 } 163 164 @Override 165 public void forEach(Consumer<? super CodeElement> consumer) { 166 Objects.requireNonNull(consumer); 167 inflateMetadata(); 168 boolean doLineNumbers = (lineNumbers != null); 169 generateCatchTargets(consumer); 170 if (classReader.context().passDebugElements()) 171 generateDebugElements(consumer); 172 generateUserAttributes(consumer); 173 for (int pos=codeStart; pos<codeEnd; ) { 174 if (labels[pos - codeStart] != null) 175 consumer.accept(labels[pos - codeStart]); 176 if (doLineNumbers && lineNumbers[pos - codeStart] != 0) 177 consumer.accept(LineNumberImpl.of(lineNumbers[pos - codeStart])); 178 int bc = classReader.readU1(pos); 179 Instruction instr = bcToInstruction(bc, pos); 180 consumer.accept(instr); 181 pos += instr.sizeInBytes(); 182 } 183 // There might be labels pointing to the bci at codeEnd 184 if (labels[codeEnd-codeStart] != null) 185 consumer.accept(labels[codeEnd - codeStart]); 186 if (doLineNumbers && lineNumbers[codeEnd - codeStart] != 0) 187 consumer.accept(LineNumberImpl.of(lineNumbers[codeEnd - codeStart])); 188 } 189 190 @Override 191 public List<ExceptionCatch> exceptionHandlers() { 192 if (exceptionTable == null) { 193 inflateMetadata(); 194 exceptionTable = new ArrayList<>(exceptionHandlerCnt); 195 iterateExceptionHandlers(new ExceptionHandlerAction() { 196 @Override 197 public void accept(int s, int e, int h, int c) { 198 ClassEntry catchTypeEntry = c == 0 199 ? null 200 : constantPool().entryByIndex(c, ClassEntry.class); 201 exceptionTable.add(new AbstractPseudoInstruction.ExceptionCatchImpl(getLabel(h), getLabel(s), getLabel(e), catchTypeEntry)); 202 } 203 }); 204 exceptionTable = Collections.unmodifiableList(exceptionTable); 205 } 206 return exceptionTable; 207 } 208 209 private void generateUserAttributes(Consumer<? super CodeElement> consumer) { 210 for (var attr : attributes) { 211 if (attr instanceof CustomAttribute || attr instanceof UnknownAttribute) { 212 consumer.accept((CodeElement) attr); 213 } 214 } 215 } 216 217 public boolean compareCodeBytes(BufWriterImpl buf, int offset, int len) { 218 return codeLength == len 219 && classReader.compare(buf, offset, codeStart, codeLength); 220 } 221 222 private int adjustForObjectOrUninitialized(int bci) { 223 int vt = classReader.readU1(bci); 224 //inflate newTarget labels from Uninitialized VTIs 225 if (vt == 8) inflateLabel(classReader.readU2(bci + 1)); 226 return (vt == 7 || vt == 8) ? bci + 3 : bci + 1; 227 } 228 229 private void inflateLabel(int bci) { 230 if (bci < 0 || bci > codeLength) 231 throw new IllegalArgumentException(String.format("Bytecode offset out of range; bci=%d, codeLength=%d", 232 bci, codeLength)); 233 if (labels[bci] == null) 234 labels[bci] = new LabelImpl(this, bci); 235 } 236 237 private void inflateLineNumbers() { 238 for (Attribute<?> a : attributes()) { 239 if (a.attributeMapper() == Attributes.lineNumberTable()) { 240 BoundLineNumberTableAttribute attr = (BoundLineNumberTableAttribute) a; 241 if (lineNumbers == null) 242 lineNumbers = new int[codeLength + 1]; 243 244 int nLn = classReader.readU2(attr.payloadStart); 245 int p = attr.payloadStart + 2; 246 int pEnd = p + (nLn * 4); 247 for (; p < pEnd; p += 4) { 248 int startPc = classReader.readU2(p); 249 if (startPc > codeLength) { 250 throw new IllegalArgumentException(String.format( 251 "Line number start_pc out of range; start_pc=%d, codeLength=%d", startPc, codeLength)); 252 } 253 int lineNumber = classReader.readU2(p + 2); 254 lineNumbers[startPc] = lineNumber; 255 } 256 } 257 } 258 } 259 260 private void inflateJumpTargets() { 261 Optional<StackMapTableAttribute> a = findAttribute(Attributes.stackMapTable()); 262 if (a.isEmpty()) { 263 if (classReader.readU2(6) <= ClassFile.JAVA_6_VERSION) { 264 //fallback to jump targets inflation without StackMapTableAttribute 265 for (int pos=codeStart; pos<codeEnd; ) { 266 var i = bcToInstruction(classReader.readU1(pos), pos); 267 switch (i.opcode().kind()) { 268 case BRANCH -> ((BranchInstruction) i).target(); 269 case DISCONTINUED_JSR -> ((DiscontinuedInstruction.JsrInstruction) i).target(); 270 case LOOKUP_SWITCH -> { 271 var ls = (LookupSwitchInstruction) i; 272 ls.defaultTarget(); 273 ls.cases(); 274 } 275 case TABLE_SWITCH -> { 276 var ts = (TableSwitchInstruction) i; 277 ts.defaultTarget(); 278 ts.cases(); 279 } 280 default -> {} 281 } 282 pos += i.sizeInBytes(); 283 } 284 } 285 return; 286 } 287 int stackMapPos = ((BoundAttribute<StackMapTableAttribute>) a.get()).payloadStart; 288 289 int bci = -1; //compensate for offsetDelta + 1 290 int nEntries = classReader.readU2(stackMapPos); 291 int p = stackMapPos + 2; 292 for (int i = 0; i < nEntries; ++i) { 293 int frameType = classReader.readU1(p); 294 int offsetDelta; 295 if (frameType < 64) { 296 offsetDelta = frameType; 297 ++p; 298 } 299 else if (frameType < 128) { 300 offsetDelta = frameType & 0x3f; 301 p = adjustForObjectOrUninitialized(p + 1); 302 } 303 else 304 switch (frameType) { 305 case 247 -> { 306 offsetDelta = classReader.readU2(p + 1); 307 p = adjustForObjectOrUninitialized(p + 3); 308 } 309 case 248, 249, 250, 251 -> { 310 offsetDelta = classReader.readU2(p + 1); 311 p += 3; 312 } 313 case 252, 253, 254 -> { 314 offsetDelta = classReader.readU2(p + 1); 315 int k = frameType - 251; 316 p += 3; 317 for (int c = 0; c < k; ++c) { 318 p = adjustForObjectOrUninitialized(p); 319 } 320 } 321 case 255 -> { 322 offsetDelta = classReader.readU2(p + 1); 323 p += 3; 324 int k = classReader.readU2(p); 325 p += 2; 326 for (int c = 0; c < k; ++c) { 327 p = adjustForObjectOrUninitialized(p); 328 } 329 k = classReader.readU2(p); 330 p += 2; 331 for (int c = 0; c < k; ++c) { 332 p = adjustForObjectOrUninitialized(p); 333 } 334 } 335 default -> throw new IllegalArgumentException("Bad frame type: " + frameType); 336 } 337 bci += offsetDelta + 1; 338 inflateLabel(bci); 339 } 340 } 341 342 private void inflateTypeAnnotations() { 343 findAttribute(Attributes.runtimeVisibleTypeAnnotations()).ifPresent(RuntimeVisibleTypeAnnotationsAttribute::annotations); 344 findAttribute(Attributes.runtimeInvisibleTypeAnnotations()).ifPresent(RuntimeInvisibleTypeAnnotationsAttribute::annotations); 345 } 346 347 private void generateCatchTargets(Consumer<? super CodeElement> consumer) { 348 // We attach all catch targets to bci zero, because trying to attach them 349 // to their range could subtly affect the order of exception processing 350 iterateExceptionHandlers(new ExceptionHandlerAction() { 351 @Override 352 public void accept(int s, int e, int h, int c) { 353 ClassEntry catchType = c == 0 354 ? null 355 : classReader.entryByIndex(c, ClassEntry.class); 356 consumer.accept(new AbstractPseudoInstruction.ExceptionCatchImpl(getLabel(h), getLabel(s), getLabel(e), catchType)); 357 } 358 }); 359 } 360 361 private void generateDebugElements(Consumer<? super CodeElement> consumer) { 362 for (Attribute<?> a : attributes()) { 363 if (a.attributeMapper() == Attributes.characterRangeTable()) { 364 var attr = (BoundCharacterRangeTableAttribute) a; 365 int cnt = classReader.readU2(attr.payloadStart); 366 int p = attr.payloadStart + 2; 367 int pEnd = p + (cnt * 14); 368 for (; p < pEnd; p += 14) { 369 var instruction = new BoundCharacterRange(this, p); 370 inflateLabel(instruction.startPc()); 371 inflateLabel(instruction.endPc() + 1); 372 consumer.accept(instruction); 373 } 374 } 375 else if (a.attributeMapper() == Attributes.localVariableTable()) { 376 var attr = (BoundLocalVariableTableAttribute) a; 377 int cnt = classReader.readU2(attr.payloadStart); 378 int p = attr.payloadStart + 2; 379 int pEnd = p + (cnt * 10); 380 for (; p < pEnd; p += 10) { 381 BoundLocalVariable instruction = new BoundLocalVariable(this, p); 382 inflateLabel(instruction.startPc()); 383 inflateLabel(instruction.startPc() + instruction.length()); 384 consumer.accept(instruction); 385 } 386 } 387 else if (a.attributeMapper() == Attributes.localVariableTypeTable()) { 388 var attr = (BoundLocalVariableTypeTableAttribute) a; 389 int cnt = classReader.readU2(attr.payloadStart); 390 int p = attr.payloadStart + 2; 391 int pEnd = p + (cnt * 10); 392 for (; p < pEnd; p += 10) { 393 BoundLocalVariableType instruction = new BoundLocalVariableType(this, p); 394 inflateLabel(instruction.startPc()); 395 inflateLabel(instruction.startPc() + instruction.length()); 396 consumer.accept(instruction); 397 } 398 } 399 else if (a.attributeMapper() == Attributes.runtimeVisibleTypeAnnotations()) { 400 consumer.accept((BoundRuntimeVisibleTypeAnnotationsAttribute) a); 401 } 402 else if (a.attributeMapper() == Attributes.runtimeInvisibleTypeAnnotations()) { 403 consumer.accept((BoundRuntimeInvisibleTypeAnnotationsAttribute) a); 404 } 405 } 406 } 407 408 public interface ExceptionHandlerAction { 409 void accept(int start, int end, int handler, int catchTypeIndex); 410 } 411 412 public void iterateExceptionHandlers(ExceptionHandlerAction a) { 413 int p = exceptionHandlerPos + 2; 414 for (int i = 0; i < exceptionHandlerCnt; ++i) { 415 a.accept(classReader.readU2(p), classReader.readU2(p + 2), classReader.readU2(p + 4), classReader.readU2(p + 6)); 416 p += 8; 417 } 418 } 419 420 private Instruction bcToInstruction(int bc, int pos) { 421 return switch (bc) { 422 case BIPUSH -> new AbstractInstruction.BoundArgumentConstantInstruction(Opcode.BIPUSH, CodeImpl.this, pos); 423 case SIPUSH -> new AbstractInstruction.BoundArgumentConstantInstruction(Opcode.SIPUSH, CodeImpl.this, pos); 424 case LDC -> new AbstractInstruction.BoundLoadConstantInstruction(Opcode.LDC, CodeImpl.this, pos); 425 case LDC_W -> new AbstractInstruction.BoundLoadConstantInstruction(Opcode.LDC_W, CodeImpl.this, pos); 426 case LDC2_W -> new AbstractInstruction.BoundLoadConstantInstruction(Opcode.LDC2_W, CodeImpl.this, pos); 427 case ILOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.ILOAD, CodeImpl.this, pos); 428 case LLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.LLOAD, CodeImpl.this, pos); 429 case FLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.FLOAD, CodeImpl.this, pos); 430 case DLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.DLOAD, CodeImpl.this, pos); 431 case ALOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.ALOAD, CodeImpl.this, pos); 432 case ISTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.ISTORE, CodeImpl.this, pos); 433 case LSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.LSTORE, CodeImpl.this, pos); 434 case FSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.FSTORE, CodeImpl.this, pos); 435 case DSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.DSTORE, CodeImpl.this, pos); 436 case ASTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.ASTORE, CodeImpl.this, pos); 437 case IINC -> new AbstractInstruction.BoundIncrementInstruction(Opcode.IINC, CodeImpl.this, pos); 438 case IFEQ -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFEQ, CodeImpl.this, pos); 439 case IFNE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFNE, CodeImpl.this, pos); 440 case IFLT -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFLT, CodeImpl.this, pos); 441 case IFGE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFGE, CodeImpl.this, pos); 442 case IFGT -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFGT, CodeImpl.this, pos); 443 case IFLE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFLE, CodeImpl.this, pos); 444 case IF_ICMPEQ -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPEQ, CodeImpl.this, pos); 445 case IF_ICMPNE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPNE, CodeImpl.this, pos); 446 case IF_ICMPLT -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPLT, CodeImpl.this, pos); 447 case IF_ICMPGE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPGE, CodeImpl.this, pos); 448 case IF_ICMPGT -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPGT, CodeImpl.this, pos); 449 case IF_ICMPLE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ICMPLE, CodeImpl.this, pos); 450 case IF_ACMPEQ -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ACMPEQ, CodeImpl.this, pos); 451 case IF_ACMPNE -> new AbstractInstruction.BoundBranchInstruction(Opcode.IF_ACMPNE, CodeImpl.this, pos); 452 case GOTO -> new AbstractInstruction.BoundBranchInstruction(Opcode.GOTO, CodeImpl.this, pos); 453 case TABLESWITCH -> new AbstractInstruction.BoundTableSwitchInstruction(Opcode.TABLESWITCH, CodeImpl.this, pos); 454 case LOOKUPSWITCH -> new AbstractInstruction.BoundLookupSwitchInstruction(Opcode.LOOKUPSWITCH, CodeImpl.this, pos); 455 case GETSTATIC -> new AbstractInstruction.BoundFieldInstruction(Opcode.GETSTATIC, CodeImpl.this, pos); 456 case PUTSTATIC -> new AbstractInstruction.BoundFieldInstruction(Opcode.PUTSTATIC, CodeImpl.this, pos); 457 case GETFIELD -> new AbstractInstruction.BoundFieldInstruction(Opcode.GETFIELD, CodeImpl.this, pos); 458 case PUTFIELD -> new AbstractInstruction.BoundFieldInstruction(Opcode.PUTFIELD, CodeImpl.this, pos); 459 case INVOKEVIRTUAL -> new AbstractInstruction.BoundInvokeInstruction(Opcode.INVOKEVIRTUAL, CodeImpl.this, pos); 460 case INVOKESPECIAL -> new AbstractInstruction.BoundInvokeInstruction(Opcode.INVOKESPECIAL, CodeImpl.this, pos); 461 case INVOKESTATIC -> new AbstractInstruction.BoundInvokeInstruction(Opcode.INVOKESTATIC, CodeImpl.this, pos); 462 case INVOKEINTERFACE -> new AbstractInstruction.BoundInvokeInterfaceInstruction(Opcode.INVOKEINTERFACE, CodeImpl.this, pos); 463 case INVOKEDYNAMIC -> new AbstractInstruction.BoundInvokeDynamicInstruction(Opcode.INVOKEDYNAMIC, CodeImpl.this, pos); 464 case NEW -> new AbstractInstruction.BoundNewObjectInstruction(CodeImpl.this, pos); 465 case NEWARRAY -> new AbstractInstruction.BoundNewPrimitiveArrayInstruction(Opcode.NEWARRAY, CodeImpl.this, pos); 466 case ANEWARRAY -> new AbstractInstruction.BoundNewReferenceArrayInstruction(Opcode.ANEWARRAY, CodeImpl.this, pos); 467 case CHECKCAST -> new AbstractInstruction.BoundTypeCheckInstruction(Opcode.CHECKCAST, CodeImpl.this, pos); 468 case INSTANCEOF -> new AbstractInstruction.BoundTypeCheckInstruction(Opcode.INSTANCEOF, CodeImpl.this, pos); 469 470 case WIDE -> { 471 int bclow = classReader.readU1(pos + 1); 472 yield switch (bclow) { 473 case ILOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.ILOAD_W, this, pos); 474 case LLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.LLOAD_W, this, pos); 475 case FLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.FLOAD_W, this, pos); 476 case DLOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.DLOAD_W, this, pos); 477 case ALOAD -> new AbstractInstruction.BoundLoadInstruction(Opcode.ALOAD_W, this, pos); 478 case ISTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.ISTORE_W, this, pos); 479 case LSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.LSTORE_W, this, pos); 480 case FSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.FSTORE_W, this, pos); 481 case DSTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.DSTORE_W, this, pos); 482 case ASTORE -> new AbstractInstruction.BoundStoreInstruction(Opcode.ASTORE_W, this, pos); 483 case IINC -> new AbstractInstruction.BoundIncrementInstruction(Opcode.IINC_W, this, pos); 484 case RET -> new AbstractInstruction.BoundRetInstruction(Opcode.RET_W, this, pos); 485 default -> throw new IllegalArgumentException("unknown wide instruction: " + bclow); 486 }; 487 } 488 489 case MULTIANEWARRAY -> new AbstractInstruction.BoundNewMultidimensionalArrayInstruction(Opcode.MULTIANEWARRAY, CodeImpl.this, pos); 490 case IFNULL -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFNULL, CodeImpl.this, pos); 491 case IFNONNULL -> new AbstractInstruction.BoundBranchInstruction(Opcode.IFNONNULL, CodeImpl.this, pos); 492 case GOTO_W -> new AbstractInstruction.BoundBranchInstruction(Opcode.GOTO_W, CodeImpl.this, pos); 493 494 case JSR -> new AbstractInstruction.BoundJsrInstruction(Opcode.JSR, CodeImpl.this, pos); 495 case RET -> new AbstractInstruction.BoundRetInstruction(Opcode.RET, this, pos); 496 case JSR_W -> new AbstractInstruction.BoundJsrInstruction(Opcode.JSR_W, CodeImpl.this, pos); 497 default -> { 498 Instruction instr = SINGLETON_INSTRUCTIONS[bc]; 499 if (instr == null) 500 throw new IllegalArgumentException("unknown instruction: " + bc); 501 yield instr; 502 } 503 }; 504 } 505 506 @Override 507 public String toString() { 508 return String.format("CodeModel[id=%d]", System.identityHashCode(this)); 509 } 510 }