summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/offlineasm
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/offlineasm')
-rw-r--r--Source/JavaScriptCore/offlineasm/asm.rb13
-rw-r--r--Source/JavaScriptCore/offlineasm/x86.rb29
2 files changed, 25 insertions, 17 deletions
diff --git a/Source/JavaScriptCore/offlineasm/asm.rb b/Source/JavaScriptCore/offlineasm/asm.rb
index e93d85536..36482660e 100644
--- a/Source/JavaScriptCore/offlineasm/asm.rb
+++ b/Source/JavaScriptCore/offlineasm/asm.rb
@@ -29,6 +29,7 @@ require "config"
require "backends"
require "digest/sha1"
require "offsets"
+require 'optparse'
require "parser"
require "self_hash"
require "settings"
@@ -301,6 +302,15 @@ asmFile = ARGV.shift
offsetsFile = ARGV.shift
outputFlnm = ARGV.shift
+$options = {}
+OptionParser.new do |opts|
+ opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>]"
+ # This option is currently only used to specify the masm assembler
+ opts.on("--assembler=[ASM]", "Specify an assembler to use.") do |assembler|
+ $options[:assembler] = assembler
+ end
+end.parse!
+
begin
configurationList = offsetsAndConfigurationIndex(offsetsFile)
rescue MissingMagicValuesException
@@ -319,7 +329,8 @@ $commentPrefix = $emitWinAsm ? ";" : "//"
inputHash =
$commentPrefix + " offlineasm input hash: " + parseHash(asmFile) +
" " + Digest::SHA1.hexdigest(configurationList.map{|v| (v[0] + [v[1]]).join(' ')}.join(' ')) +
- " " + selfHash
+ " " + selfHash +
+ " " + Digest::SHA1.hexdigest($options.has_key?(:assembler) ? $options[:assembler] : "")
if FileTest.exist? outputFlnm
File.open(outputFlnm, "r") {
diff --git a/Source/JavaScriptCore/offlineasm/x86.rb b/Source/JavaScriptCore/offlineasm/x86.rb
index 2e0693726..0da7a0240 100644
--- a/Source/JavaScriptCore/offlineasm/x86.rb
+++ b/Source/JavaScriptCore/offlineasm/x86.rb
@@ -125,20 +125,12 @@ def useX87
end
end
-def isCompilingOnWindows
- ENV['OS'] == 'Windows_NT'
-end
-
-def isGCC
- !isCompilingOnWindows
-end
-
def isMSVC
- isCompilingOnWindows
+ $options.has_key?(:assembler) && $options[:assembler] == "MASM"
end
def isIntelSyntax
- isCompilingOnWindows
+ $options.has_key?(:assembler) && $options[:assembler] == "MASM"
end
def register(name)
@@ -520,7 +512,6 @@ class Sequence
end
class Instruction
- @@floatingPointCompareImplicitOperand = isIntelSyntax ? "st(0), " : ""
def x86Operands(*kinds)
raise unless kinds.size == operands.size
@@ -574,6 +565,10 @@ class Instruction
raise
end
end
+
+ def getImplicitOperandString
+ isIntelSyntax ? "st(0), " : ""
+ end
def handleX86OpWithNumOperands(opcode, kind, numOperands)
if numOperands == 3
@@ -808,20 +803,21 @@ class Instruction
end
def handleX87Compare(mode)
+ floatingPointCompareImplicitOperand = getImplicitOperandString
case mode
when :normal
if (operands[0].x87DefaultStackPosition == 0)
- $asm.puts "fucomi #{@@floatingPointCompareImplicitOperand}#{operands[1].x87Operand(0)}"
+ $asm.puts "fucomi #{floatingPointCompareImplicitOperand}#{operands[1].x87Operand(0)}"
else
$asm.puts "fld #{operands[0].x87Operand(0)}"
- $asm.puts "fucomip #{@@floatingPointCompareImplicitOperand}#{operands[1].x87Operand(1)}"
+ $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[1].x87Operand(1)}"
end
when :reverse
if (operands[1].x87DefaultStackPosition == 0)
- $asm.puts "fucomi #{@@floatingPointCompareImplicitOperand}#{operands[0].x87Operand(0)}"
+ $asm.puts "fucomi #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(0)}"
else
$asm.puts "fld #{operands[1].x87Operand(0)}"
- $asm.puts "fucomip #{@@floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
+ $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
end
else
raise mode.inspect
@@ -1108,6 +1104,7 @@ class Instruction
$asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
when "bcd2i"
if useX87
+ floatingPointCompareImplicitOperand = getImplicitOperandString
sp = RegisterID.new(nil, "sp")
if (operands[0].x87DefaultStackPosition == 0)
$asm.puts "fistl -4(#{sp.x86Operand(:ptr)})"
@@ -1119,7 +1116,7 @@ class Instruction
$asm.puts "test#{x86Suffix(:int)} #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
$asm.puts "je #{operands[2].asmLabel}"
$asm.puts "fild#{x86Suffix(:int)} #{getSizeString(:int)}#{offsetRegister(-4, sp.x86Operand(:ptr))}"
- $asm.puts "fucomip #{@@floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
+ $asm.puts "fucomip #{floatingPointCompareImplicitOperand}#{operands[0].x87Operand(1)}"
$asm.puts "jp #{operands[2].asmLabel}"
$asm.puts "jne #{operands[2].asmLabel}"
else