Ignore:
Timestamp:
Aug 20, 2021, 10:01:00 AM (4 years ago)
Author:
[email protected]
Message:

Add some offlineasm enhancements.
https://bugs.webkit.org/show_bug.cgi?id=229332
rdar://82163923

Reviewed by Keith Miller.

  1. Enhance "include" offlineasm Instruction to always attempt to include an asm file from <build-products>/usr/local/include/WebKitAdditions/ first. If the specified file is not available there, then it will attempt to include the file from the same directory as the current source file (which in practice, means Source/JavaScriptCore/llint/).
  1. Enhance "include" offlineasm Instruction to allow an optional file to be included if it exists. For example, the following offlineasm code:

include? LowLevelInterpreterAdditions

... will attempt to include a file LowLevelInterpreterAdditions.asm. If the
file does not exist, this will be a no-op. Note: the "?" after the "include"
means the include is optional.

  1. Enhanced "emit" offlineasm Instruction to be able to take more than one operand.

"emit" used to just copy the string operand that follows into the generated
LLIntAssembly.h. Now, "emit" can take multiple comma separated operands, and
will concatenate all the operands.

Additionally, "emit" can now take a LocalLabelReference as an operand. For
example, this offline asm code:

emit "b ", .done
...

.done:

... will generate this inline asm code in LLIntAssembly.h:

"b " LOCAL_LABEL_STRING(_offlineasm_someLabel_done) "\n"

This makes it easier to emit branches to local labels.

  1. Also fixed LLInt code alignment for ARM_THUMB2 and ARM64.

Previously, it was aligned using ".align 4" which means aligned on a 4
instruction boundary. Note: the interpretation of .align varies for different
target CPU architectures.

Now, we do the alignment using ".balign 4" which means align on a 4 byte
boundary. This is the intended alignment because ARM64 instruction size is
4 bytes, and ARM_THUMB2 instruction size is either 2 bytes or 4 bytes.
Using .align before was potentially wasting some code space.

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter.cpp:
  • offlineasm/ast.rb:
  • offlineasm/parser.rb:
File:
1 edited

Legend:

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

    r254637 r281321  
    201201        when /\A".*"/
    202202            result << Token.new(CodeOrigin.new(file, lineNumber), $&)
     203        when /\?/
     204            result << Token.new(CodeOrigin.new(file, lineNumber), $&)
    203205        else
    204206            raise "Lexer error at #{CodeOrigin.new(file, lineNumber).to_s}, unexpected sequence #{str[0..20].inspect}"
     
    262264        @idx = 0
    263265        @annotation = nil
     266        # FIXME: CMake does not currently set BUILT_PRODUCTS_DIR.
     267        # https://bugs.webkit.org/show_bug.cgi?id=229340
     268        @buildProductsDirectory = ENV['BUILT_PRODUCTS_DIR'];
    264269    end
    265270   
     
    818823            elsif @tokens[@idx] == "include"
    819824                @idx += 1
     825                isOptional = false
     826                if @tokens[@idx] == "?"
     827                    isOptional = true
     828                    @idx += 1
     829                end
    820830                parseError unless isIdentifier(@tokens[@idx])
    821831                moduleName = @tokens[@idx].string
    822                 fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
    823                 @idx += 1
    824                 list << parse(fileName)
     832                @idx += 1
     833                additionsDirectoryName = "#{@buildProductsDirectory}/usr/local/include/WebKitAdditions/"
     834                fileName = IncludeFile.new(moduleName, additionsDirectoryName).fileName
     835                if not File.exists?(fileName)
     836                    fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
     837                end
     838                fileExists = File.exists?(fileName)
     839                raise "File not found: #{fileName}" if not fileExists and not isOptional
     840                list << parse(fileName) if fileExists
    825841            else
    826842                parseError "Expecting terminal #{final} #{comment}"
     
    839855            elsif @tokens[@idx] == "include"
    840856                @idx += 1
     857                isOptional = false
     858                if @tokens[@idx] == "?"
     859                    isOptional = true
     860                    @idx += 1
     861                end
    841862                parseError unless isIdentifier(@tokens[@idx])
    842863                moduleName = @tokens[@idx].string
    843                 fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
    844                 @idx += 1
    845                
    846                 fileList << fileName
     864                @idx += 1
     865                additionsDirectoryName = "#{@buildProductsDirectory}/usr/local/include/WebKitAdditions/"
     866                fileName = IncludeFile.new(moduleName, additionsDirectoryName).fileName
     867                if not File.exists?(fileName)
     868                    fileName = IncludeFile.new(moduleName, @tokens[@idx].codeOrigin.fileName.dirname).fileName
     869                end
     870                fileExists = File.exists?(fileName)
     871                raise "File not found: #{fileName}" if not fileExists and not isOptional
     872                fileList << fileName if fileExists
    847873            else
    848874                @idx += 1
Note: See TracChangeset for help on using the changeset viewer.