1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // CPU specific code for ppc independent of OS goes here.
6 
7 #if V8_TARGET_ARCH_PPC
8 
9 #include "src/assembler.h"
10 #include "src/macro-assembler.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 void CpuFeatures::FlushICache(void* buffer, size_t size) {
16 #if !defined(USE_SIMULATOR)
17   if (CpuFeatures::IsSupported(INSTR_AND_DATA_CACHE_COHERENCY)) {
18     __asm__ __volatile__(
19         "sync \n"
20         "icbi 0, %0  \n"
21         "isync  \n"
22         : /* no output */
23         : "r"(buffer)
24         : "memory");
25     return;
26   }
27 
28   const int kCacheLineSize = CpuFeatures::icache_line_size();
29   intptr_t mask = kCacheLineSize - 1;
30   byte *start =
31       reinterpret_cast<byte *>(reinterpret_cast<intptr_t>(buffer) & ~mask);
32   byte *end = static_cast<byte *>(buffer) + size;
33   for (byte *pointer = start; pointer < end; pointer += kCacheLineSize) {
34     __asm__(
35         "dcbf 0, %0  \n"
36         "sync        \n"
37         "icbi 0, %0  \n"
38         "isync       \n"
39         : /* no output */
40         : "r"(pointer));
41   }
42 
43 #endif  // !USE_SIMULATOR
44 }
45 }  // namespace internal
46 }  // namespace v8
47 
48 #endif  // V8_TARGET_ARCH_PPC
49