#include <sys/syscall.h>
#include <unistd.h>
#ifdef __mips
#include <asm/cachectl.h>
#endif
#if V8_TARGET_ARCH_MIPS64
#include "src/codegen/cpu-features.h"
namespace v8 {
namespace internal {
void CpuFeatures::FlushICache(void* start, size_t size) {
#if !defined(USE_SIMULATOR)
if (size == 0) {
return;
}
#if defined(ANDROID) && !defined(__LP64__)
char* end = reinterpret_cast<char*>(start) + size;
cacheflush(reinterpret_cast<intptr_t>(start), reinterpret_cast<intptr_t>(end),
0);
#else
long res;
res = syscall(__NR_cacheflush, start, size, ICACHE);
if (res) FATAL("Failed to flush the instruction cache");
#endif
#endif
}
}
}
#endif