1111
1212#include < algorithm>
1313
14- #include < algorithm>
15-
1614LUAU_FASTFLAG (LuauCodegenDirectUserdataFlow)
1715LUAU_FASTFLAG(LuauLoadTypeInfo) // Because new VM typeinfo load changes the format used by Codegen, same flag is used
1816LUAU_FASTFLAGVARIABLE(LuauCodegenTypeInfo, false ) // New analysis is flagged separately
19- LUAU_FASTFLAG(LuauTypeInfoLookupImprovement)
20- LUAU_FASTFLAGVARIABLE(LuauCodegenVectorMispredictFix, false )
2117LUAU_FASTFLAGVARIABLE(LuauCodegenAnalyzeHostVectorOps, false )
2218LUAU_FASTFLAGVARIABLE(LuauCodegenLoadTypeUpvalCheck, false )
2319
@@ -70,21 +66,13 @@ void loadBytecodeTypeInfo(IrFunction& function)
7066
7167 Proto* proto = function.proto ;
7268
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 ;
8371
8472 BytecodeTypeInfo& typeInfo = function.bcTypeInfo ;
8573
8674 // If there is no typeinfo, we generate default values for arguments and upvalues
87- if (FFlag::LuauTypeInfoLookupImprovement && !proto->typeinfo )
75+ if (!proto->typeinfo )
8876 {
8977 typeInfo.argumentTypes .resize (proto->numparams , LBC_TYPE_ANY);
9078 typeInfo.upvalueTypes .resize (proto->nups , LBC_TYPE_ANY);
@@ -152,8 +140,6 @@ void loadBytecodeTypeInfo(IrFunction& function)
152140
153141static void prepareRegTypeInfoLookups (BytecodeTypeInfo& typeInfo)
154142{
155- CODEGEN_ASSERT (FFlag::LuauTypeInfoLookupImprovement);
156-
157143 // Sort by register first, then by end PC
158144 std::sort (typeInfo.regTypes .begin (), typeInfo.regTypes .end (), [](const BytecodeRegTypeInfo& a, const BytecodeRegTypeInfo& b) {
159145 if (a.reg != b.reg )
@@ -188,39 +174,26 @@ static BytecodeRegTypeInfo* findRegType(BytecodeTypeInfo& info, uint8_t reg, int
188174{
189175 CODEGEN_ASSERT (FFlag::LuauCodegenTypeInfo);
190176
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 ];
199179
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 ;
211183
184+ // No info after the last live range
185+ if (pc >= (e - 1 )->endpc )
212186 return nullptr ;
213- }
214- else
187+
188+ for ( auto it = b; it != e; ++it)
215189 {
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);
221191
222- return nullptr ;
192+ if (pc >= it->startpc && pc < it->endpc )
193+ return &*it;
223194 }
195+
196+ return nullptr ;
224197}
225198
226199static 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
235208 if (regType->type == LBC_TYPE_ANY)
236209 regType->type = ty;
237210 }
238- else if (FFlag::LuauTypeInfoLookupImprovement && reg < info.argumentTypes .size ())
211+ else if (reg < info.argumentTypes .size ())
239212 {
240213 if (info.argumentTypes [reg] == LBC_TYPE_ANY)
241214 info.argumentTypes [reg] = ty;
@@ -629,8 +602,7 @@ void analyzeBytecodeTypes(IrFunction& function, const HostIrHooks& hostHooks)
629602
630603 BytecodeTypeInfo& bcTypeInfo = function.bcTypeInfo ;
631604
632- if (FFlag::LuauTypeInfoLookupImprovement)
633- prepareRegTypeInfoLookups (bcTypeInfo);
605+ prepareRegTypeInfoLookups (bcTypeInfo);
634606
635607 // Setup our current knowledge of type tags based on arguments
636608 uint8_t regTags[256 ];
@@ -788,32 +760,22 @@ void analyzeBytecodeTypes(IrFunction& function, const HostIrHooks& hostHooks)
788760
789761 regTags[ra] = LBC_TYPE_ANY;
790762
791- if (FFlag::LuauCodegenVectorMispredictFix )
763+ if (bcType. a == LBC_TYPE_VECTOR )
792764 {
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);
802767
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 ] | ' ' ;
806772
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 ;
809775 }
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 );
817779 }
818780
819781 bcType.result = regTags[ra];
0 commit comments