blob: a42fa53960cddf375ad0966b9d0de29dccacf08c [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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.
Emily Bernierd0a1eb72015-03-24 16:35:39 -04006
7#if V8_TARGET_ARCH_PPC
8
9#include "src/assembler.h"
10#include "src/macro-assembler.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040011
12namespace v8 {
13namespace internal {
14
15void CpuFeatures::FlushICache(void* buffer, size_t size) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000016#if !defined(USE_SIMULATOR)
Emily Bernierd0a1eb72015-03-24 16:35:39 -040017 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::cache_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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000043#endif // !USE_SIMULATOR
Emily Bernierd0a1eb72015-03-24 16:35:39 -040044}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000045} // namespace internal
46} // namespace v8
Emily Bernierd0a1eb72015-03-24 16:35:39 -040047
48#endif // V8_TARGET_ARCH_PPC