void verifier_scan_mos_unreachable_objects(Space* space, Heap_Verifier* heap_verifier) { Block* blocks = (Block*)space->heap_start; unsigned int start_idx = ((Blocked_Space*)space)->first_block_idx; unsigned int i; unsigned int num_block = ((Blocked_Space*)space)->free_block_idx - ((Blocked_Space*)space)->first_block_idx; for( i=0; i < num_block; i++ ){ Block_Header* block = (Block_Header*)&(blocks[i]); Partial_Reveal_Object* cur_obj = (Partial_Reveal_Object*) block->base; while( cur_obj < block->free ){ verify_object_header(cur_obj, heap_verifier); // if(!obj_is_marked_in_vt(cur_obj)) tag_unreachable_obj(cur_obj); cur_obj = obj_end(cur_obj); } } }
static void mspace_sliding_compact(Collector* collector, Mspace* mspace) { void *start_pos; while(Partial_Reveal_Object *p_obj = get_next_first_src_obj(mspace)) { Block_Header *src_block = GC_BLOCK_HEADER(p_obj); assert(src_block->dest_counter); Partial_Reveal_Object *p_target_obj = obj_get_fw_in_oi(p_obj); Block_Header *dest_block = GC_BLOCK_HEADER(p_target_obj); /* We don't set start_pos as p_obj in case that memmove of this obj may overlap itself. * In that case we can't get the correct vt and obj_info. */ #ifdef USE_32BITS_HASHCODE start_pos = obj_end_extend(p_obj); #else start_pos = obj_end(p_obj); #endif do { assert(obj_is_marked_in_vt(p_obj)); #ifdef USE_32BITS_HASHCODE obj_clear_dual_bits_in_vt(p_obj); #else obj_unmark_in_vt(p_obj); #endif unsigned int obj_size = (unsigned int)((POINTER_SIZE_INT)start_pos - (POINTER_SIZE_INT)p_obj); if(p_obj != p_target_obj) { assert((((POINTER_SIZE_INT)p_target_obj) % GC_OBJECT_ALIGNMENT) == 0); memmove(p_target_obj, p_obj, obj_size); } set_obj_info(p_target_obj, 0); p_obj = block_get_next_marked_obj_after_prefetch(src_block, &start_pos); if(!p_obj) break; p_target_obj = obj_get_fw_in_oi(p_obj); } while(GC_BLOCK_HEADER(p_target_obj) == dest_block); atomic_dec32(&src_block->dest_counter); } }
/* * Pass 2: * - process all source files */ void pass2(void) { register int fi; pass = 2; pc = 0; fi = 0; if (ver_flag) puts("Pass 2"); obj_header(); while (infiles[fi] != NULL) { if (ver_flag) printf(" Read %s\n", infiles[fi]); p2_file(infiles[fi]); fi++; } obj_end(); fclose(objfp); printf("%d error(s)\n", errors); }
void obj_write_deferred(Library *library) { for (int i = 0; i < obj_symbols_towrite.dim; i++) { Dsymbol *s = (Dsymbol *)obj_symbols_towrite.data[i]; Module *m = s->getModule(); char *mname; if (m) { mname = m->srcfile->toChars(); lastmname = mname; } else { //mname = s->ident->toChars(); mname = lastmname; assert(mname); } obj_start(mname); static int count; count++; // sequence for generating names /* Create a module that's a doppelganger of m, with just * enough to be able to create the moduleinfo. */ OutBuffer idbuf; idbuf.printf("%s.%d", m ? m->ident->toChars() : mname, count); char *idstr = idbuf.toChars(); idbuf.data = NULL; Identifier *id = new Identifier(idstr, TOKidentifier); Module *md = new Module(mname, id, 0, 0); md->members = new Array(); md->members->push(s); // its only 'member' is s if (m) { md->doppelganger = 1; // identify this module as doppelganger md->md = m->md; md->aimports.push(m); // it only 'imports' m md->massert = m->massert; md->marray = m->marray; } md->genobjfile(0); /* Set object file name to be source name with sequence number, * as mangled symbol names get way too long. */ char *fname = FileName::removeExt(mname); OutBuffer namebuf; unsigned hash = 0; for (char *p = s->toChars(); *p; p++) hash += *p; namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext); namebuf.writeByte(0); mem.free(fname); fname = (char *)namebuf.extractData(); //printf("writing '%s'\n", fname); File *objfile = new File(fname); obj_end(library, objfile); } obj_symbols_towrite.dim = 0; }
void obj_write_deferred(Library *library) { for (size_t i = 0; i < obj_symbols_towrite.dim; i++) { Dsymbol *s = obj_symbols_towrite[i]; Module *m = s->getModule(); char *mname; if (m) { mname = m->srcfile->toChars(); lastmname = mname; } else { //mname = s->ident->toChars(); mname = lastmname; assert(mname); } obj_start(mname); static int count; count++; // sequence for generating names /* Create a module that's a doppelganger of m, with just * enough to be able to create the moduleinfo. */ OutBuffer idbuf; idbuf.printf("%s.%d", m ? m->ident->toChars() : mname, count); char *idstr = idbuf.peekString(); if (!m) { // it doesn't make sense to make up a module if we don't know where to put the symbol // so output it into it's own object file without ModuleInfo objmod->initfile(idstr, NULL, mname); toObjFile(s, false); objmod->termfile(); } else { idbuf.data = NULL; Identifier *id = Identifier::create(idstr, TOKidentifier); Module *md = Module::create(mname, id, 0, 0); md->members = Dsymbols_create(); md->members->push(s); // its only 'member' is s md->doppelganger = 1; // identify this module as doppelganger md->md = m->md; md->aimports.push(m); // it only 'imports' m md->massert = m->massert; md->munittest = m->munittest; md->marray = m->marray; genObjFile(md, false); } /* Set object file name to be source name with sequence number, * as mangled symbol names get way too long. */ const char *fname = FileName::removeExt(mname); OutBuffer namebuf; unsigned hash = 0; for (char *p = s->toChars(); *p; p++) hash += *p; namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext); FileName::free((char *)fname); fname = namebuf.extractString(); //printf("writing '%s'\n", fname); File *objfile = File::create(fname); obj_end(library, objfile); } obj_symbols_towrite.dim = 0; }