diff options
Diffstat (limited to 'Source/JavaScriptCore/offlineasm/asm.rb')
| -rw-r--r-- | Source/JavaScriptCore/offlineasm/asm.rb | 130 |
1 files changed, 25 insertions, 105 deletions
diff --git a/Source/JavaScriptCore/offlineasm/asm.rb b/Source/JavaScriptCore/offlineasm/asm.rb index e93d85536..bf2426399 100644 --- a/Source/JavaScriptCore/offlineasm/asm.rb +++ b/Source/JavaScriptCore/offlineasm/asm.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -# Copyright (C) 2011, 2016 Apple Inc. All rights reserved. +# Copyright (C) 2011 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -47,32 +47,16 @@ class Assembler @numGlobalLabels = 0 @newlineSpacerState = :none - @lastlabel = "" end - + def enterAsm - @outp.puts "OFFLINE_ASM_BEGIN" if !$emitWinAsm - - if !$emitWinAsm - @outp.puts "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeStart)" - else - putsProc("llintPCRangeStart", "") - putsProcEndIfNeeded - end + @outp.puts "OFFLINE_ASM_BEGIN" @state = :asm - SourceFile.outputDotFileList(@outp) if $enableDebugAnnotations end def leaveAsm - putsProcEndIfNeeded if $emitWinAsm - if !$emitWinAsm - @outp.puts "OFFLINE_ASM_GLOBAL_LABEL(llintPCRangeEnd)" - else - putsProc("llintPCRangeEnd", "") - putsProcEndIfNeeded - end putsLastComment - @outp.puts "OFFLINE_ASM_END" if !$emitWinAsm + @outp.puts "OFFLINE_ASM_END" @state = :cpp end @@ -100,7 +84,7 @@ class Assembler result += "#{@codeOrigin}" end if result != "" - result = $commentPrefix + " " + result + result = "// " + result end # Reset all the components that we've just sent to be dumped. @@ -153,11 +137,7 @@ class Assembler def puts(*line) raise unless @state == :asm - if !$emitWinAsm - @outp.puts(formatDump(" \"\\t" + line.join('') + "\\n\"", lastComment)) - else - @outp.puts(formatDump(" " + line.join(''), lastComment)) - end + @outp.puts(formatDump(" \"\\t" + line.join('') + "\\n\"", lastComment)) end def print(line) @@ -172,45 +152,15 @@ class Assembler end end - def putsProc(label, comment) - raise unless $emitWinAsm - @outp.puts(formatDump("#{label} PROC PUBLIC", comment)) - @lastlabel = label - end - - def putsProcEndIfNeeded - raise unless $emitWinAsm - if @lastlabel != "" - @outp.puts("#{@lastlabel} ENDP") - end - @lastlabel = "" - end - - def putsLabel(labelName, isGlobal) + def putsLabel(labelName) raise unless @state == :asm @numGlobalLabels += 1 - putsProcEndIfNeeded if $emitWinAsm and isGlobal putsNewlineSpacerIfAppropriate(:global) @internalComment = $enableLabelCountComments ? "Global Label #{@numGlobalLabels}" : nil - if isGlobal - if !$emitWinAsm - @outp.puts(formatDump("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})", lastComment)) - else - putsProc(labelName, lastComment) - end - elsif /\Allint_op_/.match(labelName) - if !$emitWinAsm - @outp.puts(formatDump("OFFLINE_ASM_OPCODE_LABEL(op_#{$~.post_match})", lastComment)) - else - label = "llint_" + "op_#{$~.post_match}" - @outp.puts(formatDump(" _#{label}:", lastComment)) - end + if /\Allint_op_/.match(labelName) + @outp.puts(formatDump("OFFLINE_ASM_OPCODE_LABEL(op_#{$~.post_match})", lastComment)) else - if !$emitWinAsm - @outp.puts(formatDump("OFFLINE_ASM_GLUE_LABEL(#{labelName})", lastComment)) - else - @outp.puts(formatDump(" _#{labelName}:", lastComment)) - end + @outp.puts(formatDump("OFFLINE_ASM_GLUE_LABEL(#{labelName})", lastComment)) end @newlineSpacerState = :none # After a global label, we can use another spacer. end @@ -220,35 +170,15 @@ class Assembler @numLocalLabels += 1 @outp.puts("\n") @internalComment = $enableLabelCountComments ? "Local Label #{@numLocalLabels}" : nil - if !$emitWinAsm - @outp.puts(formatDump(" OFFLINE_ASM_LOCAL_LABEL(#{labelName})", lastComment)) - else - @outp.puts(formatDump(" #{labelName}:", lastComment)) - end - end - - def self.externLabelReference(labelName) - if !$emitWinAsm - "\" LOCAL_REFERENCE(#{labelName}) \"" - else - "#{labelName}" - end + @outp.puts(formatDump(" OFFLINE_ASM_LOCAL_LABEL(#{labelName})", lastComment)) end - + def self.labelReference(labelName) - if !$emitWinAsm - "\" LOCAL_LABEL_STRING(#{labelName}) \"" - else - "_#{labelName}" - end + "\" LOCAL_REFERENCE(#{labelName}) \"" end def self.localLabelReference(labelName) - if !$emitWinAsm - "\" LOCAL_LABEL_STRING(#{labelName}) \"" - else - "#{labelName}" - end + "\" LOCAL_LABEL_STRING(#{labelName}) \"" end def self.cLabelReference(labelName) @@ -270,13 +200,13 @@ class Assembler @commentState = :one when :one if $enableCodeOriginComments - @outp.puts " " + $commentPrefix + " #{@codeOrigin}" - @outp.puts " " + $commentPrefix + " #{text}" + @outp.puts " // #{@codeOrigin}" + @outp.puts " // #{text}" end @codeOrigin = nil @commentState = :many when :many - @outp.puts $commentPrefix + " #{text}" if $enableCodeOriginComments + @outp.puts "// #{text}" if $enableCodeOriginComments else raise end @@ -285,22 +215,17 @@ class Assembler def comment(text) @comment = text end - def annotation(text) @annotation = text end - - def debugAnnotation(text) - @outp.puts text - end end -IncludeFile.processIncludeOptions() - asmFile = ARGV.shift offsetsFile = ARGV.shift outputFlnm = ARGV.shift +$stderr.puts "offlineasm: Parsing #{asmFile} and #{offsetsFile} and creating assembly file #{outputFlnm}." + begin configurationList = offsetsAndConfigurationIndex(offsetsFile) rescue MissingMagicValuesException @@ -308,16 +233,8 @@ rescue MissingMagicValuesException exit 0 end -# The MS compiler doesn't accept DWARF2 debug annotations. -if isMSVC - $enableDebugAnnotations = false -end - -$emitWinAsm = isMSVC ? outputFlnm.index(".asm") != nil : false -$commentPrefix = $emitWinAsm ? ";" : "//" - inputHash = - $commentPrefix + " offlineasm input hash: " + parseHash(asmFile) + + "// offlineasm input hash: " + parseHash(asmFile) + " " + Digest::SHA1.hexdigest(configurationList.map{|v| (v[0] + [v[1]]).join(' ')}.join(' ')) + " " + selfHash @@ -336,11 +253,11 @@ File.open(outputFlnm, "w") { | outp | $output = outp $output.puts inputHash - + $asm = Assembler.new($output) ast = parse(asmFile) - + configurationList.each { | configuration | offsetsList = configuration[0] @@ -357,3 +274,6 @@ File.open(outputFlnm, "w") { } } } + +$stderr.puts "offlineasm: Assembly file #{outputFlnm} successfully generated." + |
