void test_process_mark_stack() { immix::Block& block = gc->get_block(); immix::SingleBlockAllocator alloc(block); memory::Address addr = alloc.allocate(sizeof(SimpleObject)); memory::Address addr2 = alloc.allocate(sizeof(SimpleObject)); SimpleObject* obj = addr.as<SimpleObject>(); SimpleObject* sub = addr2.as<SimpleObject>(); obj->marked = false; obj->sub = sub; obj->body_checked = false; sub->marked = false; sub->sub = 0; sub->body_checked = false; gc->mark_address(addr, alloc); TS_ASSERT_EQUALS(obj->marked, true); gc->process_mark_stack(alloc); TS_ASSERT_EQUALS(obj->body_checked, true); TS_ASSERT_EQUALS(sub->marked, true); TS_ASSERT_EQUALS(sub->body_checked, true); }
void test_sweep_blocks_frees_empty_blocks() { immix::Block& block = gc->get_block(); gc->sweep_blocks(); immix::Block& block2 = gc->get_block(); TS_ASSERT_EQUALS(&block, &block2); }
bool GCM_API Distance::matchCache(GC<Geocache> cache) { if (this->mUseCacheDistance) { return cache->getDistance().distance < this->distance; } else { return cache->calcDistance(this->latitudeE6, this->longitudeE6) < this->distance; } }
void ObjectVectorObject::grow(uint32 newCapacity, bool exact) { if (newCapacity > m_capacity) { if(!exact) newCapacity = newCapacity + (newCapacity >>2); //newCapacity = ((newCapacity+kGrowthIncr)/kGrowthIncr)*kGrowthIncr; GC* gc = GC::GetGC(this); Atom* newArray = (Atom*) gc->Calloc(newCapacity, sizeof(Atom), GC::kContainsPointers); nullAtomRange(newArray, newCapacity); Atom* oldAtoms = m_array; if (!newArray) { toplevel()->throwError(kOutOfMemoryError); } if (m_array) { VMPI_memcpy(newArray, m_array, m_length * sizeof(Atom)); nullAtomRange(oldAtoms, m_length); gc->Free(oldAtoms); } m_array = newArray; m_capacity = newCapacity; } }
static Val* model() { AutoPool autopool; Val* val = (Val*)pool_ret(pool(gc.oarray(3))); val->result = pool(gc.str("Calc"))->chars; val->b = eval(ebin(EMul, ebin(EAdd,eint(1),eint(2)), eint(5)))->longv; val->c = eval(ebin(EDiv, ebin(EMul,eint(10),eint(20)), eint(5)))->longv; return val; }
void test_mark_address_updates_block() { immix::Block& block = gc->get_block(); immix::SingleBlockAllocator alloc(block); memory::Address addr = alloc.allocate(24); TS_ASSERT(block.is_line_free(1)); gc->mark_address(addr, alloc); TS_ASSERT(!block.is_line_free(1)); }
void StaticLine::Paint(GC &gc, const crect &paintRect) { crect rect = ClientRect(); gc.SetFillColor(UiGetColor(uiBackground, 0,0, 0xFFFFFF)/*GetColor(0)*/); gc.FillRect(rect); //CCC gc.SetTextColor(UiGetColor(uiColor, 0,0, 0)/*GetColor(IsEnabled() ? IC_TEXT : IC_GRAY_TEXT)*/); //CCC gc.Set(GetFont()); DrawStaticText(gc,0,0,text.ptr()); }
void test_get_block_returns_recyclable_blocks() { immix::Block& block = gc->get_block(); block.set_status(immix::cRecyclable); gc->sweep_blocks(); immix::Block& block2 = gc->get_block(); TS_ASSERT_EQUALS(&block2, &block); }
static Object* eval(Object* e) { switch(e->longs[0]) { case EInt: return pool(gc.longv(e->longs[1])); case EAdd: return pool(gc.longv(eval(e->field[1])->longv + eval(e->field[2])->longv)); case ESub: return pool(gc.longv(eval(e->field[1])->longv - eval(e->field[2])->longv)); case EMul: return pool(gc.longv(eval(e->field[1])->longv * eval(e->field[2])->longv)); case EDiv: return pool(gc.longv(eval(e->field[1])->longv / eval(e->field[2])->longv)); default: return pool(gc.longv(1)); } }
void StaticLabel::Paint(GC& gc, const crect& paintRect) { crect rect = ClientRect(); gc.SetFillColor(UiGetColor(uiBackground, uiClassStaticLabel, 0, 0xFFFFFF)/*GetColor(0)*/); gc.FillRect(rect); gc.Set(GetFont()); text.DrawItem(gc, 0, 0, UiGetColor(uiColor, uiClassStaticLabel, 0, 0), UiGetColor(uiHotkeyColor, uiClassStaticLabel, 0, 0)); }
static void DrawCE( GC& gc, int x, int y, bool isSet ) { gc.SetLine( CBC_BOXFRAME ); gc.SetFillColor( CBC_BOX_BG ); gc.Ellipce( crect( x, y, x + 13, y + 13 ) ); if ( isSet ) { DrawPixelList( gc, rbPix, x + 4, y + 4, CBC_CHECK ); } }
void test_mark_address_ignores_already_marked_objects() { immix::Block& block = gc->get_block(); immix::SingleBlockAllocator alloc(block); memory::Address addr = alloc.allocate(24); addr.as<SimpleObject>()->marked = true; TS_ASSERT(block.is_line_free(1)); gc->mark_address(addr, alloc); TS_ASSERT(block.is_line_free(1)); }
void test_BlockAllocator_reset_updates_block_stats() { immix::Block& block = gc->get_block(); block.mark_line(1); block.mark_line(3); TS_ASSERT_EQUALS(block.lines_used(), 1); immix::BlockAllocator& ba = gc->block_allocator(); ba.reset(); TS_ASSERT_EQUALS(block.lines_used(), 3); }
void PopupMenu::Paint( GC& gc, const crect& paintRect ) { crect rect = ClientRect(); gc.SetFillColor( UiGetColor( uiBackground, 0, 0, 0xFFFFFF ) ); gc.FillRect( rect ); DrawBorder( gc, rect, UiGetColor( uiFrameColor, 0, 0, 0 ) ); for ( int i = 0; i < list.count(); i++ ) { DrawItem( gc, i ); } }
void DrawStaticText(GC &gc, int x, int y, const unicode_t *s, cfont *font, bool transparent) { if (font) gc.Set(font); while (*s) { const unicode_t *t = unicode_strchr(s,'\n'); int len = (t ? t-s : unicode_strlen(s)); gc.TextOutF(x,y,s,len); cpoint c = gc.GetTextExtents(s,len); s +=len; if (t) s++; if (*s == '\r') s++; y += c.y; } }
void VListWin::Paint( GC& gc, const crect& paintRect ) { crect rect = ClientRect(); switch ( borderType ) { case SINGLE_BORDER: DrawBorder( gc, rect, InFocus() ? 0x00C000 : borderColor ); break; case BORDER_3D: Draw3DButtonW2( gc, rect, bgColor, false ); default: ; } if ( !scrollRect.IsEmpty() ) { gc.SetFillColor( 0xD0D0D0 ); gc.FillRect( scrollRect ); //CCC } if ( itemHeight > 0 ) { int n = ( rect.Height() + ( itemHeight - 1 ) ) / itemHeight; crect r = this->listRect; int bottom = r.bottom; r.bottom = r.top + itemHeight; for ( int i = 0; i < n; i++ ) { gc.SetClipRgn( &r ); crect r1( r ); r1.left -= xOffset; this->DrawItem( gc, i + first, r1 ); r.top += itemHeight; r.bottom += itemHeight; if ( r.bottom > bottom ) { r.bottom = bottom; } } } else { //на всякий случай rect.Dec(); gc.SetFillColor( bgColor ); gc.FillRect( rect ); } }
void test_sweep_blocks_sorts_blocks() { immix::Block& block = gc->get_block(); immix::Block& block2 = gc->get_block(); immix::Block& block3 = gc->get_block(); block.set_status(immix::cUnavailable); block2.set_status(immix::cRecyclable); gc->evacuate_block(block3); TS_ASSERT_EQUALS(block3.status(), immix::cEvacuate); gc->sweep_blocks(); TS_ASSERT_EQUALS(block3.status(), immix::cFree); }
void gc_collect(GC **gc) { GC *g = *gc; while (g) { GC *next = g->next; if (*g->var) { g->rm(*g->var); *g->var = 0; } fr_single(&gc_free_list,g); g = next; } *gc = 0; }
void AttachSampler(avmplus::Sampler* sampler) { GCHeap* heap = GCHeap::GetGCHeap(); // May be NULL during OOM shutdown if (heap) { EnterFrame* ef = heap->GetEnterFrame(); if (ef) { GC* gc = ef->GetActiveGC(); if (gc) gc->SetAttachedSampler(sampler); } } }
void ScrollBar::Paint( GC& gc, const crect& paintRect ) { crect cr = ClientRect(); unsigned bgColor = UiGetColor( uiBackground, 0, 0, 0xD8E9EC );/*GetColor(IC_SCROLL_BG)*/; unsigned btnColor = UiGetColor( uiButtonColor, 0, 0, 0xD8E9EC ); //GetColor(IC_SCROLL_BUTTON); gc.SetFillColor( bgColor ); gc.FillRect( cr ); DrawBorder( gc, cr, UiGetColor( uiColor, 0, 0, 0xD8E9EC )/*GetColor(IC_SCROLL_BORDER)*/ ); if ( !b1Rect.IsEmpty() ) { SBCDrawButton( gc, b1Rect, vertical ? 4 : 1, btnColor, b1Pressed ); } if ( !b2Rect.IsEmpty() ) { SBCDrawButton( gc, b2Rect, vertical ? 5 : 2, btnColor, b2Pressed ); } if ( !b3Rect.IsEmpty() ) { SBCDrawButton( gc, b3Rect, vertical ? 6 : 3, btnColor, false ); } }
avmplus::Sampler* GetSampler() { GCHeap* heap = GCHeap::GetGCHeap(); // May be NULL during OOM shutdown if (heap) { EnterFrame* ef = heap->GetEnterFrame(); if (ef) { GC* gc = ef->GetActiveGC(); if (gc) return (avmplus::Sampler*)gc->GetAttachedSampler(); } } return NULL; }
inline Object* pool_ret(Object* a) { for (list<Frame*>::iterator frame = gc.frame_list.begin(); frame != gc.frame_list.end();) { frame++; if(frame != gc.frame_list.end()) return gc.add_pool(*frame, a); } return a; }
void test_get_block() { immix::Block& block = gc->get_block(); TS_ASSERT_EQUALS(block.size(), immix::cBlockSize); TS_ASSERT(block.address() != 0); TS_ASSERT_EQUALS(block.status(), immix::cFree); TS_ASSERT_EQUALS(block.lines_used(), 1); }
void test_BlockAllocator_get_free_block() { immix::BlockAllocator& ba = gc->block_allocator(); ba.add_chunk(); ba.current_chunk().get_block(0).set_status(immix::cRecyclable); immix::Block& block = ba.get_free_block(); TS_ASSERT_EQUALS(block.status(), immix::cFree); }
static Object* ebin(long tag, Object* e1, Object* e2) { Object* e = pool(gc.record(3,BIT(1) | BIT(2))); e->longs[0] = tag; e->field[1] = e1; e->field[2] = e2; return e; }
void test_mark_address_calls_describer() { immix::Block& block = gc->get_block(); immix::SingleBlockAllocator alloc(block); memory::Address addr = alloc.allocate(sizeof(SimpleObject)); SimpleObject* obj = addr.as<SimpleObject>(); memory::Address addr2 = alloc.allocate(sizeof(SimpleObject)); obj->sub = addr2.as<SimpleObject>(); obj->marked = false; gc->mark_address(addr, alloc); TS_ASSERT_EQUALS(obj->marked, true); TS_ASSERT_EQUALS(gc->mark_stack().size(), 1U); TS_ASSERT_EQUALS(gc->mark_stack()[0], addr); }
cpoint StaticTextSize(GC &gc, const unicode_t *s, cfont *font) { cpoint p(0,0); if (font) gc.Set(font); while (*s) { const unicode_t *t = unicode_strchr(s,'\n'); int len = (t ? t-s : unicode_strlen(s)); cpoint c = gc.GetTextExtents(s,len); s +=len; if (t) s++; if (*s == '\r') s++; p.y += c.y; if (p.x<c.x) p.x = c.x; } return p; }
void MenuBar::DrawItem(GC &gc, int n) { if (n<0 || n>=list.count()) return; UiCondList ucl; if (n == select && InFocus()) ucl.Set(uiCurrentItem, true); int color_text = UiGetColor(uiColor, uiItem, &ucl, 0x0); int color_bg = UiGetColor(uiBackground, uiItem, &ucl, 0xFFFFFF); gc.Set(GetFont()); crect itemRect = ItemRect(n); gc.SetFillColor(color_bg); if (n == select && InFocus()) gc.FillRect(itemRect); if (n == select) { DrawBorder(gc, itemRect, UiGetColor(uiCurrentItemFrame, uiItem, &ucl, 0xFFFFFF)); } gc.SetTextColor( color_text ); const unicode_t *text = list[n].text.ptr(); cpoint tsize = gc.GetTextExtents(text); int x = itemRect.left + (itemRect.Width()-tsize.x)/2; int y = itemRect.top + (itemRect.Height()-tsize.y)/2; #ifdef _WIN32 gc.TextOut(x,y,text); #else gc.TextOutF(x,y,text); #endif }
void Draw3DButtonW1( GC& gc, crect r, unsigned bg, bool up ) { static unsigned hp1, lp1; static unsigned lastBg = 0; static bool initialized = false; if ( !initialized || lastBg != bg ) { hp1 = ColorTone( bg, 200 ); lp1 = ColorTone( bg, -150 ); lastBg = bg; initialized = true; } unsigned php1, plp1; if ( up ) { php1 = hp1; plp1 = lp1; } else { php1 = lp1; plp1 = hp1; } gc.SetLine( plp1 ); gc.MoveTo( r.right - 1, r.top ); gc.LineTo( r.right - 1, r.bottom - 1 ); gc.LineTo( r.left, r.bottom - 1 ); gc.SetLine( php1 ); gc.LineTo( r.left, r.top ); gc.LineTo( r.right - 1, r.top ); }
void test_Block_update_stats_finds_empty_blocks() { immix::Block& block = gc->get_block(); block.set_status(immix::cRecyclable); block.update_stats(); TS_ASSERT_EQUALS(block.status(), immix::cFree); TS_ASSERT_EQUALS(block.holes(), 1); TS_ASSERT_EQUALS(block.lines_used(), 1); }