• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 || V8_TARGET_ARCH_PPC64
8 
9 #include "src/codegen/cpu-features.h"
10 
11 #define INSTR_AND_DATA_CACHE_COHERENCY PPC_6_PLUS
12 
13 namespace v8 {
14 namespace internal {
15 
FlushICache(void * buffer,size_t size)16 void CpuFeatures::FlushICache(void* buffer, size_t size) {
17 #if !defined(USE_SIMULATOR)
18   if (CpuFeatures::IsSupported(INSTR_AND_DATA_CACHE_COHERENCY)) {
19     __asm__ __volatile__(
20         "sync \n"
21         "icbi 0, %0  \n"
22         "isync  \n"
23         : /* no output */
24         : "r"(buffer)
25         : "memory");
26     return;
27   }
28 
29   const int kCacheLineSize = CpuFeatures::icache_line_size();
30   intptr_t mask = kCacheLineSize - 1;
31   byte* start =
32       reinterpret_cast<byte*>(reinterpret_cast<intptr_t>(buffer) & ~mask);
33   byte* end = static_cast<byte*>(buffer) + size;
34   for (byte* pointer = start; pointer < end; pointer += kCacheLineSize) {
35     __asm__(
36         "dcbf 0, %0  \n"
37         "sync        \n"
38         "icbi 0, %0  \n"
39         "isync       \n"
40         : /* no output */
41         : "r"(pointer));
42   }
43 
44 #endif  // !USE_SIMULATOR
45 }
46 }  // namespace internal
47 }  // namespace v8
48 
49 #undef INSTR_AND_DATA_CACHE_COHERENCY
50 #endif  // V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
51