11
11
12
12
#include < algorithm>
13
13
14
- #include < algorithm>
15
-
16
14
LUAU_FASTFLAG (LuauCodegenDirectUserdataFlow)
17
15
LUAU_FASTFLAG(LuauLoadTypeInfo) // Because new VM typeinfo load changes the format used by Codegen, same flag is used
18
16
LUAU_FASTFLAGVARIABLE(LuauCodegenTypeInfo, false ) // New analysis is flagged separately
19
- LUAU_FASTFLAG(LuauTypeInfoLookupImprovement)
20
- LUAU_FASTFLAGVARIABLE(LuauCodegenVectorMispredictFix, false )
21
17
LUAU_FASTFLAGVARIABLE(LuauCodegenAnalyzeHostVectorOps, false )
22
18
LUAU_FASTFLAGVARIABLE(LuauCodegenLoadTypeUpvalCheck, false )
23
19
@@ -70,21 +66,13 @@ void loadBytecodeTypeInfo(IrFunction& function)
70
66
71
67
Proto* proto = function.proto ;
72
68
73
- if (FFlag::LuauTypeInfoLookupImprovement)
74
- {
75
- if (!proto)
76
- return ;
77
- }
78
- else
79
- {
80
- if (!proto || !proto->typeinfo )
81
- return ;
82
- }
69
+ if (!proto)
70
+ return ;
83
71
84
72
BytecodeTypeInfo& typeInfo = function.bcTypeInfo ;
85
73
86
74
// If there is no typeinfo, we generate default values for arguments and upvalues
87
- if (FFlag::LuauTypeInfoLookupImprovement && !proto->typeinfo )
75
+ if (!proto->typeinfo )
88
76
{
89
77
typeInfo.argumentTypes .resize (proto->numparams , LBC_TYPE_ANY);
90
78
typeInfo.upvalueTypes .resize (proto->nups , LBC_TYPE_ANY);
@@ -152,8 +140,6 @@ void loadBytecodeTypeInfo(IrFunction& function)
152
140
153
141
static void prepareRegTypeInfoLookups (BytecodeTypeInfo& typeInfo)
154
142
{
155
- CODEGEN_ASSERT (FFlag::LuauTypeInfoLookupImprovement);
156
-
157
143
// Sort by register first, then by end PC
158
144
std::sort (typeInfo.regTypes .begin (), typeInfo.regTypes .end (), [](const BytecodeRegTypeInfo& a, const BytecodeRegTypeInfo& b) {
159
145
if (a.reg != b.reg )
@@ -188,39 +174,26 @@ static BytecodeRegTypeInfo* findRegType(BytecodeTypeInfo& info, uint8_t reg, int
188
174
{
189
175
CODEGEN_ASSERT (FFlag::LuauCodegenTypeInfo);
190
176
191
- if (FFlag::LuauTypeInfoLookupImprovement)
192
- {
193
- auto b = info.regTypes .begin () + info.regTypeOffsets [reg];
194
- auto e = info.regTypes .begin () + info.regTypeOffsets [reg + 1 ];
195
-
196
- // Doen't have info
197
- if (b == e)
198
- return nullptr ;
177
+ auto b = info.regTypes .begin () + info.regTypeOffsets [reg];
178
+ auto e = info.regTypes .begin () + info.regTypeOffsets [reg + 1 ];
199
179
200
- // No info after the last live range
201
- if (pc >= (e - 1 )->endpc )
202
- return nullptr ;
203
-
204
- for (auto it = b; it != e; ++it)
205
- {
206
- CODEGEN_ASSERT (it->reg == reg);
207
-
208
- if (pc >= it->startpc && pc < it->endpc )
209
- return &*it;
210
- }
180
+ // Doen't have info
181
+ if (b == e)
182
+ return nullptr ;
211
183
184
+ // No info after the last live range
185
+ if (pc >= (e - 1 )->endpc )
212
186
return nullptr ;
213
- }
214
- else
187
+
188
+ for ( auto it = b; it != e; ++it)
215
189
{
216
- for (BytecodeRegTypeInfo& el : info.regTypes )
217
- {
218
- if (reg == el.reg && pc >= el.startpc && pc < el.endpc )
219
- return ⪙
220
- }
190
+ CODEGEN_ASSERT (it->reg == reg);
221
191
222
- return nullptr ;
192
+ if (pc >= it->startpc && pc < it->endpc )
193
+ return &*it;
223
194
}
195
+
196
+ return nullptr ;
224
197
}
225
198
226
199
static void refineRegType (BytecodeTypeInfo& info, uint8_t reg, int pc, uint8_t ty)
@@ -235,7 +208,7 @@ static void refineRegType(BytecodeTypeInfo& info, uint8_t reg, int pc, uint8_t t
235
208
if (regType->type == LBC_TYPE_ANY)
236
209
regType->type = ty;
237
210
}
238
- else if (FFlag::LuauTypeInfoLookupImprovement && reg < info.argumentTypes .size ())
211
+ else if (reg < info.argumentTypes .size ())
239
212
{
240
213
if (info.argumentTypes [reg] == LBC_TYPE_ANY)
241
214
info.argumentTypes [reg] = ty;
@@ -629,8 +602,7 @@ void analyzeBytecodeTypes(IrFunction& function, const HostIrHooks& hostHooks)
629
602
630
603
BytecodeTypeInfo& bcTypeInfo = function.bcTypeInfo ;
631
604
632
- if (FFlag::LuauTypeInfoLookupImprovement)
633
- prepareRegTypeInfoLookups (bcTypeInfo);
605
+ prepareRegTypeInfoLookups (bcTypeInfo);
634
606
635
607
// Setup our current knowledge of type tags based on arguments
636
608
uint8_t regTags[256 ];
@@ -788,32 +760,22 @@ void analyzeBytecodeTypes(IrFunction& function, const HostIrHooks& hostHooks)
788
760
789
761
regTags[ra] = LBC_TYPE_ANY;
790
762
791
- if (FFlag::LuauCodegenVectorMispredictFix )
763
+ if (bcType. a == LBC_TYPE_VECTOR )
792
764
{
793
- if (bcType.a == LBC_TYPE_VECTOR)
794
- {
795
- TString* str = gco2ts (function.proto ->k [kc].value .gc );
796
- const char * field = getstr (str);
797
-
798
- if (str->len == 1 )
799
- {
800
- // Same handling as LOP_GETTABLEKS block in lvmexecute.cpp - case-insensitive comparison with "X" / "Y" / "Z"
801
- char ch = field[0 ] | ' ' ;
765
+ TString* str = gco2ts (function.proto ->k [kc].value .gc );
766
+ const char * field = getstr (str);
802
767
803
- if (ch == ' x' || ch == ' y' || ch == ' z' )
804
- regTags[ra] = LBC_TYPE_NUMBER;
805
- }
768
+ if (str->len == 1 )
769
+ {
770
+ // Same handling as LOP_GETTABLEKS block in lvmexecute.cpp - case-insensitive comparison with "X" / "Y" / "Z"
771
+ char ch = field[0 ] | ' ' ;
806
772
807
- if (FFlag::LuauCodegenAnalyzeHostVectorOps && regTags[ra] == LBC_TYPE_ANY && hostHooks. vectorAccessBytecodeType )
808
- regTags[ra] = hostHooks. vectorAccessBytecodeType (field, str-> len ) ;
773
+ if (ch == ' x ' || ch == ' y ' || ch == ' z ' )
774
+ regTags[ra] = LBC_TYPE_NUMBER ;
809
775
}
810
- }
811
- else
812
- {
813
- // Assuming that vector component is being indexed
814
- // TODO: check what key is used
815
- if (bcType.a == LBC_TYPE_VECTOR)
816
- regTags[ra] = LBC_TYPE_NUMBER;
776
+
777
+ if (FFlag::LuauCodegenAnalyzeHostVectorOps && regTags[ra] == LBC_TYPE_ANY && hostHooks.vectorAccessBytecodeType )
778
+ regTags[ra] = hostHooks.vectorAccessBytecodeType (field, str->len );
817
779
}
818
780
819
781
bcType.result = regTags[ra];
0 commit comments