mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 03:46:02 +03:00
rename rtCompileProcess() to compileDynamicCode()
This commit is contained in:
parent
6aa5a8e5a2
commit
5bb48d84c4
14 changed files with 21 additions and 35 deletions
|
@ -243,7 +243,7 @@ void rtCompileProcessImplSoInternal(const RtComileModuleList* modlist_head, cons
|
|||
SymMap symMap;
|
||||
OptimizerSettings settings;
|
||||
settings.optLevel = context.optLevel;
|
||||
settings.sizeLeve = context.sizeLeve;
|
||||
settings.sizeLevel = context.sizeLevel;
|
||||
while (nullptr != current) {
|
||||
interruptPoint(context, "load IR");
|
||||
auto buff = llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(current->irData, current->irDataSize), "", false);
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef void (*DumpHandlerT)(void*, const char* str, std::size_t len);
|
|||
struct Context final
|
||||
{
|
||||
unsigned optLevel = 0;
|
||||
unsigned sizeLeve = 0;
|
||||
unsigned sizeLevel = 0;
|
||||
InterruptPointHandlerT interruptPointHandler = nullptr;
|
||||
void* interruptPointHandlerData = nullptr;
|
||||
FatalHandlerT fatalHandler = nullptr;
|
||||
|
|
|
@ -124,7 +124,7 @@ void setupPasses(llvm::TargetMachine &targetMachine,
|
|||
mpm.add(llvm::createStripDeadPrototypesPass());
|
||||
mpm.add(llvm::createStripDeadDebugInfoPass());
|
||||
|
||||
addOptimizationPasses(mpm, fpm, settings.optLevel, settings.sizeLeve);
|
||||
addOptimizationPasses(mpm, fpm, settings.optLevel, settings.sizeLevel);
|
||||
}
|
||||
|
||||
struct FuncFinalizer final {
|
||||
|
|
|
@ -16,7 +16,7 @@ struct Context;
|
|||
|
||||
struct OptimizerSettings final {
|
||||
unsigned optLevel = 0;
|
||||
unsigned sizeLeve = 0;
|
||||
unsigned sizeLevel = 0;
|
||||
};
|
||||
|
||||
void optimizeModule(const Context &context,
|
||||
|
|
|
@ -6,31 +6,17 @@ version(LDC_RuntimeCompilation)
|
|||
struct CompilerSettings
|
||||
{
|
||||
uint optLevel = 0;
|
||||
uint sizeLeve = 0;
|
||||
void delegate(const char*,const char*) interruptHandler = null;
|
||||
void delegate(const char*) fatalHandler = null;
|
||||
uint sizeLevel = 0;
|
||||
void delegate(in char[]) dumpHandler = null;
|
||||
}
|
||||
|
||||
void rtCompileProcess(in CompilerSettings settings = CompilerSettings.init)
|
||||
void compileDynamicCode(in CompilerSettings settings = CompilerSettings.init)
|
||||
{
|
||||
Context context;
|
||||
context.optLevel = settings.optLevel;
|
||||
context.sizeLeve = settings.sizeLeve;
|
||||
if (settings.interruptHandler !is null)
|
||||
{
|
||||
context.interruptPointHandler = &delegateWrapper!(const char*,const char*);
|
||||
context.interruptPointHandlerData = cast(void*)&settings.interruptHandler;
|
||||
}
|
||||
if (settings.fatalHandler !is null)
|
||||
{
|
||||
context.fatalHandler = &delegateWrapper!(const char*);
|
||||
context.fatalHandlerData = cast(void*)&settings.fatalHandler;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.sizeLevel = settings.sizeLevel;
|
||||
|
||||
context.fatalHandler = &defaultFatalHandler;
|
||||
}
|
||||
if (settings.dumpHandler !is null)
|
||||
{
|
||||
context.dumpHandler = &delegateWrapper!(const char*, size_t);
|
||||
|
@ -54,7 +40,7 @@ void delegateWrapper(T...)(void* context, T params)
|
|||
void defaultFatalHandler(void*, const char* reason)
|
||||
{
|
||||
import std.conv;
|
||||
throw new Exception(reason.text.idup);
|
||||
throw new Error(reason.text.idup);
|
||||
}
|
||||
|
||||
// must be synchronized with cpp
|
||||
|
@ -62,7 +48,7 @@ align(1) struct Context
|
|||
{
|
||||
align(1):
|
||||
uint optLevel = 0;
|
||||
uint sizeLeve = 0;
|
||||
uint sizeLevel = 0;
|
||||
void function(void*, const char*, const char*) interruptPointHandler = null;
|
||||
void* interruptPointHandlerData = null;
|
||||
void function(void*, const char*) fatalHandler = null;
|
||||
|
|
|
@ -22,7 +22,7 @@ __gshared int[555] arr2 = 42;
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(42 == foo());
|
||||
assert(0 == bar());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void main(string[] args)
|
|||
auto fun = &f1.foo;
|
||||
f1.val = 42;
|
||||
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(42 == f1.foo());
|
||||
assert(42 == f2.foo());
|
||||
assert(42 == fun());
|
||||
|
|
|
@ -15,7 +15,7 @@ void main(string[] args)
|
|||
bool dumpHandlerCalled = false;
|
||||
CompilerSettings settings;
|
||||
settings.dumpHandler = ((a) { dumpHandlerCalled = true; });
|
||||
rtCompileProcess(settings);
|
||||
compileDynamicCode(settings);
|
||||
assert(5 == foo());
|
||||
assert(dumpHandlerCalled);
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ import ldc.runtimecompile;
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(0 == foo());
|
||||
foovar = 42;
|
||||
assert(0 == foo());
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(42 == foo());
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ void test(T,F)(ref T val, F fun)
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
|
||||
test(i8, &foo_i8);
|
||||
test(i16, &foo_i16);
|
||||
|
|
|
@ -18,7 +18,7 @@ void main(string[] args)
|
|||
return val1;
|
||||
}
|
||||
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(42 == foo());
|
||||
assert(5 == bar());
|
||||
assert(8 == val2);
|
||||
|
|
|
@ -30,7 +30,7 @@ static assert(false, "LDC_RuntimeCompilation is not defined");
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(5 == foo());
|
||||
assert(12 == bar());
|
||||
baz();
|
||||
|
|
|
@ -20,7 +20,7 @@ void bar()
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
bar();
|
||||
Thread[] threads = [new Thread(&bar),new Thread(&bar),new Thread(&bar)];
|
||||
foreach(t;threads[])
|
||||
|
|
|
@ -38,7 +38,7 @@ import ldc.runtimecompile;
|
|||
|
||||
void main(string[] args)
|
||||
{
|
||||
rtCompileProcess();
|
||||
compileDynamicCode();
|
||||
assert(collectExceptionMsg(foo()) == "foo");
|
||||
assert(42 == bar());
|
||||
assert(42 == baz());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue