OLD | NEW |
(Empty) | |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
| 5 // Use of this source code is governed by a BSD-style license that can be |
| 6 // found in the LICENSE file. |
| 7 |
| 8 // CPU specific code for ppc independent of OS goes here. |
| 9 #include "src/v8.h" |
| 10 |
| 11 #if V8_TARGET_ARCH_PPC |
| 12 |
| 13 #include "src/assembler.h" |
| 14 #include "src/macro-assembler.h" |
| 15 #include "src/simulator.h" // for cache flushing. |
| 16 |
| 17 namespace v8 { |
| 18 namespace internal { |
| 19 |
| 20 void CpuFeatures::FlushICache(void* buffer, size_t size) { |
| 21 // Nothing to do flushing no instructions. |
| 22 if (size == 0) { |
| 23 return; |
| 24 } |
| 25 |
| 26 #if defined(USE_SIMULATOR) |
| 27 // Not generating PPC instructions for C-code. This means that we are |
| 28 // building an PPC emulator based target. We should notify the simulator |
| 29 // that the Icache was flushed. |
| 30 // None of this code ends up in the snapshot so there are no issues |
| 31 // around whether or not to generate the code when building snapshots. |
| 32 Simulator::FlushICache(Isolate::Current()->simulator_i_cache(), buffer, size); |
| 33 #else |
| 34 |
| 35 if (CpuFeatures::IsSupported(INSTR_AND_DATA_CACHE_COHERENCY)) { |
| 36 __asm__ __volatile__( |
| 37 "sync \n" |
| 38 "icbi 0, %0 \n" |
| 39 "isync \n" |
| 40 : /* no output */ |
| 41 : "r"(buffer) |
| 42 : "memory"); |
| 43 return; |
| 44 } |
| 45 |
| 46 const int kCacheLineSize = CpuFeatures::cache_line_size(); |
| 47 intptr_t mask = kCacheLineSize - 1; |
| 48 byte *start = |
| 49 reinterpret_cast<byte *>(reinterpret_cast<intptr_t>(buffer) & ~mask); |
| 50 byte *end = static_cast<byte *>(buffer) + size; |
| 51 for (byte *pointer = start; pointer < end; pointer += kCacheLineSize) { |
| 52 __asm__( |
| 53 "dcbf 0, %0 \n" |
| 54 "sync \n" |
| 55 "icbi 0, %0 \n" |
| 56 "isync \n" |
| 57 : /* no output */ |
| 58 : "r"(pointer)); |
| 59 } |
| 60 |
| 61 #endif // USE_SIMULATOR |
| 62 } |
| 63 } |
| 64 } // namespace v8::internal |
| 65 |
| 66 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |