@@ -201,12 +201,12 @@ static void logPerfFunction(Proto* p, uintptr_t addr, unsigned size)
201201}
202202
203203template <typename AssemblyBuilder>
204- static std::optional<OldNativeProto> createNativeFunction (
205- AssemblyBuilder& build, ModuleHelpers& helpers, Proto* proto, uint32_t & totalIrInstCount , CodeGenCompilationResult& result)
204+ static std::optional<OldNativeProto> createNativeFunction (AssemblyBuilder& build, ModuleHelpers& helpers, Proto* proto, uint32_t & totalIrInstCount,
205+ const HostIrHooks& hooks , CodeGenCompilationResult& result)
206206{
207207 CODEGEN_ASSERT (!FFlag::LuauCodegenContext);
208208
209- IrBuilder ir;
209+ IrBuilder ir (hooks) ;
210210 ir.buildFunctionIr (proto);
211211
212212 unsigned instCount = unsigned (ir.function .instructions .size ());
@@ -476,7 +476,7 @@ void setNativeExecutionEnabled(lua_State* L, bool enabled)
476476 }
477477}
478478
479- static CompilationResult compile_OLD (lua_State* L, int idx, unsigned int flags , CompilationStats* stats)
479+ static CompilationResult compile_OLD (lua_State* L, int idx, const CompilationOptions& options , CompilationStats* stats)
480480{
481481 CompilationResult compilationResult;
482482
@@ -485,7 +485,7 @@ static CompilationResult compile_OLD(lua_State* L, int idx, unsigned int flags,
485485
486486 Proto* root = clvalue (func)->l .p ;
487487
488- if ((flags & CodeGen_OnlyNativeModules) != 0 && (root->flags & LPF_NATIVE_MODULE) == 0 )
488+ if ((options. flags & CodeGen_OnlyNativeModules) != 0 && (root->flags & LPF_NATIVE_MODULE) == 0 )
489489 {
490490 compilationResult.result = CodeGenCompilationResult::NotNativeModule;
491491 return compilationResult;
@@ -500,7 +500,7 @@ static CompilationResult compile_OLD(lua_State* L, int idx, unsigned int flags,
500500 }
501501
502502 std::vector<Proto*> protos;
503- gatherFunctions (protos, root, flags);
503+ gatherFunctions (protos, root, options. flags );
504504
505505 // Skip protos that have been compiled during previous invocations of CodeGen::compile
506506 protos.erase (std::remove_if (protos.begin (), protos.end (),
@@ -541,7 +541,7 @@ static CompilationResult compile_OLD(lua_State* L, int idx, unsigned int flags,
541541 {
542542 CodeGenCompilationResult protoResult = CodeGenCompilationResult::Success;
543543
544- if (std::optional<OldNativeProto> np = createNativeFunction (build, helpers, p, totalIrInstCount, protoResult))
544+ if (std::optional<OldNativeProto> np = createNativeFunction (build, helpers, p, totalIrInstCount, options. hooks , protoResult))
545545 results.push_back (*np);
546546 else
547547 compilationResult.protoFailures .push_back ({protoResult, p->debugname ? getstr (p->debugname ) : " " , p->linedefined });
@@ -618,21 +618,43 @@ static CompilationResult compile_OLD(lua_State* L, int idx, unsigned int flags,
618618
619619CompilationResult compile (lua_State* L, int idx, unsigned int flags, CompilationStats* stats)
620620{
621+ Luau::CodeGen::CompilationOptions options{flags};
622+
621623 if (FFlag::LuauCodegenContext)
622624 {
623- return compile_NEW (L, idx, flags , stats);
625+ return compile_NEW (L, idx, options , stats);
624626 }
625627 else
626628 {
627- return compile_OLD (L, idx, flags , stats);
629+ return compile_OLD (L, idx, options , stats);
628630 }
629631}
630632
631633CompilationResult compile (const ModuleId& moduleId, lua_State* L, int idx, unsigned int flags, CompilationStats* stats)
632634{
633635 CODEGEN_ASSERT (FFlag::LuauCodegenContext);
634636
635- return compile_NEW (moduleId, L, idx, flags, stats);
637+ Luau::CodeGen::CompilationOptions options{flags};
638+ return compile_NEW (moduleId, L, idx, options, stats);
639+ }
640+
641+ CompilationResult compile (lua_State* L, int idx, const CompilationOptions& options, CompilationStats* stats)
642+ {
643+ if (FFlag::LuauCodegenContext)
644+ {
645+ return compile_NEW (L, idx, options, stats);
646+ }
647+ else
648+ {
649+ return compile_OLD (L, idx, options, stats);
650+ }
651+ }
652+
653+ CompilationResult compile (const ModuleId& moduleId, lua_State* L, int idx, const CompilationOptions& options, CompilationStats* stats)
654+ {
655+ CODEGEN_ASSERT (FFlag::LuauCodegenContext);
656+
657+ return compile_NEW (moduleId, L, idx, options, stats);
636658}
637659
638660void setPerfLog (void * context, PerfLogFn logFn)
0 commit comments