Home | History | Annotate | Download | only in snapshot
      1 // Copyright 2018 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 #ifndef V8_SNAPSHOT_MACROS_H_
      6 #define V8_SNAPSHOT_MACROS_H_
      7 
      8 #include "include/v8config.h"
      9 
     10 // .byte portability macros.
     11 
     12 #if defined(V8_OS_MACOSX)  // MACOSX
     13 #define V8_ASM_MANGLE_LABEL "_"
     14 #define V8_ASM_RODATA_SECTION ".const_data\n"
     15 #define V8_ASM_TEXT_SECTION ".text\n"
     16 #define V8_ASM_DECLARE(NAME) ".private_extern " V8_ASM_MANGLE_LABEL NAME "\n"
     17 #elif defined(V8_OS_AIX)  // AIX
     18 #define V8_ASM_RODATA_SECTION ".csect[RO]\n"
     19 #define V8_ASM_TEXT_SECTION ".csect .text[PR]\n"
     20 #define V8_ASM_MANGLE_LABEL ""
     21 #define V8_ASM_DECLARE(NAME) ".globl " V8_ASM_MANGLE_LABEL NAME "\n"
     22 #elif defined(V8_OS_WIN)  // WIN
     23 #if defined(V8_TARGET_ARCH_X64)
     24 #define V8_ASM_MANGLE_LABEL ""
     25 #else
     26 #define V8_ASM_MANGLE_LABEL "_"
     27 #endif
     28 #define V8_ASM_RODATA_SECTION ".section .rodata\n"
     29 #define V8_ASM_TEXT_SECTION ".section .text\n"
     30 #define V8_ASM_DECLARE(NAME)
     31 #else  // !MACOSX && !WIN && !AIX
     32 #define V8_ASM_MANGLE_LABEL ""
     33 #define V8_ASM_RODATA_SECTION ".section .rodata\n"
     34 #if defined(OS_CHROMEOS)  // ChromeOS
     35 #define V8_ASM_TEXT_SECTION ".section .text.hot.embedded\n"
     36 #else
     37 #define V8_ASM_TEXT_SECTION ".section .text\n"
     38 #endif
     39 #if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)
     40 #define V8_ASM_DECLARE(NAME) ".global " V8_ASM_MANGLE_LABEL NAME "\n"
     41 #else
     42 #define V8_ASM_DECLARE(NAME) ".local " V8_ASM_MANGLE_LABEL NAME "\n"
     43 #endif
     44 #endif
     45 
     46 // Align to kCodeAlignment.
     47 #define V8_ASM_BALIGN32 ".balign 32\n"
     48 #define V8_ASM_LABEL(NAME) V8_ASM_MANGLE_LABEL NAME ":\n"
     49 
     50 // clang-format off
     51 #if defined(V8_OS_AIX)
     52 
     53 #define V8_EMBEDDED_TEXT_HEADER(LABEL)         \
     54   __asm__(V8_ASM_DECLARE(#LABEL)               \
     55           ".csect " #LABEL "[DS]\n"            \
     56           #LABEL ":\n"                         \
     57           ".llong ." #LABEL ", TOC[tc0], 0\n"  \
     58           V8_ASM_TEXT_SECTION                  \
     59           "." #LABEL ":\n");
     60 
     61 #define V8_EMBEDDED_RODATA_HEADER(LABEL)    \
     62   __asm__(V8_ASM_RODATA_SECTION             \
     63           V8_ASM_DECLARE(#LABEL)            \
     64           ".align 5\n"                      \
     65           V8_ASM_LABEL(#LABEL));
     66 
     67 #else
     68 
     69 #define V8_EMBEDDED_TEXT_HEADER(LABEL) \
     70   __asm__(V8_ASM_TEXT_SECTION          \
     71           V8_ASM_DECLARE(#LABEL)       \
     72           V8_ASM_BALIGN32              \
     73           V8_ASM_LABEL(#LABEL));
     74 
     75 #define V8_EMBEDDED_RODATA_HEADER(LABEL) \
     76   __asm__(V8_ASM_RODATA_SECTION          \
     77           V8_ASM_DECLARE(#LABEL)         \
     78           V8_ASM_BALIGN32                \
     79           V8_ASM_LABEL(#LABEL));
     80 
     81 #endif  // #if defined(V8_OS_AIX)
     82 #endif  // V8_SNAPSHOT_MACROS_H_
     83