25 STATIC_CONST( WOPAGE_WORDS = GLOBAL_PAGE_SIZE_WORDS - 2 );
29 Uint32 m_data[WOPAGE_WORDS];
41 Uint32 m_current_page_no;
43 Uint16 m_current_ref_count;
50 void * getPtr(Uint32
i);
56 void handle_invalid_release(
Ptr<void>) ATTRIBUTE_NORETURN;
57 void handle_invalid_get_ptr(Uint32 i) ATTRIBUTE_NORETURN;
58 void handle_inconsistent_release(
Ptr<void>) ATTRIBUTE_NORETURN;
65 Uint32 pos = m_current_pos;
66 Uint32
size = m_record_info.m_size;
67 WOPage *pageP = m_current_page;
68 if (likely(pos + size < WOPage::WOPAGE_WORDS))
70 ptr.i = (m_current_page_no << POOL_RECORD_BITS) + pos;
71 ptr.p = (pageP->m_data + pos);
72 pageP->m_data[pos+m_record_info.m_offset_magic] = ~(Uint32)m_record_info.m_type_id;
73 m_current_pos = pos + size;
74 m_current_ref_count++;
78 return seize_new_page(ptr);
85 Uint32 cur_page = m_current_page_no;
86 Uint32 ptr_page = ptr.i >> POOL_RECORD_BITS;
87 Uint32 *magic_ptr = (((Uint32*)ptr.p)+m_record_info.m_offset_magic);
88 Uint32 magic_val = *magic_ptr;
90 if (likely(magic_val == ~(Uint32)m_record_info.m_type_id))
93 if (cur_page == ptr_page)
95 if (m_current_ref_count == 1)
99 m_current_ref_count--;
102 return release_not_current(ptr);
104 handle_invalid_release(ptr);
109 WOPool::getPtr(Uint32
i)
111 Uint32 page_no = i >> POOL_RECORD_BITS;
112 Uint32 page_idx = i & POOL_RECORD_MASK;
114 Uint32 *
record = page->m_data + page_idx;
115 Uint32 magic_val = * (record + m_record_info.m_offset_magic);
116 if (likely(magic_val == ~(Uint32)m_record_info.m_type_id))
120 handle_invalid_get_ptr(i);