Changeset 395
- Timestamp:
- 02/21/10 21:21:56 (2 years ago)
- Files:
-
- trunk/src/backend/rtlsym.h (modified) (1 diff)
- trunk/src/glue.c (modified) (2 diffs)
- trunk/src/module.h (modified) (1 diff)
- trunk/src/s2ir.c (modified) (1 diff)
- trunk/src/toobj.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/backend/rtlsym.h
r251 r395 30 30 #define SYMBOL_SCPP_TX86(e, fl, saved, n, flags, ty) SYMBOL_Z(e,fl,saved,n,flags,ty) 31 31 #else 32 32 #define SYMBOL_SCPP_TX86(e, fl, saved, n, flags, ty) 33 33 #endif 34 34 35 35 #if MARS 36 36 #define SYMBOL_MARS(e, fl, saved, n, flags, ty) SYMBOL_Z(e,fl,saved,n,flags,ty) 37 37 #else 38 38 #define SYMBOL_MARS(e, fl, saved, n, flags, ty) 39 39 #endif 40 40 41 41 42 42 #define RTLSYMS \ 43 43 \ 44 44 SYMBOL_MARS(THROW, FLfunc,(mES | mBP),"_d_throw@4", SFLexit, tw) \ 45 45 SYMBOL_MARS(MONITOR_HANDLER, FLfunc,FREGSAVED,"_d_monitor_handler", 0, 0) \ 46 46 SYMBOL_MARS(MONITOR_PROLOG, FLfunc,FREGSAVED,"_d_monitor_prolog",0,t) \ 47 47 SYMBOL_MARS(MONITOR_EPILOG, FLfunc,FREGSAVED,"_d_monitor_epilog",0,t) \ 48 48 SYMBOL_MARS(DCOVER, FLfunc,FREGSAVED,"_d_cover_register", 0, t) \ 49 49 SYMBOL_MARS(DASSERT, FLfunc,FREGSAVED,"_d_assert", SFLexit, t) \ 50 SYMBOL_MARS(DASSERTM, FLfunc,FREGSAVED,"_d_assertm", SFLexit, t) \ 50 51 SYMBOL_MARS(DASSERT_MSG, FLfunc,FREGSAVED,"_d_assert_msg", SFLexit, t) \ 51 52 SYMBOL_MARS(DARRAY, FLfunc,FREGSAVED,"_d_array_bounds", SFLexit, t) \ 52 53 SYMBOL_MARS(DINVARIANT, FLfunc,FREGSAVED,"D9invariant12_d_invariantFC6ObjectZv", 0, tsdlib) \ 53 54 SYMBOL_MARS(_DINVARIANT, FLfunc,FREGSAVED,"_D9invariant12_d_invariantFC6ObjectZv", 0, tsdlib) \ 54 55 SYMBOL_MARS(MEMCPY, FLfunc,FREGSAVED,"memcpy", 0, t) \ 55 56 SYMBOL_MARS(MEMSET8, FLfunc,FREGSAVED,"memset", 0, t) \ 56 57 SYMBOL_MARS(MEMSET16, FLfunc,FREGSAVED,"_memset16", 0, t) \ 57 58 SYMBOL_MARS(MEMSET32, FLfunc,FREGSAVED,"_memset32", 0, t) \ 58 59 SYMBOL_MARS(MEMSET64, FLfunc,FREGSAVED,"_memset64", 0, t) \ 59 60 SYMBOL_MARS(MEMSET128, FLfunc,FREGSAVED,"_memset128",0, t) \ 60 61 SYMBOL_MARS(MEMSET80, FLfunc,FREGSAVED,"_memset80", 0, t) \ 61 62 SYMBOL_MARS(MEMSET160, FLfunc,FREGSAVED,"_memset160",0, t) \ 62 63 SYMBOL_MARS(MEMSETN, FLfunc,FREGSAVED,"_memsetn", 0, t) \ 63 64 SYMBOL_MARS(MODULO, FLfunc,FREGSAVED,"_modulo", 0, t) \ 64 65 SYMBOL_MARS(MONITORENTER, FLfunc,FREGSAVED,"_d_monitorenter",0, t) \ 65 66 SYMBOL_MARS(MONITOREXIT, FLfunc,FREGSAVED,"_d_monitorexit",0, t) \ 66 67 SYMBOL_MARS(CRITICALENTER, FLfunc,FREGSAVED,"_d_criticalenter",0, t) \ 67 68 SYMBOL_MARS(CRITICALEXIT, FLfunc,FREGSAVED,"_d_criticalexit",0, t) \ 68 69 SYMBOL_MARS(SWITCH_STRING, FLfunc,FREGSAVED,"_d_switch_string", 0, t) \ 69 70 SYMBOL_MARS(SWITCH_USTRING,FLfunc,FREGSAVED,"_d_switch_ustring", 0, t) \ 70 71 SYMBOL_MARS(SWITCH_DSTRING,FLfunc,FREGSAVED,"_d_switch_dstring", 0, t) \ 71 SYMBOL_MARS(DSWITCHERR, FLfunc,FREGSAVED,"_d_switch_error", 0, t) \72 SYMBOL_MARS(DSWITCHERR, FLfunc,FREGSAVED,"_d_switch_error", SFLexit, t) \ 72 73 SYMBOL_MARS(DHIDDENFUNC, FLfunc,FREGSAVED,"_d_hidden_func", 0, t) \ 73 74 SYMBOL_MARS(NEWCLASS, FLfunc,FREGSAVED,"_d_newclass", 0, t) \ 74 75 SYMBOL_MARS(NEWARRAYT, FLfunc,FREGSAVED,"_d_newarrayT", 0, t) \ 75 76 SYMBOL_MARS(NEWARRAYIT, FLfunc,FREGSAVED,"_d_newarrayiT", 0, t) \ 76 77 SYMBOL_MARS(NEWARRAYMT, FLfunc,FREGSAVED,"_d_newarraymT", 0, t) \ 77 78 SYMBOL_MARS(NEWARRAYMIT, FLfunc,FREGSAVED,"_d_newarraymiT", 0, t) \ 78 79 SYMBOL_MARS(ARRAYLITERALT, FLfunc,FREGSAVED,"_d_arrayliteralT", 0, t) \ 79 80 SYMBOL_MARS(ASSOCARRAYLITERALT, FLfunc,FREGSAVED,"_d_assocarrayliteralT", 0, t) \ 80 81 SYMBOL_MARS(CALLFINALIZER, FLfunc,FREGSAVED,"_d_callfinalizer", 0, t) \ 81 82 SYMBOL_MARS(CALLINTERFACEFINALIZER, FLfunc,FREGSAVED,"_d_callinterfacefinalizer", 0, t) \ 82 83 SYMBOL_MARS(DELCLASS, FLfunc,FREGSAVED,"_d_delclass", 0, t) \ 83 84 SYMBOL_MARS(DELINTERFACE, FLfunc,FREGSAVED,"_d_delinterface", 0, t) \ 84 85 SYMBOL_MARS(ALLOCMEMORY, FLfunc,FREGSAVED,"_d_allocmemory", 0, t) \ 85 86 SYMBOL_MARS(DELARRAY, FLfunc,FREGSAVED,"_d_delarray", 0, t) \ 86 87 SYMBOL_MARS(DELARRAYT, FLfunc,FREGSAVED,"_d_delarray_t", 0, t) \ 87 88 SYMBOL_MARS(DELMEMORY, FLfunc,FREGSAVED,"_d_delmemory", 0, t) \ 88 89 SYMBOL_MARS(INTERFACE, FLfunc,FREGSAVED,"_d_interface_vtbl", 0, t) \ 89 90 SYMBOL_MARS(DYNAMIC_CAST, FLfunc,FREGSAVED,"_d_dynamic_cast", 0, t) \ 90 91 SYMBOL_MARS(INTERFACE_CAST,FLfunc,FREGSAVED,"_d_interface_cast", 0, t) \ 91 92 SYMBOL_MARS(FATEXIT, FLfunc,FREGSAVED,"_fatexit", 0, t) \ trunk/src/glue.c
r393 r395 454 454 * Another way to fix it is do the main one last. 455 455 */ 456 456 toModuleAssert(); 457 457 toModuleArray(); 458 458 } 459 459 460 460 #if 1 461 461 // Always generate module info, because of templates and -cov 462 462 if (1 || needModuleInfo()) 463 463 genmoduleinfo(); 464 464 #endif 465 465 466 466 // If module assert 467 467 for (int i = 0; i < 2; i++) 468 468 { 469 469 Symbol *ma = i ? marray : massert; 470 470 471 471 if (ma) 472 472 { 473 473 elem *elinnum; 474 elem *efilename;475 474 476 475 localgot = NULL; 477 476 478 477 // Call dassert(filename, line) 479 478 // Get sole parameter, linnum 480 479 { 481 480 Symbol *sp; 482 481 483 482 sp = symbol_calloc("linnum"); 484 483 sp->Stype = type_fake(TYint); 485 484 sp->Stype->Tcount++; 486 485 sp->Sclass = SCfastpar; 487 486 sp->Spreg = AX; 488 487 sp->Sflags &= ~SFLspill; 489 488 sp->Sfl = FLpara; // FLauto? 490 489 cstate.CSpsymtab = &ma->Sfunc->Flocsym; 491 490 symbol_add(sp); 492 491 493 492 elinnum = el_var(sp); 494 493 } 495 494 496 e filename = toEmodulename();497 498 elem *e = el_var(rtlsym[i ? RTLSYM_DARRAY : RTLSYM_DASSERT ]);495 elem *efilename = el_ptr(toSymbol()); 496 497 elem *e = el_var(rtlsym[i ? RTLSYM_DARRAY : RTLSYM_DASSERTM]); 499 498 e = el_bin(OPcall, TYvoid, e, el_param(elinnum, efilename)); 500 499 501 500 block *b = block_calloc(); 502 501 b->BC = BCret; 503 502 b->Belem = e; 504 503 ma->Sfunc->Fstartblock = b; 505 504 ma->Sclass = SCglobal; 506 505 ma->Sfl = 0; 507 506 writefunc(ma); 508 507 } 509 508 } 510 509 511 510 obj_termfile(); 512 511 } 513 512 514 513 515 514 /* ================================================================== */ 516 515 517 516 void FuncDeclaration::toObjFile(int multiobj) 518 517 { … … 1142 1141 Symbol *s; 1143 1142 type *t; 1144 1143 1145 1144 t = Type::tint32->toCtype(); 1146 1145 s = symbol_name("critsec", SCstatic, t); 1147 1146 s->Sfl = FLdata; 1148 1147 /* Must match D_CRITICAL_SECTION in phobos/internal/critical.c 1149 1148 */ 1150 1149 dtnzeros(&s->Sdt, PTRSIZE + os_critsecsize()); 1151 1150 #if ELFOBJ || MACHOBJ // Burton 1152 1151 s->Sseg = DATA; 1153 1152 #endif 1154 1153 outdata(s); 1155 1154 return s; 1156 1155 } 1157 1156 1158 1157 /************************************** 1159 1158 * Generate elem that is a pointer to the module file name. 1160 1159 */ 1161 1160 1162 elem *Module::toEmodulename()1163 {1164 elem *efilename;1165 1166 // Get filename1167 if (needModuleInfo())1168 { Symbol *si;1169 1170 /* Class ModuleInfo is defined in std.moduleinfo.1171 * The module name will be at nameoffset from the start of it.1172 */1173 1174 si = toSymbol();1175 1176 //printf("nameoffset = x%x\n", nameoffset);1177 assert(nameoffset >= 4);1178 1179 efilename = el_ptr(si);1180 efilename = el_bin(OPadd, TYnptr, efilename, el_long(TYsize_t, nameoffset));1181 efilename = el_pair(TYdarray, el_long(TYsize_t, namelen), efilename);1182 }1183 else // generate our own filename1184 {1185 efilename = toEfilename();1186 }1187 return efilename;1188 }1189 1190 1161 elem *Module::toEfilename() 1191 1162 { elem *efilename; 1192 1163 1193 1164 if (!sfilename) 1194 1165 { 1195 1166 dt_t *dt = NULL; 1196 1167 char *id; 1197 1168 int len; 1198 1169 1199 1170 id = srcfile->toChars(); 1200 1171 len = strlen(id); 1201 1172 dtdword(&dt, len); 1202 1173 dtabytes(&dt,TYnptr, 0, len + 1, id); 1203 1174 1204 1175 sfilename = symbol_generate(SCstatic,type_fake(TYdarray)); 1205 1176 sfilename->Sdt = dt; 1206 1177 sfilename->Sfl = FLdata; 1207 1178 #if ELFOBJ 1208 1179 sfilename->Sseg = CDATA; 1209 1180 #endif trunk/src/module.h
r393 r395 153 153 unsigned *covb; // bit array of valid code line numbers 154 154 155 155 Symbol *sictor; // module order independent constructor 156 156 Symbol *sctor; // module constructor 157 157 Symbol *sdtor; // module destructor 158 158 Symbol *ssharedctor; // module shared constructor 159 159 Symbol *sshareddtor; // module shared destructor 160 160 Symbol *stest; // module unit test 161 161 162 162 Symbol *sfilename; // symbol for filename 163 163 164 164 Symbol *massert; // module assert function 165 165 Symbol *toModuleAssert(); // get module assert function 166 166 167 167 Symbol *marray; // module array bounds function 168 168 Symbol *toModuleArray(); // get module array bounds function 169 169 170 170 171 171 static Symbol *gencritsec(); 172 172 elem *toEfilename(); 173 elem *toEmodulename();174 173 175 174 Symbol *toSymbol(); 176 175 void genmoduleinfo(); 177 176 178 177 Module *isModule() { return this; } 179 178 }; 180 179 181 180 182 181 struct ModuleDeclaration 183 182 { 184 183 Identifier *id; 185 184 Array *packages; // array of Identifier's representing packages 186 185 bool safe; 187 186 188 187 ModuleDeclaration(Array *packages, Identifier *id, bool safe); 189 188 190 189 char *toChars(); 191 190 }; 192 191 193 192 #endif /* DMD_MODULE_H */ trunk/src/s2ir.c
r288 r395 1135 1135 for (block *bt = b->Btry; bt != bdest->Btry; bt = bt->Btry) 1136 1136 { 1137 1137 if (!bt) 1138 1138 { 1139 1139 //printf("b->Btry = %p, bdest->Btry = %p\n", b->Btry, bdest->Btry); 1140 1140 error("cannot goto into try block"); 1141 1141 break; 1142 1142 } 1143 1143 } 1144 1144 1145 1145 //setScopeIndex(blx, b, bdest->Btry ? bdest->Btry->Bscope_index : -1); 1146 1146 } 1147 1147 1148 1148 list_append(&b->Bsucc,bdest); 1149 1149 incUsage(irs, loc); 1150 1150 block_next(blx,BCgoto,NULL); 1151 1151 } 1152 1152 1153 1153 void SwitchErrorStatement::toIR(IRState *irs) 1154 1154 { 1155 elem *e;1156 elem *elinnum;1157 elem *efilename;1158 1155 Blockx *blx = irs->blx; 1159 1156 1160 1157 //printf("SwitchErrorStatement::toIR()\n"); 1161 1158 1162 e filename = blx->module->toEmodulename();1163 el innum = el_long(TYint, loc.linnum);1164 e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DSWITCHERR]), el_param(elinnum, efilename));1159 elem *efilename = el_ptr(blx->module->toSymbol()); 1160 elem *elinnum = el_long(TYint, loc.linnum); 1161 elem *e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DSWITCHERR]), el_param(elinnum, efilename)); 1165 1162 block_appendexp(blx->curblock, e); 1166 1163 } 1167 1164 1168 1165 /************************************** 1169 1166 */ 1170 1167 1171 1168 void ReturnStatement::toIR(IRState *irs) 1172 1169 { 1173 1170 Blockx *blx = irs->blx; 1174 1171 1175 1172 incUsage(irs, loc); 1176 1173 if (exp) 1177 1174 { elem *e; 1178 1175 1179 1176 FuncDeclaration *func = irs->getFunc(); 1180 1177 assert(func); 1181 1178 assert(func->type->ty == Tfunction); 1182 1179 TypeFunction *tf = (TypeFunction *)(func->type); 1183 1180 1184 1181 enum RET retmethod = tf->retStyle(); trunk/src/toobj.c
r394 r395 156 156 #endif 157 157 dtxoff(&dt, s, 0, TYnptr); 158 158 } 159 159 } 160 160 } 161 161 if (flags & MIlocalClasses) 162 162 { 163 163 dtdword(&dt, aclasses.dim); 164 164 for (int i = 0; i < aclasses.dim; i++) 165 165 { 166 166 ClassDeclaration *cd = (ClassDeclaration *)aclasses.data[i]; 167 167 dtxoff(&dt, cd->toSymbol(), 0, TYnptr); 168 168 } 169 169 } 170 170 171 171 // Put out module name as a 0-terminated string, to save bytes 172 172 nameoffset = dt_size(dt); 173 173 const char *name = toPrettyChars(); 174 174 namelen = strlen(name); 175 175 dtnbytes(&dt, namelen + 1, name); 176 //printf("nameoffset = x%x\n", nameoffset); 176 177 #else 177 178 /* The layout is: 178 179 { 179 180 void **vptr; 180 181 monitor_t monitor; 181 182 char[] name; // class name 182 183 ModuleInfo importedModules[]; 183 184 ClassInfo localClasses[]; 184 185 uint flags; // initialization state 185 186 void *ctor; 186 187 void *dtor; 187 188 void *unitTest; 188 189 const(MemberInfo[]) function(string) xgetMembers; // module getMembers() function 189 190 void *ictor; 190 191 void *sharedctor; 191 192 void *shareddtor; 192 193 uint index; 193 194 void*[1] reserved; 194 195 } 195 196 */
