2009-06-09 09:26:53 +00:00
|
|
|
// Copyright 2006-2009 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// CPU specific code for arm independent of OS goes here.
|
2010-04-22 12:41:10 +00:00
|
|
|
#ifdef __arm__
|
2014-01-02 07:04:05 +00:00
|
|
|
#ifdef __QNXNTO__
|
|
|
|
#include <sys/mman.h> // for cache flushing.
|
|
|
|
#undef MAP_TYPE
|
|
|
|
#else
|
2008-07-03 15:10:15 +00:00
|
|
|
#include <sys/syscall.h> // for cache flushing.
|
2008-07-30 08:49:36 +00:00
|
|
|
#endif
|
2014-01-02 07:04:05 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2013-06-28 15:34:48 +00:00
|
|
|
#if V8_TARGET_ARCH_ARM
|
2010-05-17 15:41:35 +00:00
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/assembler.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/macro-assembler.h"
|
2010-04-22 12:41:10 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
void CpuFeatures::FlushICache(void* start, size_t size) {
|
2015-09-11 12:59:30 +00:00
|
|
|
#if !defined(USE_SIMULATOR)
|
|
|
|
#if V8_OS_QNX
|
2014-01-02 07:04:05 +00:00
|
|
|
msync(start, size, MS_SYNC | MS_INVALIDATE_ICACHE);
|
2008-07-03 15:10:15 +00:00
|
|
|
#else
|
2014-06-23 17:30:00 +00:00
|
|
|
register uint32_t beg asm("r0") = reinterpret_cast<uint32_t>(start);
|
|
|
|
register uint32_t end asm("r1") = beg + size;
|
|
|
|
register uint32_t flg asm("r2") = 0;
|
|
|
|
|
2015-03-26 11:40:51 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
// This variant of the asm avoids a constant pool entry, which can be
|
|
|
|
// problematic when LTO'ing. It is also slightly shorter.
|
|
|
|
register uint32_t scno asm("r7") = __ARM_NR_cacheflush;
|
|
|
|
|
|
|
|
asm volatile("svc 0\n"
|
|
|
|
:
|
|
|
|
: "r"(beg), "r"(end), "r"(flg), "r"(scno)
|
|
|
|
: "memory");
|
|
|
|
#else
|
|
|
|
// Use a different variant of the asm with GCC because some versions doesn't
|
|
|
|
// support r7 as an asm input.
|
2014-06-23 17:30:00 +00:00
|
|
|
asm volatile(
|
|
|
|
// This assembly works for both ARM and Thumb targets.
|
|
|
|
|
|
|
|
// Preserve r7; it is callee-saved, and GCC uses it as a frame pointer for
|
|
|
|
// Thumb targets.
|
|
|
|
" push {r7}\n"
|
|
|
|
// r0 = beg
|
|
|
|
// r1 = end
|
|
|
|
// r2 = flags (0)
|
2014-06-24 11:26:48 +00:00
|
|
|
" ldr r7, =%c[scno]\n" // r7 = syscall number
|
2014-06-23 17:30:00 +00:00
|
|
|
" svc 0\n"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-23 17:30:00 +00:00
|
|
|
" pop {r7}\n"
|
|
|
|
:
|
|
|
|
: "r" (beg), "r" (end), "r" (flg), [scno] "i" (__ARM_NR_cacheflush)
|
|
|
|
: "memory");
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif
|
2015-03-26 11:40:51 +00:00
|
|
|
#endif
|
2015-09-11 12:59:30 +00:00
|
|
|
#endif // !USE_SIMULATOR
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 22:46:54 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2010-05-17 15:41:35 +00:00
|
|
|
|
|
|
|
#endif // V8_TARGET_ARCH_ARM
|