Skip to content

Commit ca21398

Browse files
committed
Add preoptimize() method to CompilerContext
1 parent c43c5fe commit ca21398

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

include/scratchcpp/dev/compilercontext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class LIBSCRATCHCPP_EXPORT CompilerContext
2323
IEngine *engine() const;
2424
Target *target() const;
2525

26+
/*!
27+
* Optimizes compiled scripts ahead of time.
28+
* \see Compiler#preoptimize()
29+
*/
30+
virtual void preoptimize() { }
31+
2632
private:
2733
spimpl::unique_impl_ptr<CompilerContextPrivate> impl;
2834
};

src/dev/engine/internal/llvm/llvmcompilercontext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ LLVMCompilerContext::LLVMCompilerContext(IEngine *engine, Target *target) :
2424
}
2525
}
2626

27+
void LLVMCompilerContext::preoptimize()
28+
{
29+
initJit();
30+
}
31+
2732
llvm::LLVMContext *LLVMCompilerContext::llvmCtx()
2833
{
2934
return m_llvmCtxPtr;

src/dev/engine/internal/llvm/llvmcompilercontext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class LLVMCompilerContext : public CompilerContext
2020
public:
2121
LLVMCompilerContext(IEngine *engine, Target *target);
2222

23+
void preoptimize() override;
24+
2325
llvm::LLVMContext *llvmCtx();
2426
llvm::Module *module();
2527

0 commit comments

Comments
 (0)