-
Notifications
You must be signed in to change notification settings - Fork 746
/
Copy pathJ9Optimizer.cpp
1041 lines (974 loc) · 67.1 KB
/
J9Optimizer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 2000
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#if defined(J9ZOS390)
//On zOS XLC linker can't handle files with same name at link time
//This workaround with pragma is needed. What this does is essentially
//give a different name to the codesection (csect) for this file. So it
//doesn't conflict with another file with same name.
#pragma csect(CODE,"J9Optimizer#C")
#pragma csect(STATIC,"J9Optimizer#S")
#pragma csect(TEST,"J9Optimizer#T")
#endif
#include "optimizer/Optimizer.hpp"
#include <stddef.h>
#include <stdint.h>
#include "compile/Compilation.hpp"
#include "compile/Method.hpp"
#include "control/Options.hpp"
#include "control/Options_inlines.hpp"
#include "control/Recompilation.hpp"
#include "control/RecompilationInfo.hpp"
#include "il/ResolvedMethodSymbol.hpp"
#include "optimizer/AllocationSinking.hpp"
#include "optimizer/IdiomRecognition.hpp"
#include "optimizer/Inliner.hpp"
#include "optimizer/J9Inliner.hpp"
#include "optimizer/JitProfiler.hpp"
#include "optimizer/LiveVariablesForGC.hpp"
#include "optimizer/OptimizationManager.hpp"
#include "optimizer/OptimizationStrategies.hpp"
#include "optimizer/Optimizations.hpp"
#include "optimizer/PartialRedundancy.hpp"
#include "optimizer/ProfileGenerator.hpp"
#include "optimizer/SequentialStoreSimplifier.hpp"
#include "optimizer/SignExtendLoads.hpp"
#include "optimizer/StringBuilderTransformer.hpp"
#include "optimizer/SwitchAnalyzer.hpp"
#include "optimizer/DynamicLiteralPool.hpp"
#include "optimizer/EscapeAnalysis.hpp"
#include "optimizer/PreEscapeAnalysis.hpp"
#include "optimizer/PostEscapeAnalysis.hpp"
#include "optimizer/DataAccessAccelerator.hpp"
#include "optimizer/HotFieldMarking.hpp"
#include "optimizer/IsolatedStoreElimination.hpp"
#include "optimizer/LoopAliasRefiner.hpp"
#include "optimizer/MonitorElimination.hpp"
#include "optimizer/NewInitialization.hpp"
#include "optimizer/SinkStores.hpp"
#include "optimizer/SPMDParallelizer.hpp"
#include "optimizer/StringPeepholes.hpp"
#include "optimizer/StripMiner.hpp"
#include "optimizer/ValuePropagation.hpp"
#include "optimizer/TrivialDeadBlockRemover.hpp"
#include "optimizer/OSRGuardInsertion.hpp"
#include "optimizer/OSRGuardRemoval.hpp"
#include "optimizer/JProfilingBlock.hpp"
#include "optimizer/JProfilingValue.hpp"
#include "optimizer/JProfilingRecompLoopTest.hpp"
#include "runtime/J9Profiler.hpp"
#include "optimizer/UnsafeFastPath.hpp"
#include "optimizer/TreeLowering.hpp"
#include "optimizer/VarHandleTransformer.hpp"
#include "optimizer/StaticFinalFieldFolding.hpp"
#include "optimizer/HandleRecompilationOps.hpp"
#include "optimizer/MethodHandleTransformer.hpp"
#include "optimizer/VectorAPIExpansion.hpp"
#include "optimizer/CatchBlockProfiler.hpp"
static const OptimizationStrategy J9EarlyGlobalOpts[] =
{
{ OMR::stringBuilderTransformer },
{ OMR::stringPeepholes }, // need stringpeepholes to catch bigdecimal patterns
{ OMR::inlining },
{ OMR::methodHandleInvokeInliningGroup, OMR::IfEnabled },
{ OMR::staticFinalFieldFolding, },
{ OMR::osrGuardInsertion, OMR::MustBeDone },
{ OMR::osrExceptionEdgeRemoval }, // most inlining is done by now
{ OMR::jProfilingBlock },
{ OMR::stringBuilderTransformer },
{ OMR::stringPeepholes, },
//{ basicBlockOrdering, IfLoops }, // early ordering with no extension
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::compactNullChecks }, // cleans up after inlining; MUST be done before PRE
{ OMR::virtualGuardTailSplitter }, // merge virtual guards
{ OMR::treeSimplification },
{ OMR::CFGSimplification },
{ OMR::endGroup }
};
static const OptimizationStrategy J9EarlyLocalOpts[] =
{
{ OMR::localValuePropagation },
//{ localValuePropagationGroup },
{ OMR::localReordering },
{ OMR::switchAnalyzer },
{ OMR::treeSimplification, OMR::IfEnabled }, // simplify any exprs created by LCP/LCSE
{ OMR::catchBlockRemoval }, // if all possible exceptions in a try were removed by inlining/LCP/LCSE
{ OMR::deadTreesElimination }, // remove any anchored dead loads
{ OMR::profiledNodeVersioning },
{ OMR::endGroup }
};
static const OptimizationStrategy signExtendLoadsOpts[] =
{
{ OMR::signExtendLoads },
{ OMR::endGroup }
};
// **************************************************************************
//
// Strategy that is used by full speed debug for methods that do share slots (the old FSD strategy before OSR)
//
// **************************************************************************
static const OptimizationStrategy fsdStrategyOptsForMethodsWithSlotSharing[] =
{
{ OMR::trivialInlining, OMR::IfNotFullInliningUnderOSRDebug }, //added for fsd inlining
{ OMR::inlining, OMR::IfFullInliningUnderOSRDebug }, //added for fsd inlining
{ OMR::basicBlockExtension },
{ OMR::treeSimplification }, //added for fsd inlining
{ OMR::localCSE },
{ OMR::treeSimplification },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup }, // added for fsd gra
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalLiveVariablesForGC },
{ OMR::regDepCopyRemoval },
{ OMR::endOpts },
};
// **************************************************************************
//
// Strategy that is used by full speed debug for methods that do not share slots
//
// **************************************************************************
static const OptimizationStrategy fsdStrategyOptsForMethodsWithoutSlotSharing[] =
{
{ OMR::coldBlockOutlining },
{ OMR::trivialInlining, OMR::IfNotFullInliningUnderOSRDebug }, //added for fsd inlining
{ OMR::inlining, OMR::IfFullInliningUnderOSRDebug }, //added for fsd inlining
{ OMR::virtualGuardTailSplitter }, // merge virtual guards
{ OMR::treeSimplification },
{ OMR::CFGSimplification, OMR::IfOptServer }, // for WAS trace folding
{ OMR::treeSimplification, OMR::IfOptServer }, // for WAS trace folding
{ OMR::localCSE, OMR::IfEnabledAndOptServer }, // for WAS trace folding
{ OMR::treeSimplification, OMR::IfEnabledAndOptServer }, // for WAS trace folding
{ OMR::globalValuePropagation, },
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::cheapObjectAllocationGroup, },
{ OMR::globalValuePropagation, OMR::IfEnabled }, // if inlined a call or an object
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::catchBlockRemoval, OMR::IfEnabled }, // if checks were removed
{ OMR::globalValuePropagation, OMR::IfEnabledMarkLastRun}, // mark monitors requiring sync
{ OMR::virtualGuardTailSplitter, OMR::IfEnabled }, // merge virtual guards
{ OMR::CFGSimplification },
{ OMR::globalCopyPropagation, },
{ OMR::lastLoopVersionerGroup, OMR::IfLoops },
{ OMR::globalDeadStoreElimination, OMR::IfLoops },
{ OMR::deadTreesElimination, },
{ OMR::basicBlockOrdering, OMR::IfLoops }, // required for loop reduction
{ OMR::treeSimplification },
{ OMR::loopReduction },
{ OMR::blockShuffling }, // to stress idiom recognition
{ OMR::idiomRecognition, OMR::IfLoops },
{ OMR::blockSplitter },
{ OMR::treeSimplification },
{ OMR::inductionVariableAnalysis, OMR::IfLoopsAndNotProfiling },
{ OMR::generalLoopUnroller, OMR::IfLoopsAndNotProfiling },
{ OMR::samplingJProfiling },
{ OMR::basicBlockExtension, OMR::MarkLastRun }, // extend blocks; move trees around if reqd
{ OMR::treeSimplification }, // revisit; not really required ?
{ OMR::localValuePropagationGroup, },
{ OMR::arraycopyTransformation },
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::localDeadStoreElimination, }, // after latest copy propagation
{ OMR::deadTreesElimination, }, // remove dead anchors created by check/store removal
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::localCSE },
{ OMR::treeSimplification, OMR::MarkLastRun },
{ OMR::andSimplification, }, //clean up after versioner
{ OMR::compactNullChecks, }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::treesCleansing, OMR::IfEnabled },
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::localCSE, OMR::IfEnabled }, // common up expressions for sunk stores
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // cleanup the trees after sunk store and localCSE
{ OMR::dynamicLiteralPool, },
{ OMR::localDeadStoreElimination, OMR::IfEnabled }, //remove the astore if no literal pool is required
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // Simplify non-normalized address computations introduced by prefetch insertion
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled }, // final cleanup before opcode expansion
{ OMR::globalDeadStoreElimination, },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalDeadStoreGroup, },
{ OMR::rematerialization, },
{ OMR::compactNullChecks, }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead anchors created by check/store removal
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead RegStores produced by previous deadTrees pass
{ OMR::globalLiveVariablesForGC },
{ OMR::regDepCopyRemoval },
{ OMR::endOpts },
};
static const OptimizationStrategy *fsdStrategies[] =
{
fsdStrategyOptsForMethodsWithSlotSharing,
fsdStrategyOptsForMethodsWithoutSlotSharing
};
// **********************************************************
//
// NO-OPT STRATEGY
//
// **********************************************************
static const OptimizationStrategy noOptStrategyOpts[] =
{
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled },
{ OMR::treeSimplification },
{ OMR::recompilationModifier, OMR::IfEnabled },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalLiveVariablesForGC, OMR::IfAggressiveLiveness },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for cold methods. This is an early compile for methods known to have
// loops so it should have a light optimization load.
//
// ***************************************************************************
static const OptimizationStrategy coldStrategyOpts[] =
{
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled },
{ OMR::coldBlockOutlining },
{ OMR::stringBuilderTransformer, OMR::IfNotQuickStart },
{ OMR::stringPeepholes, OMR::IfNotQuickStart }, // need stringpeepholes to catch bigdecimal patterns
{ OMR::trivialInlining },
{ OMR::jProfilingBlock },
{ OMR::virtualGuardTailSplitter },
{ OMR::recompilationModifier, OMR::IfEnabled },
{ OMR::samplingJProfiling },
{ OMR::treeSimplification }, // cleanup before basicBlockExtension
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::basicBlockExtension },
{ OMR::localValuePropagationGroup },
{ OMR::deadTreesElimination },
{ OMR::localCSE, OMR::IfEnabled },
{ OMR::treeSimplification },
{ OMR::arraycopyTransformation },
{ OMR::sequentialLoadAndStoreColdGroup, OMR::IfEnabled }, // disabled by default, enabled by -Xjit:enableSequentialLoadStoreCold
{ OMR::localCSE, OMR::IfEnabled },
{ OMR::treeSimplification, },
{ OMR::localDeadStoreElimination, OMR::IfEnabled },
{ OMR::deadTreesElimination, OMR::IfEnabled },
{ OMR::localCSE, OMR::IfEnabled },
{ OMR::treeSimplification },
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::localCSE, OMR::IfEnabled },
{ OMR::treeSimplification, OMR::MarkLastRun },
{ OMR::rematerialization },
{ OMR::compactNullChecks, OMR::IfEnabled },
{ OMR::signExtendLoadsGroup, OMR::IfEnabled },
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
{ OMR::trivialDeadTreeRemoval, },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfAOTAndEnabled },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalLiveVariablesForGC, OMR::IfAggressiveLiveness },
{ OMR::jitProfilingGroup, OMR::IfJitProfiling },
{ OMR::catchBlockProfiler, OMR::IfExceptionHandlers },
{ OMR::regDepCopyRemoval },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for warm methods.
//
// ***************************************************************************
//
static const OptimizationStrategy warmStrategyOpts[] =
{
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled },
{ OMR::coldBlockOutlining },
{ OMR::stringBuilderTransformer },
{ OMR::stringPeepholes }, // need stringpeepholes to catch bigdecimal patterns
{ OMR::inlining },
{ OMR::methodHandleInvokeInliningGroup, OMR::IfEnabled },
{ OMR::staticFinalFieldFolding, },
{ OMR::osrGuardInsertion, OMR::MustBeDone },
{ OMR::osrExceptionEdgeRemoval }, // most inlining is done by now
{ OMR::jProfilingBlock },
{ OMR::virtualGuardTailSplitter }, // merge virtual guards
{ OMR::treeSimplification },
#ifdef TR_HOST_S390
{ OMR::sequentialLoadAndStoreWarmGroup, OMR::IfEnabled },
#endif
{ OMR::cheapGlobalValuePropagationGroup },
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::dataAccessAccelerator },
#ifdef TR_HOST_S390
{ OMR::globalCopyPropagation, OMR::IfVoluntaryOSR },
#endif
{ OMR::lastLoopVersionerGroup, OMR::IfLoopsAndNotCompileTimeSensitive},
#ifdef TR_HOST_S390
{ OMR::globalDeadStoreElimination, OMR::IfEnabledAndLoops },
{ OMR::deadTreesElimination },
{ OMR::recompilationModifier, OMR::IfEnabledAndNotProfiling },
{ OMR::localReordering, OMR::IfNoLoopsOREnabledAndLoops },
{ OMR::basicBlockOrdering, OMR::IfLoops },
{ OMR::treeSimplification },
{ OMR::loopReduction },
{ OMR::blockShuffling },
#endif
{ OMR::localCSE, OMR::IfLoopsAndNotProfiling },
{ OMR::idiomRecognition, OMR::IfLoopsAndNotProfiling },
{ OMR::treeSimplification },
{ OMR::redundantGotoElimination, OMR::IfEnabledAndNotJitProfiling },
{ OMR::blockSplitter },
{ OMR::treeSimplification }, // revisit; not really required ?
{ OMR::virtualGuardHeadMerger },
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::basicBlockExtension, OMR::MarkLastRun }, // extend blocks; move trees around if reqd
{ OMR::localValuePropagationGroup },
{ OMR::explicitNewInitialization, OMR::IfNews },
{ OMR::arraycopyTransformation },
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::asyncCheckInsertion, OMR::IfNotJitProfiling },
{ OMR::localCSE },
{ OMR::treeSimplification, OMR::MarkLastRun },
{ OMR::andSimplification, OMR::IfEnabled }, //clean up after versioner
{ OMR::compactNullChecks }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::globalCopyPropagation, OMR::IfMethodHandleInvokes }, // Does a lot of good after methodHandleInvokeInliningGroup
{ OMR::treesCleansing, OMR::IfEnabled },
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::localCSE, OMR::IfEnabled }, // common up expressions for sunk stores
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // cleanup the trees after sunk store and localCSE
/** \breif
* This optimization is performance critical on z Systems. On z Systems a literal pool register is blocked off
* by default at the start of the compilation since materializing this address could be expensive depending on
* the architecture level we are executing on. This optimization pass validates support for dynamically
* materializing the literal pool address and frees up the literal pool register for register allocation.
*/
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::samplingJProfiling },
{ OMR::trivialBlockExtension },
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // Simplify non-normalized address computations introduced by prefetch insertion
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled }, // final cleanup before opcode expansion
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalDeadStoreGroup, },
{ OMR::compactNullChecks, OMR::IfEnabled }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead anchors created by check/store removal
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead RegStores produced by previous deadTrees pass
{ OMR::redundantGotoElimination, OMR::IfEnabledAndNotJitProfiling }, // dead store and dead tree elimination may have left empty blocks
{ OMR::compactLocals, OMR::IfNotJitProfiling }, // analysis results are invalidated by jitProfilingGroup
{ OMR::globalLiveVariablesForGC },
{ OMR::jitProfilingGroup, OMR::IfJitProfiling },
{ OMR::catchBlockProfiler, OMR::IfExceptionHandlers },
{ OMR::regDepCopyRemoval },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for warm methods. An initial number of invocations of the method
// have already happened, but this is the first compile of the method.
//
// ***************************************************************************
//
static const OptimizationStrategy oldWarmStrategyOpts[] =
{
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled},
{ OMR::coldBlockOutlining },
{ OMR::stringBuilderTransformer },
{ OMR::stringPeepholes }, // need stringpeepholes to catch bigdecimal patterns
{ OMR::inlining },
{ OMR::methodHandleInvokeInliningGroup, OMR::IfEnabled },
{ OMR::staticFinalFieldFolding, },
{ OMR::osrGuardInsertion, OMR::MustBeDone },
{ OMR::osrExceptionEdgeRemoval }, // most inlining is done by now
{ OMR::jProfilingBlock },
{ OMR::virtualGuardTailSplitter }, // merge virtual guards
{ OMR::treeSimplification },
{ OMR::sequentialLoadAndStoreWarmGroup, OMR::IfEnabled }, // disabled by default, enabled by -Xjit:enableSequentialLoadStoreWarm
{ OMR::cheapGlobalValuePropagationGroup },
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::dataAccessAccelerator }, // globalValuePropagation and inlining might expose opportunities for dataAccessAccelerator
{ OMR::globalCopyPropagation, OMR::IfVoluntaryOSR },
{ OMR::lastLoopVersionerGroup, OMR::IfLoops },
{ OMR::globalDeadStoreElimination, OMR::IfEnabledAndLoops },
{ OMR::deadTreesElimination },
{ OMR::recompilationModifier, OMR::IfEnabledAndNotProfiling },
{ OMR::localReordering, OMR::IfNoLoopsOREnabledAndLoops }, // if required or if not done earlier
{ OMR::basicBlockOrdering, OMR::IfLoops }, // required for loop reduction
{ OMR::treeSimplification },
{ OMR::loopReduction },
{ OMR::blockShuffling }, // to stress idiom recognition
{ OMR::idiomRecognition, OMR::IfLoopsAndNotProfiling },
{ OMR::blockSplitter },
{ OMR::treeSimplification },
{ OMR::inductionVariableAnalysis, OMR::IfLoopsAndNotProfiling },
{ OMR::generalLoopUnroller, OMR::IfLoopsAndNotProfiling },
{ OMR::virtualGuardHeadMerger },
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::basicBlockExtension, OMR::MarkLastRun }, // extend blocks; move trees around if reqd
{ OMR::treeSimplification }, // revisit; not really required ?
{ OMR::localValuePropagationGroup },
{ OMR::arraycopyTransformation },
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::redundantAsyncCheckRemoval, OMR::IfNotJitProfiling },
{ OMR::localDeadStoreElimination }, // after latest copy propagation
{ OMR::deadTreesElimination }, // remove dead anchors created by check/store removal
{ OMR::treeSimplification, OMR::IfEnabled },
{ OMR::localCSE },
{ OMR::treeSimplification, OMR::MarkLastRun },
{ OMR::andSimplification, OMR::IfEnabled }, //clean up after versioner
{ OMR::compactNullChecks }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::globalCopyPropagation, OMR::IfMethodHandleInvokes }, // Does a lot of good after methodHandleInvokeInliningGroup
{ OMR::generalStoreSinking },
{ OMR::treesCleansing, OMR::IfEnabled },
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::localCSE, OMR::IfEnabled }, // common up expressions for sunk stores
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // cleanup the trees after sunk store and localCSE
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::samplingJProfiling },
{ OMR::trivialBlockExtension },
{ OMR::localDeadStoreElimination, OMR::IfEnabled }, //remove the astore if no literal pool is required
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::signExtendLoadsGroup, OMR::IfEnabled }, // last opt before GRA
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // Simplify non-normalized address computations introduced by prefetch insertion
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled }, // final cleanup before opcode expansion
{ OMR::globalDeadStoreElimination, OMR::IfVoluntaryOSR },
{ OMR::arraysetStoreElimination },
{ OMR::checkcastAndProfiledGuardCoalescer },
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalDeadStoreGroup, },
{ OMR::rematerialization },
{ OMR::compactNullChecks, OMR::IfEnabled }, // cleanup at the end
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead anchors created by check/store removal
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead RegStores produced by previous deadTrees pass
{ OMR::compactLocals, OMR::IfNotJitProfiling }, // analysis results are invalidated by jitProfilingGroup
{ OMR::globalLiveVariablesForGC },
{ OMR::jitProfilingGroup, OMR::IfJitProfiling },
{ OMR::catchBlockProfiler, OMR::IfExceptionHandlers },
{ OMR::regDepCopyRemoval },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
};
// ***************************************************************************
// A (possibly temporary) strategy for partially optimizing W-Code
// ***************************************************************************
//
static const OptimizationStrategy reducedWarmStrategyOpts[] =
{
{ OMR::inlining },
{ OMR::staticFinalFieldFolding, },
{ OMR::osrGuardInsertion, OMR::MustBeDone },
{ OMR::osrExceptionEdgeRemoval }, // most inlining is done by now
{ OMR::jProfilingBlock },
{ OMR::dataAccessAccelerator }, // immediate does unconditional dataAccessAccelerator after inlining
{ OMR::treeSimplification },
{ OMR::deadTreesElimination },
{ OMR::treeSimplification },
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::basicBlockExtension }, // extend blocks; move trees around if reqd
{ OMR::treeSimplification }, // revisit; not really required ?
{ OMR::localCSE },
{ OMR::treeSimplification, OMR::MarkLastRun },
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for hot methods. The method has been compiled before and sampling
// has discovered that it is hot.
//
// ***************************************************************************
const OptimizationStrategy hotStrategyOpts[] =
{
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled },
{ OMR::coldBlockOutlining },
{ OMR::earlyGlobalGroup },
{ OMR::earlyLocalGroup },
{ OMR::stripMiningGroup, OMR::IfLoops }, // strip mining in loops
{ OMR::loopReplicator, OMR::IfLoops }, // tail-duplication in loops
{ OMR::expensiveGlobalValuePropagationGroup },
{ OMR::redundantGotoElimination, OMR::IfEnabledAndNotJitProfiling },
{ OMR::blockSplitter, OMR::IfNews }, // treeSimplification + blockSplitter + VP => opportunity for EA
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::loopCanonicalization, OMR::IfVectorAPI },
{ OMR::partialRedundancyEliminationGroup, OMR::IfVectorAPI },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::dataAccessAccelerator },
{ OMR::osrGuardRemoval, OMR::IfEnabled }, // run after calls/monents/asyncchecks have been removed
{ OMR::globalDeadStoreGroup, },
{ OMR::idiomRecognition, OMR::IfLoopsAndNotProfiling }, // Early pass of idiomRecognition - Loop Canonicalizer transformations break certain idioms (i.e. arrayTranslateAndTest)
{ OMR::globalCopyPropagation, OMR::IfNoLoops },
{ OMR::loopCanonicalizationGroup, OMR::IfLoops }, // canonicalize loops (improve fall throughs)
{ OMR::inductionVariableAnalysis, OMR::IfLoops },
{ OMR::redundantInductionVarElimination, OMR::IfLoops },
{ OMR::loopAliasRefinerGroup, OMR::IfLoops },
{ OMR::recompilationModifier, OMR::IfEnabledAndNotProfiling },
{ OMR::partialRedundancyEliminationGroup },
{ OMR::globalDeadStoreElimination, OMR::IfLoopsAndNotProfiling },
{ OMR::inductionVariableAnalysis, OMR::IfLoopsAndNotProfiling },
{ OMR::loopSpecializerGroup, OMR::IfLoopsAndNotProfiling },
{ OMR::inductionVariableAnalysis, OMR::IfLoopsAndNotProfiling },
{ OMR::generalLoopUnroller, OMR::IfLoopsAndNotProfiling }, // unroll Loops
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::blockManipulationGroup },
{ OMR::lateLocalGroup },
{ OMR::sequentialStoreSimplificationGroup, }, // reduce sequential stores into an arrayset
{ OMR::redundantAsyncCheckRemoval, OMR::IfNotJitProfiling }, // optimize async check placement
{ OMR::recompilationModifier, OMR::IfProfiling }, // do before GRA to avoid commoning of longs afterwards
{ OMR::globalCopyPropagation, OMR::IfMoreThanOneBlock }, // Can produce opportunities for store sinking
{ OMR::generalStoreSinking },
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::treeSimplification, OMR::IfEnabled }, // cleanup the trees after sunk store and localCSE
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::trivialBlockExtension },
{ OMR::localDeadStoreElimination, OMR::IfEnabled }, //remove the astore if no literal pool is required
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
{ OMR::signExtendLoadsGroup, OMR::IfEnabled }, // last opt before GRA
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled }, // final cleanup before opcode expansion
{ OMR::arraysetStoreElimination },
{ OMR::localValuePropagation, OMR::MarkLastRun },
{ OMR::arraycopyTransformation },
{ OMR::checkcastAndProfiledGuardCoalescer },
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
{ OMR::tacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalDeadStoreElimination, OMR::IfMoreThanOneBlock }, // global dead store removal
{ OMR::deadTreesElimination }, // cleanup after dead store removal
{ OMR::compactNullChecks }, // cleanup at the end
{ OMR::finalGlobalGroup }, // done just before codegen
{ OMR::jitProfilingGroup, OMR::IfJitProfiling },
{ OMR::catchBlockProfiler, OMR::IfExceptionHandlers },
{ OMR::regDepCopyRemoval },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for very hot methods. This is not currently used, same as hot.
//
// ***************************************************************************
const OptimizationStrategy veryHotStrategyOpts[] =
{
{ OMR::hotStrategy },
{ OMR::endOpts }
};
// ***************************************************************************
//
// Strategy for scorching hot methods. This is the last time the method will
// be compiled, so throw everything (within reason) at it.
//
// ***************************************************************************
const OptimizationStrategy scorchingStrategyOpts[] =
{
#if 0
{ OMR::hotStrategy },
{ OMR::endOpts }
#else
{ OMR::coldBlockOutlining },
{ OMR::earlyGlobalGroup },
{ OMR::earlyLocalGroup },
{ OMR::andSimplification }, // needs commoning across blocks to work well; must be done after versioning
{ OMR::stripMiningGroup, OMR::IfLoops }, // strip mining in loops
{ OMR::loopReplicator, OMR::IfLoops }, // tail-duplication in loops
{ OMR::blockSplitter, OMR::IfNews }, // treeSimplification + blockSplitter + VP => opportunity for EA
{ OMR::arrayPrivatizationGroup, OMR::IfNews }, // must precede escape analysis
{ OMR::veryExpensiveGlobalValuePropagationGroup },
{ OMR::dataAccessAccelerator }, //always run after GVP
{ OMR::osrGuardRemoval, OMR::IfEnabled }, // run after calls/monents/asyncchecks have been removed
{ OMR::globalDeadStoreGroup, },
{ OMR::idiomRecognition, OMR::IfLoopsAndNotProfiling }, // Early pass of idiomRecognition - Loop Canonicalizer transformations break certain idioms (i.e. arrayTranslateAndTest)
{ OMR::globalCopyPropagation, OMR::IfNoLoops },
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::loopCanonicalization, OMR::IfVectorAPI },
{ OMR::partialRedundancyEliminationGroup, OMR::IfVectorAPI },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::loopCanonicalizationGroup, OMR::IfLoops }, // canonicalize loops (improve fall throughs)
{ OMR::inductionVariableAnalysis, OMR::IfLoops },
{ OMR::redundantInductionVarElimination, OMR::IfLoops },
{ OMR::loopAliasRefinerGroup, OMR::IfLoops }, // version loops to improve aliasing (after versioned to reduce code growth)
{ OMR::expressionsSimplification, OMR::IfLoops },
{ OMR::recompilationModifier, OMR::IfEnabled },
{ OMR::partialRedundancyEliminationGroup },
{ OMR::globalDeadStoreElimination, OMR::IfLoops },
{ OMR::inductionVariableAnalysis, OMR::IfLoops },
{ OMR::loopSpecializerGroup, OMR::IfLoops },
{ OMR::inductionVariableAnalysis, OMR::IfLoops },
{ OMR::generalLoopUnroller, OMR::IfLoops }, // unroll Loops
{ OMR::blockSplitter, OMR::MarkLastRun },
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
{ OMR::recognizedCallTransformer, OMR::MarkLastRun },
#endif
{ OMR::blockManipulationGroup },
{ OMR::lateLocalGroup },
{ OMR::sequentialStoreSimplificationGroup }, // reduce sequential stores into an arrayset
{ OMR::redundantAsyncCheckRemoval, OMR::IfNotJitProfiling }, // optimize async check placement
{ OMR::recompilationModifier, OMR::IfProfiling }, // do before GRA to avoid commoning of longs afterwards
{ OMR::globalCopyPropagation, OMR::IfMoreThanOneBlock }, // Can produce opportunities for store sinking
{ OMR::generalStoreSinking },
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::treeSimplification, OMR::IfEnabled }, // cleanup the trees after sunk store and localCSE
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::trivialBlockExtension },
{ OMR::localDeadStoreElimination, OMR::IfEnabled }, //remove the astore if no literal pool is required
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::signExtendLoadsGroup, OMR::IfEnabled }, // last opt before GRA
{ OMR::arraysetStoreElimination },
{ OMR::localValuePropagation, OMR::MarkLastRun },
{ OMR::arraycopyTransformation },
{ OMR::checkcastAndProfiledGuardCoalescer },
{ OMR::tacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::jProfilingValue, OMR::MustBeDone },
{ OMR::treeLowering, OMR::MustBeDone },
{ OMR::globalDeadStoreElimination, OMR::IfMoreThanOneBlock }, // global dead store removal
{ OMR::deadTreesElimination }, // cleanup after dead store removal
{ OMR::compactNullChecks }, // cleanup at the end
{ OMR::finalGlobalGroup }, // done just before codegen
{ OMR::jitProfilingGroup, OMR::IfJitProfiling },
{ OMR::regDepCopyRemoval },
{ OMR::hotFieldMarking },
{ OMR::endOpts }
#endif
};
const OptimizationStrategy sequentialLoadAndStoreColdOpts[] =
{
{ OMR::localDeadStoreElimination },
{ OMR::deadTreesElimination },
{ OMR::expensiveGlobalValuePropagationGroup },
{ OMR::sequentialStoreSimplificationGroup },
{ OMR::endGroup }
};
const OptimizationStrategy sequentialLoadAndStoreWarmOpts[] =
{
{ OMR::localValuePropagationGroup },
{ OMR::localDeadStoreElimination },
{ OMR::deadTreesElimination },
{ OMR::expensiveGlobalValuePropagationGroup },
{ OMR::sequentialStoreSimplificationGroup },
{ OMR::endGroup }
};
const OptimizationStrategy sequentialStoreSimplificationOpts[] =
{
{ OMR::treeSimplification },
{ OMR::sequentialStoreSimplification },
{ OMR::treeSimplification }, // might fold expressions created by versioning/induction variables
{ OMR::endGroup }
};
// **********************************************************
//
// AHEAD-OF-TIME-COMPILATION STRATEGY
//
// **********************************************************
static const OptimizationStrategy AOTStrategyOpts[] =
{
{ OMR::earlyGlobalGroup },
{ OMR::earlyLocalGroup },
{ OMR::stripMiningGroup, OMR::IfLoops }, // strip mining in loops
{ OMR::loopReplicator, OMR::IfLoops }, // tail-duplication in loops
{ OMR::expensiveGlobalValuePropagationGroup },
{ OMR::localCSE, OMR::IfVectorAPI },
{ OMR::loopCanonicalization, OMR::IfVectorAPI },
{ OMR::partialRedundancyEliminationGroup, OMR::IfVectorAPI },
{ OMR::globalDeadStoreElimination, OMR::IfVectorAPI }, // global dead store removal
{ OMR::deadTreesElimination, OMR::IfVectorAPI }, // cleanup after dead store removal
{ OMR::vectorAPIExpansion, OMR::IfVectorAPI },
{ OMR::osrGuardRemoval, OMR::IfVectorAPI },
{ OMR::globalDeadStoreGroup, },
{ OMR::globalCopyPropagation, OMR::IfNoLoops },
{ OMR::loopCanonicalizationGroup, OMR::IfLoops }, // canonicalize loops (improve fall throughs) and versioning
{ OMR::partialRedundancyEliminationGroup },
{ OMR::globalDeadStoreElimination, OMR::IfLoops },
{ OMR::generalLoopUnroller, OMR::IfLoops }, // unroll Loops
{ OMR::blockManipulationGroup },
{ OMR::lateLocalGroup },
{ OMR::sequentialStoreSimplificationGroup }, // reduce sequential stores into an arrayset
{ OMR::redundantAsyncCheckRemoval, OMR::IfNotJitProfiling }, // optimize async check placement
{ OMR::dynamicLiteralPool, OMR::IfNotProfiling },
{ OMR::localDeadStoreElimination, OMR::IfEnabled }, //remove the astore if no literal pool is required
{ OMR::localCSE, OMR::IfEnabled }, //common up lit pool refs in the same block
{ OMR::signExtendLoadsGroup, OMR::IfEnabled }, // last opt before GRA
{ OMR::arraysetStoreElimination },
{ OMR::tacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
{ OMR::treeLowering, OMR::MustBeDone},
{ OMR::globalCopyPropagation, OMR::IfMoreThanOneBlock}, // global copy propagation
{ OMR::globalDeadStoreElimination, OMR::IfMoreThanOneBlock}, // global dead store removal
{ OMR::deadTreesElimination }, // cleanup after dead store removal
{ OMR::compactNullChecks }, // cleanup at the end
{ OMR::finalGlobalGroup }, // done just before codegen
{ OMR::regDepCopyRemoval },
{ OMR::endOpts }
};
static const OptimizationStrategy *j9CompilationStrategies[] =
{
noOptStrategyOpts,
coldStrategyOpts,
warmStrategyOpts,
hotStrategyOpts,
veryHotStrategyOpts,
scorchingStrategyOpts,
AOTStrategyOpts,
reducedWarmStrategyOpts
};
// **********************************************************
//
// Transformations that are specific to JitProfiling mode
//
// **********************************************************
static const OptimizationStrategy jitProfilingOpts[] =
{
{ OMR::profileGenerator, OMR::MustBeDone },
{ OMR::deadTreesElimination, OMR::IfEnabled },
{ OMR::endGroup }
};
static const OptimizationStrategy cheapTacticalGlobalRegisterAllocatorOpts[] =
{
{ OMR::redundantGotoElimination, OMR::IfNotJitProfiling }, // need to be run before global register allocator
{ OMR::tacticalGlobalRegisterAllocator, OMR::IfEnabled },
{ OMR::endGroup }
};
J9::Optimizer::Optimizer(TR::Compilation *comp, TR::ResolvedMethodSymbol *methodSymbol, bool isIlGen,
const OptimizationStrategy *strategy, uint16_t VNType)
: OMR::Optimizer(comp, methodSymbol, isIlGen, strategy, VNType)
{
// initialize additional J9 optimizations
_opts[OMR::inlining] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_Inliner::create, OMR::inlining);
_opts[OMR::targetedInlining] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_Inliner::create, OMR::targetedInlining);
_opts[OMR::targetedInlining]->setOptPolicy(new (comp->allocator()) TR_J9JSR292InlinerPolicy(comp));
_opts[OMR::trivialInlining] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_TrivialInliner::create, OMR::trivialInlining);
_opts[OMR::dynamicLiteralPool] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_DynamicLiteralPool::create, OMR::dynamicLiteralPool);
_opts[OMR::arraycopyTransformation] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::ArraycopyTransformation::create, OMR::arraycopyTransformation);
_opts[OMR::signExtendLoads] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_SignExtendLoads::create, OMR::signExtendLoads);
_opts[OMR::sequentialStoreSimplification] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_SequentialStoreSimplifier::create, OMR::sequentialStoreSimplification);
_opts[OMR::explicitNewInitialization] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_LocalNewInitialization::create, OMR::explicitNewInitialization);
_opts[OMR::redundantMonitorElimination] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::MonitorElimination::create, OMR::redundantMonitorElimination);
_opts[OMR::preEscapeAnalysis] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_PreEscapeAnalysis::create, OMR::preEscapeAnalysis);
_opts[OMR::escapeAnalysis] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_EscapeAnalysis::create, OMR::escapeAnalysis);
_opts[OMR::postEscapeAnalysis] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_PostEscapeAnalysis::create, OMR::postEscapeAnalysis);
_opts[OMR::isolatedStoreElimination] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_IsolatedStoreElimination::create, OMR::isolatedStoreElimination);
_opts[OMR::localLiveVariablesForGC] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_LocalLiveVariablesForGC::create, OMR::localLiveVariablesForGC);
_opts[OMR::globalLiveVariablesForGC] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_GlobalLiveVariablesForGC::create, OMR::globalLiveVariablesForGC);
_opts[OMR::recompilationModifier] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_RecompilationModifier::create, OMR::recompilationModifier);
_opts[OMR::profileGenerator] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_ProfileGenerator::create, OMR::profileGenerator);
_opts[OMR::dataAccessAccelerator] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_DataAccessAccelerator::create, OMR::dataAccessAccelerator);
_opts[OMR::stringBuilderTransformer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_StringBuilderTransformer::create, OMR::stringBuilderTransformer);
_opts[OMR::stringPeepholes] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_StringPeepholes::create, OMR::stringPeepholes);
_opts[OMR::switchAnalyzer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::SwitchAnalyzer::create, OMR::switchAnalyzer);
_opts[OMR::treeLowering] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::TreeLowering::create, OMR::treeLowering);
_opts[OMR::varHandleTransformer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_VarHandleTransformer::create, OMR::varHandleTransformer);
_opts[OMR::methodHandleTransformer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_MethodHandleTransformer::create, OMR::methodHandleTransformer);
_opts[OMR::unsafeFastPath] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_UnsafeFastPath::create, OMR::unsafeFastPath);
_opts[OMR::idiomRecognition] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_CISCTransformer::create, OMR::idiomRecognition);
_opts[OMR::loopAliasRefiner] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_LoopAliasRefiner::create, OMR::loopAliasRefiner);
_opts[OMR::allocationSinking] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_AllocationSinking::create, OMR::allocationSinking);
_opts[OMR::samplingJProfiling] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_JitProfiler::create, OMR::samplingJProfiling);
_opts[OMR::SPMDKernelParallelization] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_SPMDKernelParallelizer::create, OMR::SPMDKernelParallelization);
_opts[OMR::trivialDeadBlockRemover] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_TrivialDeadBlockRemover::create, OMR::trivialDeadBlockRemover);
_opts[OMR::osrGuardInsertion] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_OSRGuardInsertion::create, OMR::osrGuardInsertion);
_opts[OMR::osrGuardRemoval] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_OSRGuardRemoval::create, OMR::osrGuardRemoval);
_opts[OMR::jProfilingBlock] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_JProfilingBlock::create, OMR::jProfilingBlock);
_opts[OMR::jProfilingRecompLoopTest] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_JProfilingRecompLoopTest::create, OMR::jProfilingRecompLoopTest);
_opts[OMR::jProfilingValue] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_JProfilingValue::create, OMR::jProfilingValue);
_opts[OMR::staticFinalFieldFolding] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_StaticFinalFieldFolding::create, OMR::staticFinalFieldFolding);
_opts[OMR::handleRecompilationOps] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_HandleRecompilationOps::create, OMR::handleRecompilationOps);
_opts[OMR::hotFieldMarking] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_HotFieldMarking::create, OMR::hotFieldMarking);
_opts[OMR::vectorAPIExpansion] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_VectorAPIExpansion::create, OMR::vectorAPIExpansion);
_opts[OMR::catchBlockProfiler] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::CatchBlockProfiler::create, OMR::catchBlockProfiler);
// NOTE: Please add new J9 optimizations here!
// initialize additional J9 optimization groups
_opts[OMR::loopAliasRefinerGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::loopAliasRefinerGroup, loopAliasRefinerOpts);
_opts[OMR::cheapObjectAllocationGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::cheapObjectAllocationGroup, cheapObjectAllocationOpts);
_opts[OMR::expensiveObjectAllocationGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::expensiveObjectAllocationGroup, expensiveObjectAllocationOpts);
_opts[OMR::eachEscapeAnalysisPassGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::eachEscapeAnalysisPassGroup, eachEscapeAnalysisPassOpts);
_opts[OMR::cheapGlobalValuePropagationGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::cheapGlobalValuePropagationGroup, cheapGlobalValuePropagationOpts);
_opts[OMR::expensiveGlobalValuePropagationGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::expensiveGlobalValuePropagationGroup, expensiveGlobalValuePropagationOpts);
_opts[OMR::earlyGlobalGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::earlyGlobalGroup, J9EarlyGlobalOpts);
_opts[OMR::earlyLocalGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::earlyLocalGroup, J9EarlyLocalOpts);
_opts[OMR::isolatedStoreGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::isolatedStoreGroup, isolatedStoreOpts);
_opts[OMR::cheapTacticalGlobalRegisterAllocatorGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::cheapTacticalGlobalRegisterAllocatorGroup, cheapTacticalGlobalRegisterAllocatorOpts);
_opts[OMR::sequentialStoreSimplificationGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::sequentialStoreSimplificationGroup, sequentialStoreSimplificationOpts);
_opts[OMR::signExtendLoadsGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::signExtendLoadsGroup, signExtendLoadsOpts);
_opts[OMR::loopSpecializerGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::loopSpecializerGroup, loopSpecializerOpts);
_opts[OMR::jitProfilingGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::jitProfilingGroup, jitProfilingOpts);
_opts[OMR::sequentialLoadAndStoreColdGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::sequentialLoadAndStoreColdGroup, sequentialLoadAndStoreColdOpts);
_opts[OMR::sequentialLoadAndStoreWarmGroup] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::sequentialLoadAndStoreWarmGroup, sequentialLoadAndStoreWarmOpts);
_opts[OMR::noOptStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::noOptStrategy, noOptStrategyOpts);
_opts[OMR::coldStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::coldStrategy, coldStrategyOpts);
_opts[OMR::warmStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::warmStrategy, warmStrategyOpts);
_opts[OMR::hotStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::hotStrategy, hotStrategyOpts);
_opts[OMR::veryHotStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::veryHotStrategy, veryHotStrategyOpts);
_opts[OMR::scorchingStrategy] =
new (comp->allocator()) TR::OptimizationManager(self(), NULL, OMR::scorchingStrategy, scorchingStrategyOpts);
// NOTE: Please add new J9 optimization groups here!
// turn requested on for optimizations/groups
self()->setRequestOptimization(OMR::eachExpensiveGlobalValuePropagationGroup, true);
self()->setRequestOptimization(OMR::cheapTacticalGlobalRegisterAllocatorGroup, true);
self()->setRequestOptimization(OMR::tacticalGlobalRegisterAllocatorGroup, true);
self()->setRequestOptimization(OMR::tacticalGlobalRegisterAllocator, true);
if (shouldEnableSEL(comp))
self()->setRequestOptimization(OMR::signExtendLoadsGroup, true);
if (comp->getOption(TR_EnableSequentialLoadStoreWarm))
self()->setRequestOptimization(OMR::sequentialLoadAndStoreWarmGroup, true);
if (comp->getOption(TR_EnableSequentialLoadStoreCold))
self()->setRequestOptimization(OMR::sequentialLoadAndStoreColdGroup, true);
}
inline
TR::Optimizer *J9::Optimizer::self()
{
return (static_cast<TR::Optimizer *>(this));
}
OMR_InlinerPolicy *J9::Optimizer::getInlinerPolicy()
{
return new (comp()->allocator()) TR_J9InlinerPolicy(comp());
}
OMR_InlinerUtil *J9::Optimizer::getInlinerUtil()
{
return new (comp()->allocator()) TR_J9InlinerUtil(comp());
}