Skip to content

Commit

Permalink
[JSC][offlineasm] Remove $emitWinAsm
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274378

Reviewed by Yusuke Suzuki.

As of 278767@main, $emitWinAsm is constant false, so let's do away with it.

* Source/JavaScriptCore/offlineasm/asm.rb:
* Source/JavaScriptCore/offlineasm/ast.rb:
* Source/JavaScriptCore/offlineasm/parser.rb:
* Source/JavaScriptCore/offlineasm/settings.rb:

Canonical link: https://commits.webkit.org/278980@main
  • Loading branch information
rkirsling committed May 20, 2024
1 parent f988a6b commit c3c24e0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 110 deletions.
103 changes: 23 additions & 80 deletions Source/JavaScriptCore/offlineasm/asm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ def resetAsm

def enterAsm
@outp.puts ""
putStr "OFFLINE_ASM_BEGIN" if !$emitWinAsm
putStr "OFFLINE_ASM_BEGIN"

@state = :asm
SourceFile.outputDotFileList(@outp) if $enableDebugAnnotations
end

def leaveAsm
putsProcEndIfNeeded if $emitWinAsm
putsLastComment
if not @deferredOSDarwinActions.size.zero?
putStr("#if OS(DARWIN)")
Expand All @@ -79,7 +78,7 @@ def leaveAsm
}
putStr("#endif // OS(DARWIN)")
end
putStr "OFFLINE_ASM_END" if !$emitWinAsm
putStr "OFFLINE_ASM_END"
@state = :cpp
end

Expand Down Expand Up @@ -122,7 +121,7 @@ def lastComment
result += "#{@codeOrigin}"
end
if result != ""
result = $commentPrefix + " " + result
result = "// " + result
end

# Reset all the components that we've just sent to be dumped.
Expand Down Expand Up @@ -193,11 +192,7 @@ def putStr(str)

def puts(*line)
raise unless @state == :asm
if !$emitWinAsm
@outp.puts(formatDump(" \"" + line.join('') + " \\n\"", lastComment))
else
@outp.puts(formatDump(" " + line.join(''), lastComment))
end
@outp.puts(formatDump(" \"" + line.join('') + " \\n\"", lastComment))
end

