tamarin之inlinehashtable
来源:互联网 发布:越南viettel 网络类型 编辑:程序博客网 时间:2024/06/05 01:56
// ------------------------ DATA SECTION BEGIN
private:指向atom数组,该数组是atom指针。
uintptr_t m_atomsAndFlags; /** property hashtable, this has no DWB on purpose, setAtoms contains the WB */
#ifdef AVMPLUS_64BIT
// on 64-bit systems, padding will force us to 16 bytes here anyway, so let's just use unpacked ints
uint32_t m_size; // number of properties
uint32_t m_logCapacity; // (log2 of capacity) + 1
#else
uint32_t m_size:27; // number of properties
uint32_t m_logCapacity:5; // (log2 of capacity) + 1 -- gives us enough space for 2^32 entries
#endif
private:指向atom数组,该数组是atom指针。
uintptr_t m_atomsAndFlags; /** property hashtable, this has no DWB on purpose, setAtoms contains the WB */
#ifdef AVMPLUS_64BIT
// on 64-bit systems, padding will force us to 16 bytes here anyway, so let's just use unpacked ints
uint32_t m_size; // number of properties
uint32_t m_logCapacity; // (log2 of capacity) + 1
#else
uint32_t m_size:27; // number of properties
uint32_t m_logCapacity:5; // (log2 of capacity) + 1 -- gives us enough space for 2^32 entries
#endif
// ------------------------ DATA SECTION END
在32位系统下,inlinehashtable只占用8byte。
static inline uint32_t FindOneBit(uint32_t value)中用到了
_BitScanReverse()
Microsoft Specific
Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).
从最高位到最低位查找mask的1,也就是查找值为1的最高位unsigned char _BitScanReverse( unsigned long * Index, unsigned long Mask);unsigned char _BitScanReverse64( unsigned long * Index, unsigned __int64 Mask);void InlineHashtable::put(Atom name, Atom value) { Atom* atoms = getAtoms(); int i = find(name, atoms, getCapacity());获取hashtable的容量,1UL<<(m_logCapacity-1) GC *gc = GC::GetGC(atoms); if (removeDontEnumMask(atoms[i]) != name) { AvmAssert(!isFull()); //atoms[i] = name; WBATOM(gc, atoms, &atoms[i], name); m_size++; } //atoms[i+1] = value; WBATOM( gc, atoms, &atoms[i+1], value); }int InlineHashtable::find(Atom x, const Atom *t, uint32_t m) const { uintptr_t mask = ~(m_atomsAndFlags & kDontEnumBit(0x1)); x &= mask; #if 0 // debug code to print out the strings we're searching for static int debug =0; if (debug && AvmCore::isString(x)) { Stringp s = AvmCore::atomToString(x); AvmDebugMsg (s->c_str(), false); AvmDebugMsg ("\n", false); } #endif uintptr_t bitmask = (m - 1) & ~0x1; AvmAssert(x != EMPTY && x != DELETED); // this is a quadratic probe but we only hit even numbered slots since those hold keys. int n = 7 << 1; #ifdef _DEBUG uint32_t loopCount = 0; #endif // Note: Mask off MSB to avoid negative indices. Mask off bottom // 3 bits because it doesn't contribute to hash. Double it // because names, values stored adjacently. uint32_t i = ((0x7FFFFFF8 & x)>>2) & bitmask; Atom k; while ((k=t[i]&mask) != x && k != EMPTY) { i = (i + (n += 2)) & bitmask; // quadratic probe AvmAssert(loopCount++ < m); // don't scan forever } AvmAssert(i <= ((m-1)&~0x1)); return i; }Atom removeDontEnumMask(Atom a) const { return Atom(uintptr_t(a) & ~(m_atomsAndFlags & kDontEnumBit)); }清除原子的不用枚举标志对于名值对,//atoms[i+1] = value;WBATOM( gc, atoms, &atoms[i+1], value);
???如何解决冲突
- tamarin之inlinehashtable
- [tamarin系列之1] tamarin简介
- [tamarin系列之6] tamarin外篇---As3Eval
- [tamarin系列之6] tamarin外篇---As3Eval
- tamarin之Atom
- tamarin之gc
- Tamarin
- tamarin
- [tamarin系列之2] avmshell命令行基础
- [tamarin系列之9] 在线的eval
- [tamarin系列之3] ASC编译器命令行基础
- [tamarin系列之4] 构建专用的avmshell
- [tamarin系列之5] 植入本地方法实现
- [tamarin系列之7]客户端脚本引擎axscript
- [tamarin系列之8] 配合as3eval的as3c
- tamarin系列之5] 植入本地方法实现
- tamarin源码下载地址
- AVM2 - tamarin简介
- JAVA IO流 创建文件 读写字符串
- 造成win2008 500内部错误不能显示详细错误的原因和解决方法
- 博客从chinaunix迁移至CSDN
- Chrome扩展:让你使用浏览器打开Office文件
- db link
- tamarin之inlinehashtable
- Eclipse程序员要掌握的常用快捷键
- EXCEL 2010设置每次打开文件都从新窗口打开
- $.ajax()常用参数的设置及其意义
- 如何优化MySQL insert性能
- c++类型转换String^,int,string,char*,时间格式字符串
- LInux Centos 支持NTFS文件系统加载的方法
- VirtualBox虚拟机网络环境解析和搭建-NAT、桥接、Host-Only、Internal、端口映射
- 9次作业