2424 */
2525package com .oracle .svm .hosted .code ;
2626
27+ import static com .oracle .svm .hosted .code .SubstrateCompilationDirectives .DEOPT_TARGET_METHOD ;
28+
2729import java .lang .annotation .Annotation ;
2830import java .util .ArrayList ;
2931import java .util .Arrays ;
3234import java .util .List ;
3335import java .util .Map ;
3436import java .util .Map .Entry ;
35- import java .util .Objects ;
3637import java .util .TreeMap ;
3738import java .util .concurrent .ConcurrentHashMap ;
3839import java .util .concurrent .ConcurrentMap ;
102103import com .oracle .graal .pointsto .phases .SubstrateIntrinsicGraphBuilder ;
103104import com .oracle .graal .pointsto .util .CompletionExecutor ;
104105import com .oracle .graal .pointsto .util .CompletionExecutor .DebugContextRunnable ;
106+ import com .oracle .svm .common .meta .MultiMethod ;
105107import com .oracle .svm .core .SubstrateOptions ;
106- import com .oracle .svm .core .Uninterruptible ;
107108import com .oracle .svm .core .SubstrateOptions .OptimizationLevel ;
109+ import com .oracle .svm .core .Uninterruptible ;
108110import com .oracle .svm .core .deopt .DeoptTest ;
109111import com .oracle .svm .core .deopt .Specialize ;
110112import com .oracle .svm .core .graal .code .SubstrateBackend ;
@@ -511,18 +513,19 @@ private void printMethodHistogram() {
511513 CompilationResult result = task .result ;
512514
513515 CompilationInfo ci = method .compilationInfo ;
514- if (!ci .isDeoptTarget ()) {
516+ if (!method .isDeoptTarget ()) {
515517 numberOfMethods += 1 ;
516518 sizeAllMethods += result .getTargetCodeSize ();
517519 System .out .format ("%8d; %5d; %5d; %5d; %s;" , result .getTargetCodeSize (), ci .numNodesAfterParsing , ci .numNodesBeforeCompilation , ci .numNodesAfterCompilation ,
518520 ci .isTrivialMethod ? "T" : " " );
519521
520522 int deoptMethodSize = 0 ;
521- if (ci .deoptTarget != null ) {
522- CompilationInfo dci = ci .deoptTarget .compilationInfo ;
523+ HostedMethod deoptTargetMethod = method .getMultiMethod (DEOPT_TARGET_METHOD );
524+ if (deoptTargetMethod != null ) {
525+ CompilationInfo dci = deoptTargetMethod .compilationInfo ;
523526
524527 numberOfDeopt += 1 ;
525- deoptMethodSize = compilations .get (ci . deoptTarget ).result .getTargetCodeSize ();
528+ deoptMethodSize = compilations .get (deoptTargetMethod ).result .getTargetCodeSize ();
526529 sizeDeoptMethods += deoptMethodSize ;
527530 sizeDeoptMethodsInNonDeopt += result .getTargetCodeSize ();
528531 totalNumDeoptEntryPoints += dci .numDeoptEntryPoints ;
@@ -607,7 +610,7 @@ private void parseDeoptimizationTargetMethods() {
607610 */
608611 universe .getMethods ().stream ()
609612 .filter (method -> SubstrateCompilationDirectives .singleton ().isDeoptTarget (method ))
610- .forEach (method -> ensureParsed (universe . createDeoptTarget ( method ), null , new EntryPointReason ()));
613+ .forEach (method -> ensureParsed (method . getOrCreateMultiMethod ( DEOPT_TARGET_METHOD ), null , new EntryPointReason ()));
611614
612615 /*
613616 * Deoptimization target code for deoptimization testing: all methods that are not
@@ -616,12 +619,10 @@ private void parseDeoptimizationTargetMethods() {
616619 */
617620 universe .getMethods ().stream ()
618621 .filter (method -> method .getWrapped ().isImplementationInvoked () && DeoptimizationUtils .canDeoptForTesting (universe , method , deoptimizeAll ))
619- .forEach (this ::ensureParsedForDeoptTesting );
620- }
621-
622- private void ensureParsedForDeoptTesting (HostedMethod method ) {
623- method .compilationInfo .canDeoptForTesting = true ;
624- ensureParsed (universe .createDeoptTarget (method ), null , new EntryPointReason ());
622+ .forEach (method -> {
623+ method .compilationInfo .canDeoptForTesting = true ;
624+ ensureParsed (method .getOrCreateMultiMethod (DEOPT_TARGET_METHOD ), null , new EntryPointReason ());
625+ });
625626 }
626627
627628 private static boolean checkTrivial (HostedMethod method , StructuredGraph graph ) {
@@ -643,12 +644,15 @@ protected void inlineTrivialMethods(DebugContext debug) throws InterruptedExcept
643644 try (Indent ignored = debug .logAndIndent ("==== Trivial Inlining round %d\n " , round )) {
644645
645646 executor .init ();
646- universe .getMethods ().stream ()
647- .filter (method -> method .compilationInfo .getCompilationGraph () != null )
648- .forEach (method -> executor .execute (new TrivialInlineTask (method )));
649- universe .getMethods ().stream ()
650- .map (method -> method .compilationInfo .getDeoptTargetMethod ()).filter (Objects ::nonNull )
651- .forEach (deoptTargetMethod -> executor .execute (new TrivialInlineTask (deoptTargetMethod )));
647+ universe .getMethods ().forEach (method -> {
648+ assert method .getMultiMethodKey () == MultiMethod .ORIGINAL_METHOD ;
649+ for (MultiMethod multiMethod : method .getAllMultiMethods ()) {
650+ HostedMethod hMethod = (HostedMethod ) multiMethod ;
651+ if (hMethod .compilationInfo .getCompilationGraph () != null ) {
652+ executor .execute (new TrivialInlineTask (hMethod ));
653+ }
654+ }
655+ });
652656 executor .start ();
653657 executor .complete ();
654658 executor .shutdown ();
@@ -799,7 +803,7 @@ public void scheduleEntryPoints() {
799803 ensureCompiled (impl , new EntryPointReason ());
800804 }
801805 }
802- HostedMethod deoptTargetMethod = method .compilationInfo . getDeoptTargetMethod ( );
806+ HostedMethod deoptTargetMethod = method .getMultiMethod ( DEOPT_TARGET_METHOD );
803807 if (deoptTargetMethod != null ) {
804808 ensureCompiled (deoptTargetMethod , new EntryPointReason ());
805809 }
@@ -1011,7 +1015,7 @@ protected boolean canBeUsedForInlining(Invoke invoke) {
10111015 }
10121016
10131017 private static void handleSpecialization (final HostedMethod method , CallTargetNode targetNode , HostedMethod invokeTarget , HostedMethod invokeImplementation ) {
1014- if (method .getAnnotation (Specialize .class ) != null && !method .compilationInfo . isDeoptTarget () && invokeTarget .getAnnotation (DeoptTest .class ) != null ) {
1018+ if (method .getAnnotation (Specialize .class ) != null && !method .isDeoptTarget () && invokeTarget .getAnnotation (DeoptTest .class ) != null ) {
10151019 /*
10161020 * Collect the constant arguments to a method which should be specialized.
10171021 */
@@ -1138,8 +1142,8 @@ private CompilationResult defaultCompileFunction(DebugContext debug, HostedMetho
11381142 .filter (invoke -> method .compilationInfo .isDeoptEntry (invoke .bci (), true , false ))
11391143 .count ();
11401144
1141- Suites suites = method .compilationInfo . isDeoptTarget () ? deoptTargetSuites : regularSuites ;
1142- LIRSuites lirSuites = method .compilationInfo . isDeoptTarget () ? deoptTargetLIRSuites : regularLIRSuites ;
1145+ Suites suites = method .isDeoptTarget () ? deoptTargetSuites : regularSuites ;
1146+ LIRSuites lirSuites = method .isDeoptTarget () ? deoptTargetLIRSuites : regularLIRSuites ;
11431147
11441148 CompilationResult result = backend .newCompilationResult (compilationIdentifier , method .format ("%H.%n(%p)" ));
11451149
@@ -1149,7 +1153,7 @@ private CompilationResult defaultCompileFunction(DebugContext debug, HostedMetho
11491153 }
11501154 method .compilationInfo .numNodesAfterCompilation = graph .getNodeCount ();
11511155
1152- if (method .compilationInfo . isDeoptTarget ()) {
1156+ if (method .isDeoptTarget ()) {
11531157 assert DeoptimizationUtils .verifyDeoptTarget (method , graph , result );
11541158 }
11551159 ensureCalleesCompiled (method , reason , result );
0 commit comments