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 const int kCacheLineSize = CpuFeatures::cache_line_size(); |
| 36 intptr_t mask = kCacheLineSize - 1; |
| 37 byte *start = reinterpret_cast<byte *>( |
| 38 reinterpret_cast<intptr_t>(buffer) & ~mask); |
| 39 byte *end = static_cast<byte *>(buffer) + size; |
| 40 for (byte *pointer = start; pointer < end; pointer += kCacheLineSize) { |
| 41 __asm__( |
| 42 "dcbf 0, %0 \n" \ |
| 43 "sync \n" \ |
| 44 "icbi 0, %0 \n" \ |
| 45 "isync \n" |
| 46 : /* no output */ |
| 47 : "r" (pointer)); |
| 48 } |
| 49 |
| 50 #endif // USE_SIMULATOR |
| 51 } |
| 52 |
| 53 } } // namespace v8::internal |
| 54 |
| 55 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |