diff --git a/erts/emulator/beam/jit/arm/beam_asm.hpp b/erts/emulator/beam/jit/arm/beam_asm.hpp index 9ce3e2e4f452..f4dff0cb7b9e 100644 --- a/erts/emulator/beam/jit/arm/beam_asm.hpp +++ b/erts/emulator/beam/jit/arm/beam_asm.hpp @@ -967,9 +967,9 @@ class BeamModuleAssembler : public BeamAssembler, arm::Mem mem; }; - /* Using more than two cache entries does not seem worthwhile. */ - static const int num_cache_entries = 4; - CacheEntry cache[num_cache_entries]; + static const int max_cache_entries = 16; + CacheEntry cache[max_cache_entries]; + int num_cache_entries = 0; /* Private helpers. */ void preserve__cache(bool cache_was_valid) { @@ -989,10 +989,7 @@ class BeamModuleAssembler : public BeamAssembler, void consolidate_cache() { if (!is_cache_valid()) { - for (int i = 0; i < num_cache_entries; i++) { - cache[i].reg1 = cache[i].reg2 = arm::Gp(); - cache[i].mem = arm::Mem(); - } + num_cache_entries = 0; } last_destination_offset = a.offset(); @@ -1005,8 +1002,12 @@ class BeamModuleAssembler : public BeamAssembler, } } - comment("blurf"); - return 0; + if (num_cache_entries < max_cache_entries) { + return num_cache_entries++; + } else { + comment("blurf"); + return 0; + } } int get_cache_entry(arm::Mem mem) { @@ -1130,14 +1131,10 @@ class BeamModuleAssembler : public BeamAssembler, a.ldr(dst, mem); last_destination_offset = a.offset(); + num_cache_entries = 1; cache[0].reg1 = dst; cache[0].reg2 = arm::Gp(); cache[0].mem = mem; - - for (int i = 1; i < num_cache_entries; i++) { - cache[i].reg1 = cache[i].reg2 = arm::Gp(); - cache[i].mem = arm::Mem(); - } } }