< prev index next >

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java

Print this page




 224     @Override
 225     public Constant getEncoding() {
 226         return getMetaspaceMethodConstant();
 227     }
 228 
 229     /**
 230      * Gets the complete set of modifiers for this method which includes the JVM specification
 231      * modifiers as well as the HotSpot internal modifiers.
 232      */
 233     public int getAllModifiers() {
 234         return UNSAFE.getInt(getMetaspaceMethod() + config().methodAccessFlagsOffset);
 235     }
 236 
 237     @Override
 238     public int getModifiers() {
 239         return getAllModifiers() & jvmMethodModifiers();
 240     }
 241 
 242     @Override
 243     public boolean canBeStaticallyBound() {
 244         return (isFinal() || isPrivate() || isStatic() || holder.isLeaf() || isConstructor()) && isConcrete();
 245     }
 246 
 247     @Override
 248     public byte[] getCode() {
 249         if (getCodeSize() == 0) {
 250             return null;
 251         }
 252         if (code == null && holder.isLinked()) {
 253             code = compilerToVM().getBytecode(this);
 254             assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length;
 255         }
 256         return code;
 257     }
 258 
 259     @Override
 260     public int getCodeSize() {
 261         return UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset);
 262     }
 263 
 264     @Override


 389     public int getMaxStackSize() {
 390         if (isAbstract() || isNative()) {
 391             return 0;
 392         }
 393         HotSpotVMConfig config = config();
 394         return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset);
 395     }
 396 
 397     @Override
 398     public StackTraceElement asStackTraceElement(int bci) {
 399         if (bci < 0 || bci >= getCodeSize()) {
 400             // HotSpot code can only construct stack trace elements for valid bcis
 401             StackTraceElement ste = compilerToVM().getStackTraceElement(this, 0);
 402             return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1);
 403         }
 404         return compilerToVM().getStackTraceElement(this, bci);
 405     }
 406 
 407     @Override
 408     public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) {
 409         assert !canBeStaticallyBound() : this;
 410 
 411         if (receiver.isInterface()) {
 412             // Cannot trust interfaces. Because of:
 413             // interface I { void foo(); }
 414             // class A { public void foo() {} }
 415             // class B extends A implements I { }
 416             // class C extends B { public void foo() { } }
 417             // class D extends B { }
 418             // Would lead to identify C.foo() as the unique concrete method for I.foo() without
 419             // seeing A.foo().
 420             return null;
 421         }
 422         assert !receiver.isLinked() || isInVirtualMethodTable(receiver);
 423         if (this.isDefault()) {
 424             // CHA for default methods doesn't work and may crash the VM
 425             return null;
 426         }
 427         return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this);
 428     }
 429 
 430     @Override
 431     public HotSpotSignature getSignature() {
 432         return signature;
 433     }
 434 
 435     /**
 436      * Gets the value of {@code Method::_code}.
 437      *
 438      * @return the value of {@code Method::_code}
 439      */
 440     private long getCompiledCode() {
 441         HotSpotVMConfig config = config();
 442         return UNSAFE.getAddress(getMetaspaceMethod() + config.methodCodeOffset);


 493     @Override
 494     public void reprofile() {
 495         compilerToVM().reprofile(this);
 496     }
 497 
 498     @Override
 499     public ConstantPool getConstantPool() {
 500         return constantPool;
 501     }
 502 
 503     @Override
 504     public Parameter[] getParameters() {
 505         if (signature.getParameterCount(false) == 0) {
 506             return new ResolvedJavaMethod.Parameter[0];
 507         }
 508         return runtime().reflection.getParameters(this);
 509     }
 510 
 511     @Override
 512     public Annotation[][] getParameterAnnotations() {
 513         if ((getConstMethodFlags() & config().constMethodHasParameterAnnotations) == 0 || isClassInitializer()) {
 514             return new Annotation[signature.getParameterCount(false)][0];
 515         }
 516         return runtime().reflection.getParameterAnnotations(this);
 517     }
 518 
 519     @Override
 520     public Annotation[] getAnnotations() {
 521         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) {
 522             return new Annotation[0];
 523         }
 524         return runtime().reflection.getMethodAnnotations(this);
 525     }
 526 
 527     @Override
 528     public Annotation[] getDeclaredAnnotations() {
 529         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) {
 530             return new Annotation[0];
 531         }
 532         return runtime().reflection.getMethodDeclaredAnnotations(this);
 533     }
 534 
 535     @Override
 536     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 537         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0 || isClassInitializer()) {
 538             return null;
 539         }
 540         return runtime().reflection.getMethodAnnotation(this, annotationClass);
 541     }
 542 
 543     @Override
 544     public boolean isBridge() {
 545         return (BRIDGE & getModifiers()) != 0;
 546     }
 547 
 548     @Override
 549     public boolean isSynthetic() {
 550         return (SYNTHETIC & getModifiers()) != 0;
 551     }
 552 
 553     @Override
 554     public boolean isVarArgs() {
 555         return (VARARGS & getModifiers()) != 0;
 556     }
 557 




 224     @Override
 225     public Constant getEncoding() {
 226         return getMetaspaceMethodConstant();
 227     }
 228 
 229     /**
 230      * Gets the complete set of modifiers for this method which includes the JVM specification
 231      * modifiers as well as the HotSpot internal modifiers.
 232      */
 233     public int getAllModifiers() {
 234         return UNSAFE.getInt(getMetaspaceMethod() + config().methodAccessFlagsOffset);
 235     }
 236 
 237     @Override
 238     public int getModifiers() {
 239         return getAllModifiers() & jvmMethodModifiers();
 240     }
 241 
 242     @Override
 243     public boolean canBeStaticallyBound() {
 244         return (isFinal() || isPrivate() || isStatic() || holder.isLeaf()) && isConcrete();
 245     }
 246 
 247     @Override
 248     public byte[] getCode() {
 249         if (getCodeSize() == 0) {
 250             return null;
 251         }
 252         if (code == null && holder.isLinked()) {
 253             code = compilerToVM().getBytecode(this);
 254             assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length;
 255         }
 256         return code;
 257     }
 258 
 259     @Override
 260     public int getCodeSize() {
 261         return UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset);
 262     }
 263 
 264     @Override


 389     public int getMaxStackSize() {
 390         if (isAbstract() || isNative()) {
 391             return 0;
 392         }
 393         HotSpotVMConfig config = config();
 394         return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset);
 395     }
 396 
 397     @Override
 398     public StackTraceElement asStackTraceElement(int bci) {
 399         if (bci < 0 || bci >= getCodeSize()) {
 400             // HotSpot code can only construct stack trace elements for valid bcis
 401             StackTraceElement ste = compilerToVM().getStackTraceElement(this, 0);
 402             return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1);
 403         }
 404         return compilerToVM().getStackTraceElement(this, bci);
 405     }
 406 
 407     @Override
 408     public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) {


 409         if (receiver.isInterface()) {
 410             // Cannot trust interfaces. Because of:
 411             // interface I { void foo(); }
 412             // class A { public void foo() {} }
 413             // class B extends A implements I { }
 414             // class C extends B { public void foo() { } }
 415             // class D extends B { }
 416             // Would lead to identify C.foo() as the unique concrete method for I.foo() without
 417             // seeing A.foo().
 418             return null;
 419         }

 420         if (this.isDefault()) {
 421             // CHA for default methods doesn't work and may crash the VM
 422             return null;
 423         }
 424         return compilerToVM().findUniqueConcreteMethod(((HotSpotResolvedObjectTypeImpl) receiver), this);
 425     }
 426 
 427     @Override
 428     public HotSpotSignature getSignature() {
 429         return signature;
 430     }
 431 
 432     /**
 433      * Gets the value of {@code Method::_code}.
 434      *
 435      * @return the value of {@code Method::_code}
 436      */
 437     private long getCompiledCode() {
 438         HotSpotVMConfig config = config();
 439         return UNSAFE.getAddress(getMetaspaceMethod() + config.methodCodeOffset);


 490     @Override
 491     public void reprofile() {
 492         compilerToVM().reprofile(this);
 493     }
 494 
 495     @Override
 496     public ConstantPool getConstantPool() {
 497         return constantPool;
 498     }
 499 
 500     @Override
 501     public Parameter[] getParameters() {
 502         if (signature.getParameterCount(false) == 0) {
 503             return new ResolvedJavaMethod.Parameter[0];
 504         }
 505         return runtime().reflection.getParameters(this);
 506     }
 507 
 508     @Override
 509     public Annotation[][] getParameterAnnotations() {
 510         if ((getConstMethodFlags() & config().constMethodHasParameterAnnotations) == 0) {
 511             return new Annotation[signature.getParameterCount(false)][0];
 512         }
 513         return runtime().reflection.getParameterAnnotations(this);
 514     }
 515 
 516     @Override
 517     public Annotation[] getAnnotations() {
 518         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) {
 519             return new Annotation[0];
 520         }
 521         return runtime().reflection.getMethodAnnotations(this);
 522     }
 523 
 524     @Override
 525     public Annotation[] getDeclaredAnnotations() {
 526         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) {
 527             return new Annotation[0];
 528         }
 529         return runtime().reflection.getMethodDeclaredAnnotations(this);
 530     }
 531 
 532     @Override
 533     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 534         if ((getConstMethodFlags() & config().constMethodHasMethodAnnotations) == 0) {
 535             return null;
 536         }
 537         return runtime().reflection.getMethodAnnotation(this, annotationClass);
 538     }
 539 
 540     @Override
 541     public boolean isBridge() {
 542         return (BRIDGE & getModifiers()) != 0;
 543     }
 544 
 545     @Override
 546     public boolean isSynthetic() {
 547         return (SYNTHETIC & getModifiers()) != 0;
 548     }
 549 
 550     @Override
 551     public boolean isVarArgs() {
 552         return (VARARGS & getModifiers()) != 0;
 553     }
 554 


< prev index next >