def print(line)
Expand All @@ -212,20 +207,6 @@ def putsNewlineSpacerIfAppropriate(state)
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, isExport, isAligned, alignTo)
raise unless @state == :asm
@deferredNextLabelActions.each {
Expand All @@ -234,45 +215,31 @@ def putsLabel(labelName, isGlobal, isExport, isAligned, alignTo)
}
@deferredNextLabelActions = []
@numGlobalLabels += 1
putsProcEndIfNeeded if $emitWinAsm and isGlobal
putsNewlineSpacerIfAppropriate(:global)
@internalComment = $enableLabelCountComments ? "Global Label #{@numGlobalLabels}" : nil
if isGlobal
if !$emitWinAsm
if isAligned
if isExport
@outp.puts(formatDump("OFFLINE_ASM_GLOBAL_EXPORT_LABEL(#{labelName})", lastComment))
elsif alignTo
@outp.puts(formatDump("OFFLINE_ASM_ALIGNED_GLOBAL_LABEL(#{labelName}, #{alignTo})", lastComment))
else
@outp.puts(formatDump("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})", lastComment))
end
if isAligned
if isExport
@outp.puts(formatDump("OFFLINE_ASM_GLOBAL_EXPORT_LABEL(#{labelName})", lastComment))
elsif alignTo
@outp.puts(formatDump("OFFLINE_ASM_ALIGNED_GLOBAL_LABEL(#{labelName}, #{alignTo})", lastComment))
else
if isExport
@outp.puts(formatDump("OFFLINE_ASM_UNALIGNED_GLOBAL_EXPORT_LABEL(#{labelName})", lastComment))
else
@outp.puts(formatDump("OFFLINE_ASM_UNALIGNED_GLOBAL_LABEL(#{labelName})", lastComment))
end
@outp.puts(formatDump("OFFLINE_ASM_GLOBAL_LABEL(#{labelName})", lastComment))
end
else
putsProc(labelName, lastComment)
end
if isExport
@outp.puts(formatDump("OFFLINE_ASM_UNALIGNED_GLOBAL_EXPORT_LABEL(#{labelName})", lastComment))
else
@outp.puts(formatDump("OFFLINE_ASM_UNALIGNED_GLOBAL_LABEL(#{labelName})", lastComment))
end
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
@outp.puts(formatDump("OFFLINE_ASM_OPCODE_LABEL(op_#{$~.post_match})", lastComment))
else
if alignTo
@outp.puts(formatDump("OFFLINE_ASM_ALIGN_TRAP(#{alignTo})", lastComment))
end
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
if $emitELFDebugDirectives
deferNextLabelAction {
Expand All @@ -288,35 +255,19 @@ def putsLocalLabel(labelName)
@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
@outp.puts(formatDump(" OFFLINE_ASM_LOCAL_LABEL(#{labelName})", lastComment))
end

def self.externLabelReference(labelName)
if !$emitWinAsm
"\" LOCAL_REFERENCE(#{labelName}) \""
else
"#{labelName}"
end
"\" LOCAL_REFERENCE(#{labelName}) \""
end

def self.labelReference(labelName)
if !$emitWinAsm
"\" LOCAL_LABEL_STRING(#{labelName}) \""
else
"_#{labelName}"
end
"\" LOCAL_LABEL_STRING(#{labelName}) \""
end

def self.localLabelReference(labelName)
if !$emitWinAsm
"\" LOCAL_LABEL_STRING(#{labelName}) \""
else
"#{labelName}"
end
"\" LOCAL_LABEL_STRING(#{labelName}) \""
end

def self.cLabelReference(labelName)
Expand Down Expand Up @@ -380,19 +331,11 @@ def debugAnnotation(text)
exit 1
end

# The MS compiler doesn't accept DWARF2 debug annotations.
if isMSVC
$enableDebugAnnotations = false
end

$emitWinAsm = false # TODO Cleanup unused emitWinAsm code paths
$commentPrefix = $emitWinAsm ? ";" : "//"

# We want this in all ELF systems we support, except for C_LOOP (we'll disable it later on if we are building cloop)
$emitELFDebugDirectives = $options.has_key?(:binary_format) && $options[:binary_format] == "ELF"

inputHash =
$commentPrefix + " offlineasm input hash: " + parseHash(asmFile, $options) +
"// offlineasm input hash: " + parseHash(asmFile, $options) +
" " + Digest::SHA1.hexdigest(configurationList.map{|v| (v[0] + [v[1]]).join(' ')}.join(' ')) +
" " + selfHash +
" " + Digest::SHA1.hexdigest($options.has_key?(:assembler) ? $options[:assembler] : "")
Expand Down
3 changes: 0 additions & 3 deletions Source/JavaScriptCore/offlineasm/ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1257,9 +1257,6 @@ def self.forName(codeOrigin, name)

def self.unique(comment)
newName = "_#{comment}"
if $emitWinAsm and newName.length > 90
newName = newName[0...45] + "___" + newName[-45..-1]
end
if $labelMapping[newName]
while $labelMapping[newName = "_#{@@uniqueNameCounter}_#{comment}"]
@@uniqueNameCounter += 1
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/offlineasm/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def fileName
end

def debugDirective
$emitWinAsm ? nil : "\".loc #{@sourceFile.fileNumber} #{lineNumber}\\n\""
"\".loc #{@sourceFile.fileNumber} #{lineNumber}\\n\""
end

def to_s
Expand Down
29 changes: 3 additions & 26 deletions Source/JavaScriptCore/offlineasm/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,40 +191,17 @@ def assertConfiguration(concreteSettings)

def emitCodeInConfiguration(concreteSettings, ast, backend)
Label.resetReferenced
$output.puts cppSettingsTest(concreteSettings)

if !$emitWinAsm
$output.puts cppSettingsTest(concreteSettings)
else
if backend == "X86_WIN"
$output.puts ".MODEL FLAT, C"
end
$output.puts "INCLUDE #{File.basename($output.path)}.sym"
$output.puts "_TEXT SEGMENT"
end

if isASTErroneous(ast)
$output.puts "#error \"Invalid configuration. Error at: #{ast.filter(Error)[0].codeOrigin}\""
elsif not WORKING_BACKENDS.include? backend
$output.puts "#error \"This backend is not supported yet.\""
else
yield concreteSettings, ast, backend
end

if !$emitWinAsm
$output.puts "#endif"
else
$output.puts "_TEXT ENDS"
$output.puts "END"

# Write symbols needed by MASM
File.open("#{File.basename($output.path)}.sym", "w") {
| outp |
Label.forReferencedExtern {
| name |
outp.puts "EXTERN #{name[1..-1]} : near"
}
}
end

$output.puts "#endif"
end

#
Expand Down

0 comments on commit c3c24e0

Please sign in to comment.