summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/offlineasm/asm.rb
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-07-16 14:51:15 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-07-16 14:51:15 +0200
commit4e6b3a206fa4ad8bb0b664f7674c9a70376d6e26 (patch)
tree7bb9ad7e31c24d1cf1707e03e6f1a80f6d033951 /Source/JavaScriptCore/offlineasm/asm.rb
parent3977e3d2f72f7fe2c887c1ec0e0c342e1d169f42 (diff)
downloadqtwebkit-4e6b3a206fa4ad8bb0b664f7674c9a70376d6e26.tar.gz
Imported WebKit commit 953baa67aa07087b6ecd4199351ec554c724e27d (http://svn.webkit.org/repository/webkit/trunk@122676)
Diffstat (limited to 'Source/JavaScriptCore/offlineasm/asm.rb')
-rw-r--r--Source/JavaScriptCore/offlineasm/asm.rb70
1 files changed, 55 insertions, 15 deletions
diff --git a/Source/JavaScriptCore/offlineasm/asm.rb b/Source/JavaScriptCore/offlineasm/asm.rb
index 50f9bc886..0cf6320af 100644
--- a/Source/JavaScriptCore/offlineasm/asm.rb
+++ b/Source/JavaScriptCore/offlineasm/asm.rb
@@ -25,6 +25,7 @@
$: << File.dirname(__FILE__)
+require "config"
require "backends"
require "digest/sha1"
require "offsets"
@@ -39,16 +40,21 @@ class Assembler
@state = :cpp
@commentState = :none
@comment = nil
+ @internalComment = nil
+ @annotation = nil
+ @codeOrigin = nil
+ @numLocalLabels = 0
+ @numGlobalLabels = 0
end
def enterAsm
- @outp.puts "asm ("
+ @outp.puts "OFFLINE_ASM_BEGIN"
@state = :asm
end
def leaveAsm
putsLastComment
- @outp.puts ");"
+ @outp.puts "OFFLINE_ASM_END"
@state = :cpp
end
@@ -58,17 +64,35 @@ class Assembler
leaveAsm
end
+ # Concatenates all the various components of the comment to dump.
def lastComment
- if @comment
- result = "// #{@comment}"
- else
- result = ""
+ result = ""
+ result = " #{@comment} ." if @comment
+ result += " #{@annotation} ." if @annotation and $enableTrailingInstrAnnotations
+ result += " #{@internalComment} ." if @internalComment
+ result += " #{@codeOrigin} ." if @codeOrigin and $enableCodeOriginComments
+ if result != ""
+ result = " //" + result
end
+
+ # Reset all the components that we've just sent to be dumped.
@commentState = :none
@comment = nil
+ @internalComment = nil
+ @annotation = nil
+ @codeOrigin = nil
result
end
+ # Dumps the current instruction annotation in interlaced mode if appropriate.
+ def putInterlacedAnnotation()
+ raise unless @state == :asm
+ if $enableInterlacedInstrAnnotations
+ @outp.puts(" // #{@annotation}") if @annotation
+ @annotation = nil
+ end
+ end
+
def putsLastComment
comment = lastComment
unless comment.empty?
@@ -78,7 +102,8 @@ class Assembler
def puts(*line)
raise unless @state == :asm
- @outp.puts("\"\\t" + line.join('') + "\\n\" #{lastComment}")
+ putInterlacedAnnotation
+ @outp.puts(" \"\\t" + line.join('') + "\\n\"#{lastComment}")
end
def print(line)
@@ -88,12 +113,18 @@ class Assembler
def putsLabel(labelName)
raise unless @state == :asm
- @outp.puts("OFFLINE_ASM_GLOBAL_LABEL(#{labelName}) #{lastComment}")
+ @numGlobalLabels += 1
+ @outp.puts("\n")
+ @internalComment = $enableLabelCountComments ? "Global Label #{@numGlobalLabels}" : nil
+ @outp.puts("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})#{lastComment}")
end
def putsLocalLabel(labelName)
raise unless @state == :asm
- @outp.puts("LOCAL_LABEL_STRING(#{labelName}) \":\\n\" #{lastComment}")
+ @numLocalLabels += 1
+ @outp.puts("\n")
+ @internalComment = $enableLabelCountComments ? "Local Label #{@numLocalLabels}" : nil
+ @outp.puts("OFFLINE_ASM_LOCAL_LABEL(#{labelName})#{lastComment}")
end
def self.labelReference(labelName)
@@ -104,22 +135,31 @@ class Assembler
"\" LOCAL_LABEL_STRING(#{labelName}) \""
end
- def comment(text)
+ def codeOrigin(text)
case @commentState
when :none
- @comment = text
+ @codeOrigin = text
@commentState = :one
when :one
- @outp.puts "// #{@comment}"
- @outp.puts "// #{text}"
- @comment = nil
+ if $enableCodeOriginComments
+ @outp.puts " // #{@codeOrigin}"
+ @outp.puts " // #{text}"
+ end
+ @codeOrigin = nil
@commentState = :many
when :many
- @outp.puts "// #{text}"
+ @outp.puts "// #{text}" if $enableCodeOriginComments
else
raise
end
end
+
+ def comment(text)
+ @comment = text
+ end
+ def annotation(text)
+ @annotation = text
+ end
end
asmFile = ARGV.shift