diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-18 21:36:14 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-18 21:36:14 (GMT) |
commit | d50544a3de540727137f2b13010ca4450f8ea10f (patch) | |
tree | 05e4ad65c25570016d5732f425a9eff2f4117d34 /src/arch/dalvik/operands/register.c | |
parent | b0bcf250999b2242019f137e38f52390a86e71cd (diff) |
Used a fast sorted array to track shared instances instead of a simple hash table.
Diffstat (limited to 'src/arch/dalvik/operands/register.c')
-rw-r--r-- | src/arch/dalvik/operands/register.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c index dcdcbac..613e0d4 100644 --- a/src/arch/dalvik/operands/register.c +++ b/src/arch/dalvik/operands/register.c @@ -65,13 +65,10 @@ static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *); static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *); /* Initialise un nouvel objet partagé avec des informations. */ -static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *, const GDalvikRegister *); - -/* Indique l'objet partagé correspond à une description donnée. */ -static gboolean g_dalvik_register_operand_compare_info(const GDalvikRegisterOperand *, const GDalvikRegister *); +static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *, const GDalvikRegisterOperand *); /* Compare un opérande avec un autre. */ -static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); +static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand * const *, const GDalvikRegisterOperand * const *); /* Traduit un opérande en version humainement lisible. */ static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *, GBufferLine *, AsmSyntax); @@ -120,7 +117,6 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl operand = G_ARCH_OPERAND_CLASS(klass); operand->init = (init_shared_fc)g_dalvik_register_operand_do_init; - operand->cmp_info = (compare_shared_info_fc)g_dalvik_register_operand_compare_info; operand->compare = (operand_compare_fc)g_dalvik_register_operand_compare; operand->print = (operand_print_fc)g_dalvik_register_operand_print; @@ -275,8 +271,11 @@ GArchOperand *g_dalvik_register_operand_new(const GBinContent *content, vmpa2t * GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) { GArchOperand *result; /* Structure à retourner */ + GDalvikRegisterOperand fake; /* Transport d'informations */ + + fake.reg = reg; - result = G_ARCH_OPERAND(g_share_manager_get(_dalvik_register_operand_manager, reg)); + result = G_ARCH_OPERAND(g_share_manager_get(_dalvik_register_operand_manager, (GSharedInstance *)&fake)); return result; @@ -286,7 +285,7 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) /****************************************************************************** * * * Paramètres : operand = objet partagé à initialiser. * -* reg = registre Dalvik à associer à l'opérande. * +* fake = coquille vide contenant les infos à enregistrer. * * * * Description : Initialise un nouvel objet partagé avec des informations. * * * @@ -296,9 +295,9 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) * * ******************************************************************************/ -static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *operand, const GDalvikRegister *reg) +static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *operand, const GDalvikRegisterOperand *fake) { - operand->reg = reg; + operand->reg = fake->reg; return true; @@ -307,30 +306,6 @@ static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *operand, c /****************************************************************************** * * -* Paramètres : operand = objet partagé à consulter. * -* reg = registre Dalvik utilisé comme description. * -* * -* Description : Indique l'objet partagé correspond à une description donnée. * -* * -* Retour : TRUE si les détails centraux sont partagés, FALSE sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static gboolean g_dalvik_register_operand_compare_info(const GDalvikRegisterOperand *operand, const GDalvikRegister *reg) -{ - gboolean result; /* Bilan à retourner */ - - result = g_arch_register_equal(G_ARCH_REGISTER(operand->reg), G_ARCH_REGISTER(reg)); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : a = premier opérande à consulter. * * b = second opérande à consulter. * * * @@ -342,9 +317,13 @@ static gboolean g_dalvik_register_operand_compare_info(const GDalvikRegisterOper * * ******************************************************************************/ -static bool g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b) +static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand * const *a, const GDalvikRegisterOperand * const *b) { - return (g_arch_register_compare(G_ARCH_REGISTER(a->reg), G_ARCH_REGISTER(b->reg)) == 0); + int result; /* Bilan à retourner */ + + result = g_dalvik_register_compare(&(*a)->reg, &(*b)->reg); + + return result; } |