Changeset 284341 in webkit


Ignore:
Timestamp:
Oct 17, 2021 1:47:30 PM (3 years ago)
Author:
mark.lam@apple.com
Message:

Make LLIntAssembly.h more readable.
https://bugs.webkit.org/show_bug.cgi?id=231876

Reviewed by Yusuki Suzuki.

In this patch, I did the following:

  1. Changed CodeOrigin to only dump the filename, and not the full path.
  1. Deferred printing the ".loc" metadata in $asm.debugAnnotation till we format the line to dump in $asm.formatDump. This enabled the ".loc" metadata to be dumped on the same line as the asm instruction.
  1. Changed $asm.codeOrigin to not dump multiple codeOrigin comments. The only times when there appears to be "multiple" codeOrigins for any given instruction is if the instruction before it was elided, thereby leaving the elided instruction's codeOrigin to be mis-attributed to the subsequent instruction.
  1. Moved the MIPS Assembler.putStr method to asm.rb. This method was already commonly used in arm.rb and arm64.rb previously. Hence, it belongs in common code.

Also enhanced it to support indenting by the column width of ".loc" debug
annotations if $enableDebugAnnotations is true. This keeps the ".loc" column
on the left clear of other content, thereby making it easy to visually filter
out that column when scanning through the generated asm code.

  1. Changed some code that called outp.puts directly to call $asm.putStr instead. This yields the nice alignment for easy visual filtering described in (4).
  1. Changed $preferredCommentStartColumn to be at column 40 to make the generated asm code more compact. However, if the backend is the C_LOOP, then change it back to 60 because C_LOOP code is more verbose and need the extra space.

Demo time:
Before this patch, LLIntAssembly.h looks like this:
`
#if !OFFLINE_ASM_X86 && !OFFLINE_ASM_X86_WIN && !OFFLINE_ASM_X86_64 && !OFFLINE_ASM_X86_64_WIN && !OFFLINE_ASM_ARMv7 && !OFFLINE_ASM_ARM64 && OFFLINE_ASM_ARM64E && !OFFLINE_ASM_MIPS && !OFFLINE_ASM_RISCV64 && !OFFLINE_ASM_C_LOOP && !OFFLINE_ASM_C_LOOP_WIN && !OFFLINE_ASM_ARMv7k && !OFFLINE_ASM_ARMv7s && OFFLINE_ASM_JSVALUE64 && !OFFLINE_ASM_BIGINT32 && OFFLINE_ASM_GIGACAGE_ENABLED && !OFFLINE_ASM_ASSERT_ENABLED && !OFFLINE_ASM_TRACING && OFFLINE_ASM_ADDRESS64 && OFFLINE_ASM_JIT && OFFLINE_ASM_WEBASSEMBLY && OFFLINE_ASM_HAVE_FAST_TLS && OFFLINE_ASM_WEBASSEMBLY_B3JIT
OFFLINE_ASM_BEGIN
OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)
".file 1 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter.asm\"\n"
".file 2 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitBytecodes.asm\"\n"
".file 3 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm\"\n"
".file 4 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm\"\n"
".file 5 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitWasm.asm\"\n"
".file 6 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/WebAssembly.asm\"\n"
".file 7 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/usr/local/include/WebKitAdditions/LowLevelInterpreterAdditions.asm\"\n"
".loc 1 1672\n"

"\tbrk #0xc471\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1672

".loc 1 1681\n"

OFFLINE_ASM_GLOBAL_LABEL(vmEntryToJavaScript)
".loc 1 1066\n"

"\tpacibsp\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1066

".loc 1 1070\n"

"\tstp x29, x30, [sp, #-16]!\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1070

".loc 1 1075\n"

"\tmov x29, sp\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1075

".loc 1 1090\n"

"\tsub sp, x29, #176\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1090

".loc 3 169\n"

"\tmovz x13, #48040, lsl #0\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:169

".loc 3 169\n"

"\tadd x17, x1, x13, lsl #0\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:169

".loc 3 169\n"

"\tldr w4, [x17, #0]\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:169

".loc 3 170\n"

"\tcbnz w4, " LOCAL_LABEL_STRING(_offlineasm_doVMEntrycheckVMEntryPermission) "\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:170

".loc 3 172\n"

"\tstr x1, [sp, #0]\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:172

...

".loc 3 309\n"

"\tmov x3, x0\n" JavaScriptCore/llint/LowLevelInterpreter64.asm:309

".loc 1 1\n"
#if OS(DARWIN)

"\tL_offlineasm_loh_adrp_1:\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1
"\tadrp x2, " LOCAL_REFERENCE(g_config) "@GOTPAGE\n"
"\tL_offlineasm_loh_ldr_1:\n"
"\tldr x2, [x2, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF]\n"

#elif OS(LINUX)

"\tadrp x2, :got:" LOCAL_REFERENCE(g_config) "\n"
"\tldr x2, [x2, :got_lo12:" LOCAL_REFERENCE(g_config) "]\n"

#else
#error Missing globaladdr implementation
#endif
".loc 1 1\n"

"\tadd x2, x2, #3072\n" JavaScriptCore/llint/LowLevelInterpreter.asm:1

`

After this patch, LLIntAssembly.h looks like this:
`
#if !OFFLINE_ASM_X86 && !OFFLINE_ASM_X86_WIN && !OFFLINE_ASM_X86_64 && !OFFLINE_ASM_X86_64_WIN && !OFFLINE_ASM_ARMv7 && !OFFLINE_ASM_ARM64 && OFFLINE_ASM_ARM64E && !OFFLINE_ASM_MIPS && !OFFLINE_ASM_RISCV64 && !OFFLINE_ASM_C_LOOP && !OFFLINE_ASM_C_LOOP_WIN && !OFFLINE_ASM_ARMv7k && !OFFLINE_ASM_ARMv7s && OFFLINE_ASM_JSVALUE64 && !OFFLINE_ASM_BIGINT32 && OFFLINE_ASM_GIGACAGE_ENABLED && !OFFLINE_ASM_ASSERT_ENABLED && !OFFLINE_ASM_TRACING && OFFLINE_ASM_ADDRESS64 && OFFLINE_ASM_JIT && OFFLINE_ASM_WEBASSEMBLY && OFFLINE_ASM_HAVE_FAST_TLS && OFFLINE_ASM_WEBASSEMBLY_B3JIT

OFFLINE_ASM_BEGIN
OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)
".file 1 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter.asm\"\n"
".file 2 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitBytecodes.asm\"\n"
".file 3 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm\"\n"
".file 4 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm\"\n"
".file 5 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitWasm.asm\"\n"
".file 6 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/WebAssembly.asm\"\n"
".file 7 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/usr/local/include/WebKitAdditions/LowLevelInterpreterAdditions.asm\"\n"

".loc 1 1672\n" "brk #0xc471 \n" LowLevelInterpreter.asm:1672

".loc 1 1681\n" OFFLINE_ASM_GLOBAL_LABEL(vmEntryToJavaScript)
".loc 1 1066\n" "pacibsp \n" LowLevelInterpreter.asm:1066
".loc 1 1070\n" "stp x29, x30, [sp, #-16]! \n"
LowLevelInterpreter.asm:1070
".loc 1 1075\n" "mov x29, sp \n" LowLevelInterpreter.asm:1075
".loc 1 1090\n" "sub sp, x29, #176 \n"
LowLevelInterpreter.asm:1090
".loc 3 169\n" "movz x13, #48040, lsl #0 \n" LowLevelInterpreter64.asm:169

"add x17, x1, x13, lsl #0 \n"
"ldr w4, [x17, #0] \n"

".loc 3 170\n" "cbnz w4, " LOCAL_LABEL_STRING(_offlineasm_doVMEntrycheckVMEntryPermission) " \n" LowLevelInterpreter64.asm:170
".loc 3 172\n" "str x1, [sp, #0] \n"
LowLevelInterpreter64.asm:172

...

".loc 3 309\n" "mov x3, x0 \n" LowLevelInterpreter64.asm:309

#if OS(DARWIN)

".loc 1 1\n" "L_offlineasm_loh_adrp_1: \n" LowLevelInterpreter.asm:1

"adrp x2, " LOCAL_REFERENCE(g_config) "@GOTPAGE \n"
"L_offlineasm_loh_ldr_1: \n"
"ldr x2, [x2, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF] \n"

#elif OS(LINUX)

"adrp x2, :got:" LOCAL_REFERENCE(g_config) " \n"
"ldr x2, [x2, :got_lo12:" LOCAL_REFERENCE(g_config) "] \n"

#else
#error Missing globaladdr implementation
#endif

".loc 1 1\n" "add x2, x2, #3072 \n"
`

  • offlineasm/asm.rb:
  • offlineasm/cloop.rb:
  • offlineasm/config.rb:
  • offlineasm/mips.rb:
  • offlineasm/parser.rb:
Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r284332 r284341  
     12021-10-16  Mark Lam  <mark.lam@apple.com>
     2
     3        Make LLIntAssembly.h more readable.
     4        https://bugs.webkit.org/show_bug.cgi?id=231876
     5
     6        Reviewed by Yusuki Suzuki.
     7
     8        In this patch, I did the following:
     9
     10        1. Changed `CodeOrigin` to only dump the filename, and not the full path.
     11
     12        2. Deferred printing the ".loc" metadata in `$asm.debugAnnotation` till we format
     13           the line to dump in `$asm.formatDump`.  This enabled the ".loc" metadata to be
     14           dumped on the same line as the asm instruction.
     15
     16        3. Changed `$asm.codeOrigin` to not dump multiple codeOrigin comments.  The only
     17           times when there appears to be "multiple" codeOrigins for any given instruction
     18           is if the instruction before it was elided, thereby leaving the elided
     19           instruction's codeOrigin to be mis-attributed to the subsequent instruction.
     20
     21        4. Moved the MIPS `Assembler.putStr` method to asm.rb.  This method was already
     22           commonly used in arm.rb and arm64.rb previously.  Hence, it belongs in common
     23           code.
     24
     25           Also enhanced it to support indenting by the column width of ".loc" debug
     26           annotations if `$enableDebugAnnotations` is true.  This keeps the ".loc" column
     27           on the left clear of other content, thereby making it easy to visually filter
     28           out that column when scanning through the generated asm code.
     29
     30        5. Changed some code that called `outp.puts` directly to call `$asm.putStr` instead.
     31           This yields the nice alignment for easy visual filtering described in (4).
     32
     33        6. Changed `$preferredCommentStartColumn` to be at column 40 to make the generated
     34           asm code more compact.  However, if the backend is the C_LOOP, then change it
     35           back to 60 because C_LOOP code is more verbose and need the extra space.
     36
     37        Demo time:
     38        Before this patch, LLIntAssembly.h looks like this:
     39        ```
     40        #if !OFFLINE_ASM_X86 && !OFFLINE_ASM_X86_WIN && !OFFLINE_ASM_X86_64 && !OFFLINE_ASM_X86_64_WIN && !OFFLINE_ASM_ARMv7 && !OFFLINE_ASM_ARM64 && OFFLINE_ASM_ARM64E && !OFFLINE_ASM_MIPS && !OFFLINE_ASM_RISCV64 && !OFFLINE_ASM_C_LOOP && !OFFLINE_ASM_C_LOOP_WIN && !OFFLINE_ASM_ARMv7k && !OFFLINE_ASM_ARMv7s && OFFLINE_ASM_JSVALUE64 && !OFFLINE_ASM_BIGINT32 && OFFLINE_ASM_GIGACAGE_ENABLED && !OFFLINE_ASM_ASSERT_ENABLED && !OFFLINE_ASM_TRACING && OFFLINE_ASM_ADDRESS64 && OFFLINE_ASM_JIT && OFFLINE_ASM_WEBASSEMBLY && OFFLINE_ASM_HAVE_FAST_TLS && OFFLINE_ASM_WEBASSEMBLY_B3JIT
     41        OFFLINE_ASM_BEGIN
     42        OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)
     43        ".file 1 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter.asm\"\n"
     44        ".file 2 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitBytecodes.asm\"\n"
     45        ".file 3 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm\"\n"
     46        ".file 4 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm\"\n"
     47        ".file 5 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitWasm.asm\"\n"
     48        ".file 6 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/WebAssembly.asm\"\n"
     49        ".file 7 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/usr/local/include/WebKitAdditions/LowLevelInterpreterAdditions.asm\"\n"
     50        ".loc 1 1672\n"
     51            "\tbrk #0xc471\n"                                        // JavaScriptCore/llint/LowLevelInterpreter.asm:1672
     52        ".loc 1 1681\n"
     53
     54        OFFLINE_ASM_GLOBAL_LABEL(vmEntryToJavaScript)
     55        ".loc 1 1066\n"
     56            "\tpacibsp\n"                                            // JavaScriptCore/llint/LowLevelInterpreter.asm:1066
     57        ".loc 1 1070\n"
     58            "\tstp x29, x30, [sp, #-16]!\n"                          // JavaScriptCore/llint/LowLevelInterpreter.asm:1070
     59        ".loc 1 1075\n"
     60            "\tmov x29, sp\n"                                        // JavaScriptCore/llint/LowLevelInterpreter.asm:1075
     61        ".loc 1 1090\n"
     62            "\tsub sp, x29, #176\n"                                  // JavaScriptCore/llint/LowLevelInterpreter.asm:1090
     63        ".loc 3 169\n"
     64            "\tmovz x13, #48040, lsl #0\n"                           // JavaScriptCore/llint/LowLevelInterpreter64.asm:169
     65        ".loc 3 169\n"
     66            "\tadd x17, x1, x13, lsl #0\n"                           // JavaScriptCore/llint/LowLevelInterpreter64.asm:169
     67        ".loc 3 169\n"
     68            "\tldr w4, [x17, #0]\n"                                  // JavaScriptCore/llint/LowLevelInterpreter64.asm:169
     69        ".loc 3 170\n"
     70            "\tcbnz w4, " LOCAL_LABEL_STRING(_offlineasm_doVMEntry__checkVMEntryPermission) "\n" // JavaScriptCore/llint/LowLevelInterpreter64.asm:170
     71        ".loc 3 172\n"
     72            "\tstr x1, [sp, #0]\n"                                   // JavaScriptCore/llint/LowLevelInterpreter64.asm:172
     73
     74        ...
     75
     76        ".loc 3 309\n"
     77            "\tmov x3, x0\n"                                         // JavaScriptCore/llint/LowLevelInterpreter64.asm:309
     78        ".loc 1 1\n"
     79        #if OS(DARWIN)
     80            "\tL_offlineasm_loh_adrp_1:\n"                           // JavaScriptCore/llint/LowLevelInterpreter.asm:1
     81            "\tadrp x2, " LOCAL_REFERENCE(g_config) "@GOTPAGE\n"
     82            "\tL_offlineasm_loh_ldr_1:\n"
     83            "\tldr x2, [x2, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF]\n"
     84        #elif OS(LINUX)
     85            "\tadrp x2, :got:" LOCAL_REFERENCE(g_config) "\n"
     86            "\tldr x2, [x2, :got_lo12:" LOCAL_REFERENCE(g_config) "]\n"
     87        #else
     88        #error Missing globaladdr implementation
     89        #endif
     90        ".loc 1 1\n"
     91            "\tadd x2, x2, #3072\n"                                  // JavaScriptCore/llint/LowLevelInterpreter.asm:1
     92        ```
     93
     94        After this patch, LLIntAssembly.h looks like this:
     95        ```
     96        #if !OFFLINE_ASM_X86 && !OFFLINE_ASM_X86_WIN && !OFFLINE_ASM_X86_64 && !OFFLINE_ASM_X86_64_WIN && !OFFLINE_ASM_ARMv7 && !OFFLINE_ASM_ARM64 && OFFLINE_ASM_ARM64E && !OFFLINE_ASM_MIPS && !OFFLINE_ASM_RISCV64 && !OFFLINE_ASM_C_LOOP && !OFFLINE_ASM_C_LOOP_WIN && !OFFLINE_ASM_ARMv7k && !OFFLINE_ASM_ARMv7s && OFFLINE_ASM_JSVALUE64 && !OFFLINE_ASM_BIGINT32 && OFFLINE_ASM_GIGACAGE_ENABLED && !OFFLINE_ASM_ASSERT_ENABLED && !OFFLINE_ASM_TRACING && OFFLINE_ASM_ADDRESS64 && OFFLINE_ASM_JIT && OFFLINE_ASM_WEBASSEMBLY && OFFLINE_ASM_HAVE_FAST_TLS && OFFLINE_ASM_WEBASSEMBLY_B3JIT
     97
     98                          OFFLINE_ASM_BEGIN
     99                          OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)
     100                          ".file 1 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter.asm\"\n"
     101                          ".file 2 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitBytecodes.asm\"\n"
     102                          ".file 3 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm\"\n"
     103                          ".file 4 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm\"\n"
     104                          ".file 5 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/DerivedSources/JavaScriptCore/InitWasm.asm\"\n"
     105                          ".file 6 \"/Users/mlam/ws1/OpenSource/Source/JavaScriptCore/llint/WebAssembly.asm\"\n"
     106                          ".file 7 \"/Users/mlam/ws1/OpenSource/WebKitBuild/Release/usr/local/include/WebKitAdditions/LowLevelInterpreterAdditions.asm\"\n"
     107        ".loc 1 1672\n"       "brk #0xc471 \n"                     // LowLevelInterpreter.asm:1672
     108
     109        ".loc 1 1681\n"   OFFLINE_ASM_GLOBAL_LABEL(vmEntryToJavaScript)
     110        ".loc 1 1066\n"       "pacibsp \n"                         // LowLevelInterpreter.asm:1066
     111        ".loc 1 1070\n"       "stp x29, x30, [sp, #-16]! \n"       // LowLevelInterpreter.asm:1070
     112        ".loc 1 1075\n"       "mov x29, sp \n"                     // LowLevelInterpreter.asm:1075
     113        ".loc 1 1090\n"       "sub sp, x29, #176 \n"               // LowLevelInterpreter.asm:1090
     114        ".loc 3 169\n"        "movz x13, #48040, lsl #0 \n"        // LowLevelInterpreter64.asm:169
     115                              "add x17, x1, x13, lsl #0 \n"
     116                              "ldr w4, [x17, #0] \n"
     117        ".loc 3 170\n"        "cbnz w4, " LOCAL_LABEL_STRING(_offlineasm_doVMEntry__checkVMEntryPermission) " \n" // LowLevelInterpreter64.asm:170
     118        ".loc 3 172\n"        "str x1, [sp, #0] \n"                // LowLevelInterpreter64.asm:172
     119
     120        ...
     121
     122        ".loc 3 309\n"        "mov x3, x0 \n"                      // LowLevelInterpreter64.asm:309
     123                          #if OS(DARWIN)
     124        ".loc 1 1\n"          "L_offlineasm_loh_adrp_1: \n"        // LowLevelInterpreter.asm:1
     125                              "adrp x2, " LOCAL_REFERENCE(g_config) "@GOTPAGE \n"
     126                              "L_offlineasm_loh_ldr_1: \n"
     127                              "ldr x2, [x2, " LOCAL_REFERENCE(g_config) "@GOTPAGEOFF] \n"
     128                          #elif OS(LINUX)
     129                              "adrp x2, :got:" LOCAL_REFERENCE(g_config) " \n"
     130                              "ldr x2, [x2, :got_lo12:" LOCAL_REFERENCE(g_config) "] \n"
     131                          #else
     132                          #error Missing globaladdr implementation
     133                          #endif
     134        ".loc 1 1\n"          "add x2, x2, #3072 \n"
     135        ```
     136
     137        * offlineasm/asm.rb:
     138        * offlineasm/cloop.rb:
     139        * offlineasm/config.rb:
     140        * offlineasm/mips.rb:
     141        * offlineasm/parser.rb:
     142
    11432021-10-16  Yusuke Suzuki  <ysuzuki@apple.com>
    2144
  • trunk/Source/JavaScriptCore/offlineasm/asm.rb

    r282009 r284341  
    11#!/usr/bin/env ruby
    22
    3 # Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
     3# Copyright (C) 2011-2021 Apple Inc. All rights reserved.
    44#
    55# Redistribution and use in source and binary forms, with or without
     
    4444
    4545    def resetAsm
    46         @commentState = :none
    4746        @comment = nil
    4847        @internalComment = nil
     
    5453        @deferredNextLabelActions = []
    5554        @count = 0
     55        @debugAnnotationStr = nil
     56        @lastDebugAnnotationStr = nil
    5657
    5758        @newlineSpacerState = :none
     
    6061
    6162    def enterAsm
    62         @outp.puts "OFFLINE_ASM_BEGIN" if !$emitWinAsm
    63 
    64         if !$emitWinAsm
    65             @outp.puts "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)"
     63        @outp.puts ""
     64        putStr "OFFLINE_ASM_BEGIN" if !$emitWinAsm
     65
     66        if !$emitWinAsm
     67            putStr "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)"
    6668        else
    6769            putsProc("llintPCRangeStart", "")
     
    7577        putsProcEndIfNeeded if $emitWinAsm
    7678        if !$emitWinAsm
    77             @outp.puts "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeEnd)"
     79            putStr "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeEnd)"
    7880        else
    7981            putsProc("llintPCRangeEnd", "")
     
    8587            action.call()
    8688        }
    87         @outp.puts "OFFLINE_ASM_END" if !$emitWinAsm
     89        putStr "OFFLINE_ASM_END" if !$emitWinAsm
    8890        @state = :cpp
    8991    end
     
    122124            result += "#{@internalComment}"
    123125        end
    124         if @codeOrigin and $enableCodeOriginComments
     126        if $enableCodeOriginComments and @codeOrigin and @codeOrigin != @lastCodeOrigin
     127            @lastCodeOrigin = @codeOrigin
    125128            result += separator if result != ""
    126129            result += "#{@codeOrigin}"
     
    131134
    132135        # Reset all the components that we've just sent to be dumped.
    133         @commentState = :none
    134136        @comment = nil
    135137        @annotation = nil
     
    146148   
    147149    def formatDump(dumpStr, comment, commentColumns=$preferredCommentStartColumn)
     150        result = ""
    148151        if comment.length > 0
    149             "%-#{commentColumns}s %s" % [dumpStr, comment]
    150         else
    151             dumpStr
    152         end
     152            result = "%-#{commentColumns}s %s" % [dumpStr, comment]
     153        else
     154            result = dumpStr
     155        end
     156        if $enableDebugAnnotations
     157            if @debugAnnotationStr and @debugAnnotationStr != @lastDebugAnnotationStr
     158                result = "%-#{$preferredDebugAnnotationColumns}s%s" % [@debugAnnotationStr, result]
     159            else
     160                result = "%-#{$preferredDebugAnnotationColumns}s%s" % ["", result]
     161            end
     162            @lastDebugAnnotationStr = @debugAnnotationStr
     163            @debugAnnotationStr = nil
     164        end
     165        result
    153166    end
    154167
     
    177190        end
    178191    end
    179    
     192
     193    def putStr(str)
     194        if $enableDebugAnnotations
     195            @outp.puts "%-#{$preferredDebugAnnotationColumns}s%s" % ["", str]
     196        else
     197            @outp.puts str
     198        end
     199    end
     200
    180201    def puts(*line)
    181202        raise unless @state == :asm
    182203        if !$emitWinAsm
    183             @outp.puts(formatDump("    \"\\t" + line.join('') + "\\n\"", lastComment))
     204            @outp.puts(formatDump("    \"" + line.join('') + " \\n\"", lastComment))
    184205        else
    185206            @outp.puts(formatDump("    " + line.join(''), lastComment))
     
    296317   
    297318    def codeOrigin(text)
    298         case @commentState
    299         when :none
    300             @codeOrigin = text
    301             @commentState = :one
    302         when :one
    303             if $enableCodeOriginComments
    304                 @outp.puts "    " + $commentPrefix + " #{@codeOrigin}"
    305                 @outp.puts "    " + $commentPrefix + " #{text}"
    306             end
    307             @codeOrigin = nil
    308             @commentState = :many
    309         when :many
    310             @outp.puts $commentPrefix + " #{text}" if $enableCodeOriginComments
    311         else
    312             raise
    313         end
     319        @codeOrigin = text
    314320    end
    315321
     
    323329
    324330    def debugAnnotation(text)
    325         @outp.puts text
     331        @debugAnnotationStr = text
    326332    end
    327333end
     
    406412            if backend == "C_LOOP" || backend == "C_LOOP_WIN"
    407413                $enableDebugAnnotations = false
     414                $preferredCommentStartColumn = 60
    408415            end
    409416
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r283168 r284341  
    1 # Copyright (C) 2012-2020 Apple Inc. All rights reserved.
     1# Copyright (C) 2012-2021 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    11941194        $asm.codeOrigin codeOriginString if $enableCodeOriginComments
    11951195        $asm.annotation annotation if $enableInstrAnnotations && (opcode != "cloopDo")
    1196         $asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations
    1197     end
    1198 end
     1196    end
     1197end
  • trunk/Source/JavaScriptCore/offlineasm/config.rb

    r259734 r284341  
    1 # Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     1# Copyright (C) 2012-2021 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    3232
    3333
    34 $preferredCommentStartColumn = 60
     34$preferredCommentStartColumn = 40
     35$preferredDebugAnnotationColumns = 18
    3536
    3637
  • trunk/Source/JavaScriptCore/offlineasm/mips.rb

    r279343 r284341  
    1 # Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     1# Copyright (C) 2012-2021 Apple Inc. All rights reserved.
    22# Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
    33#
     
    6363# $f16 =>            (scratch)
    6464# $f18 =>            (scratch)
    65 
    66 class Assembler
    67     def putStr(str)
    68         @outp.puts str
    69     end
    70 end
    7165
    7266class Node
  • trunk/Source/JavaScriptCore/offlineasm/parser.rb

    r282009 r284341  
    1 # Copyright (C) 2011, 2016 Apple Inc. All rights reserved.
     1# Copyright (C) 2011-2021 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    3232    @@fileNames = []
    3333   
    34     attr_reader :name, :fileNumber
     34    attr_reader :name, :basename, :fileNumber
    3535
    3636    def SourceFile.outputDotFileList(outp)
    3737        @@fileNames.each_index {
    3838            | index |
    39             outp.puts "\".file #{index+1} \\\"#{@@fileNames[index]}\\\"\\n\""
     39            $asm.putStr "\".file #{index+1} \\\"#{@@fileNames[index]}\\\"\\n\""
    4040        }
    4141    end
     
    4343    def initialize(fileName)
    4444        @name = Pathname.new(fileName)
     45        @basename = File.basename(fileName)
    4546        pathName = "#{@name.realpath}"
    4647        fileNumber = @@fileNames.index(pathName)
     
    7273
    7374    def to_s
    74         "#{fileName}:#{lineNumber}"
     75        "#{@sourceFile.basename}:#{lineNumber}"
    7576    end
    7677end
Note: See TracChangeset for help on using the changeset viewer.