Merge "Flush icache when making pages executable." into dalvik-dev
diff --git a/src/assembler.cc b/src/assembler.cc
index 4ab882e..d97cf5c 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -88,8 +88,6 @@
// Copy the instructions from the buffer.
MemoryRegion from(reinterpret_cast<void*>(contents()), Size());
instructions.CopyFrom(0, from);
- // Flush instruction cache
- __builtin___clear_cache(instructions.start(), instructions.end());
// Process fixups in the instructions.
ProcessFixups(instructions);
#if defined(DEBUG)
diff --git a/src/common_test.h b/src/common_test.h
index 1039ff1..950020d 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -144,6 +144,8 @@
uintptr_t limit = RoundUp(data + code_length, kPageSize);
uintptr_t len = limit - base;
int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC);
+ // Flush instruction cache
+ __builtin___clear_cache(reinterpret_cast<void*>(base), reinterpret_cast<void*>(base + len));
CHECK_EQ(result, 0);
}