void MarkStack::drain() { #if !ASSERT_DISABLED ASSERT(!m_isDraining); m_isDraining = true; #endif while (!m_markSets.isEmpty() || !m_values.isEmpty()) { while (!m_markSets.isEmpty() && m_values.size() < 50) { ASSERT(!m_markSets.isEmpty()); MarkSet& current = m_markSets.last(); ASSERT(current.m_values); JSValue* end = current.m_end; ASSERT(current.m_values); ASSERT(current.m_values != end); findNextUnmarkedNullValue: ASSERT(current.m_values != end); JSValue value = *current.m_values; current.m_values++; JSCell* cell; if (!value || !value.isCell() || Heap::testAndSetMarked(cell = value.asCell())) { if (current.m_values == end) { m_markSets.removeLast(); continue; } goto findNextUnmarkedNullValue; } if (cell->structure()->typeInfo().type() < CompoundType) { if (current.m_values == end) { m_markSets.removeLast(); continue; } goto findNextUnmarkedNullValue; } if (current.m_values == end) m_markSets.removeLast(); markChildren(cell); } while (!m_values.isEmpty()) markChildren(m_values.removeLast()); } #if !ASSERT_DISABLED m_isDraining = false; #endif }
void markChildren(word* p, int s[]){ if(Color(p[0]) == White){ p[0] = Paint(p[0], Black); for(int i = 1; i <= Length(p[0]); i++){ if(!IsInt(p[i]) && p[i] != 0) markChildren((word*) p[i], s); } } }
void markPhase(int s[], int sp) { printf("marking ...\n"); while(sp > 0){ if(!IsInt(s[sp]) && s[sp] != 0) { markChildren((word*) s[sp],s); } sp--; } }
void Object::mark () { // don't end up in a mark loop if (!gc_marked) { gc_marked = true; markChildren(); } }
void markChildren(SSMGraph* g, bool* marked, size_t vtx) { marked[vtx] = true; size_t cnb = g->countNeighbors(vtx); size_t* nbs = g->getNeighbors(vtx); for(size_t i=0; i < cnb; i++) { size_t nb = nbs[i]; if (!marked[nb]) { markChildren(g, marked, nb); } } }
int verifyCC(SSMGraph* g) { size_t glen = g->length(); bool* marked = new bool[glen]; for (size_t i=0; i < glen; i++) { marked[i] = false; } markChildren(g, marked, 0); for (size_t i=0; i < glen; i++) { if (!marked[i]) { std::cerr << "Not a connected component; " << i; std::cerr <<" doesn't connect to 0." << std::endl; return 1; } } return 0; }