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