Created
October 26, 2010 12:12
-
-
Save bga/646798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct HashTable // Open addressing Hash Table with linear probing | |
{ | |
int entriesCount; | |
int id; | |
HashTableEntry entries[0]; | |
}; | |
void HashTable::_set(Const String key, Value& value) | |
{ | |
// if key is new | |
id++; | |
} | |
void HashTable::_delete(Const String key) | |
{ | |
// if key is exist | |
id++; | |
} | |
void _patch(void *ip) | |
{ | |
// calculate offset in hash table | |
// create new opcodes by template | |
// and patch code at address ip | |
// if key not exist return undefined | |
// else return address of Value | |
} | |
.code | |
// jit code | |
; ebx - Object address | |
; var a:int = b.c | |
_a: | |
cmp dword ptr [ebx + 8], %id%; compare .id and inlined id | |
je _directOffset | |
push %_a address% | |
push %address of key String% | |
call _patch | |
_directOffset: | |
mov eax, dword ptr [ebx + 12 + %offset%*32 + 4] ; for int | |
; fld st(0), [ebx + 12 + %offset%*32 + 4] ; for double | |
; 12 - .entries, 32 - size of HashTableEntry, 4 - .numberIntValue in Value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment