14 #ifndef __UT_PageArray__
15 #define __UT_PageArray__
36 #pragma warning(disable: 4519)
234 template<
typename DATA_T,ex
int TSIZE=1,
bool TABLEHARDENED=false,
bool PAGESHARDENED=false,ex
int THEPAGEBITS=10,
typename IDX_T=ex
int>
247 template<
typename DATA_T2,ex
int TSIZE2,
bool TABLEHARDENED2,
bool PAGESHARDENED2,ex
int THEPAGEBITS2,
typename IDX_T2>
266 myImpl.getPages() =
nullptr;
277 myImpl.getPages() =
nullptr;
278 myImpl.setTupleSize(tuplesize);
288 myImpl.getPages() =
nullptr;
289 myImpl.setStorage(storage);
301 myImpl.getPages() =
nullptr;
302 myImpl.setStorage(storage);
303 myImpl.setTupleSize(tuplesize);
312 myImpl.getPages() =
nullptr;
316 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
319 myImpl.getPages() =
nullptr;
332 if (myImpl.getPages())
333 myImpl.getPages()->setSize(IDX_T(0));
338 if (!myImpl.getPages())
341 const exint tuplesize = myImpl.getTupleSize();
344 if (!SYSisSame<DATA_T,void>())
345 myImpl.getPages()->decRef(tuplesize);
352 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
355 castType<int8>().myImpl.getPages()->decRef(tuplesize);
return;
357 castType<uint8>().myImpl.getPages()->decRef(tuplesize);
return;
359 castType<int16>().myImpl.getPages()->decRef(tuplesize);
return;
361 castType<int32>().myImpl.getPages()->decRef(tuplesize);
return;
363 castType<int64>().myImpl.getPages()->decRef(tuplesize);
return;
365 castType<fpreal16>().myImpl.getPages()->decRef(tuplesize);
return;
367 castType<fpreal32>().myImpl.getPages()->decRef(tuplesize);
return;
369 castType<fpreal64>().myImpl.getPages()->decRef(tuplesize);
return;
372 myImpl.getPages() =
nullptr;
386 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
396 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
402 if ((
void *)
this == (
const void *)&that)
407 if (!TABLEHARDENED &&
408 myImpl.getStorage() == that.myImpl.getStorage() &&
409 myImpl.getTupleSize() == that.myImpl.getTupleSize() &&
410 (
void *)myImpl.getPages() == (
const void *)that.myImpl.getPages())
415 if (SYSisSame<DATA_T,void>())
416 myImpl.setStorage(that.myImpl.getStorage());
418 myImpl.setTupleSize(that.myImpl.getTupleSize());
421 if ((SYSisSame<DATA_T,void>() || SYSisSame<DATA_T,SRC_DATA_T>()) && (TSIZE == -1 || TSIZE == SRC_TSIZE))
423 PageTable *pages =
reinterpret_cast<PageTable *
>(
SYSconst_cast(that.myImpl.getPages()));
424 myImpl.getPages() = pages;
428 if (TABLEHARDENED || PAGESHARDENED || SRC_TABLEHARDENED || SRC_PAGESHARDENED)
431 if (PAGESHARDENED || SRC_PAGESHARDENED)
435 ->template hardenAllPages<false>();
445 moveRange(that, IDX_T(0), IDX_T(0), size);
456 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
459 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
463 bool isconst = !PAGESHARDENED && page->isConstant();
470 return page->getFirstPtr()[TSIZE*pageoff + component];
479 return page->getFirstPtr()[myImpl.getTupleSize()*pageoff + component];
481 return getConstant(page, component, myImpl.getTupleSize());
492 template<
typename DEST_DATA_T=DATA_T>
497 return UTconvertStorage<DEST_DATA_T>((*this)(i,component));
499 return getUnknownType<DEST_DATA_T>(i,component);
502 template<
typename DEST_DATA_T=NotVo
idType,ex
int DEST_TSIZE=theSafeTupleSize>
505 if (SYSisSame<DATA_T,void>())
509 dest = this->getVectorUnknownType<DEST_DATA_T,DEST_TSIZE>(i);
513 if (!SYSisSame<DEST_DATA_T,DATA_T>())
517 dest = this->convertVectorStorage<DEST_DATA_T>(this->getVector<NotVoidType,DEST_TSIZE>(i));
526 dest = this->getVectorUnknownSize<DEST_DATA_T,DEST_TSIZE>(i);
530 if (TSIZE!=DEST_TSIZE)
534 dest = this->getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
548 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
552 bool isconst = !PAGESHARDENED && page->isConstant();
577 UT_ASSERT_P(component >= 0 && component < myImpl.getTupleSize());
584 PageTable *pages = myImpl.getPages();
585 PageTableEntry *page = pages->getPPage(pagenum);
589 if (page->isConstant())
596 else if (page->isShared())
606 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
613 template<
typename SRC_DATA_T>
619 template<
typename SRC_DATA_T>
629 template<
typename SRC_DATA_T>
632 op<0>(i, component,
v);
634 template<
typename SRC_DATA_T>
637 op<1>(i, component,
v);
639 template<
int OP,
typename SRC_DATA_T>
644 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
646 if (SYSisSame<DATA_T,void>())
648 opUnknownType<OP>(i, component,
v);
662 PageTable *pages = myImpl.getPages();
663 PageTableEntry *page = pages->getPPage(pagenum);
667 if (page->isConstant())
679 if (
getConstant(page, component, myImpl.getTupleSize()) == vt)
688 else if (page->isShared())
694 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
707 + pageoff*((TSIZE >= 1) ? TSIZE : myImpl.getTupleSize())
720 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_INSTANTIATED>
725 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_INSTANTIATED>
734 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
738 UT_ASSERT_MSG_P(OP == 0 || OP == 1,
"Only OP 0 (set) and 1 (add) are defined!");
740 if (SYSisSame<DATA_T,void>())
743 this->opVectorUnknownType<OP>(i,
v);
748 const exint tuplesize = myImpl.getTupleSize();
749 if (TSIZE == -1 && tuplesize == SRC_TSIZE)
752 this->castTupleSize<SRC_TSIZE>().
template opVector<OP>(i, v);
756 const exint mintuplesize =
SYSmin(tuplesize, SRC_TSIZE);
760 constexpr
bool TYPE_MATCH = SYSisSame<SRC_DATA_T,NotVoidType>();
763 converted_v = convertVectorStorage<NotVoidType>(
v);
772 PageTable *pages = myImpl.getPages();
773 PageTableEntry *page = pages->getPPage(pagenum);
777 if (page->isConstant())
784 data = page->getInlinePtr(tuplesize);
786 data = page->getMaskedPtr();
796 if (
isEqual(data, converted_v.data(), mintuplesize))
809 if (
isZero(converted_v.data(), mintuplesize))
819 else if (page->isShared())
825 + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
833 if (
isEqual(data, converted_v.data(), mintuplesize))
844 NotVoidType *
data = page->getFirstPtr() + pageoff*((TSIZE >= 0) ? TSIZE : tuplesize);
845 for (
exint component = 0; component < mintuplesize; ++component)
850 data[component] = v[component];
852 data[component] = converted_v[component];
857 data[component] += v[component];
859 data[component] += converted_v[component];
870 const PageTable *pages = myImpl.getPages();
873 return pages->size();
878 const PageTable *pages = myImpl.getPages();
881 return pages->capacity();
899 if (capacity <= IDX_T(2))
901 return IDX_T(SYSmakePow2(
exint(capacity)));
910 if (newcapacity <
size())
934 PageTable *pages = myImpl.getPages();
937 pages->setSize(newsize);
980 template<
typename SRC_T>
1013 void moveRange(IDX_T srcstart, IDX_T deststart, IDX_T nelements);
1018 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
1024 void swapRange(IDX_T astart, IDX_T bstart, IDX_T nelements);
1042 PageTable *pages = myImpl.getPages();
1043 PageTableEntry *destpage = pages->getPPage(destpagenum);
1044 const PageTableEntry *srcpage = pages->getPPage(srcpagenum);
1046 const int8 *srcdata;
1047 if (srcpage->isConstant())
1049 if (bytesize <
sizeof(PageTableEntry))
1052 if (*srcpage == *destpage)
1055 srcdata = ((
const int8 *)(srcpage+1)) - bytesize;
1057 else if (srcpage->getUnmaskedPtrVoid() == destpage->getUnmaskedPtrVoid())
1065 srcdata = (
const int8 *)srcpage->getMaskedPtrVoid();
1070 srcdata = ((
const int8*)srcpage->getFirstPtrVoid()) +
pageOff(src)*bytesize;
1074 if (destpage->isConstant())
1076 if (bytesize <
sizeof(PageTableEntry))
1077 destdata = ((
int8 *)(destpage+1)) - bytesize;
1080 void *destmasked = destpage->getMaskedPtrVoid();
1081 if (destmasked ==
nullptr)
1083 if (
isZero(srcdata, bytesize))
1088 destdata = (
int8*)destmasked;
1090 if (destdata !=
nullptr &&
isEqual(srcdata, destdata, bytesize))
1093 if (!SYSisSame<DATA_T,void>())
1102 auto &
a = castType<int8>();
1103 auto a_pages =
a.myImpl.getPages();
1104 auto a_destpage = a_pages->getPPage(destpagenum);
1111 auto &
a = castType<int16>();
1112 auto a_pages =
a.myImpl.getPages();
1113 auto a_destpage = a_pages->getPPage(destpagenum);
1120 auto &
a = castType<int32>();
1121 auto a_pages =
a.myImpl.getPages();
1122 auto a_destpage = a_pages->getPPage(destpagenum);
1129 auto &
a = castType<int64>();
1130 auto a_pages =
a.myImpl.getPages();
1131 auto a_destpage = a_pages->getPPage(destpagenum);
1136 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1141 else if (!PAGESHARDENED && destpage->isShared())
1143 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1146 if (
isEqual(srcdata, destdata, bytesize))
1151 if (
isZero(destdata, bytesize))
1155 if (!SYSisSame<DATA_T,void>())
1164 auto &
a = castType<int8>();
1165 auto a_pages =
a.myImpl.getPages();
1166 auto a_destpage = a_pages->getPPage(destpagenum);
1173 auto &
a = castType<int16>();
1174 auto a_pages =
a.myImpl.getPages();
1175 auto a_destpage = a_pages->getPPage(destpagenum);
1182 auto &
a = castType<int32>();
1183 auto a_pages =
a.myImpl.getPages();
1184 auto a_destpage = a_pages->getPPage(destpagenum);
1191 auto &
a = castType<int64>();
1192 auto a_pages =
a.myImpl.getPages();
1193 auto a_destpage = a_pages->getPPage(destpagenum);
1198 UT_ASSERT_MSG(0,
"Storage must be valid if DATA_T is void.");
1203 destdata = ((
int8*)destpage->getFirstPtrVoid()) +
pageOff(dest)*bytesize;
1205 for (
const int8 *srcdataend = srcdata+bytesize; srcdata != srcdataend; ++srcdata, ++destdata)
1206 *destdata = *srcdata;
1211 template<
typename T>
1221 template<
typename T>
1231 template<
typename DEST_DATA_T,ex
int DEST_TSIZE,
bool DEST_INSTANTIATED>
1236 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_INSTANTIATED>
1262 UT_ASSERT_P(!TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared());
1264 return TABLEHARDENED || !myImpl.getPages() || !myImpl.getPages()->isShared();
1285 template <
bool including_capacity=false>
1289 PageTable *pages = myImpl.getPages();
1290 if (PAGESHARDENED || (pages ==
nullptr))
1296 end = including_capacity ? pages->capacity() : pages->size();
1301 if (!SYSisSame<DATA_T,void>())
1306 pages->hardenAllPages(
start,
end, myImpl.getTupleSize());
1312 hard.hardenAllPagesUnknownType(
start,
end);
1318 template <
bool including_capacity=false>
1322 PageTable *pages = myImpl.getPages();
1323 if (PAGESHARDENED || (pages ==
nullptr))
1329 end = including_capacity ? pages->capacity() : pages->size();
1334 if (!SYSisSame<DATA_T,void>())
1337 pages->tryCompressAllPages(
start,
end);
1339 pages->tryCompressAllPages(
start,
end, myImpl.getTupleSize());
1345 hard.tryCompressAllPagesUnknownType(
start,
end);
1352 template<
typename DEST_DATA_T>
1360 template<
typename DEST_DATA_T>
1373 template<ex
int DEST_TSIZE>
1381 template<ex
int DEST_TSIZE>
1393 return myImpl.getTupleSize();
1397 return myImpl.getStorage();
1405 return myImpl.getPages()->getPPage(pagenum)->isConstant();
1412 if (myImpl.getPages() ==
nullptr)
1415 const PageTable *pages = myImpl.getPages();
1418 for (
UT_PageNum pagenum = 0; pagenum < npages; pagenum++)
1420 const PageTableEntry *page = pages->getPPage(pagenum);
1421 if (!page->isConstantAndZeroSafe())
1437 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1446 template<
typename SRC_DATA_T>
1449 if (SYSisSame<DATA_T,void>())
1459 if (!SYSisSame<DATA_T,SRC_DATA_T>())
1464 new_val[i] = UTconvertStorage<NotVoidType>(val[i]);
1477 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1484 template<
typename SRC_DATA_T>
1487 if (SYSisSame<DATA_T,void>())
1497 if (!SYSisSame<DATA_T,SRC_DATA_T>())
1511 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1526 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1527 return !page->isConstant() && !page->isShared();
1540 PageTable *pages = myImpl.getPages();
1541 PageTableEntry *page = pages->getPPage(pagenum);
1544 return page->getFirstPtr();
1546 if (page->isConstant())
1548 else if (page->isShared())
1550 return page->getFirstPtr();
1560 PageTable *pages = myImpl.getPages();
1561 PageTableEntry *page = pages->getPPage(pagenum);
1564 return page->getFirstPtr();
1566 if (page->isConstant())
1568 else if (page->isShared())
1570 return page->getFirstPtr();
1586 PageTable *pages = myImpl.getPages();
1587 PageTableEntry *page = pages->getPPage(pagenum);
1589 UT_ASSERT_P(!PAGESHARDENED && page->isConstant());
1594 const exint tuplesize = (TSIZE >= 0) ? TSIZE : myImpl.getTupleSize();
1596 return page->getInlinePtr(tuplesize);
1599 if (!page->isShared())
1602 PageTableEntry newpage;
1606 newpage.setConstantBit();
1618 PageTable *pages = myImpl.getPages();
1619 if (PAGESHARDENED || (pages ==
nullptr))
1627 if (!SYSisSame<DATA_T,void>())
1630 pages->tryCompressPage(pagenum);
1632 pages->tryCompressPage(pagenum, myImpl.getTupleSize());
1638 hard.tryCompressPageUnknownType(pagenum);
1653 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1654 if (!page->isConstant())
1655 return page->getFirstPtr();
1674 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1675 if (!page->isConstant())
1676 return page->getFirstPtr();
1695 PageTable *
table = myImpl.getPages();
1699 bool decremented = table->decRefIffShared();
1701 myImpl.getPages() =
nullptr;
1725 PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1726 if (page->isConstant())
1728 if (
sizeof(
NotVoidType)*TSIZE <
sizeof(PageTableEntry))
1731 bool decremented = page->decRefIffShared();
1748 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1752 bool isconst = !PAGESHARDENED && page->isConstant();
1758 const void *
first = page->getFirstPtrVoid();
1762 UT_ASSERT_MSG_P(0,
"getGuaranteedInt() only supports int16, int32, and int64.");
1774 if (!page->isConstantZero())
1783 const void *
v = page->getMaskedPtrVoid();
1789 return *(
const int64 *)v;
1797 return *page->template castType<int64>()->getInlinePtr(1);
1801 return (
int64)*page->template castType<int32>()->getInlinePtr(1);
1803 return (
int64)*page->template castType<int16>()->getInlinePtr(1);
1812 template<
typename DEST_DATA_T=DATA_T>
1822 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
1826 bool isconst = !PAGESHARDENED && page->isConstant();
1832 const void *
first = page->getFirstPtrVoid();
1837 i = TSIZE*pageoff + component;
1839 i = myImpl.getTupleSize()*pageoff + component;
1843 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1844 return DEST_DATA_T();
1846 return (DEST_DATA_T)((
int8*)first)[i];
1848 return (DEST_DATA_T)((
uint8*)first)[i];
1850 return (DEST_DATA_T)((
int16*)first)[i];
1852 return (DEST_DATA_T)((
int32*)first)[i];
1854 return (DEST_DATA_T)((
int64*)first)[i];
1856 return (DEST_DATA_T)((
fpreal16*)first)[i];
1858 return (DEST_DATA_T)((
fpreal32*)first)[i];
1860 return (DEST_DATA_T)((
fpreal64*)first)[i];
1863 return DEST_DATA_T();
1869 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with a cast to a different type.");
1870 return DEST_DATA_T();
1872 return (DEST_DATA_T)castType<int8>().
getConstant(page->template castType<int8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1874 return (DEST_DATA_T)castType<uint8>().
getConstant(page->template castType<uint8>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1876 return (DEST_DATA_T)castType<int16>().
getConstant(page->template castType<int16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1878 return (DEST_DATA_T)castType<int32>().
getConstant(page->template castType<int32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1880 return (DEST_DATA_T)castType<int64>().
getConstant(page->template castType<int64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1882 return (DEST_DATA_T)castType<fpreal16>().
getConstant(page->template castType<fpreal16>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1884 return (DEST_DATA_T)castType<fpreal32>().
getConstant(page->template castType<fpreal32>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1886 return (DEST_DATA_T)castType<fpreal64>().
getConstant(page->template castType<fpreal64>(), component, (TSIZE >= 1 ? TSIZE : myImpl.getTupleSize()));
1888 return DEST_DATA_T();
1891 template<
int OP,
typename SRC_DATA_T>
1899 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opUnknownType.");
1902 castType<int8 >().
template op<OP>(i,component, UTconvertStorage<int8>(v));
return;
1904 castType<uint8 >().
template op<OP>(i,component, UTconvertStorage<uint8>(v));
return;
1906 castType<int16 >().
template op<OP>(i,component, UTconvertStorage<int16>(v));
return;
1908 castType<int32 >().
template op<OP>(i,component, UTconvertStorage<int32>(v));
return;
1910 castType<int64 >().
template op<OP>(i,component, UTconvertStorage<int64>(v));
return;
1912 castType<fpreal16>().
template op<OP>(i,component, (
fpreal16)
v);
return;
1914 castType<fpreal32>().
template op<OP>(i,component, (
fpreal32)
v);
return;
1916 castType<fpreal64>().
template op<OP>(i,component, (
fpreal64)
v);
return;
1920 template<
int OP,
typename SRC_DATA_T,ex
int SRC_TSIZE>
1928 UT_ASSERT_MSG_P(0,
"Can't write a non-numeric type with opVectorUnknownType.");
1931 castType<int8 >().
template opVector<OP>(i,v);
return;
1933 castType<uint8 >().
template opVector<OP>(i,v);
return;
1935 castType<int16 >().
template opVector<OP>(i,v);
return;
1937 castType<int32 >().
template opVector<OP>(i,v);
return;
1939 castType<int64 >().
template opVector<OP>(i,v);
return;
1941 castType<fpreal16>().
template opVector<OP>(i,v);
return;
1943 castType<fpreal32>().
template opVector<OP>(i,v);
return;
1945 castType<fpreal64>().
template opVector<OP>(i,v);
return;
1949 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1958 return castType<DEST_DATA_T>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1962 return castType<typename UT_StorageNum<DEST_DATA_T>::SecondGuess>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1967 UT_ASSERT_MSG_P(0,
"Can't read a non-numeric type with getVectorUnknownType.");
1970 return castType<int8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1972 return castType<uint8 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1974 return castType<int16 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1976 return castType<int32 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1978 return castType<int64 >().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1980 return castType<fpreal16>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1982 return castType<fpreal32>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1984 return castType<fpreal64>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
1989 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
1998 if (tuplesize == DEST_TSIZE)
1999 return castTupleSize<DEST_TSIZE>().
template getVector<DEST_DATA_T,DEST_TSIZE>(i);
2003 return castTupleSize<1>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2005 return castTupleSize<2>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2007 return castTupleSize<3>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2009 return castTupleSize<4>().
template getVectorMismatchedSize<DEST_DATA_T,DEST_TSIZE>(i);
2013 const exint minsize =
SYSmin(tuplesize,DEST_TSIZE);
2014 for (
exint component = 0; component < minsize; ++component)
2015 v[component] = get<DEST_DATA_T>(i, component);
2019 template<
typename DEST_DATA_T,ex
int DEST_TSIZE>
2028 const PageTableEntry *page = myImpl.getPages()->getPPage(pagenum);
2032 bool isconst = !PAGESHARDENED && page->isConstant();
2047 if (DEST_TSIZE < TSIZE)
2051 for (
exint component = 0; component < TSIZE; ++component)
2052 dsttuple[component] = srctuple[component];
2053 for (
exint component = TSIZE; component < DEST_TSIZE; ++component)
2054 dsttuple[component] = DEST_DATA_T(0);
2064 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2067 castType<int8>().
template hardenAllPages<false>(start, end);
return;
2069 castType<uint8>().
template hardenAllPages<false>(start, end);
return;
2071 castType<int16>().
template hardenAllPages<false>(start, end);
return;
2073 castType<int32>().
template hardenAllPages<false>(start, end);
return;
2075 castType<int64>().
template hardenAllPages<false>(start, end);
return;
2077 castType<fpreal16>().
template hardenAllPages<false>(start, end);
return;
2079 castType<fpreal32>().
template hardenAllPages<false>(start, end);
return;
2081 castType<fpreal64>().
template hardenAllPages<false>(start, end);
return;
2093 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2096 castType<int8>().
template tryCompressAllPages<false>(start, end);
return;
2098 castType<uint8>().
template tryCompressAllPages<false>(start, end);
return;
2100 castType<int16>().
template tryCompressAllPages<false>(start, end);
return;
2102 castType<int32>().
template tryCompressAllPages<false>(start, end);
return;
2104 castType<int64>().
template tryCompressAllPages<false>(start, end);
return;
2106 castType<fpreal16>().
template tryCompressAllPages<false>(start, end);
return;
2108 castType<fpreal32>().
template tryCompressAllPages<false>(start, end);
return;
2110 castType<fpreal64>().
template tryCompressAllPages<false>(start, end);
return;
2122 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2144 template<
typename SRC_DATA_T>
2152 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2174 template<
typename SRC_DATA_T>
2182 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
2204 template<
typename SRC_DATA_T>
2214 const exint tuplesize = myImpl.getTupleSize();
2215 dest_values.setSize(tuplesize);
2217 for (
exint i = 0; i < tuplesize; ++i)
2218 dest_values(i) = UTconvertStorage<NotVoidType>(values[i]);
2246 && (myPRefCount ==
nullptr);
2284 myPRefCount->
add(1);
2291 int64 new_count = myPRefCount->
add(-1);
2298 printf(
"Free page %d pages total\n",
int(thePageTablePageCount.add(-1)));
2319 printf(
"Alloc page %d pages total\n",
int(thePageTablePageCount.add(1)));
2326 UT_ASSERT_P(sizetocopy >= 0 && sizetocopy <= newpagecapacity);
2339 newpage.
alloc(newpagecapacity, tuplesize);
2344 sizetocopy *= tuplesize;
2347 *newdata = *olddata;
2353 myData = newpage.myData;
2354 myPRefCount = newpage.myPRefCount;
2501 myPRefCount =
nullptr;
2515 tuplesize = (TSIZE >= 0 ? TSIZE : tuplesize);
2519 for (
const NotVoidType *other = first+tuplesize; other <
end; other += tuplesize)
2521 for (
exint component = 0; component < (TSIZE >= 0 ? TSIZE : tuplesize); ++component)
2523 if (other[component] != first[component])
2531 const exint bytesize =
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize);
2542 if (!
isZero(first, (TSIZE >= 0 ? TSIZE : tuplesize)))
2546 memcpy(newfirst, first, bytesize);
2565 template<
typename DEST_DATA_T>
2573 template<
typename DEST_DATA_T>
2586 return (myData == that.myData) && (myPRefCount == that.myPRefCount);
2592 return (myData != that.myData) || (myPRefCount != that.myPRefCount);
2614 exint new_count = cur_count-1;
2616 if (prev_count == cur_count)
2618 cur_count = prev_count;
2628 UT_ASSERT_P(component >= 0 && component < tuplesize);
2636 return page->getInlinePtr(tuplesize)[component];
2648 return masked[component];
2659 UT_ASSERT_P(component >= 0 && component < tuplesize);
2665 return page->getInlinePtr(tuplesize) + component;
2673 return masked + component;
2696 bool wasconst = page->isConstant();
2701 if (
sizeof(PageTableEntry) >
sizeof(Tuple))
2705 *(Tuple *)tuple = val;
2721 else if (iszero || (page->isShared() && (*(
const Tuple*)masked != val)))
2726 else if (!page->isShared())
2729 *(Tuple*)masked = val;
2747 PageTableEntry newpage;
2750 (*(Tuple*)tuple) =
val;
2751 newpage.setConstantBit();
2766 bool wasconst = page->isConstant();
2774 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2775 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2797 else if (page->isShared())
2800 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2802 if (masked[i] != val)
2821 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2834 PageTableEntry newpage;
2837 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2839 newpage.setConstantBit();
2854 bool wasconst = page->isConstant();
2862 NotVoidType *tuple = page->getInlinePtr(tuplesize);
2863 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2864 tuple[i] = values[i];
2868 bool iszero =
isZero(values, (TSIZE >= 0 ? TSIZE : tuplesize));
2885 else if (page->isShared())
2888 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2890 if (masked[i] != values[i])
2909 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2910 masked[i] = values[i];
2922 PageTableEntry newpage;
2925 for (
exint i = 0; i < (TSIZE >= 0 ? TSIZE : tuplesize); ++i)
2926 tuple[i] = values[i];
2927 newpage.setConstantBit();
2934 template<
typename SrcType>
2943 template<
typename SrcType>
2953 template<
typename SrcType>
2958 template<
typename SrcNotVo
idType>
2964 template<
typename SrcNotVo
idType>
2969 template<
typename SrcNotVo
idType>
2978 PageTableEntry newpage;
2979 newpage.alloc(pagecapacity, tuplesize);
2982 if (isinline ? page->isConstantAndZeroSafe() : page->isConstantZero())
2984 memset(dest, 0, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
2990 src = page->getInlinePtr(tuplesize);
2992 src = page->getMaskedPtr();
2994 for (
UT_PageOff i = 0; i < pagecapacity; ++i)
2996 for (
exint component = 0; component < tuplesize; ++component, ++dest)
2997 *dest = src[component];
3012 PageTableEntry newpage;
3013 newpage.alloc(pagecapacity, tuplesize);
3016 if (!isinline && !page->isConstantZero())
3030 PageTableEntry newpage;
3031 newpage.alloc(pagecapacity, tuplesize);
3034 memcpy(dest, src, (
sizeof(
NotVoidType)*(TSIZE >= 0 ? TSIZE : tuplesize))*pagecapacity);
3048 PageTableEntry newpage;
3049 newpage.alloc(pagecapacity, tuplesize);
3080 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3085 UT_ASSERT_P(myCapacity > IDX_T(i << THEPAGEBITS));
3113 if (PAGESHARDENED && newsize > mySize)
3141 if (PAGESHARDENED && newsize > mySize)
3173 const int64 new_count = myRefCount.
add(-1);
3182 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3189 if (page->
isRefd(bytesize))
3194 printf(
"Free table %d pages (case 0); %d tables total\n",
int(npages),
int(thePageTableCount.add(-1)));
3237 pagesize = pagesizetemp;
3255 if (pagenum+1 >= npages)
3257 if (pagenum+1 == npages)
3261 pagesize = pagesizetemp;
3276 printf(
"Alloc table %d pages; %d tables total\n",
int(npages),
int(thePageTableCount.add(1)));
3286 if (newcapacity == IDX_T(0))
3289 pages->
decRef(tuplesize);
3296 bool wasshared = pages && pages->
isShared();
3298 IDX_T oldcapacity = pages ? pages->
capacity() : IDX_T(0);
3320 if (nonconstfirst && newcapacity != oldcapacity)
3326 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3331 pages->myCapacity = newcapacity;
3332 if (pages->mySize > newcapacity)
3333 pages->mySize = newcapacity;
3338 table->myCapacity = newcapacity;
3345 const bool willbesmallfirstpage = newcapacity < IDX_T(
thePageSize);
3348 table->mySize = pages->mySize;
3353 const size_t bytesize =
sizeof(
NotVoidType)*((TSIZE >= 0) ? TSIZE : tuplesize);
3362 if (page->
isRefd(bytesize))
3365 pages->
decRef(tuplesize);
3377 if (page->
isRefd(bytesize))
3383 printf(
"Free table %d pages (case 1); %d tables total\n",
int(oldnpages),
int(thePageTableCount.add(-1)));
3390 if (table->mySize > newcapacity)
3391 table->mySize = newcapacity;
3398 if (nonconstfirst && (wassmallfirstpage || willbesmallfirstpage) && newcapacity != oldcapacity)
3403 page->
realloc(sizetocopy, newpagecapacity, tuplesize);
3409 table->mySize = IDX_T(0);
3419 if (PAGESHARDENED && wasshared)
3457 const exint arraycapacity(
exint(pages->capacity()));
3463 const exint arraycapacity(
exint(pages->capacity()));
3469 const exint arraycapacity(
exint(pages->capacity()));
3475 const exint arraycapacity(
exint(pages->capacity()));
3481 const exint arraycapacity(
exint(pages->capacity()));
3487 const exint arraycapacity(
exint(pages->capacity()));
3493 const exint arraycapacity(
exint(pages->capacity()));
3499 const exint arraycapacity(
exint(pages->capacity()));
3507 if (SYSisSame<DATA_T,void>())
3513 UT_ASSERT_MSG_P(0,
"Can't have a non-numeric type with a void DATA_T.");
3535 PageTable *&pages = myImpl.getPages();
3540 template<
typename T>
3547 memset(&zero, 0,
sizeof(
T));
3548 return (val == zero);
3551 template<
typename T>
3562 memset(&zero, 0,
sizeof(
T));
3565 for (
exint i = 1; i < tuplesize; ++i)
3566 iszero &= (val[i] == zero);
3570 template<
typename T0,
typename T1>
3577 for (
exint i = 0; i < tuplesize; ++i)
3585 template<
typename DEST_TYPE,
typename SRC_TYPE,ex
int SRC_TSIZE,
bool SRC_INSTANTIATED>
3589 if (SYSisSame<DEST_TYPE,SRC_TYPE>())
3593 for (
exint i = 0; i < SRC_TSIZE; ++i)
3594 dest[i] = UTconvertStorage<DEST_TYPE>(src[i]);
3610 template<ex
int ITSIZE,
typename IDATA_T>
3612 private ImplPageData,
3616 SYS_FORCE_INLINE const PageTable *getPages()
const {
return ImplPageData::myPages; }
3624 Impl<TSIZE,DATA_T> myImpl;
void hardenAllPages(IDX_T start, IDX_T end, exint tuplesize=TSIZE)
SYS_FORCE_INLINE NotVoidType operator()(IDX_T i, exint component=0) const
Read element i's specified component (default component 0).
SYS_FORCE_INLINE constexpr const T * data() const noexcept
static void hardenConstantPageNoInit(PageTable *pages, PageTableEntry *page)
static void copyNonConst(NotVoidType *destpagedata, const SrcNotVoidType *srcpagedata, exint desttuplesize, exint srctuplesize, UT_PageOff ntuples)
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
static void hardenConstantPage(PageTable *pages, PageTableEntry *page, exint tuplesize)
SYS_FORCE_INLINE void opVector(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE > &v)
void printf(internal::basic_buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
static SYS_FORCE_INLINE const NotVoidType * getConstantPtr(const PageTableEntry *page, exint component=0, exint tuplesize=TSIZE)
SYS_FORCE_INLINE void setSize(IDX_T newsize)
static SYS_FORCE_INLINE bool decCounterIffAbove1(SYS_AtomicCounter &counter)
SYS_FORCE_INLINE const NotVoidType * getInlinePtr(exint tuplesize) const
Returns the data pointer, if an inline constant page.
SYS_FORCE_INLINE void * getFirstPtrVoid()
Returns the data pointer, if not a constant page.
static void hardenSharedPageNoInit(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
void hardenAllPagesUnknownType(IDX_T start, IDX_T end)
void tryCompressPage(UT_PageOff pagesize, exint tuplesize=TSIZE)
static ThisType * harden(ThisType *pages, IDX_T newcapacity, exint tuplesize=TSIZE)
static void hardenSharedPage(PageTable *pages, PageTableEntry *page, exint tuplesize)
SYS_FORCE_INLINE bool isArrayZero() const
Returns true iff the entire array is constant & zero.
static const UT_Storage theStorage
static SYS_FORCE_INLINE NotVoidType getConstant(const PageTableEntry *const page, exint component, exint tuplesize=TSIZE)
NotVoid< DATA_T >::type NotVoidType
UT_PageArray(const ThisType &that)
void setTupleSize(exint newtuplesize, const UT_Defaults &v)
static ThisType * alloc(UT_PageNum npages)
void tryCompressPage(UT_PageNum pagenum, exint tuplesize=TSIZE)
SYS_FORCE_INLINE const NotVoidType * getMaskedPtr() const
void copy(IDX_T dest, IDX_T src)
Copies a single element from src to dest within this.
void tryCompressAllPagesUnknownType(IDX_T start, IDX_T end)
SYS_FORCE_INLINE ~UT_PageArray()
SYS_FORCE_INLINE bool operator!=(const ThisType &that) const
NOTE: This just does a shallow comparison.
SYS_FORCE_INLINE bool isZero() const noexcept
void tryCompressAllPages(IDX_T start, IDX_T end, exint tuplesize=TSIZE)
GLuint const GLfloat * val
SYS_FORCE_INLINE void clear()
SYS_FORCE_INLINE ThisType & operator=(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
static void hardenSharedPageNoInit(PageTable *pages, PageTableEntry *page, exint tuplesize)
GLboolean GLboolean GLboolean GLboolean a
void opVectorUnknownType(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE > &v)
GLenum GLsizei GLenum GLenum const void * table
SYS_FORCE_INLINE IDX_T size() const
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
GLint GLsizei const GLuint64 * values
SYS_FORCE_INLINE void add(IDX_T i, SRC_DATA_T v)
component == 0 in this version
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorUnknownSize(IDX_T i) const
SYS_FORCE_INLINE bool isShared() const
void countMemory(UT_MemoryCounter &counter, bool inclusive) const
SYS_FORCE_INLINE PageTableEntry * getFirstPage()
static void hardenSharedPageNoInit(PageTable *pages, PageTableEntry *page)
void setConstant(IDX_T start, IDX_T end, NotVoidType v)
void opUnknownType(IDX_T i, exint component, SRC_DATA_T v)
SYS_FORCE_INLINE const PageTableEntry * getPPage(UT_PageNum i) const
static void hardenConstantPage(PageTable *pages, PageTableEntry *page)
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, true, THEPAGEBITS, IDX_T > & hardenAllPages(IDX_T start=IDX_T(0), IDX_T end=IDX_T(-1))
static const exint theTupleSize
SYS_FORCE_INLINE UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T >::PageTableEntry * castType()
SYS_FORCE_INLINE exint getTupleSize() const
DEST_DATA_T getUnknownType(IDX_T i, exint component=0) const
SYS_SelectType< T, float, SYS_IsSame< T, void >::value >::type type
#define UT_ASSERT_MSG_P(ZZ,...)
SYS_FORCE_INLINE IDX_T size() const
NOTE: This is the size of the full array, not the number of pages.
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(IDX_T i) const
#define UT_IF_ASSERT_P(ZZ)
SYS_FORCE_INLINE void set(IDX_T i, SRC_DATA_T v)
component == 0 in this version
SYS_FORCE_INLINE UT_Storage getStorage() const
static SYS_FORCE_INLINE IDX_T roundUpCapacity(IDX_T capacity)
SYS_FORCE_INLINE bool isTableHardened() const
Returns true iff the table isn't shared with any other UT_PageArray's.
SYS_FORCE_INLINE exint getRefCount() const
SYS_FORCE_INLINE UT_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castTupleSize()
bool hasNanInRange(IDX_T start, IDX_T end) const
static SYS_FORCE_INLINE UT_FixedVector< DEST_TYPE, SRC_TSIZE > convertVectorStorage(const UT_FixedVector< SRC_TYPE, SRC_TSIZE, SRC_INSTANTIATED > &src)
UT_PageArray(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
UT_PageArray(exint tuplesize, UT_Storage storage)
SYS_FORCE_INLINE void addVector(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE, SRC_INSTANTIATED > &v)
void tryCompressPageUnknownType(UT_PageNum pagenum)
void decRef(exint tuplesize)
SYS_FORCE_INLINE bool isShared() const
void fill(IDX_T start, IDX_T end, const NotVoidType &val)
static bool isEqualConst(const NotVoidType *tuple, const SrcNotVoidType *stuple, exint mintuplesize)
SYS_FORCE_INLINE void setConstantBit()
#define UT_ASSERT_MSG(ZZ,...)
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorMismatchedSize(IDX_T i) const
UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVectorUnknownType(IDX_T i) const
SYS_FORCE_INLINE exint getRefCount() const
SYS_FORCE_INLINE bool isConstantZero() const
This is only valid to call if the type doesn't fit inline.
SYS_FORCE_INLINE void setSize(IDX_T newsize, exint tuplesize)
static SYS_FORCE_INLINE UT_PageOff pageOff(IDX_T i)
UT_PageArray(UT_Storage storage)
static SYS_FORCE_INLINE void call(FUNCTOR functor, ARGS &&...args)
SYS_FORCE_INLINE void tryCompressPage(UT_PageNum pagenum)
SYS_FORCE_INLINE ThisType & operator=(const ThisType &that)
static SYS_FORCE_INLINE bool typeFitsInline(exint tuplesize=TSIZE)
This is only valid to call when DATA_T is non-void.
SYS_FORCE_INLINE const PageTableEntry * getFirstPage() const
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const UT_FixedVector< SRC_DATA_T, theSafeTupleSize > &val)
static SYS_FORCE_INLINE UT_PageNum numPages(IDX_T nelements)
static SYS_FORCE_INLINE bool isEqual(const T0 *a, const T1 *b, exint tuplesize)
SYS_FORCE_INLINE void getRange(IDX_T srcstart, IDX_T nelements, T *dest) const
GLint GLenum GLsizei GLint GLsizei const void * data
SYS_FORCE_INLINE bool isRefd(exint tuplebytes) const
SYS_FORCE_INLINE bool operator==(const ThisType &that) const
NOTE: This just does a shallow comparison.
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
SYS_FORCE_INLINE IDX_T capacity() const
NOTE: This is the capacity of the full array, not the capacity of pages.
static SYS_FORCE_INLINE bool isZero(const T &val)
SYS_FORCE_INLINE IDX_T capacity() const
T compare_swap(T expected, T desired)
SYS_FORCE_INLINE NotVoidType * hardenPage(UT_PageNum pagenum)
UT_FixedVector< NotVoidType, theSafeTupleSize > Tuple
SYS_FORCE_INLINE void op(IDX_T i, exint component, SRC_DATA_T v)
SYS_FORCE_INLINE NotVoidType * getInlinePtr(exint tuplesize)
Returns the data pointer, if an inline constant page.
void setCapacity(IDX_T newcapacity)
SYS_FORCE_INLINE void setVector(IDX_T i, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE, SRC_INSTANTIATED > &v)
SYS_FORCE_INLINE void * getMaskedPtrVoid()
static SYS_FORCE_INLINE UT_PageOff pageStart(IDX_T page)
UT_PageArray(exint tuplesize)
SYS_FORCE_INLINE const void * getFirstPtrVoidUnsafe() const
static void copyPartialPage(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize, UT_PageOff destoff, UT_PageOff srcoff, UT_PageOff ntuples, UT_PageOff destpagecapacity)
SYS_FORCE_INLINE bool isConstantAndZeroSafe() const
void setPageConstantUnknownType(UT_PageNum pagenum, const UT_FixedVector< SRC_DATA_T, theSafeTupleSize > &val)
SYS_FORCE_INLINE bool decRefIffShared(exint tuplesize=TSIZE)
static void makeConstant(PageTableEntry *page, const NotVoidType *values, exint tuplesize)
SYS_FORCE_INLINE NotVoidType * hardenPageNoInit(UT_PageNum pagenum)
SYS_FORCE_INLINE void tryCompressAllPages(IDX_T start=IDX_T(0), IDX_T end=IDX_T(-1))
static const exint thePageBits
SYS_FORCE_INLINE void add(IDX_T i, exint component, SRC_DATA_T v)
const NotVoidType * getPageData(UT_PageNum pagenum) const
static const exint theSafeTupleSize
SYS_FORCE_INLINE void incRef()
void realloc(UT_PageOff sizetocopy, UT_PageOff newpagecapacity, exint tuplesize=TSIZE)
static void makeConstantFrom(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize)
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const SRC_DATA_T *values)
void moveRange(IDX_T srcstart, IDX_T deststart, IDX_T nelements)
static const exint thePageMask
void getVectorRange(IDX_T srcstart, IDX_T nelements, UT_FixedVector< DEST_DATA_T, DEST_TSIZE, DEST_INSTANTIATED > *dest) const
static void hardenConstantPageNoInit(PageTable *pages, PageTableEntry *page, exint tuplesize)
GLdouble GLdouble GLdouble b
static const uintptr_t theConstantPageBit
SYS_FORCE_INLINE int64 getMemoryUsage(exint tuplebytes) const
SYS_AtomicInt< int32 > SYS_AtomicCounter
SYS_FORCE_INLINE const UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castType() const
void setSize(IDX_T newsize)
SYS_FORCE_INLINE const void * getMaskedPtrVoid() const
SYS_FORCE_INLINE const UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T >::PageTableEntry * castType() const
void swapRange(IDX_T astart, IDX_T bstart, IDX_T nelements)
SYS_FORCE_INLINE void * getFirstPtrVoidUnsafe()
bool decRefIffSharedPage(UT_PageNum pagenum)
void setPageConstantUnknownType(UT_PageNum pagenum, const SRC_DATA_T *values)
SYS_FORCE_INLINE PageTableEntry * getPPage(UT_PageNum i)
void setStorage(const UT_Storage newstorage)
SYS_FORCE_INLINE void set(IDX_T i, exint component, SRC_DATA_T v)
static void hardenConstantPageNoInit(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
static void fillNonConstWithConst(NotVoidType *destpagedata, NotVoidType *destpageend, const SrcNotVoidType *stuple, exint mintuplesize, exint desttupleextra)
SYS_FORCE_INLINE NotVoidType * getMaskedPtr()
bool decRefIffSharedTable()
SYS_FORCE_INLINE const UT_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castTupleSize() const
SYS_FORCE_INLINE bool isConstant() const
This is always valid to call.
SYS_FORCE_INLINE void setRange(IDX_T deststart, IDX_T nelements, const T *src)
static void hardenSharedPage(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
SYS_FORCE_INLINE const void * getFirstPtrVoid() const
Returns the data pointer, if not a constant page.
static SYS_FORCE_INLINE NotVoidType * getConstantPtr(PageTableEntry *page, exint component=0, exint tuplesize=TSIZE)
static SYS_FORCE_INLINE void makeConstant(PageTableEntry *page, const UT_FixedVector< NotVoidType, theSafeTupleSize > &val)
bool equal(T1 a, T2 b, T3 t)
static void makeConstant(PageTableEntry *page, const NotVoidType &val, exint tuplesize=TSIZE)
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, PAGESHARDENED, THEPAGEBITS, IDX_T > & hardenTable()
static const exint thePageSize
static SYS_FORCE_INLINE bool isZero(const T *val, exint tuplesize)
SYS_FORCE_INLINE void alloc(UT_PageOff nelements, exint tuplesize=TSIZE)
T add(T val)
Atomically adds val to myValue, returning the new value of myValue.
static void hardenConstantPage(PageTableEntry *page, UT_PageOff pagecapacity, exint tuplesize=TSIZE)
getOption("OpenEXR.storage") storage
Container class for all geometry.
int64 getMemoryUsage(bool inclusive) const
static SYS_FORCE_INLINE UT_PageNum pageNum(IDX_T i)
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > ThisType
static void hardenSharedPage(PageTable *pages, PageTableEntry *page)
void setCapacityIfNeeded(IDX_T newcapacity)
void forceHardenTable(IDX_T newcapacity)
SYS_FORCE_INLINE int64 getGuaranteedInt(IDX_T i) const
SYS_FORCE_INLINE void relaxedStore(T val)
SYS_FORCE_INLINE NotVoidType * unshareConstantPage(UT_PageNum pagenum)
ImageBuf OIIO_API zero(ROI roi, int nthreads=0)
SYS_FORCE_INLINE bool isPageHard(UT_PageNum pagenum) const
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > ParentType
SYS_FORCE_INLINE constexpr int UTstorageSize(UT_Storage storage)
Returns the number of bytes in the given storage type.
SYS_FORCE_INLINE void initZero()
SYS_FORCE_INLINE const NotVoidType * getFirstPtr() const
Returns the data pointer, if not a constant page.
SYS_FORCE_INLINE NotVoidType * getFirstPtr()
Returns the data pointer, if not a constant page.
void setPageConstantMismatchedType(UT_PageNum pagenum, const SRC_DATA_T *values)
void replace(const UT_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED, THEPAGEBITS, IDX_T > &that)
SYS_FORCE_INLINE NotVoidType & operator()(IDX_T i, exint component=0)
SYS_FORCE_INLINE T relaxedLoad() const
NotVoidType * getPageData(UT_PageNum pagenum)
void setVectorRange(IDX_T deststart, IDX_T nelements, const UT_FixedVector< SRC_DATA_T, SRC_TSIZE, SRC_INSTANTIATED > *src)
SYS_FORCE_INLINE void decRef()
static void replacePage(PageTableEntry *dest, const typename SrcType::PageTableEntry *src, exint desttuplesize, exint srctuplesize, UT_PageOff destpagesize, UT_PageOff destpagecapacity)
SYS_FORCE_INLINE UT_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, THEPAGEBITS, IDX_T > & castType()