Ignore:
Timestamp:
Jul 29, 2017, 8:01:12 PM (8 years ago)
Author:
[email protected]
Message:

LLInt offsets extractor should be able to handle C++ constexprs
https://bugs.webkit.org/show_bug.cgi?id=174964

Reviewed by Saam Barati.

This patch adds new syntax to the offline asm language. The new keyword,
constexpr, takes the subsequent identifier and maps it to a C++ constexpr
expression. Additionally, if the value is not an identifier you can wrap it in
parentheses. e.g. constexpr (myConstexprFunction() + OBJECT_OFFSET(Foo, bar)),
which will get converted into:
static_cast<int64_t>(myConstexprFunction() + OBJECT_OFFSET(Foo, bar));

This patch also changes the data format the LLIntOffsetsExtractor
binary produces. Previously, it would produce unsigned values,
after this patch every value is an int64_t. Using an int64_t is
useful because it means that we can represent any constant needed.
int32_t masks are sign extended then passed then converted to a
negative literal sting in the assembler so it will be the constant
expected.

  • llint/LLIntOffsetsExtractor.cpp:

(JSC::LLIntOffsetsExtractor::dummy):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/asm.rb:
  • offlineasm/ast.rb:
  • offlineasm/generate_offset_extractor.rb:
  • offlineasm/offsets.rb:
  • offlineasm/parser.rb:
  • offlineasm/transform.rb:
File:
1 edited

Legend:

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

    r172429 r220047  
    946946end
    947947
     948class ConstExpr < NoChildren
     949    attr_reader :variable, :value
     950
     951    def initialize(codeOrigin, value)
     952        super(codeOrigin)
     953        @value = value
     954    end
     955
     956    @@mapping = {}
     957
     958    def self.forName(codeOrigin, text)
     959        unless @@mapping[text]
     960            @@mapping[text] = ConstExpr.new(codeOrigin, text)
     961        end
     962        @@mapping[text]
     963    end
     964
     965    def dump
     966        "constexpr (#{@value.dump})"
     967    end
     968
     969    def <=>(other)
     970        @value <=> other.value
     971    end
     972
     973    def immediate?
     974        true
     975    end
     976end
     977
    948978class ConstDecl < Node
    949979    attr_reader :variable, :value
    950    
     980
    951981    def initialize(codeOrigin, variable, value)
    952982        super(codeOrigin)
     
    954984        @value = value
    955985    end
    956    
     986
    957987    def children
    958988        [@variable, @value]
    959989    end
    960    
     990
    961991    def mapChildren
    962992        ConstDecl.new(codeOrigin, (yield @variable), (yield @value))
    963993    end
    964    
     994
    965995    def dump
    966996        "const #{@variable.dump} = #{@value.dump}"
Note: See TracChangeset for help on using the changeset viewer.