Ignore:
Timestamp:
Jul 19, 2012, 1:53:22 PM (13 years ago)
Author:
[email protected]
Message:

Bug fixes and enhancements for OfflineASM annotation system.
https://bugs.webkit.org/show_bug.cgi?id=91690

Patch by Mark Lam <[email protected]> on 2012-07-19
Reviewed by Filip Pizlo.

  • offlineasm/armv7.rb: added default handling of Instruction lower().
  • offlineasm/asm.rb: added more support for annotations and more pretty printing.
  • offlineasm/ast.rb: added more support for annotations.
  • offlineasm/config.rb: added $preferredCommentStartColumn, simplified $enableInstrAnnotations.
  • offlineasm/parser.rb: added more support for annotations.
  • offlineasm/transform.rb: added more support for annotations.
  • offlineasm/x86.rb: added default handling of Instruction lower().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/asm.rb

    r122650 r123147  
    4646        @numLocalLabels = 0
    4747        @numGlobalLabels = 0
     48
     49        @newlineSpacerState = :none
    4850    end
    4951   
     
    6769    # Concatenates all the various components of the comment to dump.
    6870    def lastComment
     71        separator = " "
    6972        result = ""
    70         result = " #{@comment} ." if @comment
    71         result += " #{@annotation} ." if @annotation and $enableTrailingInstrAnnotations
    72         result += " #{@internalComment} ." if @internalComment
    73         result += " #{@codeOrigin} ." if @codeOrigin and $enableCodeOriginComments
     73        result = "#{@comment}" if @comment
     74        if @annotation and $enableInstrAnnotations
     75            result += separator if result != ""
     76            result += "#{@annotation}"
     77        end
     78        if @internalComment
     79            result += separator if result != ""
     80            result += "#{@internalComment}"
     81        end
     82        if @codeOrigin and $enableCodeOriginComments
     83            result += separator if result != ""
     84            result += "#{@codeOrigin}"
     85        end
    7486        if result != ""
    75             result = "  //" + result
     87            result = "// " + result
    7688        end
    7789
     
    7991        @commentState = :none
    8092        @comment = nil
    81         @internalComment = nil
    8293        @annotation = nil
    8394        @codeOrigin = nil
     95        @internalComment = nil
    8496        result
    8597    end
    8698   
    87     # Dumps the current instruction annotation in interlaced mode if appropriate.
    88     def putInterlacedAnnotation()
    89         raise unless @state == :asm
    90         if $enableInterlacedInstrAnnotations
    91             @outp.puts("    // #{@annotation}") if @annotation
     99    def formatDump(dumpStr, comment, commentColumns=$preferredCommentStartColumn)
     100        if comment.length > 0
     101            "%-#{commentColumns}s %s" % [dumpStr, comment]
     102        else
     103            dumpStr
     104        end
     105    end
     106
     107    # private method for internal use only.
     108    def putAnnotation(text)
     109        raise unless @state == :asm
     110        if $enableInstrAnnotations
     111            @outp.puts text
    92112            @annotation = nil
    93113        end
     114    end
     115
     116    def putLocalAnnotation()
     117        putAnnotation "    // #{@annotation}" if @annotation
     118    end
     119
     120    def putGlobalAnnotation()
     121        putsNewlineSpacerIfAppropriate(:annotation)
     122        putAnnotation "// #{@annotation}" if @annotation
    94123    end
    95124
     
    103132    def puts(*line)
    104133        raise unless @state == :asm
    105         putInterlacedAnnotation
    106         @outp.puts("    \"\\t" + line.join('') + "\\n\"#{lastComment}")
     134        @outp.puts(formatDump("    \"\\t" + line.join('') + "\\n\"", lastComment))
    107135    end
    108136   
     
    112140    end
    113141   
     142    def putsNewlineSpacerIfAppropriate(state)
     143        if @newlineSpacerState != state
     144            @outp.puts("\n")
     145            @newlineSpacerState = state
     146        end
     147    end
     148
    114149    def putsLabel(labelName)
    115150        raise unless @state == :asm
    116151        @numGlobalLabels += 1
    117         @outp.puts("\n")
     152        putsNewlineSpacerIfAppropriate(:global)
    118153        @internalComment = $enableLabelCountComments ? "Global Label #{@numGlobalLabels}" : nil
    119         @outp.puts("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})#{lastComment}")
     154        @outp.puts(formatDump("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})", lastComment))
     155        @newlineSpacerState = :none # After a global label, we can use another spacer.
    120156    end
    121157   
     
    125161        @outp.puts("\n")
    126162        @internalComment = $enableLabelCountComments ? "Local Label #{@numLocalLabels}" : nil
    127         @outp.puts("OFFLINE_ASM_LOCAL_LABEL(#{labelName})#{lastComment}")
     163        @outp.puts(formatDump("  OFFLINE_ASM_LOCAL_LABEL(#{labelName})", lastComment))
    128164    end
    129165   
Note: See TracChangeset for help on using the changeset viewer.