mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Keep _d_newclass() semantics, re-introduce _d_allocclass() instead
And use that one in DtoNewClass(), keeping 3rd party code from breaking.
This commit is contained in:
parent
97921fbb8d
commit
a5e5bd1716
6 changed files with 20 additions and 6 deletions
|
@ -192,6 +192,14 @@ else
|
||||||
return cast(Object)p;
|
return cast(Object)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version (LDC)
|
||||||
|
{
|
||||||
|
extern (C) Object _d_allocclass(const ClassInfo ci) nothrow
|
||||||
|
{
|
||||||
|
return cast(Object)allocmemory(ci.init.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern (C) void* _d_newitemT(TypeInfo ti) nothrow
|
extern (C) void* _d_newitemT(TypeInfo ti) nothrow
|
||||||
{
|
{
|
||||||
auto p = allocmemory(ti.tsize);
|
auto p = allocmemory(ti.tsize);
|
||||||
|
|
|
@ -84,8 +84,8 @@ DValue *DtoNewClass(Loc &loc, TypeClass *tc, NewExp *newexp) {
|
||||||
// allocate
|
// allocate
|
||||||
LLValue *mem;
|
LLValue *mem;
|
||||||
if (newexp->onstack) {
|
if (newexp->onstack) {
|
||||||
// FIXME align scope class to its largest member
|
mem = DtoRawAlloca(DtoType(tc)->getContainedType(0), DtoAlignment(tc),
|
||||||
mem = DtoRawAlloca(DtoType(tc)->getContainedType(0), 0, ".newclass_alloca");
|
".newclass_alloca");
|
||||||
}
|
}
|
||||||
// custom allocator
|
// custom allocator
|
||||||
else if (newexp->allocator) {
|
else if (newexp->allocator) {
|
||||||
|
@ -97,7 +97,7 @@ DValue *DtoNewClass(Loc &loc, TypeClass *tc, NewExp *newexp) {
|
||||||
// default allocator
|
// default allocator
|
||||||
else {
|
else {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn =
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_newclass");
|
getRuntimeFunction(loc, gIR->module, "_d_allocclass");
|
||||||
LLConstant *ci = DtoBitCast(getIrAggr(tc->sym)->getClassInfoSymbol(),
|
LLConstant *ci = DtoBitCast(getIrAggr(tc->sym)->getClassInfoSymbol(),
|
||||||
DtoType(Type::typeinfoclass->type));
|
DtoType(Type::typeinfoclass->type));
|
||||||
mem =
|
mem =
|
||||||
|
|
|
@ -255,7 +255,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FunctionInfo for _d_newclass
|
// FunctionInfo for _d_allocclass
|
||||||
class AllocClassFI : public FunctionInfo {
|
class AllocClassFI : public FunctionInfo {
|
||||||
public:
|
public:
|
||||||
bool analyze(CallSite CS, const Analysis &A) override {
|
bool analyze(CallSite CS, const Analysis &A) override {
|
||||||
|
@ -436,7 +436,7 @@ GarbageCollect2Stack::GarbageCollect2Stack()
|
||||||
KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT;
|
KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT;
|
||||||
KnownFunctions["_d_newarrayU"] = &NewArrayU;
|
KnownFunctions["_d_newarrayU"] = &NewArrayU;
|
||||||
KnownFunctions["_d_newarrayT"] = &NewArrayT;
|
KnownFunctions["_d_newarrayT"] = &NewArrayT;
|
||||||
KnownFunctions["_d_newclass"] = &AllocClass;
|
KnownFunctions["_d_allocclass"] = &AllocClass;
|
||||||
KnownFunctions["_d_allocmemory"] = &AllocMemory;
|
KnownFunctions["_d_allocmemory"] = &AllocMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,6 +372,7 @@ void SimplifyDRuntimeCalls::InitOptimizations() {
|
||||||
Optimizations["_d_newarraymiT"] = &Allocation;
|
Optimizations["_d_newarraymiT"] = &Allocation;
|
||||||
Optimizations["_d_newarraymvT"] = &Allocation;
|
Optimizations["_d_newarraymvT"] = &Allocation;
|
||||||
Optimizations["_d_newclass"] = &Allocation;
|
Optimizations["_d_newclass"] = &Allocation;
|
||||||
|
Optimizations["_d_allocclass"] = &Allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// runOnFunction - Top level algorithm.
|
/// runOnFunction - Top level algorithm.
|
||||||
|
|
|
@ -85,6 +85,7 @@ static void checkForImplicitGCCall(const Loc &loc, const char *name) {
|
||||||
"_d_newarraymiTX",
|
"_d_newarraymiTX",
|
||||||
"_d_newarrayU",
|
"_d_newarrayU",
|
||||||
"_d_newclass",
|
"_d_newclass",
|
||||||
|
"_d_allocclass",
|
||||||
"_d_newitemT",
|
"_d_newitemT",
|
||||||
"_d_newitemiT",
|
"_d_newitemiT",
|
||||||
};
|
};
|
||||||
|
@ -397,6 +398,10 @@ static void buildRuntimeModule() {
|
||||||
createFwdDecl(LINKc, objectTy, {"_d_newclass"}, {classInfoTy}, {STCconst},
|
createFwdDecl(LINKc, objectTy, {"_d_newclass"}, {classInfoTy}, {STCconst},
|
||||||
Attr_NoAlias);
|
Attr_NoAlias);
|
||||||
|
|
||||||
|
// Object _d_allocclass(const ClassInfo ci)
|
||||||
|
createFwdDecl(LINKc, objectTy, {"_d_allocclass"}, {classInfoTy}, {STCconst},
|
||||||
|
Attr_NoAlias);
|
||||||
|
|
||||||
// void* _d_newitemT (TypeInfo ti)
|
// void* _d_newitemT (TypeInfo ti)
|
||||||
// void* _d_newitemiT(TypeInfo ti)
|
// void* _d_newitemiT(TypeInfo ti)
|
||||||
createFwdDecl(LINKc, voidPtrTy, {"_d_newitemT", "_d_newitemiT"}, {typeInfoTy},
|
createFwdDecl(LINKc, voidPtrTy, {"_d_newitemT", "_d_newitemiT"}, {typeInfoTy},
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5c5dd37e433afdb5b1f2cd33f170014cdd96312a
|
Subproject commit 0aeb4da53e922f7d17401dd13f69b8e355f327f9
|
Loading…
Add table
Add a link
Reference in a new issue