# HG changeset patch # User Tomas Lindquist Olsen # Date 1228102674 -3600 # Node ID 6c2ff06c42019b070b56dfb69ce6dd7faac853ad # Parent 8e6135be6999dee78267856658751f62645fdc35 Fixed a nasty bug with how interface vtables for class initializers were output, causing some class fields to be skipped. Fixed a problem in definition of ClassInfos where an invalid constant was potentially used. This needs to be looked into proper as it might happen again in the future. diff -r 8e6135be6999 -r 6c2ff06c4201 gen/classes.cpp --- a/gen/classes.cpp Mon Dec 01 02:10:16 2008 +0100 +++ b/gen/classes.cpp Mon Dec 01 04:37:54 2008 +0100 @@ -435,7 +435,7 @@ offsetbegin = init_class_initializer(inits, target, cd->baseClass, offsetbegin); } - Logger::println("adding data of %s to %s", cd->toChars(), target->toChars()); + Logger::println("adding data of %s to %s starting at %lu", cd->toChars(), target->toChars(), offsetbegin); LOG_SCOPE; // add default fields @@ -464,7 +464,7 @@ } else { - Logger::println(" skipped %s", var->toChars()); + Logger::println(" skipped %s at offset %u, current pos is %lu", var->toChars(), var->offset, lastoffset+lastsize); } } @@ -519,7 +519,7 @@ else // abstract impl inits.push_back(getNullPtr(getVoidPtrType())); - lastoffset += PTRSIZE; + lastoffset += lastsize; lastsize = PTRSIZE; } @@ -749,6 +749,7 @@ init_class_interface_vtbl_initializers(cd); // build constant from inits + assert(!irstruct->constInit); irstruct->constInit = LLConstantStruct::get(inits); // classes are never packed // refine __initZ global type to the one of the initializer @@ -1437,7 +1438,7 @@ assert(ir->classInfo); TypeClass* cdty = (TypeClass*)cd->type; - if (!cd->isInterfaceDeclaration() && !cd->isAbstract()) + if (!cd->isInterfaceDeclaration()) { assert(ir->init); assert(ir->constInit); @@ -1450,7 +1451,6 @@ ClassDeclaration* cinfo = ClassDeclaration::classinfo; DtoForceConstInitDsymbol(cinfo); - assert(cinfo->ir.irStruct->constInit); LLConstant* c; @@ -1473,7 +1473,7 @@ { c = DtoBitCast(ir->init, voidPtr); //Logger::cout() << *ir->constInit->getType() << std::endl; - size_t initsz = getABITypeSize(ir->constInit->getType()); + size_t initsz = getABITypeSize(ir->init->getType()->getContainedType(0)); c = DtoConstSlice(DtoConstSize_t(initsz), c); } inits.push_back(c); diff -r 8e6135be6999 -r 6c2ff06c4201 gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Mon Dec 01 02:10:16 2008 +0100 +++ b/gen/llvmhelpers.cpp Mon Dec 01 04:37:54 2008 +0100 @@ -1005,6 +1005,7 @@ // refine the global's opaque type to the type of the initializer llvm::cast(glob->type.get())->refineAbstractTypeTo(initVal->getType()); + assert(!glob->constInit); glob->constInit = initVal; bool istempl = false; diff -r 8e6135be6999 -r 6c2ff06c4201 gen/structs.cpp --- a/gen/structs.cpp Mon Dec 01 02:10:16 2008 +0100 +++ b/gen/structs.cpp Mon Dec 01 04:37:54 2008 +0100 @@ -467,6 +467,7 @@ const llvm::StructType* structtype = isaStruct(sd->type->ir.type->get()); // always generate the constant initalizer + assert(!irstruct->constInit); if (sd->zeroInit) { Logger::println("Zero initialized");