Ignore:
Timestamp:
Jul 13, 2012, 5:44:47 PM (13 years ago)
Author:
[email protected]
Message:

OfflineASM Pretty printing and commenting enhancements.
https://bugs.webkit.org/show_bug.cgi?id=91281

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

Added some minor pretty printing in the OfflineASM.
Also added infrastruture for adding multiple types of comments and
annotations with the ability to enable/disable them in the generated
output as desired.

  • GNUmakefile.list.am: add new file config.rb.
  • llint/LLIntOfflineAsmConfig.h: Added OFFLINE_ASM_BEGIN, OFFLINE_ASM_END, and OFFLINE_ASM_LOCAL_LABEL macros. This will allow us to redefine these for other backends later.
  • llint/LowLevelInterpreter32_64.asm: Add a small example of instruction annotations for now.
  • llint/LowLevelInterpreter64.asm: Add a small example of instruction annotations for now.
  • offlineasm/armv7.rb: Added handling of annotations.
  • offlineasm/asm.rb: Added machinery to dump the new comments and annotations. Also added some indentations to make the output a little prettier.
  • offlineasm/ast.rb: Added annotation field in class Instruction.
  • offlineasm/backends.rb:
  • offlineasm/config.rb: Added. Currently only contains commenting options. This file is meant to be a centralized place for build config values much like config.h for JavaScriptCore.
  • offlineasm/generate_offset_extractor.rb:
  • offlineasm/instructions.rb:
  • offlineasm/offsets.rb:
  • offlineasm/opt.rb:
  • offlineasm/parser.rb: Parse and record annotations.
  • offlineasm/registers.rb:
  • offlineasm/self_hash.rb:
  • offlineasm/settings.rb:
  • offlineasm/transform.rb:
  • offlineasm/x86.rb: Added handling of annotations.
File:
1 edited

Legend:

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

    r110383 r122650  
    2222# THE POSSIBILITY OF SUCH DAMAGE.
    2323
     24require "config"
    2425require "ast"
    2526require "instructions"
     
    8283    result = []
    8384    lineNumber = 1
     85    annotation = nil
    8486    while not str.empty?
    8587        case str
    8688        when /\A\#([^\n]*)/
    8789            # comment, ignore
     90        when /\A\/\/([^\n]*)/
     91            # annotation
     92            annotation = $1
    8893        when /\A\n/
     94            # We've found a '\n'.  Emit the last comment recorded if appropriate:
     95            if $enableInstrAnnotations and annotation
     96                result << Token.new(CodeOrigin.new(fileName, lineNumber), "@" + annotation)
     97                annotation = nil
     98            end
    8999            result << Token.new(CodeOrigin.new(fileName, lineNumber), $&)
    90100            lineNumber += 1
     
    137147end
    138148
     149def isAnnotation(token)
     150    token =~ /\A\@([^\n]*)/
     151end
     152
    139153def isLabel(token)
    140154    token =~ /\A_([a-zA-Z0-9_]*)\Z/
     
    536550                    list << Instruction.new(codeOrigin, name, [])
    537551                    break
     552                elsif isAnnotation @tokens[@idx]
     553                    annotation = @tokens[@idx].string
     554                    list << Instruction.new(codeOrigin, name, [], annotation)
     555                    @idx += 2 # Consume the newline as well.
    538556                elsif @tokens[@idx] == "\n"
    539557                    # Zero operand instruction.
     
    544562                    operands = []
    545563                    endOfSequence = false
     564                    annotation = nil
    546565                    loop {
    547566                        operands << parseOperand("while inside of instruction #{name}")
     
    553572                            # Has another operand.
    554573                            @idx += 1
     574                        elsif isAnnotation @tokens[@idx]
     575                            annotation = @tokens[@idx].string
     576                            @idx += 2 # Consume the newline as well.
     577                            break
    555578                        elsif @tokens[@idx] == "\n"
    556579                            # The end of the instruction.
     
    561584                        end
    562585                    }
    563                     list << Instruction.new(codeOrigin, name, operands)
     586                    list << Instruction.new(codeOrigin, name, operands, annotation)
    564587                    if endOfSequence
    565588                        break
Note: See TracChangeset for help on using the changeset viewer.