-
Notifications
You must be signed in to change notification settings - Fork 751
/
Copy pathJ9TreeEvaluator.cpp
1710 lines (1487 loc) · 68.8 KB
/
J9TreeEvaluator.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 (c) 2000, 2021 IBM Corp. and others
*
* 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] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
#include "codegen/TreeEvaluator.hpp"
#include "codegen/CodeGenerator.hpp"
#include "codegen/J9WatchedInstanceFieldSnippet.hpp"
#include "codegen/J9WatchedStaticFieldSnippet.hpp"
#include "env/CompilerEnv.hpp"
#include "env/IO.hpp"
#include "env/PersistentCHTable.hpp"
#include "env/VMJ9.h"
#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "il/StaticSymbol.hpp"
#include "runtime/RuntimeAssumptions.hpp"
#include "runtime/J9Profiler.hpp"
#include "runtime/J9ValueProfiler.hpp"
#include "util_api.h"
TR::Snippet *
J9::TreeEvaluator::getFieldWatchInstanceSnippet(TR::CodeGenerator *cg, TR::Node *node, J9Method *m, UDATA loc, UDATA os)
{
return new (cg->trHeapMemory()) TR::J9WatchedInstanceFieldSnippet(cg, node, m, loc, os);
}
TR::Snippet *
J9::TreeEvaluator::getFieldWatchStaticSnippet(TR::CodeGenerator *cg, TR::Node *node, J9Method *m, UDATA loc, void *fieldAddress, J9Class *fieldClass)
{
return new (cg->trHeapMemory()) TR::J9WatchedStaticFieldSnippet(cg, node, m, loc, fieldAddress, fieldClass);
}
void
J9::TreeEvaluator::rdWrtbarHelperForFieldWatch(TR::Node *node, TR::CodeGenerator *cg, TR::Register *sideEffectRegister, TR::Register *valueReg)
{
TR_ASSERT_FATAL(J9ClassHasWatchedFields >= std::numeric_limits<uint16_t>::min() && J9ClassHasWatchedFields <= std::numeric_limits<uint16_t>::max(), "Expecting value of J9ClassHasWatchedFields to be within 16 bits. Currently it's %d(%p).", J9ClassHasWatchedFields, J9ClassHasWatchedFields);
// Populate a data snippet with the required information so we can call a VM helper to report the Field Watch event.
TR::SymbolReference *symRef = node->getSymbolReference();
J9Method *owningMethod = reinterpret_cast<J9Method *>(node->getOwningMethod());
TR::Register *dataSnippetRegister = cg->allocateRegister();
bool isWrite = node->getOpCode().isWrtBar();
bool isUnresolved = symRef->isUnresolved();
int32_t bcIndex = node->getByteCodeInfo().getByteCodeIndex();
TR::Snippet *dataSnippet = NULL;
if (symRef->getSymbol()->isStatic())
{
void *fieldAddress = isUnresolved ? reinterpret_cast<void *>(-1) : symRef->getSymbol()->getStaticSymbol()->getStaticAddress();
J9Class *fieldClass = isUnresolved ? NULL : reinterpret_cast<J9Class *>(symRef->getOwningMethod(cg->comp())->getDeclaringClassFromFieldOrStatic(cg->comp(), symRef->getCPIndex()));
dataSnippet = TR::TreeEvaluator::getFieldWatchStaticSnippet(cg, node, owningMethod, bcIndex, fieldAddress, fieldClass);
}
else
{
dataSnippet = TR::TreeEvaluator::getFieldWatchInstanceSnippet(cg, node, owningMethod, bcIndex, isUnresolved ? -1 : symRef->getOffset() - TR::Compiler->om.objectHeaderSizeInBytes());
}
cg->addSnippet(dataSnippet);
// If unresolved, then we generate instructions to populate the data snippet's fields correctly at runtime.
// Note: We also call the VM Helper routine to fill in the data snippet's fields if this is an AOT compilation.
// Once the infrastructure to support AOT during fieldwatch is enabled and functionally correct, we can remove is check.
if (isUnresolved || cg->needClassAndMethodPointerRelocations())
{
// Resolve and populate dataSnippet fields.
TR::TreeEvaluator::generateFillInDataBlockSequenceForUnresolvedField(cg, node, dataSnippet, isWrite, sideEffectRegister, dataSnippetRegister);
}
// Generate instructions to call the VM helper and report the fieldwatch event
TR::TreeEvaluator::generateTestAndReportFieldWatchInstructions(cg, node, dataSnippet, isWrite, sideEffectRegister, valueReg, dataSnippetRegister);
cg->stopUsingRegister(dataSnippetRegister);
}
TR::Register *
J9::TreeEvaluator::bwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getFirstChild());
TR::Node *sideEffectNode = node->getSecondChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::bstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::bwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getSecondChild());
TR::Node *sideEffectNode = node->getThirdChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::bstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::swrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getFirstChild());
TR::Node *sideEffectNode = node->getSecondChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::sstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::swrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getSecondChild());
TR::Node *sideEffectNode = node->getThirdChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::sstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::iwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getFirstChild());
TR::Node *sideEffectNode = node->getSecondChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::istoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::iwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getSecondChild());
TR::Node *sideEffectNode = node->getThirdChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::istoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::lwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getFirstChild());
TR::Node *sideEffectNode = node->getSecondChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::lstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::lwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *valueReg = cg->evaluate(node->getSecondChild());
TR::Node *sideEffectNode = node->getThirdChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, valueReg);
}
// Note: The reference count for valueReg's node is not decremented here because the
// store evaluator also uses it and so it will evaluate+decrement it. Thus we must skip decrementing here
// to avoid double decrementing.
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::lstoreEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::frdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Node *sideEffectNode = node->getFirstChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::floadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::frdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *sideEffectRegister = cg->evaluate(node->getFirstChild());
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
// Note: For indirect rdbar nodes, the first child (sideEffectNode) is also used by the
// load evaluator. The load evaluator will also evaluate+decrement it. In order to avoid double
// decrementing the node we skip doing it here and let the load evaluator do it.
return TR::TreeEvaluator::floadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::drdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Node *sideEffectNode = node->getFirstChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::dloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::drdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *sideEffectRegister = cg->evaluate(node->getFirstChild());
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
// Note: For indirect rdbar nodes, the first child (sideEffectNode) is also used by the
// load evaluator. The load evaluator will also evaluate+decrement it. In order to avoid double
// decrementing the node we skip doing it here and let the load evaluator do it.
return TR::TreeEvaluator::dloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::brdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Node *sideEffectNode = node->getFirstChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::bloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::brdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *sideEffectRegister = cg->evaluate(node->getFirstChild());
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
// Note: For indirect rdbar nodes, the first child (sideEffectNode) is also used by the
// load evaluator. The load evaluator will also evaluate+decrement it. In order to avoid double
// decrementing the node we skip doing it here and let the load evaluator do it.
return TR::TreeEvaluator::bloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::srdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Node *sideEffectNode = node->getFirstChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::sloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::srdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *sideEffectRegister = cg->evaluate(node->getFirstChild());
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
// Note: For indirect rdbar nodes, the first child (sideEffectNode) is also used by the
// load evaluator. The load evaluator will also evaluate+decrement it. In order to avoid double
// decrementing the node we skip doing it here and let the load evaluator do it.
return TR::TreeEvaluator::sloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::lrdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Node *sideEffectNode = node->getFirstChild();
TR::Register *sideEffectRegister = cg->evaluate(sideEffectNode);
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
cg->decReferenceCount(sideEffectNode);
return TR::TreeEvaluator::lloadEvaluator(node, cg);
}
TR::Register *
J9::TreeEvaluator::lrdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// For rdbar and wrtbar nodes we first evaluate the children we need to
// handle the side effects. Then we delegate the evaluation of the remaining
// children and the load/store operation to the appropriate load/store evaluator.
TR::Register *sideEffectRegister = cg->evaluate(node->getFirstChild());
if (cg->comp()->getOption(TR_EnableFieldWatch))
{
TR::TreeEvaluator::rdWrtbarHelperForFieldWatch(node, cg, sideEffectRegister, NULL);
}
// Note: For indirect rdbar nodes, the first child (sideEffectNode) is also used by the
// load evaluator. The load evaluator will also evaluate+decrement it. In order to avoid double
// decrementing the node we skip doing it here and let the load evaluator do it.
return TR::TreeEvaluator::lloadEvaluator(node, cg);
}
///////////////////////////////////////////////////////////////////////////////////////
// monexitfence -- do nothing, just a placeholder for live monitor meta data
///////////////////////////////////////////////////////////////////////////////////////
TR::Register *
J9::TreeEvaluator::monexitfenceEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return NULL;
}
bool J9::TreeEvaluator::getIndirectWrtbarValueNode(TR::CodeGenerator *cg, TR::Node *node, TR::Node*& sourceChild, bool incSrcRefCount)
{
TR_ASSERT_FATAL(node->getOpCode().isIndirect() && node->getOpCode().isWrtBar(), "getIndirectWrtbarValueNode expects indirect wrtbar nodes only n%dn (%p)\n", node->getGlobalIndex(), node);
bool usingCompressedPointers = false;
sourceChild = node->getSecondChild();
if (cg->comp()->useCompressedPointers() && (node->getSymbolReference()->getSymbol()->getDataType() == TR::Address) &&
(node->getSecondChild()->getDataType() != TR::Address))
{
// pattern match the sequence
// awrtbari f awrtbari f <- node
// aload O aload O
// value l2i
// lshr
// lsub <- translatedNode
// a2l
// value <- sourceChild
// lconst HB
// iconst shftKonst
//
// -or- if the field is known to be null
// awrtbari f
// aload O
// l2i
// a2l
// value <- sourceChild
//
TR::Node *translatedNode = sourceChild;
if (translatedNode->getOpCodeValue() == TR::l2i)
{
translatedNode = translatedNode->getFirstChild();
}
if (translatedNode->getOpCode().isRightShift())
{
TR::Node *shiftAmountChild = translatedNode->getSecondChild();
TR_ASSERT_FATAL(TR::Compiler->om.compressedReferenceShiftOffset() == shiftAmountChild->getConstValue(),
"Expect shift amount in the compressedref conversion sequence to be %d but get %d for indirect wrtbar node n%dn (%p)\n",
TR::Compiler->om.compressedReferenceShiftOffset(), shiftAmountChild->getConstValue(), node->getGlobalIndex(), node);
translatedNode = translatedNode->getFirstChild();
}
usingCompressedPointers = true;
while ((sourceChild->getNumChildren() > 0) && (sourceChild->getOpCodeValue() != TR::a2l))
{
sourceChild = sourceChild->getFirstChild();
}
if (sourceChild->getOpCodeValue() == TR::a2l)
{
sourceChild = sourceChild->getFirstChild();
}
// Artificially bump up the refCount on the value so
// that different registers are allocated for the actual
// and compressed values. This is done so that the VMwrtbarEvaluator
// uses the uncompressed value. We only need to do this when the caller
// is evaluating the actual write barrier.
if (incSrcRefCount)
{
sourceChild->incReferenceCount();
}
}
return usingCompressedPointers;
}
static
void traceInstanceOfOrCheckCastProfilingInfo(TR::CodeGenerator *cg, TR::Node *node, TR_OpaqueClassBlock *castClass)
{
TR::Compilation *comp = cg->comp();
TR_J9VMBase *fej9 = (TR_J9VMBase *)(cg->fe());
TR_ByteCodeInfo bcInfo = node->getByteCodeInfo();
TR_ValueProfileInfoManager *valueProfileInfo = TR_ValueProfileInfoManager::get(comp);
if (!valueProfileInfo)
{
return;
}
TR_AddressInfo * valueInfo = static_cast<TR_AddressInfo*>(valueProfileInfo->getValueInfo(bcInfo, comp, AddressInfo, TR_ValueProfileInfoManager::justInterpreterProfileInfo));
if (!valueInfo || valueInfo->getNumProfiledValues() == 0)
{
return;
}
traceMsg(comp, "%s:\n", __func__);
TR_ScratchList<TR_ExtraAddressInfo> valuesSortedByFrequency(comp->trMemory());
valueInfo->getSortedList(comp, &valuesSortedByFrequency);
ListIterator<TR_ExtraAddressInfo> sortedValuesIt(&valuesSortedByFrequency);
for (TR_ExtraAddressInfo *profiledInfo = sortedValuesIt.getFirst(); profiledInfo != NULL; profiledInfo = sortedValuesIt.getNext())
{
TR_OpaqueClassBlock *profiledClass = fej9->getProfiledClassFromProfiledInfo(profiledInfo);
traceMsg(comp, "%s:\tProfiled class [" POINTER_PRINTF_FORMAT "] (%u/%u)\n",
node->getOpCode().getName(), profiledClass, profiledInfo->_frequency, valueInfo->getTotalFrequency());
if (!profiledClass)
continue;
if (comp->getPersistentInfo()->isObsoleteClass(profiledClass, fej9))
{
traceMsg(comp, "%s:\tProfiled class [" POINTER_PRINTF_FORMAT "] is obsolete\n",
node->getOpCode().getName(), profiledClass);
continue;
}
bool isInstanceOf = fej9->instanceOfOrCheckCastNoCacheUpdate((J9Class *)profiledClass, (J9Class *)castClass);
traceMsg(comp, "%s:\tProfiled class [" POINTER_PRINTF_FORMAT "] is %san instance of cast class\n",
node->getOpCode().getName(), profiledClass, isInstanceOf ? "" : "not ");
}
}
/** \brief Generates an array of profiled classes with the boolean representing if the profiled class is instanceOf cast class or not
** \param profiledClassList
** An array of InstanceOfOrCheckCasrProfiledClasses structure passed from the main evaluator to fill up with profiled classes info
** \param topClassProbability
** float pointer passed from main evaluator, we update the value with the probability for the top profiled class to be castClass
** \param maxProfiledClass
** An int denoting how many profiled classes we want
**/
static
uint32_t getInstanceOfOrCheckCastTopProfiledClass(TR::CodeGenerator *cg, TR::Node *node, TR_OpaqueClassBlock *castClass, J9::TreeEvaluator::InstanceOfOrCheckCastProfiledClasses *profiledClassList, bool *topClassWasCastClass, uint32_t maxProfiledClass, float *topClassProbability)
{
TR::Compilation *comp = cg->comp();
if (comp->getOption(TR_TraceCG))
{
static bool traceProfilingInfo = feGetEnv("TR_traceInstanceOfOrCheckCastProfilingInfo") != NULL;
if (traceProfilingInfo)
traceInstanceOfOrCheckCastProfilingInfo(cg, node, castClass);
}
TR_J9VMBase *fej9 = (TR_J9VMBase *)(cg->fe());
TR_ByteCodeInfo bcInfo = node->getByteCodeInfo();
TR_ValueProfileInfoManager *valueProfileInfo = TR_ValueProfileInfoManager::get(comp);
// We do not have validation record to verify that relocated profiled class
// in the load run is instanceof castclass or not. So without that
// verification, we could end up generating code where we have a defined
// relationship between profiled class and cast class which could not be
// true in load run and we could end up with incorrect execution in the
// application.
// TODO: Once we have validation record for instanceOfOrCheckCastNoCacheUpdate
// enable profiled class test in AOT when SVM is enabled.
if (!valueProfileInfo || comp->compileRelocatableCode())
{
return 0;
}
TR_AddressInfo * valueInfo = static_cast<TR_AddressInfo*>(valueProfileInfo->getValueInfo(bcInfo, comp, AddressInfo, TR_ValueProfileInfoManager::justInterpreterProfileInfo));
if (!valueInfo || valueInfo->getNumProfiledValues() == 0)
{
return 0;
}
if (topClassWasCastClass)
*topClassWasCastClass = false;
TR_ScratchList<TR_ExtraAddressInfo> valuesSortedByFrequency(comp->trMemory());
valueInfo->getSortedList(comp, &valuesSortedByFrequency);
float totalFrequency = valueInfo->getTotalFrequency();
ListIterator<TR_ExtraAddressInfo> sortedValuesIt(&valuesSortedByFrequency);
uint32_t numProfiledClasses = 0;
for (TR_ExtraAddressInfo *profiledInfo = sortedValuesIt.getFirst(); profiledInfo != NULL && numProfiledClasses < maxProfiledClass ; profiledInfo = sortedValuesIt.getNext())
{
TR_OpaqueClassBlock *tempProfiledClass = fej9->getProfiledClassFromProfiledInfo(profiledInfo);
if (!tempProfiledClass)
continue;
// Skip unloaded classes.
//
if (comp->getPersistentInfo()->isObsoleteClass(tempProfiledClass, fej9))
{
if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "%s: Profiled class [" POINTER_PRINTF_FORMAT "] is obsolete, skipping\n",
node->getOpCode().getName(), tempProfiledClass);
}
continue;
}
// For checkcast, skip classes that will fail the cast, not much value in optimizing for those cases.
// We also don't want to pollute the cast class cache with a failing class for the same reason.
//
bool isInstanceOf = fej9->instanceOfOrCheckCastNoCacheUpdate((J9Class *)tempProfiledClass, (J9Class *)castClass);
if (node->getOpCode().isCheckCast() && !isInstanceOf)
{
if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "%s: Profiled class [" POINTER_PRINTF_FORMAT "] is not an instance of cast class, skipping\n",
node->getOpCode().getName(), tempProfiledClass);
}
continue;
}
// If the cast class is the top class skip it and return the next highest class if the caller requested it by providing an output param.
//
if (tempProfiledClass == castClass && topClassWasCastClass && numProfiledClasses == 0)
{
if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "%s: Profiled class [" POINTER_PRINTF_FORMAT "] is the cast class, informing caller and skipping\n",
node->getOpCode().getName(), tempProfiledClass);
}
*topClassWasCastClass = true;
*topClassProbability = profiledInfo->_frequency / totalFrequency;
continue;
}
// For AOT compiles with a SymbolValidationManager, skip any classes which cannot be verified.
//
if (comp->compileRelocatableCode() && comp->getOption(TR_UseSymbolValidationManager))
if (!comp->getSymbolValidationManager()->addProfiledClassRecord(tempProfiledClass))
continue;
float frequency = profiledInfo->_frequency / totalFrequency;
if ( frequency >= TR::Options::getMinProfiledCheckcastFrequency() )
{
// We have a winner.
//
profiledClassList[numProfiledClasses].profiledClass = tempProfiledClass;
profiledClassList[numProfiledClasses].isProfiledClassInstanceOfCastClass = isInstanceOf;
profiledClassList[numProfiledClasses].frequency = frequency;
numProfiledClasses++;
}
else
{
// Profiled Class is sorted by frequency so if the frequency is less than the Minimum don't bother with generating another profiled Class
break;
}
}
return numProfiledClasses;
}
/** \brief Generates an array of profiled classes with the boolean representing if the profiled class is instanceOf cast class or not
** \param profiledClassList
** An array of InstanceOfOrCheckCasrProfiledClasses structure passed from the main evaluator to fill up with profiled classes info
** \param numberOfProfiledClass
** An int pointer passed from main evaluator, we update the value with the number of classes we get from profilef info
** \param maxProfiledClass
** An int denoting how many profiled classes we want
** \param topClassProbability
** Probability of having topClass to be castClass.
** \param topClassWasCastClass
** Boolean pointer which will be set to true or false depending on if top profiled class was cast class or not
**/
uint32_t J9::TreeEvaluator::calculateInstanceOfOrCheckCastSequences(TR::Node *instanceOfOrCheckCastNode, InstanceOfOrCheckCastSequences *sequences, TR_OpaqueClassBlock **compileTimeGuessClass, TR::CodeGenerator *cg, InstanceOfOrCheckCastProfiledClasses *profiledClassList, uint32_t *numberOfProfiledClass, uint32_t maxProfiledClass, float * topClassProbability, bool *topClassWasCastClass)
{
TR_J9VMBase *fej9 = (TR_J9VMBase *)(cg->fe());
TR_ASSERT(instanceOfOrCheckCastNode->getOpCode().isCheckCast() || instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof, "Unexpected node opcode");
TR::Node *objectNode = instanceOfOrCheckCastNode->getFirstChild();
TR::Node *castClassNode = instanceOfOrCheckCastNode->getSecondChild();
bool isInstanceOf = instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof;
bool mayBeNull = !instanceOfOrCheckCastNode->isReferenceNonNull() && !objectNode->isNonNull();
// By default maxOnsiteCacheSlotForInstanceOf is set to 0 which means cache is disable.
// To enable test pass JIT option maxOnsiteCacheSlotForInstanceOf=<number_of_slots>
bool createDynamicCacheTests = cg->comp()->getOptions()->getMaxOnsiteCacheSlotForInstanceOf() > 0;
uint32_t i = 0;
uint32_t numProfiledClasses = 0;
if (castClassNode->getReferenceCount() > 1)
{
sequences[i++] = EvaluateCastClass;
}
TR::SymbolReference *castClassSymRef = castClassNode->getSymbolReference();
if (cg->comp()->getOption(TR_OptimizeForSpace) || (cg->comp()->getOption(TR_DisableInlineCheckCast) && (instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcast || instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcastAndNULLCHK)) || (cg->comp()->getOption(TR_DisableInlineInstanceOf) && instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof))
{
if (instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcastAndNULLCHK)
sequences[i++] = NullTest;
sequences[i++] = HelperCall;
}
// Object is known to be null, usually removed by the optimizer, but in case they're not we know the result of the cast/instanceof.
//
else if (objectNode->isNull())
{
if (instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcastAndNULLCHK)
sequences[i++] = NullTest;
sequences[i++] = isInstanceOf ? GoToFalse : GoToTrue;
}
// Cast class is unresolved, not a lot of room to be fancy here.
//
else if (castClassSymRef->isUnresolved())
{
if (cg->comp()->getOption(TR_TraceCG))
traceMsg(cg->comp(),"Cast Class unresolved\n");
if (mayBeNull)
sequences[i++] = NullTest;
sequences[i++] = ClassEqualityTest;
// There is a possibility of attempt to cast object to another class and having cache on that object updated by helper.
// Before going to helper checking the cache.
sequences[i++] = CastClassCacheTest;
if (createDynamicCacheTests)
sequences[i++] = DynamicCacheObjectClassTest;
sequences[i++] = HelperCall;
}
// Cast class is a runtime variable, still not a lot of room to be fancy.
//
else if (!OMR::TreeEvaluator::isStaticClassSymRef(castClassSymRef))
{
traceMsg(cg->comp(),"Cast Class runtimeVariable\n");
TR_ASSERT(isInstanceOf, "Expecting instanceof when cast class is a runtime variable");
if (mayBeNull)
sequences[i++] = NullTest;
sequences[i++] = ClassEqualityTest;
sequences[i++] = CastClassCacheTest;
// On Z, We were having support for Super Class Test for dynamic Cast Class so adding it here. It can be guarded if Power/X do not need it.
if (cg->supportsInliningOfIsInstance() &&
instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof &&
instanceOfOrCheckCastNode->getSecondChild()->getOpCodeValue() != TR::loadaddr)
sequences[i++] = SuperClassTest;
if (createDynamicCacheTests)
sequences[i++] = DynamicCacheDynamicCastClassTest;
sequences[i++] = HelperCall;
}
// Cast class is a compile-time constant, we can generate better code in this case.
//
else
{
TR::StaticSymbol *castClassSym = castClassSymRef->getSymbol()->getStaticSymbol();
TR_OpaqueClassBlock *castClass = (TR_OpaqueClassBlock *)castClassSym->getStaticAddress();
J9UTF8 *castClassName = J9ROMCLASS_CLASSNAME(TR::Compiler->cls.romClassOf((TR_OpaqueClassBlock *) castClass));
// Cast class is a primitive (implies this is an instanceof, since you can't cast an object to a primitive).
// Usually removed by the optimizer, but in case they're not we know they'll always fail, no object can be of a primitive type.
// We don't even need to do a null test unless it's a checkcastAndNULLCHK node.
//
if (TR::Compiler->cls.isPrimitiveClass(cg->comp(), castClass))
{
TR_ASSERT(isInstanceOf, "Expecting instanceof when cast class is a primitive");
if (instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcastAndNULLCHK)
sequences[i++] = NullTest;
sequences[i++] = GoToFalse;
}
// Cast class is java/lang/Object.
// Usually removed by the optimizer, if not we know everything is an Object, instanceof on null is the only thing that needs to be checked.
//
else if (cg->comp()->getObjectClassPointer() == castClass)
{
if (isInstanceOf)
{
if (mayBeNull)
sequences[i++] = NullTest;
sequences[i++] = GoToTrue;
}
else
{
if (instanceOfOrCheckCastNode->getOpCodeValue() == TR::checkcastAndNULLCHK)
sequences[i++] = NullTest;
sequences[i++] = GoToTrue;
}
}
else
{
if (mayBeNull)
{
sequences[i++] = NullTest;
}
TR_OpaqueClassBlock *topProfiledClass = NULL;
// If the caller doesn't provide the output param don't bother with profiling.
//
if (profiledClassList)
{
*numberOfProfiledClass = getInstanceOfOrCheckCastTopProfiledClass(cg, instanceOfOrCheckCastNode, castClass, profiledClassList, topClassWasCastClass, maxProfiledClass, topClassProbability);
numProfiledClasses = *numberOfProfiledClass;
if (cg->comp()->getOption(TR_TraceCG))
{
for (int i=0; i<numProfiledClasses; i++)
{
J9UTF8 *profiledClassName = J9ROMCLASS_CLASSNAME(TR::Compiler->cls.romClassOf((TR_OpaqueClassBlock *) profiledClassList[i].profiledClass));
traceMsg(cg->comp(), "%s:Interpreter profiling instance class: [" POINTER_PRINTF_FORMAT "] %.*s, probability=%.1f\n",
instanceOfOrCheckCastNode->getOpCode().getName(), profiledClassList[i].profiledClass, J9UTF8_LENGTH(profiledClassName), J9UTF8_DATA(profiledClassName), profiledClassList[i].frequency);
}
}
}
TR_OpaqueClassBlock *singleImplementerClass = NULL;
// If the caller doesn't provide the output param don't bother with guessing.
//
if ((!cg->comp()->compileRelocatableCode() || cg->comp()->getOption(TR_UseSymbolValidationManager))
&& compileTimeGuessClass
&& !TR::Compiler->cls.isConcreteClass(cg->comp(), castClass))
{
// Figuring out that an interface/abstract class has a single concrete implementation is not as useful for instanceof as it is for checkcast.
// For checkcast we expect the cast to succeed and the single concrete implementation is the logical class to do a quick up front test against.
// For instanceof false can be a common result and the single concrete implementation doesn't tell us anything special.
//
if (!isInstanceOf)
{
singleImplementerClass = cg->comp()->getPersistentInfo()->getPersistentCHTable()->findSingleConcreteSubClass(castClass, cg->comp());
if (cg->comp()->getOption(TR_TraceCG))
{
if (singleImplementerClass)
{
J9UTF8 *singleImplementerClassName = J9ROMCLASS_CLASSNAME(TR::Compiler->cls.romClassOf((TR_OpaqueClassBlock *) singleImplementerClass));
traceMsg(cg->comp(), "%s: Single implementer for interface/abstract class: [" POINTER_PRINTF_FORMAT "] %.*s\n",
instanceOfOrCheckCastNode->getOpCode().getName(), singleImplementerClass, J9UTF8_LENGTH(singleImplementerClassName), J9UTF8_DATA(singleImplementerClassName));
}
}
}
*compileTimeGuessClass = singleImplementerClass;
}
if (TR::Compiler->cls.isClassArray(cg->comp(), castClass))
{
if (TR::Compiler->cls.isReferenceArray(cg->comp(), castClass))
{
TR_OpaqueClassBlock *componentClass = fej9->getComponentClassFromArrayClass(castClass);
TR_OpaqueClassBlock *leafClass = fej9->getLeafComponentClassFromArrayClass(castClass);
// Cast class is a single dim array of java/lang/Object, all we need to do is check if the object is an array of non-primitives.
//
if (cg->comp()->getObjectClassPointer() == componentClass && componentClass == leafClass)
{
sequences[i++] = ArrayOfJavaLangObjectTest;
sequences[i++] = GoToFalse;
}
// Cast class is a single dim array of a final class, all we need to do is check if the object is of this type, anything else is false.
//
else if (fej9->isClassFinal(componentClass) && componentClass == leafClass)
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = GoToFalse;
}
// Cast class is an array of some non-final class or multiple dimensions.
//
else
{
if (numProfiledClasses > 0)
{
if (!*topClassWasCastClass)
{
sequences[i++] = ProfiledClassTest;
sequences[i++] = CastClassCacheTest;
}
else
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = ProfiledClassTest;
sequences[i++] = CastClassCacheTest;
}
}
else
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = CastClassCacheTest;
}
sequences[i++] = HelperCall;
}
}
// Cast class is an array of some primitive, all we need to do is check if the object is of this type, anything else is false.
//
else
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = GoToFalse;
}
}
// Cast class is an interface, we can skip the class equality test.
//
else if (TR::Compiler->cls.isInterfaceClass(cg->comp(), castClass))
{
if (singleImplementerClass)
{
sequences[i++] = CompileTimeGuessClassTest;
}
else if (numProfiledClasses > 0)
{
sequences[i++] = ProfiledClassTest;
sequences[i++] = CastClassCacheTest;
}
else
{
sequences[i++] = CastClassCacheTest;
}
if (createDynamicCacheTests)
sequences[i++] = DynamicCacheObjectClassTest;
sequences[i++] = HelperCall;
}
// Cast class is an abstract class, we can skip the class equality test, a superclass test is enough.
//
else if (fej9->isAbstractClass(castClass))
{
// Don't bother with the cast class cache, it's not updated by the VM when the cast can be determined via a superclass test.
//
if (singleImplementerClass)
sequences[i++] = CompileTimeGuessClassTest;
else if (numProfiledClasses > 0)
sequences[i++] = ProfiledClassTest;
sequences[i++] = SuperClassTest;
sequences[i++] = GoToFalse;
}
// Cast class is a final class, all we need to do is check if the object is of this type, anything else is false.
//
else if (fej9->isClassFinal(castClass))
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = GoToFalse;
}
// Arbitrary concrete class.
//
else
{
// Don't bother with the cast class cache, it's not updated by the VM when the cast can be determined via a superclass test.
//
if (numProfiledClasses > 0)
{
if (!*topClassWasCastClass)
{
sequences[i++] = ProfiledClassTest;
sequences[i++] = ClassEqualityTest;
}
else
{
sequences[i++] = ClassEqualityTest;
sequences[i++] = ProfiledClassTest;
}
}
else
{
sequences[i++] = ClassEqualityTest;
}