• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 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 LoongArch independent of OS goes here.
6 
7 #include <sys/syscall.h>
8 #include <unistd.h>
9 
10 #if V8_TARGET_ARCH_LOONG64
11 
12 #include "src/codegen/cpu-features.h"
13 
14 namespace v8 {
15 namespace internal {
16 
FlushICache(void * start,size_t size)17 void CpuFeatures::FlushICache(void* start, size_t size) {
18 #if defined(V8_HOST_ARCH_LOONG64)
19   // Nothing to do, flushing no instructions.
20   if (size == 0) {
21     return;
22   }
23 
24 #if defined(ANDROID) && !defined(__LP64__)
25   // Bionic cacheflush can typically run in userland, avoiding kernel call.
26   char* end = reinterpret_cast<char*>(start) + size;
27   cacheflush(reinterpret_cast<intptr_t>(start), reinterpret_cast<intptr_t>(end),
28              0);
29 #else   // ANDROID
30   asm("ibar 0\n");
31 #endif  // ANDROID
32 #endif  // V8_HOST_ARCH_LOONG64
33 }
34 
35 }  // namespace internal
36 }  // namespace v8
37 
38 #endif  // V8_TARGET_ARCH_LOONG64
39