comparison gen/classes.cpp @ 622:26fce59fe80a

Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested. Commented some logging calls that could potentially write out many megabytes of type dumps.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 01 Oct 2008 18:32:31 +0200
parents c9aa338280ed
children 8aebdf56c455
comparison
equal deleted inserted replaced
619:722630261d62 622:26fce59fe80a
92 if (cd->ir.resolved) return; 92 if (cd->ir.resolved) return;
93 cd->ir.resolved = true; 93 cd->ir.resolved = true;
94 94
95 Logger::println("DtoResolveClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars()); 95 Logger::println("DtoResolveClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
96 LOG_SCOPE; 96 LOG_SCOPE;
97
98 //printf("resolve class: %s\n", cd->toPrettyChars());
97 99
98 // get the TypeClass 100 // get the TypeClass
99 assert(cd->type->ty == Tclass); 101 assert(cd->type->ty == Tclass);
100 TypeClass* ts = (TypeClass*)cd->type; 102 TypeClass* ts = (TypeClass*)cd->type;
101 103
242 244
243 // set vtbl type 245 // set vtbl type
244 TypeClass* itc = (TypeClass*)id->type; 246 TypeClass* itc = (TypeClass*)id->type;
245 const LLType* ivtblTy = itc->ir.vtblType->get(); 247 const LLType* ivtblTy = itc->ir.vtblType->get();
246 assert(ivtblTy); 248 assert(ivtblTy);
247 Logger::cout() << "interface vtbl type: " << *ivtblTy << '\n'; 249 if (Logger::enabled())
250 Logger::cout() << "interface vtbl type: " << *ivtblTy << '\n';
248 fieldtypes.push_back(getPtrToType(ivtblTy)); 251 fieldtypes.push_back(getPtrToType(ivtblTy));
249 252
250 // fix the interface vtable type 253 // fix the interface vtable type
251 assert(iri->vtblTy == NULL); 254 assert(iri->vtblTy == NULL);
252 iri->vtblTy = new llvm::PATypeHolder(ivtblTy); 255 iri->vtblTy = new llvm::PATypeHolder(ivtblTy);
358 cd->ir.declared = true; 361 cd->ir.declared = true;
359 362
360 Logger::println("DtoDeclareClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars()); 363 Logger::println("DtoDeclareClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
361 LOG_SCOPE; 364 LOG_SCOPE;
362 365
366 //printf("declare class: %s\n", cd->toPrettyChars());
367
363 assert(cd->type->ty == Tclass); 368 assert(cd->type->ty == Tclass);
364 TypeClass* ts = (TypeClass*)cd->type; 369 TypeClass* ts = (TypeClass*)cd->type;
365 370
366 assert(cd->ir.irStruct); 371 assert(cd->ir.irStruct);
367 IrStruct* irstruct = cd->ir.irStruct; 372 IrStruct* irstruct = cd->ir.irStruct;
652 iinits.push_back(iri->info); 657 iinits.push_back(iri->info);
653 #endif 658 #endif
654 659
655 for (int k=1; k < b->vtbl.dim; k++) 660 for (int k=1; k < b->vtbl.dim; k++)
656 { 661 {
657 Logger::println("interface vtbl const init nr. %d", k); 662 // Logger::println("interface vtbl const init nr. %d", k);
658 Dsymbol* dsym = (Dsymbol*)b->vtbl.data[k]; 663 Dsymbol* dsym = (Dsymbol*)b->vtbl.data[k];
659 664
660 // error on unimplemented functions, error was already generated earlier 665 // error on unimplemented functions, error was already generated earlier
661 if(!dsym) 666 if(!dsym)
662 fatal(); 667 fatal();
672 #endif 677 #endif
673 678
674 // we have to bitcast, as the type created in ResolveClass expects a different this type 679 // we have to bitcast, as the type created in ResolveClass expects a different this type
675 c = llvm::ConstantExpr::getBitCast(c, targetTy); 680 c = llvm::ConstantExpr::getBitCast(c, targetTy);
676 iinits.push_back(c); 681 iinits.push_back(c);
677 Logger::cout() << "c: " << *c << '\n'; 682 // if (Logger::enabled())
683 // Logger::cout() << "c: " << *c << '\n';
678 } 684 }
679 685
680 #if OPAQUE_VTBLS 686 #if OPAQUE_VTBLS
681 Logger::cout() << "n: " << iinits.size() << " ivtbl_ty: " << *ivtbl_ty << '\n'; 687 // if (Logger::enabled())
688 // Logger::cout() << "n: " << iinits.size() << " ivtbl_ty: " << *ivtbl_ty << '\n';
682 LLConstant* civtblInit = llvm::ConstantArray::get(ivtbl_ty, iinits); 689 LLConstant* civtblInit = llvm::ConstantArray::get(ivtbl_ty, iinits);
683 iri->vtblInit = llvm::cast<llvm::ConstantArray>(civtblInit); 690 iri->vtblInit = llvm::cast<llvm::ConstantArray>(civtblInit);
684 #else 691 #else
685 LLConstant* civtblInit = llvm::ConstantStruct::get(ivtbl_ty, iinits); 692 LLConstant* civtblInit = llvm::ConstantStruct::get(ivtbl_ty, iinits);
686 iri->vtblInit = llvm::cast<llvm::ConstantStruct>(civtblInit); 693 iri->vtblInit = llvm::cast<llvm::ConstantStruct>(civtblInit);
823 LOG_SCOPE; 830 LOG_SCOPE;
824 DValue* thisval = newexp->thisexp->toElem(gIR); 831 DValue* thisval = newexp->thisexp->toElem(gIR);
825 size_t idx = 2 + tc->sym->vthis->ir.irField->index; 832 size_t idx = 2 + tc->sym->vthis->ir.irField->index;
826 LLValue* src = thisval->getRVal(); 833 LLValue* src = thisval->getRVal();
827 LLValue* dst = DtoGEPi(mem,0,idx,"tmp"); 834 LLValue* dst = DtoGEPi(mem,0,idx,"tmp");
828 Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n'; 835 if (Logger::enabled())
836 Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
829 DtoStore(src, dst); 837 DtoStore(src, dst);
830 } 838 }
831 // set the context for nested classes 839 // set the context for nested classes
832 else if (tc->sym->isNested() && tc->sym->vthis) 840 else if (tc->sym->isNested() && tc->sym->vthis)
833 { 841 {
1173 assert(fdecl->isVirtual());//fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())); 1181 assert(fdecl->isVirtual());//fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual()));
1174 assert(fdecl->vtblIndex > 0); 1182 assert(fdecl->vtblIndex > 0);
1175 assert(inst->getType()->toBasetype()->ty == Tclass); 1183 assert(inst->getType()->toBasetype()->ty == Tclass);
1176 1184
1177 LLValue* vthis = inst->getRVal(); 1185 LLValue* vthis = inst->getRVal();
1178 Logger::cout() << "vthis: " << *vthis << '\n'; 1186 if (Logger::enabled())
1187 Logger::cout() << "vthis: " << *vthis << '\n';
1179 1188
1180 LLValue* funcval; 1189 LLValue* funcval;
1181 funcval = DtoGEPi(vthis, 0, 0, "tmp"); 1190 funcval = DtoGEPi(vthis, 0, 0, "tmp");
1182 funcval = DtoLoad(funcval); 1191 funcval = DtoLoad(funcval);
1183 funcval = DtoGEPi(funcval, 0, fdecl->vtblIndex, fdecl->toPrettyChars()); 1192 funcval = DtoGEPi(funcval, 0, fdecl->vtblIndex, fdecl->toPrettyChars());
1184 funcval = DtoLoad(funcval); 1193 funcval = DtoLoad(funcval);
1185 1194
1186 Logger::cout() << "funcval: " << *funcval << '\n'; 1195 if (Logger::enabled())
1196 Logger::cout() << "funcval: " << *funcval << '\n';
1187 1197
1188 #if OPAQUE_VTBLS 1198 #if OPAQUE_VTBLS
1189 funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type))); 1199 funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type)));
1190 Logger::cout() << "funcval casted: " << *funcval << '\n'; 1200 if (Logger::enabled())
1201 Logger::cout() << "funcval casted: " << *funcval << '\n';
1191 #endif 1202 #endif
1192 1203
1193 return funcval; 1204 return funcval;
1194 } 1205 }
1195 1206