forked from openjdk/panama-vector
/
type.cpp
5507 lines (4886 loc) · 203 KB
/
type.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) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "ci/ciMethodData.hpp"
#include "ci/ciTypeFlow.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/symbolTable.hpp"
#include "compiler/compileLog.hpp"
#include "libadt/dict.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/typeArrayKlass.hpp"
#include "opto/matcher.hpp"
#include "opto/node.hpp"
#include "opto/opcodes.hpp"
#include "opto/type.hpp"
#include "utilities/powerOfTwo.hpp"
#include "utilities/stringUtils.hpp"
// Portions of code courtesy of Clifford Click
// Optimization - Graph Style
// Dictionary of types shared among compilations.
Dict* Type::_shared_type_dict = NULL;
// Array which maps compiler types to Basic Types
const Type::TypeInfo Type::_type_info[Type::lastype] = {
{ Bad, T_ILLEGAL, "bad", false, Node::NotAMachineReg, relocInfo::none }, // Bad
{ Control, T_ILLEGAL, "control", false, 0, relocInfo::none }, // Control
{ Bottom, T_VOID, "top", false, 0, relocInfo::none }, // Top
{ Bad, T_INT, "int:", false, Op_RegI, relocInfo::none }, // Int
{ Bad, T_LONG, "long:", false, Op_RegL, relocInfo::none }, // Long
{ Half, T_VOID, "half", false, 0, relocInfo::none }, // Half
{ Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop
{ Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass
{ Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple
{ Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array
#if defined(PPC64)
{ Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask.
{ Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA.
{ Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS
{ Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD
{ Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX
{ Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY
{ Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ
#elif defined(S390)
{ Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask.
{ Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA.
{ Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS
{ Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD
{ Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX
{ Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY
{ Bad, T_ILLEGAL, "vectorz:", false, 0, relocInfo::none }, // VectorZ
#else // all other
{ Bad, T_ILLEGAL, "vectormask:", false, Op_RegVectMask, relocInfo::none }, // VectorMask.
{ Bad, T_ILLEGAL, "vectora:", false, Op_VecA, relocInfo::none }, // VectorA.
{ Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS
{ Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD
{ Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX
{ Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY
{ Bad, T_ILLEGAL, "vectorz:", false, Op_VecZ, relocInfo::none }, // VectorZ
#endif
{ Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr
{ Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr
{ Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr
{ Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr
{ Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr
{ Bad, T_METADATA, "metadata:", false, Op_RegP, relocInfo::metadata_type }, // MetadataPtr
{ Bad, T_METADATA, "klass:", false, Op_RegP, relocInfo::metadata_type }, // KlassPtr
{ Bad, T_OBJECT, "func", false, 0, relocInfo::none }, // Function
{ Abio, T_ILLEGAL, "abIO", false, 0, relocInfo::none }, // Abio
{ Return_Address, T_ADDRESS, "return_address",false, Op_RegP, relocInfo::none }, // Return_Address
{ Memory, T_ILLEGAL, "memory", false, 0, relocInfo::none }, // Memory
{ FloatBot, T_FLOAT, "float_top", false, Op_RegF, relocInfo::none }, // FloatTop
{ FloatCon, T_FLOAT, "ftcon:", false, Op_RegF, relocInfo::none }, // FloatCon
{ FloatTop, T_FLOAT, "float", false, Op_RegF, relocInfo::none }, // FloatBot
{ DoubleBot, T_DOUBLE, "double_top", false, Op_RegD, relocInfo::none }, // DoubleTop
{ DoubleCon, T_DOUBLE, "dblcon:", false, Op_RegD, relocInfo::none }, // DoubleCon
{ DoubleTop, T_DOUBLE, "double", false, Op_RegD, relocInfo::none }, // DoubleBot
{ Top, T_ILLEGAL, "bottom", false, 0, relocInfo::none } // Bottom
};
// Map ideal registers (machine types) to ideal types
const Type *Type::mreg2type[_last_machine_leaf];
// Map basic types to canonical Type* pointers.
const Type* Type:: _const_basic_type[T_CONFLICT+1];
// Map basic types to constant-zero Types.
const Type* Type:: _zero_type[T_CONFLICT+1];
// Map basic types to array-body alias types.
const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1];
//=============================================================================
// Convenience common pre-built types.
const Type *Type::ABIO; // State-of-machine only
const Type *Type::BOTTOM; // All values
const Type *Type::CONTROL; // Control only
const Type *Type::DOUBLE; // All doubles
const Type *Type::FLOAT; // All floats
const Type *Type::HALF; // Placeholder half of doublewide type
const Type *Type::MEMORY; // Abstract store only
const Type *Type::RETURN_ADDRESS;
const Type *Type::TOP; // No values in set
//------------------------------get_const_type---------------------------
const Type* Type::get_const_type(ciType* type) {
if (type == NULL) {
return NULL;
} else if (type->is_primitive_type()) {
return get_const_basic_type(type->basic_type());
} else {
return TypeOopPtr::make_from_klass(type->as_klass());
}
}
//---------------------------array_element_basic_type---------------------------------
// Mapping to the array element's basic type.
BasicType Type::array_element_basic_type() const {
BasicType bt = basic_type();
if (bt == T_INT) {
if (this == TypeInt::INT) return T_INT;
if (this == TypeInt::CHAR) return T_CHAR;
if (this == TypeInt::BYTE) return T_BYTE;
if (this == TypeInt::BOOL) return T_BOOLEAN;
if (this == TypeInt::SHORT) return T_SHORT;
return T_VOID;
}
return bt;
}
// For two instance arrays of same dimension, return the base element types.
// Otherwise or if the arrays have different dimensions, return NULL.
void Type::get_arrays_base_elements(const Type *a1, const Type *a2,
const TypeInstPtr **e1, const TypeInstPtr **e2) {
if (e1) *e1 = NULL;
if (e2) *e2 = NULL;
const TypeAryPtr* a1tap = (a1 == NULL) ? NULL : a1->isa_aryptr();
const TypeAryPtr* a2tap = (a2 == NULL) ? NULL : a2->isa_aryptr();
if (a1tap != NULL && a2tap != NULL) {
// Handle multidimensional arrays
const TypePtr* a1tp = a1tap->elem()->make_ptr();
const TypePtr* a2tp = a2tap->elem()->make_ptr();
while (a1tp && a1tp->isa_aryptr() && a2tp && a2tp->isa_aryptr()) {
a1tap = a1tp->is_aryptr();
a2tap = a2tp->is_aryptr();
a1tp = a1tap->elem()->make_ptr();
a2tp = a2tap->elem()->make_ptr();
}
if (a1tp && a1tp->isa_instptr() && a2tp && a2tp->isa_instptr()) {
if (e1) *e1 = a1tp->is_instptr();
if (e2) *e2 = a2tp->is_instptr();
}
}
}
//---------------------------get_typeflow_type---------------------------------
// Import a type produced by ciTypeFlow.
const Type* Type::get_typeflow_type(ciType* type) {
switch (type->basic_type()) {
case ciTypeFlow::StateVector::T_BOTTOM:
assert(type == ciTypeFlow::StateVector::bottom_type(), "");
return Type::BOTTOM;
case ciTypeFlow::StateVector::T_TOP:
assert(type == ciTypeFlow::StateVector::top_type(), "");
return Type::TOP;
case ciTypeFlow::StateVector::T_NULL:
assert(type == ciTypeFlow::StateVector::null_type(), "");
return TypePtr::NULL_PTR;
case ciTypeFlow::StateVector::T_LONG2:
// The ciTypeFlow pass pushes a long, then the half.
// We do the same.
assert(type == ciTypeFlow::StateVector::long2_type(), "");
return TypeInt::TOP;
case ciTypeFlow::StateVector::T_DOUBLE2:
// The ciTypeFlow pass pushes double, then the half.
// Our convention is the same.
assert(type == ciTypeFlow::StateVector::double2_type(), "");
return Type::TOP;
case T_ADDRESS:
assert(type->is_return_address(), "");
return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci());
default:
// make sure we did not mix up the cases:
assert(type != ciTypeFlow::StateVector::bottom_type(), "");
assert(type != ciTypeFlow::StateVector::top_type(), "");
assert(type != ciTypeFlow::StateVector::null_type(), "");
assert(type != ciTypeFlow::StateVector::long2_type(), "");
assert(type != ciTypeFlow::StateVector::double2_type(), "");
assert(!type->is_return_address(), "");
return Type::get_const_type(type);
}
}
//-----------------------make_from_constant------------------------------------
const Type* Type::make_from_constant(ciConstant constant, bool require_constant,
int stable_dimension, bool is_narrow_oop,
bool is_autobox_cache) {
switch (constant.basic_type()) {
case T_BOOLEAN: return TypeInt::make(constant.as_boolean());
case T_CHAR: return TypeInt::make(constant.as_char());
case T_BYTE: return TypeInt::make(constant.as_byte());
case T_SHORT: return TypeInt::make(constant.as_short());
case T_INT: return TypeInt::make(constant.as_int());
case T_LONG: return TypeLong::make(constant.as_long());
case T_FLOAT: return TypeF::make(constant.as_float());
case T_DOUBLE: return TypeD::make(constant.as_double());
case T_ARRAY:
case T_OBJECT: {
const Type* con_type = NULL;
ciObject* oop_constant = constant.as_object();
if (oop_constant->is_null_object()) {
con_type = Type::get_zero_type(T_OBJECT);
} else {
guarantee(require_constant || oop_constant->should_be_constant(), "con_type must get computed");
con_type = TypeOopPtr::make_from_constant(oop_constant, require_constant);
if (Compile::current()->eliminate_boxing() && is_autobox_cache) {
con_type = con_type->is_aryptr()->cast_to_autobox_cache();
}
if (stable_dimension > 0) {
assert(FoldStableValues, "sanity");
assert(!con_type->is_zero_type(), "default value for stable field");
con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension);
}
}
if (is_narrow_oop) {
con_type = con_type->make_narrowoop();
}
return con_type;
}
case T_ILLEGAL:
// Invalid ciConstant returned due to OutOfMemoryError in the CI
assert(Compile::current()->env()->failing(), "otherwise should not see this");
return NULL;
default:
// Fall through to failure
return NULL;
}
}
static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
BasicType conbt = con.basic_type();
switch (conbt) {
case T_BOOLEAN: conbt = T_BYTE; break;
case T_ARRAY: conbt = T_OBJECT; break;
default: break;
}
switch (loadbt) {
case T_BOOLEAN: loadbt = T_BYTE; break;
case T_NARROWOOP: loadbt = T_OBJECT; break;
case T_ARRAY: loadbt = T_OBJECT; break;
case T_ADDRESS: loadbt = T_OBJECT; break;
default: break;
}
if (conbt == loadbt) {
if (is_unsigned && conbt == T_BYTE) {
// LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE).
return ciConstant(T_INT, con.as_int() & 0xFF);
} else {
return con;
}
}
if (conbt == T_SHORT && loadbt == T_CHAR) {
// LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR).
return ciConstant(T_INT, con.as_int() & 0xFFFF);
}
return ciConstant(); // T_ILLEGAL
}
// Try to constant-fold a stable array element.
const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension,
BasicType loadbt, bool is_unsigned_load) {
// Decode the results of GraphKit::array_element_address.
ciConstant element_value = array->element_value_by_offset(off);
if (element_value.basic_type() == T_ILLEGAL) {
return NULL; // wrong offset
}
ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load);
assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d",
type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load);
if (con.is_valid() && // not a mismatched access
!con.is_null_or_zero()) { // not a default value
bool is_narrow_oop = (loadbt == T_NARROWOOP);
return Type::make_from_constant(con, /*require_constant=*/true, stable_dimension, is_narrow_oop, /*is_autobox_cache=*/false);
}
return NULL;
}
const Type* Type::make_constant_from_field(ciInstance* holder, int off, bool is_unsigned_load, BasicType loadbt) {
ciField* field;
ciType* type = holder->java_mirror_type();
if (type != NULL && type->is_instance_klass() && off >= InstanceMirrorKlass::offset_of_static_fields()) {
// Static field
field = type->as_instance_klass()->get_field_by_offset(off, /*is_static=*/true);
} else {
// Instance field
field = holder->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/false);
}
if (field == NULL) {
return NULL; // Wrong offset
}
return Type::make_constant_from_field(field, holder, loadbt, is_unsigned_load);
}
const Type* Type::make_constant_from_field(ciField* field, ciInstance* holder,
BasicType loadbt, bool is_unsigned_load) {
if (!field->is_constant()) {
return NULL; // Non-constant field
}
ciConstant field_value;
if (field->is_static()) {
// final static field
field_value = field->constant_value();
} else if (holder != NULL) {
// final or stable non-static field
// Treat final non-static fields of trusted classes (classes in
// java.lang.invoke and sun.invoke packages and subpackages) as
// compile time constants.
field_value = field->constant_value_of(holder);
}
if (!field_value.is_valid()) {
return NULL; // Not a constant
}
ciConstant con = check_mismatched_access(field_value, loadbt, is_unsigned_load);
assert(con.is_valid(), "elembt=%s; loadbt=%s; unsigned=%d",
type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load);
bool is_stable_array = FoldStableValues && field->is_stable() && field->type()->is_array_klass();
int stable_dimension = (is_stable_array ? field->type()->as_array_klass()->dimension() : 0);
bool is_narrow_oop = (loadbt == T_NARROWOOP);
const Type* con_type = make_from_constant(con, /*require_constant=*/ true,
stable_dimension, is_narrow_oop,
field->is_autobox_cache());
if (con_type != NULL && field->is_call_site_target()) {
ciCallSite* call_site = holder->as_call_site();
if (!call_site->is_fully_initialized_constant_call_site()) {
ciMethodHandle* target = con.as_object()->as_method_handle();
Compile::current()->dependencies()->assert_call_site_target_value(call_site, target);
}
}
return con_type;
}
//------------------------------make-------------------------------------------
// Create a simple Type, with default empty symbol sets. Then hashcons it
// and look for an existing copy in the type dictionary.
const Type *Type::make( enum TYPES t ) {
return (new Type(t))->hashcons();
}
//------------------------------cmp--------------------------------------------
int Type::cmp( const Type *const t1, const Type *const t2 ) {
if( t1->_base != t2->_base )
return 1; // Missed badly
assert(t1 != t2 || t1->eq(t2), "eq must be reflexive");
return !t1->eq(t2); // Return ZERO if equal
}
const Type* Type::maybe_remove_speculative(bool include_speculative) const {
if (!include_speculative) {
return remove_speculative();
}
return this;
}
//------------------------------hash-------------------------------------------
int Type::uhash( const Type *const t ) {
return t->hash();
}
#define SMALLINT ((juint)3) // a value too insignificant to consider widening
#define POSITIVE_INFINITE_F 0x7f800000 // hex representation for IEEE 754 single precision positive infinite
#define POSITIVE_INFINITE_D 0x7ff0000000000000 // hex representation for IEEE 754 double precision positive infinite
//--------------------------Initialize_shared----------------------------------
void Type::Initialize_shared(Compile* current) {
// This method does not need to be locked because the first system
// compilations (stub compilations) occur serially. If they are
// changed to proceed in parallel, then this section will need
// locking.
Arena* save = current->type_arena();
Arena* shared_type_arena = new (mtCompiler)Arena(mtCompiler);
current->set_type_arena(shared_type_arena);
_shared_type_dict =
new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash,
shared_type_arena, 128 );
current->set_type_dict(_shared_type_dict);
// Make shared pre-built types.
CONTROL = make(Control); // Control only
TOP = make(Top); // No values in set
MEMORY = make(Memory); // Abstract store only
ABIO = make(Abio); // State-of-machine only
RETURN_ADDRESS=make(Return_Address);
FLOAT = make(FloatBot); // All floats
DOUBLE = make(DoubleBot); // All doubles
BOTTOM = make(Bottom); // Everything
HALF = make(Half); // Placeholder half of doublewide type
TypeF::MAX = TypeF::make(max_jfloat); // Float MAX
TypeF::MIN = TypeF::make(min_jfloat); // Float MIN
TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero)
TypeF::ONE = TypeF::make(1.0); // Float 1
TypeF::POS_INF = TypeF::make(jfloat_cast(POSITIVE_INFINITE_F));
TypeF::NEG_INF = TypeF::make(-jfloat_cast(POSITIVE_INFINITE_F));
TypeD::MAX = TypeD::make(max_jdouble); // Double MAX
TypeD::MIN = TypeD::make(min_jdouble); // Double MIN
TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero)
TypeD::ONE = TypeD::make(1.0); // Double 1
TypeD::POS_INF = TypeD::make(jdouble_cast(POSITIVE_INFINITE_D));
TypeD::NEG_INF = TypeD::make(-jdouble_cast(POSITIVE_INFINITE_D));
TypeInt::MAX = TypeInt::make(max_jint); // Int MAX
TypeInt::MIN = TypeInt::make(min_jint); // Int MIN
TypeInt::MINUS_1 = TypeInt::make(-1); // -1
TypeInt::ZERO = TypeInt::make( 0); // 0
TypeInt::ONE = TypeInt::make( 1); // 1
TypeInt::BOOL = TypeInt::make(0,1, WidenMin); // 0 or 1, FALSE or TRUE.
TypeInt::CC = TypeInt::make(-1, 1, WidenMin); // -1, 0 or 1, condition codes
TypeInt::CC_LT = TypeInt::make(-1,-1, WidenMin); // == TypeInt::MINUS_1
TypeInt::CC_GT = TypeInt::make( 1, 1, WidenMin); // == TypeInt::ONE
TypeInt::CC_EQ = TypeInt::make( 0, 0, WidenMin); // == TypeInt::ZERO
TypeInt::CC_LE = TypeInt::make(-1, 0, WidenMin);
TypeInt::CC_GE = TypeInt::make( 0, 1, WidenMin); // == TypeInt::BOOL
TypeInt::BYTE = TypeInt::make(-128,127, WidenMin); // Bytes
TypeInt::UBYTE = TypeInt::make(0, 255, WidenMin); // Unsigned Bytes
TypeInt::CHAR = TypeInt::make(0,65535, WidenMin); // Java chars
TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts
TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values
TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range
TypeInt::TYPE_DOMAIN = TypeInt::INT;
// CmpL is overloaded both as the bytecode computation returning
// a trinary (-1,0,+1) integer result AND as an efficient long
// compare returning optimizer ideal-type flags.
assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" );
assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" );
assert( TypeInt::CC_EQ == TypeInt::ZERO, "types must match for CmpL to work" );
assert( TypeInt::CC_GE == TypeInt::BOOL, "types must match for CmpL to work" );
assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small");
TypeLong::MAX = TypeLong::make(max_jlong); // Long MAX
TypeLong::MIN = TypeLong::make(min_jlong); // Long MIN
TypeLong::MINUS_1 = TypeLong::make(-1); // -1
TypeLong::ZERO = TypeLong::make( 0); // 0
TypeLong::ONE = TypeLong::make( 1); // 1
TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values
TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers
TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin);
TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin);
TypeLong::TYPE_DOMAIN = TypeLong::LONG;
const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
fboth[0] = Type::CONTROL;
fboth[1] = Type::CONTROL;
TypeTuple::IFBOTH = TypeTuple::make( 2, fboth );
const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
ffalse[0] = Type::CONTROL;
ffalse[1] = Type::TOP;
TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse );
const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
fneither[0] = Type::TOP;
fneither[1] = Type::TOP;
TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither );
const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
ftrue[0] = Type::TOP;
ftrue[1] = Type::CONTROL;
TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue );
const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
floop[0] = Type::CONTROL;
floop[1] = TypeInt::INT;
TypeTuple::LOOPBODY = TypeTuple::make( 2, floop );
TypePtr::NULL_PTR= TypePtr::make(AnyPtr, TypePtr::Null, 0);
TypePtr::NOTNULL = TypePtr::make(AnyPtr, TypePtr::NotNull, OffsetBot);
TypePtr::BOTTOM = TypePtr::make(AnyPtr, TypePtr::BotPTR, OffsetBot);
TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR );
TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull );
const Type **fmembar = TypeTuple::fields(0);
TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar);
const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
fsc[0] = TypeInt::CC;
fsc[1] = Type::MEMORY;
TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc);
TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass());
TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass());
TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass());
TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
false, 0, oopDesc::mark_offset_in_bytes());
TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(),
false, 0, oopDesc::klass_offset_in_bytes());
TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot);
TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot);
TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR );
TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM );
TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR );
mreg2type[Op_Node] = Type::BOTTOM;
mreg2type[Op_Set ] = 0;
mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM;
mreg2type[Op_RegI] = TypeInt::INT;
mreg2type[Op_RegP] = TypePtr::BOTTOM;
mreg2type[Op_RegF] = Type::FLOAT;
mreg2type[Op_RegD] = Type::DOUBLE;
mreg2type[Op_RegL] = TypeLong::LONG;
mreg2type[Op_RegFlags] = TypeInt::CC;
TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes());
TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot);
#ifdef _LP64
if (UseCompressedOops) {
assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop");
TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS;
} else
#endif
{
// There is no shared klass for Object[]. See note in TypeAryPtr::klass().
TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot);
}
TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot);
TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot);
TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot);
TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot);
TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot);
TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Type::OffsetBot);
TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Type::OffsetBot);
// Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert.
TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL;
TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS;
TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays
TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES;
TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array
TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS;
TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS;
TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS;
TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS;
TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS;
TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES;
TypeKlassPtr::OBJECT = TypeKlassPtr::make( TypePtr::NotNull, current->env()->Object_klass(), 0 );
TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 );
const Type **fi2c = TypeTuple::fields(2);
fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method*
fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer
TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c);
const Type **intpair = TypeTuple::fields(2);
intpair[0] = TypeInt::INT;
intpair[1] = TypeInt::INT;
TypeTuple::INT_PAIR = TypeTuple::make(2, intpair);
const Type **longpair = TypeTuple::fields(2);
longpair[0] = TypeLong::LONG;
longpair[1] = TypeLong::LONG;
TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair);
const Type **intccpair = TypeTuple::fields(2);
intccpair[0] = TypeInt::INT;
intccpair[1] = TypeInt::CC;
TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair);
const Type **longccpair = TypeTuple::fields(2);
longccpair[0] = TypeLong::LONG;
longccpair[1] = TypeInt::CC;
TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair);
_const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM;
_const_basic_type[T_NARROWKLASS] = Type::BOTTOM;
_const_basic_type[T_BOOLEAN] = TypeInt::BOOL;
_const_basic_type[T_CHAR] = TypeInt::CHAR;
_const_basic_type[T_BYTE] = TypeInt::BYTE;
_const_basic_type[T_SHORT] = TypeInt::SHORT;
_const_basic_type[T_INT] = TypeInt::INT;
_const_basic_type[T_LONG] = TypeLong::LONG;
_const_basic_type[T_FLOAT] = Type::FLOAT;
_const_basic_type[T_DOUBLE] = Type::DOUBLE;
_const_basic_type[T_OBJECT] = TypeInstPtr::BOTTOM;
_const_basic_type[T_ARRAY] = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays
_const_basic_type[T_VOID] = TypePtr::NULL_PTR; // reflection represents void this way
_const_basic_type[T_ADDRESS] = TypeRawPtr::BOTTOM; // both interpreter return addresses & random raw ptrs
_const_basic_type[T_CONFLICT] = Type::BOTTOM; // why not?
_zero_type[T_NARROWOOP] = TypeNarrowOop::NULL_PTR;
_zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR;
_zero_type[T_BOOLEAN] = TypeInt::ZERO; // false == 0
_zero_type[T_CHAR] = TypeInt::ZERO; // '\0' == 0
_zero_type[T_BYTE] = TypeInt::ZERO; // 0x00 == 0
_zero_type[T_SHORT] = TypeInt::ZERO; // 0x0000 == 0
_zero_type[T_INT] = TypeInt::ZERO;
_zero_type[T_LONG] = TypeLong::ZERO;
_zero_type[T_FLOAT] = TypeF::ZERO;
_zero_type[T_DOUBLE] = TypeD::ZERO;
_zero_type[T_OBJECT] = TypePtr::NULL_PTR;
_zero_type[T_ARRAY] = TypePtr::NULL_PTR; // null array is null oop
_zero_type[T_ADDRESS] = TypePtr::NULL_PTR; // raw pointers use the same null
_zero_type[T_VOID] = Type::TOP; // the only void value is no value at all
// get_zero_type() should not happen for T_CONFLICT
_zero_type[T_CONFLICT]= NULL;
TypeVect::VECTMASK = (TypeVect*)(new TypeVectMask(TypeInt::BOOL, MaxVectorSize))->hashcons();
mreg2type[Op_RegVectMask] = TypeVect::VECTMASK;
if (Matcher::supports_scalable_vector()) {
TypeVect::VECTA = TypeVect::make(T_BYTE, Matcher::scalable_vector_reg_size(T_BYTE));
}
// Vector predefined types, it needs initialized _const_basic_type[].
if (Matcher::vector_size_supported(T_BYTE,4)) {
TypeVect::VECTS = TypeVect::make(T_BYTE,4);
}
if (Matcher::vector_size_supported(T_FLOAT,2)) {
TypeVect::VECTD = TypeVect::make(T_FLOAT,2);
}
if (Matcher::vector_size_supported(T_FLOAT,4)) {
TypeVect::VECTX = TypeVect::make(T_FLOAT,4);
}
if (Matcher::vector_size_supported(T_FLOAT,8)) {
TypeVect::VECTY = TypeVect::make(T_FLOAT,8);
}
if (Matcher::vector_size_supported(T_FLOAT,16)) {
TypeVect::VECTZ = TypeVect::make(T_FLOAT,16);
}
mreg2type[Op_VecA] = TypeVect::VECTA;
mreg2type[Op_VecS] = TypeVect::VECTS;
mreg2type[Op_VecD] = TypeVect::VECTD;
mreg2type[Op_VecX] = TypeVect::VECTX;
mreg2type[Op_VecY] = TypeVect::VECTY;
mreg2type[Op_VecZ] = TypeVect::VECTZ;
// Restore working type arena.
current->set_type_arena(save);
current->set_type_dict(NULL);
}
//------------------------------Initialize-------------------------------------
void Type::Initialize(Compile* current) {
assert(current->type_arena() != NULL, "must have created type arena");
if (_shared_type_dict == NULL) {
Initialize_shared(current);
}
Arena* type_arena = current->type_arena();
// Create the hash-cons'ing dictionary with top-level storage allocation
Dict *tdic = new (type_arena) Dict(*_shared_type_dict, type_arena);
current->set_type_dict(tdic);
}
//------------------------------hashcons---------------------------------------
// Do the hash-cons trick. If the Type already exists in the type table,
// delete the current Type and return the existing Type. Otherwise stick the
// current Type in the Type table.
const Type *Type::hashcons(void) {
debug_only(base()); // Check the assertion in Type::base().
// Look up the Type in the Type dictionary
Dict *tdic = type_dict();
Type* old = (Type*)(tdic->Insert(this, this, false));
if( old ) { // Pre-existing Type?
if( old != this ) // Yes, this guy is not the pre-existing?
delete this; // Yes, Nuke this guy
assert( old->_dual, "" );
return old; // Return pre-existing
}
// Every type has a dual (to make my lattice symmetric).
// Since we just discovered a new Type, compute its dual right now.
assert( !_dual, "" ); // No dual yet
_dual = xdual(); // Compute the dual
if (cmp(this, _dual) == 0) { // Handle self-symmetric
if (_dual != this) {
delete _dual;
_dual = this;
}
return this;
}
assert( !_dual->_dual, "" ); // No reverse dual yet
assert( !(*tdic)[_dual], "" ); // Dual not in type system either
// New Type, insert into Type table
tdic->Insert((void*)_dual,(void*)_dual);
((Type*)_dual)->_dual = this; // Finish up being symmetric
#ifdef ASSERT
Type *dual_dual = (Type*)_dual->xdual();
assert( eq(dual_dual), "xdual(xdual()) should be identity" );
delete dual_dual;
#endif
return this; // Return new Type
}
//------------------------------eq---------------------------------------------
// Structural equality check for Type representations
bool Type::eq( const Type * ) const {
return true; // Nothing else can go wrong
}
//------------------------------hash-------------------------------------------
// Type-specific hashing function.
int Type::hash(void) const {
return _base;
}
//------------------------------is_finite--------------------------------------
// Has a finite value
bool Type::is_finite() const {
return false;
}
//------------------------------is_nan-----------------------------------------
// Is not a number (NaN)
bool Type::is_nan() const {
return false;
}
//----------------------interface_vs_oop---------------------------------------
#ifdef ASSERT
bool Type::interface_vs_oop_helper(const Type *t) const {
bool result = false;
const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
const TypePtr* t_ptr = t->make_ptr();
if( this_ptr == NULL || t_ptr == NULL )
return result;
const TypeInstPtr* this_inst = this_ptr->isa_instptr();
const TypeInstPtr* t_inst = t_ptr->isa_instptr();
if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
bool this_interface = this_inst->klass()->is_interface();
bool t_interface = t_inst->klass()->is_interface();
result = this_interface ^ t_interface;
}
return result;
}
bool Type::interface_vs_oop(const Type *t) const {
if (interface_vs_oop_helper(t)) {
return true;
}
// Now check the speculative parts as well
const TypePtr* this_spec = isa_ptr() != NULL ? is_ptr()->speculative() : NULL;
const TypePtr* t_spec = t->isa_ptr() != NULL ? t->is_ptr()->speculative() : NULL;
if (this_spec != NULL && t_spec != NULL) {
if (this_spec->interface_vs_oop_helper(t_spec)) {
return true;
}
return false;
}
if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) {
return true;
}
if (t_spec != NULL && interface_vs_oop_helper(t_spec)) {
return true;
}
return false;
}
#endif
void Type::check_symmetrical(const Type* t, const Type* mt) const {
#ifdef ASSERT
const Type* mt2 = t->xmeet(this);
if (mt != mt2) {
tty->print_cr("=== Meet Not Commutative ===");
tty->print("t = "); t->dump(); tty->cr();
tty->print("this = "); dump(); tty->cr();
tty->print("t meet this = "); mt2->dump(); tty->cr();
tty->print("this meet t = "); mt->dump(); tty->cr();
fatal("meet not commutative");
}
const Type* dual_join = mt->_dual;
const Type* t2t = dual_join->xmeet(t->_dual);
const Type* t2this = dual_join->xmeet(this->_dual);
// Interface meet Oop is Not Symmetric:
// Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull
// Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull
if (!interface_vs_oop(t) && (t2t != t->_dual || t2this != this->_dual)) {
tty->print_cr("=== Meet Not Symmetric ===");
tty->print("t = "); t->dump(); tty->cr();
tty->print("this= "); dump(); tty->cr();
tty->print("mt=(t meet this)= "); mt->dump(); tty->cr();
tty->print("t_dual= "); t->_dual->dump(); tty->cr();
tty->print("this_dual= "); _dual->dump(); tty->cr();
tty->print("mt_dual= "); mt->_dual->dump(); tty->cr();
tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr();
tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr();
fatal("meet not symmetric");
}
#endif
}
//------------------------------meet-------------------------------------------
// Compute the MEET of two types. NOT virtual. It enforces that meet is
// commutative and the lattice is symmetric.
const Type *Type::meet_helper(const Type *t, bool include_speculative) const {
if (isa_narrowoop() && t->isa_narrowoop()) {
const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative);
return result->make_narrowoop();
}
if (isa_narrowklass() && t->isa_narrowklass()) {
const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative);
return result->make_narrowklass();
}
const Type *this_t = maybe_remove_speculative(include_speculative);
t = t->maybe_remove_speculative(include_speculative);
const Type *mt = this_t->xmeet(t);
#ifdef ASSERT
if (isa_narrowoop() || t->isa_narrowoop()) return mt;
if (isa_narrowklass() || t->isa_narrowklass()) return mt;
Compile* C = Compile::current();
if (!C->_type_verify_symmetry) {
return mt;
}
this_t->check_symmetrical(t, mt);
// In the case of an array, computing the meet above, caused the
// computation of the meet of the elements which at verification
// time caused the computation of the meet of the dual of the
// elements. Computing the meet of the dual of the arrays here
// causes the meet of the dual of the elements to be computed which
// would cause the meet of the dual of the dual of the elements,
// that is the meet of the elements already computed above to be
// computed. Avoid redundant computations by requesting no
// verification.
C->_type_verify_symmetry = false;
const Type *mt_dual = this_t->_dual->xmeet(t->_dual);
this_t->_dual->check_symmetrical(t->_dual, mt_dual);
assert(!C->_type_verify_symmetry, "shouldn't have changed");
C->_type_verify_symmetry = true;
#endif
return mt;
}
//------------------------------xmeet------------------------------------------
// Compute the MEET of two types. It returns a new Type object.
const Type *Type::xmeet( const Type *t ) const {
// Perform a fast test for common case; meeting the same types together.
if( this == t ) return this; // Meeting same type-rep?
// Meeting TOP with anything?
if( _base == Top ) return t;
// Meeting BOTTOM with anything?
if( _base == Bottom ) return BOTTOM;
// Current "this->_base" is one of: Bad, Multi, Control, Top,
// Abio, Abstore, Floatxxx, Doublexxx, Bottom, lastype.
switch (t->base()) { // Switch on original type
// Cut in half the number of cases I must handle. Only need cases for when
// the given enum "t->type" is less than or equal to the local enum "type".
case FloatCon:
case DoubleCon:
case Int:
case Long:
return t->xmeet(this);
case OopPtr:
return t->xmeet(this);
case InstPtr:
return t->xmeet(this);
case MetadataPtr:
case KlassPtr:
return t->xmeet(this);
case AryPtr:
return t->xmeet(this);
case NarrowOop:
return t->xmeet(this);
case NarrowKlass:
return t->xmeet(this);
case Bad: // Type check
default: // Bogus type not in lattice
typerr(t);
return Type::BOTTOM;
case Bottom: // Ye Olde Default
return t;
case FloatTop:
if( _base == FloatTop ) return this;
case FloatBot: // Float
if( _base == FloatBot || _base == FloatTop ) return FLOAT;
if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM;
typerr(t);
return Type::BOTTOM;
case DoubleTop:
if( _base == DoubleTop ) return this;
case DoubleBot: // Double
if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE;
if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM;
typerr(t);
return Type::BOTTOM;
// These next few cases must match exactly or it is a compile-time error.
case Control: // Control of code
case Abio: // State of world outside of program
case Memory:
if( _base == t->_base ) return this;
typerr(t);
return Type::BOTTOM;
case Top: // Top of the lattice
return this;
}
// The type is unchanged
return this;
}
//-----------------------------filter------------------------------------------
const Type *Type::filter_helper(const Type *kills, bool include_speculative) const {
const Type* ft = join_helper(kills, include_speculative);
if (ft->empty())
return Type::TOP; // Canonical empty value
return ft;
}
//------------------------------xdual------------------------------------------
// Compute dual right now.
const Type::TYPES Type::dual_type[Type::lastype] = {
Bad, // Bad
Control, // Control
Bottom, // Top