void ThreadSharedVariant::getStats(SharedVariantStats *stats) { stats->initStats(); stats->variantCount = 1; switch (m_type) { case KindOfBoolean: case KindOfInt64: stats->dataSize = sizeof(m_data.num); stats->dataTotalSize = sizeof(ThreadSharedVariant); break; case KindOfDouble: stats->dataSize = sizeof(m_data.dbl); stats->dataTotalSize = sizeof(ThreadSharedVariant); break; case KindOfString: case KindOfObject: if (m_data.str->isStatic()) { stats->dataSize = 0; stats->dataTotalSize = sizeof(ThreadSharedVariant); break; } stats->dataSize = m_data.str->size(); stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(StringData) + stats->dataSize; break; default: ASSERT(is(KindOfArray)); if (getSerializedArray()) { stats->dataSize = m_data.str->size(); stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(StringData) + stats->dataSize; break; } if (getIsVector()) { stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(VectorData); stats->dataTotalSize += sizeof(ThreadSharedVariant*) * m_data.vec->size; for (size_t i = 0; i < m_data.vec->size; i++) { ThreadSharedVariant *v = m_data.vec->vals[i]; SharedVariantStats childStats; v->getStats(&childStats); stats->addChildStats(&childStats); } } else { ImmutableMap *map = m_data.map; stats->dataTotalSize = sizeof(ThreadSharedVariant) + map->getStructSize(); for (int i = 0; i < map->size(); i++) { SharedVariantStats childStats; map->getKeyIndex(i)->getStats(&childStats); stats->addChildStats(&childStats); map->getValIndex(i)->getStats(&childStats); stats->addChildStats(&childStats); } } break; } }
void ThreadSharedVariant::getStats(SharedVariantStats *stats) { stats->initStats(); stats->variantCount = 1; switch (m_type) { case KindOfNull: case KindOfBoolean: case KindOfInt64: case KindOfDouble: stats->dataSize = sizeof(m_data.dbl); stats->dataTotalSize = sizeof(ThreadSharedVariant); break; case KindOfObject: if (getIsObj()) { SharedVariantStats childStats; m_data.obj->getSizeStats(&childStats); stats->addChildStats(&childStats); break; } // fall through case KindOfString: if (m_data.str->isStatic()) { stats->dataSize = 0; stats->dataTotalSize = sizeof(ThreadSharedVariant); break; } stats->dataSize = m_data.str->size(); stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(StringData) + stats->dataSize; break; default: ASSERT(is(KindOfArray)); if (getSerializedArray()) { stats->dataSize = m_data.str->size(); stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(StringData) + stats->dataSize; break; } if (getIsVector()) { stats->dataTotalSize = sizeof(ThreadSharedVariant) + sizeof(VectorData); stats->dataTotalSize += sizeof(ThreadSharedVariant*) * m_data.vec->size; for (size_t i = 0; i < m_data.vec->size; i++) { ThreadSharedVariant *v = m_data.vec->vals[i]; SharedVariantStats childStats; v->getStats(&childStats); stats->addChildStats(&childStats); } } else if (RuntimeOption::ApcUseGnuMap) { // There is no way to calculate this accurately, and this should be only // used if ImmutableMap is seriously broken, when profiling is less // important. Just not do basic thing here: stats->dataTotalSize = sizeof(MapData); } else { ImmutableMap *map = m_data.map; stats->dataTotalSize = sizeof(ThreadSharedVariant) + map->getStructSize(); for (int i = 0; i < map->size(); i++) { SharedVariantStats childStats; map->getKeyIndex(i)->getStats(&childStats); stats->addChildStats(&childStats); map->getValIndex(i)->getStats(&childStats); stats->addChildStats(&childStats); } } break; } }