LCOV - code coverage report
Current view: top level - src/snapshot - embedded-file-writer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 43 48 89.6 %
Date: 2019-01-20 Functions: 17 19 89.5 %

          Line data    Source code
       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             : #include "src/snapshot/embedded-file-writer.h"
       6             : 
       7             : #include <cinttypes>
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : 
      12             : // V8_CC_MSVC is true for both MSVC and clang on windows. clang can handle
      13             : // __asm__-style inline assembly but MSVC cannot, and thus we need a more
      14             : // precise compiler detection that can distinguish between the two. clang on
      15             : // windows sets both __clang__ and _MSC_VER, MSVC sets only _MSC_VER.
      16             : #if defined(_MSC_VER) && !defined(__clang__)
      17             : #define V8_COMPILER_IS_MSVC
      18             : #endif
      19             : 
      20             : // MSVC uses MASM for x86 and x64, while it has a ARMASM for ARM32 and
      21             : // ARMASM64 for ARM64. Since ARMASM and ARMASM64 accept a slightly tweaked
      22             : // version of ARM assembly language, they are referred to together in Visual
      23             : // Studio project files as MARMASM.
      24             : //
      25             : // ARM assembly language docs:
      26             : // http://infocenter.arm.com/help/topic/com.arm.doc.dui0802b/index.html
      27             : // Microsoft ARM assembler and assembly language docs:
      28             : // https://docs.microsoft.com/en-us/cpp/assembler/arm/arm-assembler-reference
      29             : #if defined(V8_COMPILER_IS_MSVC)
      30             : #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_ARM)
      31             : #define V8_ASSEMBLER_IS_MARMASM
      32             : #elif defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64)
      33             : #define V8_ASSEMBLER_IS_MASM
      34             : #else
      35             : #error Unknown Windows assembler target architecture.
      36             : #endif
      37             : #endif
      38             : 
      39             : // Name mangling.
      40             : // Symbols are prefixed with an underscore on 32-bit architectures.
      41             : #if defined(V8_OS_WIN) && !defined(V8_TARGET_ARCH_X64) && \
      42             :     !defined(V8_TARGET_ARCH_ARM64)
      43             : #define SYMBOL_PREFIX "_"
      44             : #else
      45             : #define SYMBOL_PREFIX ""
      46             : #endif
      47             : 
      48             : // Platform-independent bits.
      49             : // -----------------------------------------------------------------------------
      50             : 
      51             : namespace {
      52             : 
      53             : DataDirective PointerSizeDirective() {
      54             :   if (kSystemPointerSize == 8) {
      55             :     return kQuad;
      56             :   } else {
      57             :     CHECK_EQ(4, kSystemPointerSize);
      58             :     return kLong;
      59             :   }
      60             : }
      61             : 
      62             : }  // namespace
      63             : 
      64       36617 : const char* DirectiveAsString(DataDirective directive) {
      65             : #if defined(V8_OS_WIN) && defined(V8_ASSEMBLER_IS_MASM)
      66             :   switch (directive) {
      67             :     case kByte:
      68             :       return "BYTE";
      69             :     case kLong:
      70             :       return "DWORD";
      71             :     case kQuad:
      72             :       return "QWORD";
      73             :     default:
      74             :       UNREACHABLE();
      75             :   }
      76             : #elif defined(V8_OS_WIN) && defined(V8_ASSEMBLER_IS_MARMASM)
      77             :   switch (directive) {
      78             :     case kByte:
      79             :       return "DCB";
      80             :     case kLong:
      81             :       return "DCDU";
      82             :     case kQuad:
      83             :       return "DCQU";
      84             :     default:
      85             :       UNREACHABLE();
      86             :   }
      87             : #elif defined(V8_OS_AIX)
      88             :   switch (directive) {
      89             :     case kByte:
      90             :       return ".byte";
      91             :     case kLong:
      92             :       return ".long";
      93             :     case kQuad:
      94             :       return ".llong";
      95             :     default:
      96             :       UNREACHABLE();
      97             :   }
      98             : #else
      99       36617 :   switch (directive) {
     100             :     case kByte:
     101             :       return ".byte";
     102             :     case kLong:
     103           1 :       return ".long";
     104             :     case kQuad:
     105           1 :       return ".quad";
     106             :     case kOcta:
     107       36615 :       return ".octa";
     108             :   }
     109           0 :   UNREACHABLE();
     110             : #endif
     111             : }
     112             : 
     113             : // V8_OS_MACOSX
     114             : // Fuchsia target is explicitly excluded here for Mac hosts. This is to avoid
     115             : // generating uncompilable assembly files for the Fuchsia target.
     116             : // -----------------------------------------------------------------------------
     117             : 
     118             : #if defined(V8_OS_MACOSX) && !defined(V8_TARGET_OS_FUCHSIA)
     119             : 
     120             : void PlatformDependentEmbeddedFileWriter::SectionText() {
     121             :   fprintf(fp_, ".text\n");
     122             : }
     123             : 
     124             : void PlatformDependentEmbeddedFileWriter::SectionData() {
     125             :   fprintf(fp_, ".data\n");
     126             : }
     127             : 
     128             : void PlatformDependentEmbeddedFileWriter::SectionRoData() {
     129             :   fprintf(fp_, ".const_data\n");
     130             : }
     131             : 
     132             : void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
     133             :                                                         uint32_t value) {
     134             :   DeclareSymbolGlobal(name);
     135             :   DeclareLabel(name);
     136             :   IndentedDataDirective(kLong);
     137             :   fprintf(fp_, "%d", value);
     138             :   Newline();
     139             : }
     140             : 
     141             : void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
     142             :     const char* name, const char* target) {
     143             :   DeclareSymbolGlobal(name);
     144             :   DeclareLabel(name);
     145             :   fprintf(fp_, "  %s _%s\n", DirectiveAsString(PointerSizeDirective()), target);
     146             : }
     147             : 
     148             : void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
     149             :     const char* name) {
     150             :   // TODO(jgruber): Investigate switching to .globl. Using .private_extern
     151             :   // prevents something along the compilation chain from messing with the
     152             :   // embedded blob. Using .global here causes embedded blob hash verification
     153             :   // failures at runtime.
     154             :   fprintf(fp_, ".private_extern _%s\n", name);
     155             : }
     156             : 
     157             : void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
     158             :   fprintf(fp_, ".balign 32\n");
     159             : }
     160             : 
     161             : void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {}
     162             : 
     163             : void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
     164             :   fprintf(fp_, "// %s\n", string);
     165             : }
     166             : 
     167             : void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
     168             :   fprintf(fp_, "_%s:\n", name);
     169             : }
     170             : 
     171             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
     172             :     const char* name) {
     173             :   DeclareLabel(name);
     174             : 
     175             :   // TODO(mvstanton): Investigate the proper incantations to mark the label as
     176             :   // a function on OSX.
     177             : }
     178             : 
     179             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
     180             : }
     181             : 
     182             : int PlatformDependentEmbeddedFileWriter::HexLiteral(uint64_t value) {
     183             :   return fprintf(fp_, "0x%" PRIx64, value);
     184             : }
     185             : 
     186             : void PlatformDependentEmbeddedFileWriter::FilePrologue() {}
     187             : 
     188             : void PlatformDependentEmbeddedFileWriter::FileEpilogue() {}
     189             : 
     190             : int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
     191             :     DataDirective directive) {
     192             :   return fprintf(fp_, "  %s ", DirectiveAsString(directive));
     193             : }
     194             : 
     195             : // V8_OS_AIX
     196             : // -----------------------------------------------------------------------------
     197             : 
     198             : #elif defined(V8_OS_AIX)
     199             : 
     200             : void PlatformDependentEmbeddedFileWriter::SectionText() {
     201             :   fprintf(fp_, ".csect .text[PR]\n");
     202             : }
     203             : 
     204             : void PlatformDependentEmbeddedFileWriter::SectionData() {
     205             :   fprintf(fp_, ".csect .data[RW]\n");
     206             : }
     207             : 
     208             : void PlatformDependentEmbeddedFileWriter::SectionRoData() {
     209             :   fprintf(fp_, ".csect[RO]\n");
     210             : }
     211             : 
     212             : void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
     213             :                                                         uint32_t value) {
     214             :   DeclareSymbolGlobal(name);
     215             :   fprintf(fp_, ".align 2\n");
     216             :   fprintf(fp_, "%s:\n", name);
     217             :   IndentedDataDirective(kLong);
     218             :   fprintf(fp_, "%d\n", value);
     219             :   Newline();
     220             : }
     221             : 
     222             : void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
     223             :     const char* name, const char* target) {
     224             :   AlignToCodeAlignment();
     225             :   DeclareLabel(name);
     226             :   fprintf(fp_, "  %s %s\n", DirectiveAsString(PointerSizeDirective()), target);
     227             :   Newline();
     228             : }
     229             : 
     230             : void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
     231             :     const char* name) {
     232             :   fprintf(fp_, ".globl %s\n", name);
     233             : }
     234             : 
     235             : void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
     236             :   fprintf(fp_, ".align 5\n");
     237             : }
     238             : 
     239             : void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {}
     240             : 
     241             : void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
     242             :   fprintf(fp_, "// %s\n", string);
     243             : }
     244             : 
     245             : void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
     246             :   DeclareSymbolGlobal(name);
     247             :   fprintf(fp_, "%s:\n", name);
     248             : }
     249             : 
     250             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
     251             :     const char* name) {
     252             :   Newline();
     253             :   DeclareSymbolGlobal(name);
     254             :   fprintf(fp_, ".csect %s[DS]\n", name); // function descriptor
     255             :   fprintf(fp_, "%s:\n", name);
     256             :   fprintf(fp_, ".llong .%s, 0, 0\n", name);
     257             :   SectionText();
     258             :   fprintf(fp_, ".%s:\n", name);
     259             : }
     260             : 
     261             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
     262             : }
     263             : 
     264             : int PlatformDependentEmbeddedFileWriter::HexLiteral(uint64_t value) {
     265             :   return fprintf(fp_, "0x%" PRIx64, value);
     266             : }
     267             : 
     268             : void PlatformDependentEmbeddedFileWriter::FilePrologue() {}
     269             : 
     270             : void PlatformDependentEmbeddedFileWriter::FileEpilogue() {}
     271             : 
     272             : int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
     273             :     DataDirective directive) {
     274             :   return fprintf(fp_, "  %s ", DirectiveAsString(directive));
     275             : }
     276             : 
     277             : // V8_OS_WIN (MSVC)
     278             : // -----------------------------------------------------------------------------
     279             : 
     280             : #elif defined(V8_OS_WIN) && defined(V8_ASSEMBLER_IS_MASM)
     281             : 
     282             : // For MSVC builds we emit assembly in MASM syntax.
     283             : // See https://docs.microsoft.com/en-us/cpp/assembler/masm/directives-reference.
     284             : 
     285             : void PlatformDependentEmbeddedFileWriter::SectionText() {
     286             :   fprintf(fp_, ".CODE\n");
     287             : }
     288             : 
     289             : void PlatformDependentEmbeddedFileWriter::SectionData() {
     290             :   fprintf(fp_, ".DATA\n");
     291             : }
     292             : 
     293             : void PlatformDependentEmbeddedFileWriter::SectionRoData() {
     294             :   fprintf(fp_, ".CONST\n");
     295             : }
     296             : 
     297             : void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
     298             :                                                         uint32_t value) {
     299             :   DeclareSymbolGlobal(name);
     300             :   fprintf(fp_, "%s%s %s %d\n", SYMBOL_PREFIX, name, DirectiveAsString(kLong),
     301             :           value);
     302             : }
     303             : 
     304             : void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
     305             :     const char* name, const char* target) {
     306             :   DeclareSymbolGlobal(name);
     307             :   fprintf(fp_, "%s%s %s %s%s\n", SYMBOL_PREFIX, name,
     308             :           DirectiveAsString(PointerSizeDirective()), SYMBOL_PREFIX, target);
     309             : }
     310             : 
     311             : void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
     312             :     const char* name) {
     313             :   fprintf(fp_, "PUBLIC %s%s\n", SYMBOL_PREFIX, name);
     314             : }
     315             : 
     316             : void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
     317             :   // Diverges from other platforms due to compile error
     318             :   // 'invalid combination with segment alignment'.
     319             :   fprintf(fp_, "ALIGN 4\n");
     320             : }
     321             : 
     322             : void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {}
     323             : 
     324             : void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
     325             :   fprintf(fp_, "; %s\n", string);
     326             : }
     327             : 
     328             : void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
     329             :   fprintf(fp_, "%s%s LABEL %s\n", SYMBOL_PREFIX, name,
     330             :           DirectiveAsString(kByte));
     331             : }
     332             : 
     333             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
     334             :     const char* name) {
     335             :   fprintf(fp_, "%s%s PROC\n", SYMBOL_PREFIX, name);
     336             : }
     337             : 
     338             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
     339             :   fprintf(fp_, "%s%s ENDP\n", SYMBOL_PREFIX, name);
     340             : }
     341             : 
     342             : int PlatformDependentEmbeddedFileWriter::HexLiteral(uint64_t value) {
     343             :   return fprintf(fp_, "0%" PRIx64 "h", value);
     344             : }
     345             : 
     346             : void PlatformDependentEmbeddedFileWriter::FilePrologue() {
     347             : #if !defined(V8_TARGET_ARCH_X64)
     348             :   fprintf(fp_, ".MODEL FLAT\n");
     349             : #endif
     350             : }
     351             : 
     352             : void PlatformDependentEmbeddedFileWriter::FileEpilogue() {
     353             :   fprintf(fp_, "END\n");
     354             : }
     355             : 
     356             : int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
     357             :     DataDirective directive) {
     358             :   return fprintf(fp_, "  %s ", DirectiveAsString(directive));
     359             : }
     360             : 
     361             : #undef V8_ASSEMBLER_IS_MASM
     362             : 
     363             : #elif defined(V8_OS_WIN) && defined(V8_ASSEMBLER_IS_MARMASM)
     364             : 
     365             : // The the AARCH64 ABI requires instructions be 4-byte-aligned and Windows does
     366             : // not have a stricter alignment requirement (see the TEXTAREA macro of
     367             : // kxarm64.h in the Windows SDK), so code is 4-byte-aligned.
     368             : // The data fields in the emitted assembly tend to be accessed with 8-byte
     369             : // LDR instructions, so data is 8-byte-aligned.
     370             : //
     371             : // armasm64's warning A4228 states
     372             : //     Alignment value exceeds AREA alignment; alignment not guaranteed
     373             : // To ensure that ALIGN directives are honored, their values are defined as
     374             : // equal to their corresponding AREA's ALIGN attributes.
     375             : 
     376             : #define ARM64_DATA_ALIGNMENT_POWER (3)
     377             : #define ARM64_DATA_ALIGNMENT (1 << ARM64_DATA_ALIGNMENT_POWER)
     378             : #define ARM64_CODE_ALIGNMENT_POWER (2)
     379             : #define ARM64_CODE_ALIGNMENT (1 << ARM64_CODE_ALIGNMENT_POWER)
     380             : 
     381             : void PlatformDependentEmbeddedFileWriter::SectionText() {
     382             :   fprintf(fp_, "  AREA |.text|, CODE, ALIGN=%d, READONLY\n",
     383             :           ARM64_CODE_ALIGNMENT_POWER);
     384             : }
     385             : 
     386             : void PlatformDependentEmbeddedFileWriter::SectionData() {
     387             :   fprintf(fp_, "  AREA |.data|, DATA, ALIGN=%d, READWRITE\n",
     388             :           ARM64_DATA_ALIGNMENT_POWER);
     389             : }
     390             : 
     391             : void PlatformDependentEmbeddedFileWriter::SectionRoData() {
     392             :   fprintf(fp_, "  AREA |.rodata|, DATA, ALIGN=%d, READONLY\n",
     393             :           ARM64_DATA_ALIGNMENT_POWER);
     394             : }
     395             : 
     396             : void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
     397             :                                                         uint32_t value) {
     398             :   DeclareSymbolGlobal(name);
     399             :   fprintf(fp_, "%s%s %s %d\n", SYMBOL_PREFIX, name, DirectiveAsString(kLong),
     400             :           value);
     401             : }
     402             : 
     403             : void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
     404             :     const char* name, const char* target) {
     405             :   DeclareSymbolGlobal(name);
     406             :   fprintf(fp_, "%s%s %s %s%s\n", SYMBOL_PREFIX, name,
     407             :           DirectiveAsString(PointerSizeDirective()), SYMBOL_PREFIX, target);
     408             : }
     409             : 
     410             : void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
     411             :     const char* name) {
     412             :   fprintf(fp_, "  EXPORT %s%s\n", SYMBOL_PREFIX, name);
     413             : }
     414             : 
     415             : void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
     416             :   fprintf(fp_, "  ALIGN %d\n", ARM64_CODE_ALIGNMENT);
     417             : }
     418             : 
     419             : void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {
     420             :   fprintf(fp_, "  ALIGN %d\n", ARM64_DATA_ALIGNMENT);
     421             : }
     422             : 
     423             : void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
     424             :   fprintf(fp_, "; %s\n", string);
     425             : }
     426             : 
     427             : void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
     428             :   fprintf(fp_, "%s%s\n", SYMBOL_PREFIX, name);
     429             : }
     430             : 
     431             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
     432             :     const char* name) {
     433             :   fprintf(fp_, "%s%s FUNCTION\n", SYMBOL_PREFIX, name);
     434             : }
     435             : 
     436             : void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
     437             :   fprintf(fp_, "  ENDFUNC\n");
     438             : }
     439             : 
     440             : int PlatformDependentEmbeddedFileWriter::HexLiteral(uint64_t value) {
     441             :   return fprintf(fp_, "0x%" PRIx64, value);
     442             : }
     443             : 
     444             : void PlatformDependentEmbeddedFileWriter::FilePrologue() {}
     445             : 
     446             : void PlatformDependentEmbeddedFileWriter::FileEpilogue() {
     447             :   fprintf(fp_, "  END\n");
     448             : }
     449             : 
     450             : int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
     451             :     DataDirective directive) {
     452             :   return fprintf(fp_, "  %s ", DirectiveAsString(directive));
     453             : }
     454             : 
     455             : #undef V8_ASSEMBLER_IS_MARMASM
     456             : #undef ARM64_DATA_ALIGNMENT_POWER
     457             : #undef ARM64_DATA_ALIGNMENT
     458             : #undef ARM64_CODE_ALIGNMENT_POWER
     459             : #undef ARM64_CODE_ALIGNMENT
     460             : 
     461             : // Everything but AIX, Windows with MSVC, or OSX.
     462             : // -----------------------------------------------------------------------------
     463             : 
     464             : #else
     465             : 
     466           1 : void PlatformDependentEmbeddedFileWriter::SectionText() {
     467             : #ifdef OS_CHROMEOS
     468             :   fprintf(fp_, ".section .text.hot.embedded\n");
     469             : #else
     470           1 :   fprintf(fp_, ".section .text\n");
     471             : #endif
     472           1 : }
     473             : 
     474           1 : void PlatformDependentEmbeddedFileWriter::SectionData() {
     475           1 :   fprintf(fp_, ".section .data\n");
     476           1 : }
     477             : 
     478           1 : void PlatformDependentEmbeddedFileWriter::SectionRoData() {
     479             : #if defined(V8_OS_WIN)
     480             :   fprintf(fp_, ".section .rdata\n");
     481             : #else
     482           1 :   fprintf(fp_, ".section .rodata\n");
     483             : #endif
     484           1 : }
     485             : 
     486           1 : void PlatformDependentEmbeddedFileWriter::DeclareUint32(const char* name,
     487             :                                                         uint32_t value) {
     488             :   DeclareSymbolGlobal(name);
     489             :   DeclareLabel(name);
     490           1 :   IndentedDataDirective(kLong);
     491           1 :   fprintf(fp_, "%d", value);
     492             :   Newline();
     493           1 : }
     494             : 
     495           1 : void PlatformDependentEmbeddedFileWriter::DeclarePointerToSymbol(
     496             :     const char* name, const char* target) {
     497             :   DeclareSymbolGlobal(name);
     498             :   DeclareLabel(name);
     499             :   fprintf(fp_, "  %s %s%s\n", DirectiveAsString(PointerSizeDirective()),
     500           1 :           SYMBOL_PREFIX, target);
     501           1 : }
     502             : 
     503           0 : void PlatformDependentEmbeddedFileWriter::DeclareSymbolGlobal(
     504             :     const char* name) {
     505           2 :   fprintf(fp_, ".global %s%s\n", SYMBOL_PREFIX, name);
     506           0 : }
     507             : 
     508           1 : void PlatformDependentEmbeddedFileWriter::AlignToCodeAlignment() {
     509           1 :   fprintf(fp_, ".balign 32\n");
     510           1 : }
     511             : 
     512           1 : void PlatformDependentEmbeddedFileWriter::AlignToDataAlignment() {
     513             : #if defined(V8_OS_WIN) && defined(V8_TARGET_ARCH_ARM64)
     514             :   // On Windows ARM64, instruction "ldr xt,[xn,v8_Default_embedded_blob_]" is
     515             :   // generated by clang-cl to load elements in v8_Default_embedded_blob_.
     516             :   // The generated instruction has scale 3 which requires the load target to be
     517             :   // aligned at 8 bytes (2^3).
     518             :   fprintf(fp_, ".balign 8\n");
     519             : #endif
     520           1 : }
     521             : 
     522           5 : void PlatformDependentEmbeddedFileWriter::Comment(const char* string) {
     523           5 :   fprintf(fp_, "// %s\n", string);
     524           5 : }
     525             : 
     526           1 : void PlatformDependentEmbeddedFileWriter::DeclareLabel(const char* name) {
     527        1514 :   fprintf(fp_, "%s%s:\n", SYMBOL_PREFIX, name);
     528           1 : }
     529             : 
     530        1511 : void PlatformDependentEmbeddedFileWriter::DeclareFunctionBegin(
     531             :     const char* name) {
     532             :   DeclareLabel(name);
     533             : 
     534             : #if defined(V8_OS_WIN)
     535             : #if defined(V8_TARGET_ARCH_ARM64)
     536             :   // Windows ARM64 assembly is in GAS syntax, but ".type" is invalid directive
     537             :   // in PE/COFF for Windows.
     538             : #else
     539             :   // The directives for inserting debugging information on Windows come
     540             :   // from the PE (Portable Executable) and COFF (Common Object File Format)
     541             :   // standards. Documented here:
     542             :   // https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format
     543             :   //
     544             :   // .scl 2 means StorageClass external.
     545             :   // .type 32 means Type Representation Function.
     546             :   fprintf(fp_, ".def %s%s; .scl 2; .type 32; .endef;\n", SYMBOL_PREFIX, name);
     547             : #endif
     548             : #elif defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_ARM64)
     549             :   // ELF format binaries on ARM use ".type <function name>, %function"
     550             :   // to create a DWARF subprogram entry.
     551             :   fprintf(fp_, ".type %s, %%function\n", name);
     552             : #else
     553             :   // Other ELF Format binaries use ".type <function name>, @function"
     554             :   // to create a DWARF subprogram entry.
     555        1511 :   fprintf(fp_, ".type %s, @function\n", name);
     556             : #endif
     557        1511 : }
     558             : 
     559        1511 : void PlatformDependentEmbeddedFileWriter::DeclareFunctionEnd(const char* name) {
     560        1511 : }
     561             : 
     562           0 : int PlatformDependentEmbeddedFileWriter::HexLiteral(uint64_t value) {
     563           0 :   return fprintf(fp_, "0x%" PRIx64, value);
     564             : }
     565             : 
     566           1 : void PlatformDependentEmbeddedFileWriter::FilePrologue() {}
     567             : 
     568           1 : void PlatformDependentEmbeddedFileWriter::FileEpilogue() {}
     569             : 
     570       36616 : int PlatformDependentEmbeddedFileWriter::IndentedDataDirective(
     571             :     DataDirective directive) {
     572       73232 :   return fprintf(fp_, "  %s ", DirectiveAsString(directive));
     573             : }
     574             : 
     575             : #endif
     576             : 
     577             : #undef SYMBOL_PREFIX
     578             : #undef V8_COMPILER_IS_MSVC
     579             : 
     580             : }  // namespace internal
     581           3 : }  // namespace v8

Generated by: LCOV version 1.10